gdritter repos frony-ritter-designs / f3ee8fa
Start to convert edit pages Getty Ritter 4 years ago
9 changed file(s) with 185 addition(s) and 69 deletion(s). Collapse all Expand all
3030 design_page = load_template("design_page")
3131 design_list = load_template("design_list")
3232 text_list = load_template("text_list")
33
34 edit_design_list = load_template("edit_design_list")
3335
3436
3537 def thumb(img):
6971 return "Frony Ritter Designs", markdown.markdown(pg.text)
7072
7173
72 @app.route("/design/<id>/<slug>/")
74 @app.route("/design/<id>/<_slug>/")
7375 @main
7476 def get_design(id, _slug=None):
7577 design = db.get_design(int(id))
151153 return page.title, markdown.markdown(page.text)
152154
153155
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 # raise web.notfound()
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("???")
193179
194180 # class delete_design:
195181
55
66 body {
77 background-repeat: repeat-y, repeat;
8 background-color: #ddeeff;
8 background-color: #fff;
99 font-family: "Noto Sans", "Arial", sans-serif;
1010 font-size: medium;
1111 margin: 0pt;
1919 h1 a {
2020 color: #000;
2121 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;
2236 }
2337
2438 .contents a:link {
5165 flex-wrap: nowrap;
5266
5367 width: 100%;
54 background-color: #fff;
68 background-color: #ddeeff;
5569 }
5670
5771 .nav a {
6680 text-decoration: none;
6781 }
6882
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
69107 #contents {
70 background-color: #ddeeff;
71108 width: 70%;
72109 font-size: medium;
73110 padding: 10px;
75112 margin-right: auto;
76113 margin-top: 10px;
77114 margin-bottom: 10px;
78 border-style: solid;
79 border-width: 1px;
80115 height: auto;
81116 float: left;
82117 }
84119 #sidebyside {
85120 margin-left: auto;
86121 margin-right: auto;
87 width: 95%;
122 width: 100%;
88123 overflow: hidden;
89124 }
90125
91126 #footer {
92 background-color: #ddeeff;
93127 max-width: 80%;
94128 font-size: medium;
95129 padding: 10px;
96130 margin-left: auto;
97131 margin-right: auto;
98 border-style: solid;
99 border-width: 1px;
100132 }
101133
102134 .all-designs {
104136 margin-left: auto;
105137 margin-right: auto;
106138 grid-template-columns: 25% 25% 25% 25%;
139 align-items: center;
140 }
141
142 .all-designs a {
143 text-align: center;
107144 }
108145
109146 .design-tile {
115152 height: 150px;
116153 margin: 0 15px 15px 0;
117154 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;
118165 }
119166
120167 .design {
126173 }
127174
128175 .design .images {
176 display: flex;
177 justify-content: space-evenly;
178
179 align-items: center;
129180 max-width: 80%;
130181 margin-left: auto;
131182 margin-right: auto;
136187 max-width: 80%;
137188 margin-left: auto;
138189 margin-right: auto;
139 border-style: solid;
140 border-width: 0px;
141190 padding: 10px;
142191 }
143192
147196 }
148197
149198 .topnav {
150 background-color: #ddeeff;
151199 width: 22%;
152 border-style: solid;
153 border-width: 1px;
154200 height: auto;
155201 padding: 0px;
156202 margin: 10px;
6464 def thumbnail(self):
6565 if self.images:
6666 return self.images[0].thumb()
67
68 def tags(self):
69 return db.get_tags_for_design(self.id)
6770
6871 @classmethod
6972 def list(cls, query_results) -> typing.List["Design"]:
33 {{>design_tile}}
44 {{/contents}}
55 </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>
88 {{#prev_page}}
9 <a href="?page={{page}}"><li class="navitem">Newer</li></a>
9 <a href="?page={{page}}">Newer</a>
1010 {{/prev_page}}
1111 {{^prev_page}}
12 <li class="navitem greyed">Newer</li>
12 <span class="greyed">Newer</span>
1313 {{/prev_page}}
1414
1515 {{#next_page}}
16 <a href="?page={{page}}"><li class="navitem">Older</li></a>
16 <a href="?page={{page}}">Older</a>
1717 {{/next_page}}
1818 {{^next_page}}
19 <li class="navitem greyed">Older</li>
19 <span class="navitem greyed">Older</span>
2020 {{/next_page}}
21 <a href="?page={{last_page}}"><li class="navitem">Oldest</li></a>
22 <li class="break"></li>
23 </ul></div>
21 <a href="?page={{last_page}}">Oldest</a>
22 </div>
11 <div class="design">
2 <div class="title">{{title}}</div>
2 <div class="title">
3 <h2>{{title}}</h2>
4 </div>
35 <div class="images">
46 {{#images}}
5 <img src="/static/photos/{{image}}" />
7 <div class="image">
8 <img src="/static/photos/{{image}}" />
9 </div>
610 {{/images}}
711 </div>
812 <div class="description">{{#description}}{{{ rendered }}}{{/description}}</div>
11 <a href="/design/{{id_str}}/{{slug}}/">
2 <li class="design-tile">
2 <div class="design-tile">
33 <div id="img">
44 <img src="/static/photos/{{thumbnail}}" alt="{{title}} photo" />
55 </div>
66 <span class="title">{{title}}</span>
7 </li>
7 </div>
88 </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> &mdash;
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>
7878 </div>
7979 <div style="clear: both;"></div>
8080 </div>
81 <div id="footer">
82 &copy;2020 | <a href="/about/">About</a> | <a href="/contact/">Contact</a>
81 <div class="nav bottom">
82 <span class="text"> &copy;2020 Frony Ritter Designs</span> <a href="/about/">About</a> <a href="/contact/">Contact</a>
8383 </div>
8484 </div>
8585 </body>