Start to convert edit pages
Getty Ritter
4 years ago
30 | 30 | design_page = load_template("design_page") |
31 | 31 | design_list = load_template("design_list") |
32 | 32 | text_list = load_template("text_list") |
33 | ||
34 | edit_design_list = load_template("edit_design_list") | |
33 | 35 | |
34 | 36 | |
35 | 37 | def thumb(img): |
69 | 71 | return "Frony Ritter Designs", markdown.markdown(pg.text) |
70 | 72 | |
71 | 73 | |
72 |
@app.route("/design/<id>/< |
|
74 | @app.route("/design/<id>/<_slug>/") | |
73 | 75 | @main |
74 | 76 | def get_design(id, _slug=None): |
75 | 77 | design = db.get_design(int(id)) |
151 | 153 | return page.title, markdown.markdown(page.text) |
152 | 154 | |
153 | 155 | |
154 | # class admin: | |
155 | ||
156 | # class edit_all_designs: | |
157 | ||
158 | ||
159 | # @main | |
160 | # def GET(self): | |
161 | # winput = web.input(page=0) | |
162 | # page = int(winput['page']) | |
163 | # min, max = db.max_page_ranges() | |
164 | # data = db.get_all(offset=page) | |
165 | # return ('Edit Mode', | |
166 | # render.edit_design_list( | |
167 | # ((name, pics, id) for name, pics, _, _, id in data), | |
168 | # page, | |
169 | # page > min, | |
170 | # page < max)) | |
171 | ||
172 | # def POST(self): | |
173 | # id = db.new_design() | |
174 | # raise web.redirect('/edit/design/{0:05}/'.format( | |
175 | # id)) | |
176 | ||
177 | # class edit_design: | |
178 | ||
179 | ||
180 | # @main | |
181 | # def GET(self, id, slug=None): | |
182 | # try: | |
183 | # id = int(id) | |
184 | # design = db.get_design(id) | |
185 | # tags = ' '.join(db.get_tags_for_design(id)) | |
186 | # (name, images, | |
187 | # description, | |
188 | # cat, id) = design | |
189 | # return name, render.edit_design( | |
190 | # name, images, description, cat, id, tags) | |
191 | # except: | |
192 |
|
|
156 | @app.route("/edit/design/") | |
157 | @main | |
158 | def edit_all_designs(): | |
159 | page = int(flask.request.args.get("page") or 0) | |
160 | min, max = db.max_page_ranges() | |
161 | data = db.get_all(offset=page) | |
162 | print(data) | |
163 | return 'Edit Mode', Templates.edit_design_list(data) | |
164 | ||
165 | @app.route("/edit/design", methods=["POST"]) | |
166 | def post_new_design(): | |
167 | id = db.new_design() | |
168 | return flask.redirect(f"/edit/design/{id:05}/") | |
169 | ||
170 | @app.route("/edit/design/<id>/") | |
171 | @main | |
172 | def edit_design(id): | |
173 | try: | |
174 | id = int(id) | |
175 | design = db.get_design(id) | |
176 | return name, Templates.edit_design(design) | |
177 | except: | |
178 | raise Exception("???") | |
193 | 179 | |
194 | 180 | # class delete_design: |
195 | 181 |
5 | 5 | |
6 | 6 | body { |
7 | 7 | background-repeat: repeat-y, repeat; |
8 |
background-color: # |
|
8 | background-color: #fff; | |
9 | 9 | font-family: "Noto Sans", "Arial", sans-serif; |
10 | 10 | font-size: medium; |
11 | 11 | margin: 0pt; |
19 | 19 | h1 a { |
20 | 20 | color: #000; |
21 | 21 | text-decoration: none; |
22 | } | |
23 | ||
24 | h2 { | |
25 | font-family: sacramento, sans-serif; | |
26 | font-size: 32pt; | |
27 | } | |
28 | ||
29 | .title { | |
30 | text-align: center; | |
31 | } | |
32 | ||
33 | .description h1 { | |
34 | font-family: sacramento, sans-serif; | |
35 | font-size: 24pt; | |
22 | 36 | } |
23 | 37 | |
24 | 38 | .contents a:link { |
51 | 65 | flex-wrap: nowrap; |
52 | 66 | |
53 | 67 | width: 100%; |
54 |
background-color: # |
|
68 | background-color: #ddeeff; | |
55 | 69 | } |
56 | 70 | |
57 | 71 | .nav a { |
66 | 80 | text-decoration: none; |
67 | 81 | } |
68 | 82 | |
83 | .round { | |
84 | border-radius: 5pt; | |
85 | } | |
86 | ||
87 | .nav .greyed { | |
88 | width: 12%; | |
89 | display: inline-block; | |
90 | text-align: center; | |
91 | padding: 3pt 0pt; | |
92 | margin: 5pt 0pt; | |
93 | background-color: #ddd; | |
94 | color: #fff; | |
95 | border-radius: 5pt; | |
96 | user-select: none; | |
97 | } | |
98 | ||
99 | .nav .text { | |
100 | width: 12%; | |
101 | display: inline-block; | |
102 | text-align: center; | |
103 | padding: 3pt 0pt; | |
104 | margin: 5pt 0pt; | |
105 | } | |
106 | ||
69 | 107 | #contents { |
70 | background-color: #ddeeff; | |
71 | 108 | width: 70%; |
72 | 109 | font-size: medium; |
73 | 110 | padding: 10px; |
75 | 112 | margin-right: auto; |
76 | 113 | margin-top: 10px; |
77 | 114 | margin-bottom: 10px; |
78 | border-style: solid; | |
79 | border-width: 1px; | |
80 | 115 | height: auto; |
81 | 116 | float: left; |
82 | 117 | } |
84 | 119 | #sidebyside { |
85 | 120 | margin-left: auto; |
86 | 121 | margin-right: auto; |
87 |
width: |
|
122 | width: 100%; | |
88 | 123 | overflow: hidden; |
89 | 124 | } |
90 | 125 | |
91 | 126 | #footer { |
92 | background-color: #ddeeff; | |
93 | 127 | max-width: 80%; |
94 | 128 | font-size: medium; |
95 | 129 | padding: 10px; |
96 | 130 | margin-left: auto; |
97 | 131 | margin-right: auto; |
98 | border-style: solid; | |
99 | border-width: 1px; | |
100 | 132 | } |
101 | 133 | |
102 | 134 | .all-designs { |
104 | 136 | margin-left: auto; |
105 | 137 | margin-right: auto; |
106 | 138 | grid-template-columns: 25% 25% 25% 25%; |
139 | align-items: center; | |
140 | } | |
141 | ||
142 | .all-designs a { | |
143 | text-align: center; | |
107 | 144 | } |
108 | 145 | |
109 | 146 | .design-tile { |
115 | 152 | height: 150px; |
116 | 153 | margin: 0 15px 15px 0; |
117 | 154 | padding: 5px; |
155 | align-items: center; | |
156 | border-radius: 5pt; | |
157 | position: relative; | |
158 | } | |
159 | ||
160 | .design-tile .title { | |
161 | width: 100%; | |
162 | position: absolute; | |
163 | bottom: 6pt; | |
164 | left: 0pt; | |
118 | 165 | } |
119 | 166 | |
120 | 167 | .design { |
126 | 173 | } |
127 | 174 | |
128 | 175 | .design .images { |
176 | display: flex; | |
177 | justify-content: space-evenly; | |
178 | ||
179 | align-items: center; | |
129 | 180 | max-width: 80%; |
130 | 181 | margin-left: auto; |
131 | 182 | margin-right: auto; |
136 | 187 | max-width: 80%; |
137 | 188 | margin-left: auto; |
138 | 189 | margin-right: auto; |
139 | border-style: solid; | |
140 | border-width: 0px; | |
141 | 190 | padding: 10px; |
142 | 191 | } |
143 | 192 | |
147 | 196 | } |
148 | 197 | |
149 | 198 | .topnav { |
150 | background-color: #ddeeff; | |
151 | 199 | width: 22%; |
152 | border-style: solid; | |
153 | border-width: 1px; | |
154 | 200 | height: auto; |
155 | 201 | padding: 0px; |
156 | 202 | margin: 10px; |
64 | 64 | def thumbnail(self): |
65 | 65 | if self.images: |
66 | 66 | return self.images[0].thumb() |
67 | ||
68 | def tags(self): | |
69 | return db.get_tags_for_design(self.id) | |
67 | 70 | |
68 | 71 | @classmethod |
69 | 72 | def list(cls, query_results) -> typing.List["Design"]: |
3 | 3 | {{>design_tile}} |
4 | 4 | {{/contents}} |
5 | 5 | </div> |
6 | <div class="lrnav"><ul> | |
7 | <a href="?page=0"><li class="navitem">Newest</li></a> | |
6 | <div class="nav round"> | |
7 | <a href="?page=0">Newest</a> | |
8 | 8 | {{#prev_page}} |
9 |
<a href="?page={{page}}"> |
|
9 | <a href="?page={{page}}">Newer</a> | |
10 | 10 | {{/prev_page}} |
11 | 11 | {{^prev_page}} |
12 |
< |
|
12 | <span class="greyed">Newer</span> | |
13 | 13 | {{/prev_page}} |
14 | 14 | |
15 | 15 | {{#next_page}} |
16 |
<a href="?page={{page}}"> |
|
16 | <a href="?page={{page}}">Older</a> | |
17 | 17 | {{/next_page}} |
18 | 18 | {{^next_page}} |
19 |
< |
|
19 | <span class="navitem greyed">Older</span> | |
20 | 20 | {{/next_page}} |
21 | <a href="?page={{last_page}}"><li class="navitem">Oldest</li></a> | |
22 | <li class="break"></li> | |
23 |
|
|
21 | <a href="?page={{last_page}}">Oldest</a> | |
22 | </div> |
1 | 1 | <div class="design"> |
2 |
<div class="title"> |
|
2 | <div class="title"> | |
3 | <h2>{{title}}</h2> | |
4 | </div> | |
3 | 5 | <div class="images"> |
4 | 6 | {{#images}} |
5 |
< |
|
7 | <div class="image"> | |
8 | <img src="/static/photos/{{image}}" /> | |
9 | </div> | |
6 | 10 | {{/images}} |
7 | 11 | </div> |
8 | 12 | <div class="description">{{#description}}{{{ rendered }}}{{/description}}</div> |
1 | 1 | <a href="/design/{{id_str}}/{{slug}}/"> |
2 |
< |
|
2 | <div class="design-tile"> | |
3 | 3 | <div id="img"> |
4 | 4 | <img src="/static/photos/{{thumbnail}}" alt="{{title}} photo" /> |
5 | 5 | </div> |
6 | 6 | <span class="title">{{title}}</span> |
7 |
</ |
|
7 | </div> | |
8 | 8 | </a> |
1 | <div id="design"> | |
2 | <p> | |
3 | <a href="/edit/design/">Return to Editing List</a> | |
4 | </p> | |
5 | <h1>See This Design</h1> | |
6 | <a href="/design/{{id_str}}/">Click Here</a> | |
7 | <h1>Design Data</h1> | |
8 | <form name="design-data" method="post" action="/design/{{id_str}}/"> | |
9 | <p> | |
10 | design id: {{id_str}} | |
11 | </p> | |
12 | <p><input type="text" name="title" value="{{title}}" size="80"/></p> | |
13 | <p> | |
14 | <select name="category"> | |
15 | {{#categories}} | |
16 | <option value="{{id}}" ${{selected}}>{{name}}</option> | |
17 | {{/categories}} | |
18 | </select> | |
19 | </p> | |
20 | <p> | |
21 | <textarea rows="8" cols="90" name="description">{{description}}</textarea> | |
22 | </p> | |
23 | <p> | |
24 | <input type="text" name="tags" value="$tags" size="80"/> | |
25 | </p> | |
26 | <p> | |
27 | <input type="submit" value="Submit Design Data"/> | |
28 | </p> | |
29 | </form> | |
30 | <h1>Photos</h1> | |
31 | {{#photos}} | |
32 | <form name="img_$loop.index" method="get" action="/edit/photo/$image/"> | |
33 | <img src="/static/photos/{{image}}" /> | |
34 | <input type="hidden" name="design_id" value="$id" /> | |
35 | <input type="submit" value="Delete This Photo" /> | |
36 | </form> | |
37 | {{/photos}} | |
38 | <p> | |
39 | <form name="img_upload" method="get" action="/edit/photo/"> | |
40 | <input type="hidden" name="id" value="$five(id)" /> | |
41 | <input type="submit" value="Upload New Photo" /> | |
42 | </form> | |
43 | </p> | |
44 | <h1>Delete</h1> | |
45 | <p> | |
46 | <a href="/edit/delete/$five(id)/">Delete This Design</a> | |
47 | </p> | |
48 | </div> |
1 | <p><a href="/edit/about/">Edit About Text</a></p> | |
2 | <form name="add-new" action="/edit/design/" method="post"> | |
3 | <input type="submit" value="Add New Design" /> | |
4 | </form> | |
5 | {{#contents}} | |
6 | <div class="design-edit-tile"> | |
7 | <img src="/static/photos/{{thumbnail}}" /> | |
8 | <a href="/edit/design/{{id_str}}/"> | |
9 | <span class="title">{{title}}</span> | |
10 | </a> — | |
11 | <a href="/edit/delete/{{id_str}}/"> | |
12 | Delete this design | |
13 | </a> | |
14 | </div> | |
15 | {{/contents}} | |
16 | <div class="lrnav"> | |
17 | {{#prev_page}} | |
18 | <a href="?page={{page}}"><li class="navitem">Newer</li></a> | |
19 | {{/prev_page}} | |
20 | {{^prev_page}} | |
21 | <li class="navitem greyed">Newer</li> | |
22 | {{/prev_page}} | |
23 | ||
24 | {{#next_page}} | |
25 | <a href="?page={{page}}"><li class="navitem">Older</li></a> | |
26 | {{/next_page}} | |
27 | {{^next_page}} | |
28 | <li class="navitem greyed">Older</li> | |
29 | {{/next_page}} | |
30 | </div> |
78 | 78 | </div> |
79 | 79 | <div style="clear: both;"></div> |
80 | 80 | </div> |
81 | <div id="footer"> | |
82 | ©2020 | <a href="/about/">About</a> | <a href="/contact/">Contact</a> | |
81 | <div class="nav bottom"> | |
82 | <span class="text"> ©2020 Frony Ritter Designs</span> <a href="/about/">About</a> <a href="/contact/">Contact</a> | |
83 | 83 | </div> |
84 | 84 | </div> |
85 | 85 | </body> |