Skip to content

Commit 9809d7e

Browse files
committed
tiny modification
1 parent c95d735 commit 9809d7e

File tree

8 files changed

+271
-18
lines changed

8 files changed

+271
-18
lines changed

flowpython.incantation/Module/Component/Badges.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ class badge:
1313
badge(name, new=False, href='', color='')
1414
"""
1515
def __new__(self, name, href = '#!', new:{True,False,None} = None, num = "", color = ''):
16-
if new is None:
17-
return dict(href=href, style=f"{name}")
16+
1817
class_ = 'new badge' if new else 'badge'
18+
1919
if color: class_ += color
20-
return dict(href = href, style = f'{name}<span class="{class_}">{num}</span>')
20+
res = f'{name}<span class="{class_}">{num}</span>'
21+
22+
if href:
23+
res = f'<a href="{href}">{res}</a>'
2124

25+
return res
2226

2327
class collections(indent_setter, abstract_object):
2428
"""
@@ -45,7 +49,7 @@ def init(self, content : (list,[badge]), **attributes):
4549
"""
4650
{{indent}}<div {{attributes_dict}}>
4751
{{indent+Indent_unit}}{% for badge in content%}
48-
{{indent+Indent_unit*2}}<a href="{{badge.href}}" class="collection-item">{{badge.style}}</a>
52+
{{indent+Indent_unit*2}}<div class="collection-item">{{badge}}</div>
4953
{{indent+Indent_unit}}{% endfor %}
5054
{{indent}}</div>
5155
"""
@@ -72,7 +76,7 @@ def init(self, content:(list,[badge]), **attributes:dict(material_icons = 'arrow
7276
"""
7377
{{indent}}<ul id="{{id}}" class="dropdown-content">
7478
{{indent+Indent_unit}}{% for badge in content%}
75-
{{indent+Indent_unit*2}}<li><a href="{{badge.href}}">{{badge.style}}</a></li>
79+
{{indent+Indent_unit*2}}<li>{{badge}}</li>
7680
{{indent+Indent_unit}}{% endfor %}
7781
{{indent}}</ul>
7882
{{indent}}<a {{attributes_dict}} data-activates="{{id}}">{{name}}<i class="material-icons right">{{material_icons}}</i></a>
@@ -103,21 +107,23 @@ class collapsible(indent_setter, abstract_object):
103107
@default_attr(attr = 'class', value = "collapsible")
104108
@default_attr(attr = 'data-collapsible', value = 'accordion')
105109
def init(self, content, **attributes):
110+
sugar = attrset_sugar(self.conf, attributes)
111+
sugar('active', False)
106112
body = \
107113
"""
108114
{{indent}}<ul {{attributes_dict}}>
109115
{{indent+Indent_unit}}{% for item in content %}
110116
{{indent+Indent_unit}}<li>
111-
{{indent+Indent_unit}}<div class="collapsible-header">
117+
{{indent+Indent_unit}}<div class="collapsible-header {%if active%}active{%- endif -%}">
112118
{{indent+Indent_unit}}{{item[0]}}
113-
{{indent+Indent_unit}}{% if item[1].href %}
114-
{{indent+Indent_unit}}<a href="{{item[1].href}}">{{item[1].style}}</a>
115-
{{indent+Indent_unit}}{% else -%}
116-
{{indent+Indent_unit}}{{item[1].style}}
117-
{{indent+Indent_unit}}{%- endif %}
119+
{{indent+Indent_unit}}{{item[1]}}
118120
{{indent+Indent_unit}}</div>
119121
{{indent+Indent_unit}}<div class="collapsible-body">
120-
{{indent+Indent_unit}}{{item[2]}}
122+
{{indent+Indent_unit*2}}<ul>
123+
{{indent+Indent_unit*2}}<li>
124+
{{indent+Indent_unit*3}}{{item[2]}}
125+
{{indent+Indent_unit*2}}</li>
126+
{{indent+Indent_unit*2}}</ul>
121127
{{indent+Indent_unit}}</div>
122128
{{indent+Indent_unit}}</li>
123129
{{indent+Indent_unit}}{% endfor %}

flowpython.incantation/Module/Component/Form.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ def init(self, grid : "CSS.Grid.grid" , **attributes):
4747
{% if icon %}
4848
{{indent+Indent_unit}}<i class="material-icons prefix">{{icon}}</i>
4949
{% endif %}
50-
{{indent+Indent_unit}}<input id="{{id}}" name="{{id}}" class="{{class}}" type="{{type}}"{%- if value %} value="{{value}}" {% endif %}>
5150
{{indent+Indent_unit}}<label for="{{id}}">{{field_name}}</label>
51+
{{indent+Indent_unit}}<input id="{{id}}" name="{{id}}" class="input-field {{class}}" type="{{type}}"{%- if value %} value="{{value}}" {% endif %}>
5252
{{indent}}</div>
5353
"""
54+
5455
self.conf.update(dict(indent = " ", attributes_dict = attributes))
5556
self.append_class(grid.gen())
5657
self.body = body
57-
self.cons_class("input-field")
58+
5859

5960

6061
class form(indent_setter, abstract_object):

flowpython.incantation/Module/abst.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def gen(self):
8080
indent =self.conf['indent'],
8181
Indent_unit =default_conf['Indent_unit'])
8282
return rendered
83-
83+
84+
def __str__(self):
85+
return self.gen()
86+
8487
def common_init(self):
8588
"""
8689
Do some common initial actions when initializing the Materialize-CSS object.
@@ -151,8 +154,8 @@ class Seq(list):
151154
"""
152155
def __init__(self, *args):
153156
return super(Seq, self).__init__(args)
154-
155-
157+
def gen(self):
158+
return gen_helper(self)
156159

157160

158161

-47 Bytes
Binary file not shown.
-25 Bytes
Binary file not shown.

incantation/Module/abst.pyc

232 Bytes
Binary file not shown.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
cat = os.path.join
1515
setup(name='Incantation',
16-
version='0.3.1',
16+
version='0.3.2',
1717
keywords='website, web-design',
1818
description = "Python Object Design about Website. Make Developing websites like saying incantations.",
1919
long_description=readme,

test.html

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<!--Import Google Icon Font-->
6+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
7+
<!--Import materialize.css-->
8+
<link type="text/css" rel="stylesheet" href="static/materialize/css/materialize.min.css" media="screen,projection"/>
9+
10+
<!--Let browser know website is optimized for mobile-->
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
12+
<meta charset="utf-8">
13+
</head>
14+
15+
<body>
16+
<!--Import jQuery before materialize.js-->
17+
<script type="text/javascript" src="static/jquery-3.2.1.min.js"></script>
18+
<script type="text/javascript" src="static/materialize/js/materialize.min.js"></script>
19+
20+
<nav>
21+
<div class = "nav-wrapper">
22+
<a href="https://github.com/thautwarm" class="brand-logo left">Logo</a>
23+
<ul id="nav-mobile" class="right hide-on-med-and-down">
24+
25+
<li><a href="https://baidu.com">link1</a></li>
26+
27+
<li><a href="https://google.com">link2</a></li>
28+
29+
</ul>
30+
</div>
31+
</nav>
32+
33+
<div class = "container">
34+
<!-- Page Content goes here -->
35+
36+
<blockquote >
37+
Columns.
38+
</blockquote>
39+
40+
<div name = "test_row" class = "center-align row">
41+
42+
<div class = "col s6 m3 l2">
43+
contents
44+
</div>
45+
46+
<div class = "col s6 m3 l2">
47+
contents
48+
</div>
49+
</div>
50+
51+
<div class = "col s36 m18 l12">
52+
53+
<ul id="someid" class="dropdown-content">
54+
55+
<li><a href="#!">Alan<span class="">1</span></a></li>
56+
57+
<li><a href="#!">Alan<span class="new badge">4</span></a></li>
58+
59+
<li><a href="#!">Alan<span class=""></span></a></li>
60+
61+
<li><a href="#!">Alan<span class="">14</span></a></li>
62+
63+
</ul>
64+
<a class = "btn dropdown-button" href = "#!" data-activates="someid">a dropdown list<i class="material-icons right">arrow_drop_down</i></a>
65+
66+
</div>
67+
68+
<ul class = "collapsible" data-collapsible = "accordion">
69+
70+
<li>
71+
<div class="collapsible-header">
72+
<i class="material-icons " >filter_drama</i>
73+
<a href="#!">First<span class=""></span></a>
74+
</div>
75+
<div class="collapsible-body">
76+
<p>Lorem ipsum dolor sit amet.</p>
77+
</div>
78+
</li>
79+
80+
<li>
81+
<div class="collapsible-header">
82+
<i class="material-icons " >place</i>
83+
<a href="#!">Second<span class=""></span></a>
84+
</div>
85+
<div class="collapsible-body">
86+
place
87+
</div>
88+
</li>
89+
90+
</ul>
91+
92+
<div class = "row">
93+
94+
<div class = "col s6 m3 l2">
95+
96+
<div class = "collection">
97+
98+
<div class="collection-item"><a href="#!">Alan<span class="">1</span></a></div>
99+
100+
<div class="collection-item"><a href="#!">Alan<span class="new badge">4</span></a></div>
101+
102+
<div class="collection-item"><a href="#!">Alan<span class=""></span></a></div>
103+
104+
<div class="collection-item"><a href="#!">Alan<span class="">14</span></a></div>
105+
106+
</div>
107+
</div>
108+
109+
<div class = "col s6 m3 l2 push-s0 push-m6 push-l8">
110+
111+
<div class = "collection">
112+
113+
<div class="collection-item"><a href="#!">Alan<span class="">1</span></a></div>
114+
115+
<div class="collection-item"><a href="#!">Alan<span class="new badge">4</span></a></div>
116+
117+
<div class="collection-item"><a href="#!">Alan<span class=""></span></a></div>
118+
119+
<div class="collection-item"><a href="#!">Alan<span class="">14</span></a></div>
120+
121+
</div>
122+
</div>
123+
</div>
124+
125+
<blockquote >
126+
Tables.
127+
</blockquote>
128+
129+
<table action = "somescirpt">
130+
<thead>
131+
<tr>
132+
133+
<th>name</th>
134+
135+
<th>email</th>
136+
137+
<th>phone number</th>
138+
139+
</tr>
140+
</thead>
141+
<tbody>
142+
143+
<tr>
144+
145+
<td>thautwarm</td>
146+
147+
148+
149+
<td>None</td>
150+
151+
</tr>
152+
153+
<tr>
154+
155+
<td>person1</td>
156+
157+
<td>email1</td>
158+
159+
<td>phone1</td>
160+
161+
</tr>
162+
163+
<tr>
164+
165+
<td>deep</td>
166+
167+
<td>dark</td>
168+
169+
<td>fantasy</td>
170+
171+
</tr>
172+
173+
<tr>
174+
175+
<td>Ass</td>
176+
177+
<td>Tol</td>
178+
179+
<td>Fo</td>
180+
181+
</tr>
182+
183+
</tbody>
184+
</table>
185+
186+
<div class = "collection">
187+
188+
<div class="collection-item"><a href="#!">Alan<span class="">1</span></a></div>
189+
190+
<div class="collection-item"><a href="#!">Alan<span class="new badge">4</span></a></div>
191+
192+
<div class="collection-item"><a href="#!">Alan<span class=""></span></a></div>
193+
194+
<div class="collection-item"><a href="#!">Alan<span class="">14</span></a></div>
195+
196+
</div>
197+
198+
<div class = "fixed-action-btn" >
199+
<a class="btn-floating btn-large purple">
200+
<i class="large material-icons"><i class="material-icons " >publish</i></i>
201+
</a>
202+
<ul>
203+
204+
<li><a href="https://www.baidu.com" class="btn-floating red"><i class="material-icons " >insert_chart</i></a></li>
205+
206+
<li><a href="https://www.google.com" class="btn-floating blue"><i class="material-icons " >publish</i></a></li>
207+
208+
</ul>
209+
</div>
210+
211+
<a href = "https://www.baidu.com" class = "waves-effect waves-light btn"><i class="material-icons " >add_alarm</i>YHZ</a>
212+
213+
<form action = "script" method = "POST">
214+
215+
<div class = "input-field col s12 m6 l4">
216+
217+
<i class="material-icons prefix"><i class="material-icons " >mode_edit</i></i>
218+
219+
<input id="for-username" name="for-username" class="validate" type="text">
220+
<label for="for-username">Username</label>
221+
</div>
222+
223+
<div class = "input-field col s12 m6 l4">
224+
225+
<i class="material-icons prefix"><i class="material-icons " >brightness_auto</i></i>
226+
227+
<input id="for-password" name="for-password" class="validate" type="password">
228+
<label for="for-password">Password</label>
229+
</div>
230+
231+
<div class = "input-field col s12 m6 l4">
232+
233+
<i class="material-icons prefix"><i class="material-icons " >brightness_3</i></i>
234+
235+
<input id="for-school" name="for-school" class="validate" type="text">
236+
<label for="for-school">School</label>
237+
</div>
238+
239+
<input class = "right-align input-field waves-effect waves-light btn col s12 m6 l4" id="for-submit" name = "for-submit" type = "submit">
240+
</form>
241+
</div>
242+
</body>
243+
</html>

0 commit comments

Comments
 (0)