Browse Source

dont make all nested lists font size smaller, only for menu

Thomas B 1 month ago
parent
commit
3a76416a97
2 changed files with 58 additions and 10 deletions
  1. 57
    9
      macros.py
  2. 1
    1
      static/css/style.css

+ 57
- 9
macros.py View File

160
             ret += ".svg?logo=git&style=flat\" /></a>"
160
             ret += ".svg?logo=git&style=flat\" /></a>"
161
     return ret
161
     return ret
162
 
162
 
163
-def printMenuItem(p, yearsAsHeading = False, showDateSpan = False, showOnlyStartDate = False, nicelyFormatFullDate = False, lastyear = "0", lang = "", showLastCommit = True, hide_description = False, indent_count = 0, updates_as_heading = False):
163
+def printMenuItem(p, yearsAsHeading = False, showDateSpan = False, showOnlyStartDate = False, nicelyFormatFullDate = False, lastyear = "0", lang = "", showLastCommit = True, hide_description = False, updates_as_heading = False):
164
     title = p.title
164
     title = p.title
165
     if lang != "":
165
     if lang != "":
166
         if p.get("title_" + lang, "") != "":
166
         if p.get("title_" + lang, "") != "":
175
     if year != lastyear:
175
     if year != lastyear:
176
         lastyear = year
176
         lastyear = year
177
         if yearsAsHeading:
177
         if yearsAsHeading:
178
-            print("\n\n#### %s\n" % (year))
178
+            print("<h4>" + str(year) + "</h4>")
179
 
179
 
180
     dateto = ""
180
     dateto = ""
181
     if p.get("date", "" != ""):
181
     if p.get("date", "" != ""):
190
         if nicelyFormatFullDate:
190
         if nicelyFormatFullDate:
191
             dateto = " - " + datetime.strptime(p.get("update", p.date), "%Y-%m-%d").strftime("%B %d, %Y")
191
             dateto = " - " + datetime.strptime(p.get("update", p.date), "%Y-%m-%d").strftime("%B %d, %Y")
192
 
192
 
193
-    indent = "  " * (indent_count + 1)
194
-    print(indent + "* **[%s](%s)**%s" % (title, p.url, dateto))
193
+    print("<li>")
194
+    print("<a href=\"" + p.url + "\"><b>" + title + "</b></a>" + dateto)
195
 
195
 
196
     if hide_description == False:
196
     if hide_description == False:
197
         if p.get("description", "") != "":
197
         if p.get("description", "") != "":
206
         if len(link) > 0:
206
         if len(link) > 0:
207
             print("<br>" + link)
207
             print("<br>" + link)
208
 
208
 
209
+    print("</li>")
210
+
209
     return lastyear
211
     return lastyear
210
 
212
 
211
 def printRecentMenu(count = 5):
213
 def printRecentMenu(count = 5):
215
     if count > 0:
217
     if count > 0:
216
         posts = posts[0:count]
218
         posts = posts[0:count]
217
 
219
 
220
+    print("<ul id='menulist'>")
221
+
218
     lastyear = "0"
222
     lastyear = "0"
219
     for p in posts:
223
     for p in posts:
220
-        lastyear = printMenuItem(p, count == 0, False, False, True, lastyear, "", False, False, 0, True)
224
+        lastyear = printMenuItem(p, count == 0, False, False, True, lastyear, "", False, False, True)
225
+
226
+    print("</ul>")
221
 
227
 
222
 def printBlogMenu(year_min=None, year_max=None):
228
 def printBlogMenu(year_min=None, year_max=None):
223
     posts = [p for p in pages if "post" in p and p.lang == "en"]
229
     posts = [p for p in pages if "post" in p and p.lang == "en"]
228
     if year_max != None:
234
     if year_max != None:
229
         posts = [p for p in posts if int(p.get("date", "9999-01-01")[0:4]) <= int(year_max)]
235
         posts = [p for p in posts if int(p.get("date", "9999-01-01")[0:4]) <= int(year_max)]
230
 
236
 
237
+    print("<ul id='menulist'>")
238
+
231
     lastyear = "0"
239
     lastyear = "0"
232
     for p in posts:
240
     for p in posts:
233
         lastyear = printMenuItem(p, True, False, False, True, lastyear)
241
         lastyear = printMenuItem(p, True, False, False, True, lastyear)
234
 
242
 
243
+    print("</ul>")
244
+
235
 def printProjectsMenu():
245
 def printProjectsMenu():
236
     # prints all pages with parent 'projects' or 'stuff'.
246
     # prints all pages with parent 'projects' or 'stuff'.
237
     # first the ones without date, sorted by position.
247
     # first the ones without date, sorted by position.
246
     mpages = [p for p in dpages if any(x in p.get("parent", "") for x in [ 'projects', 'stuff' ])]
256
     mpages = [p for p in dpages if any(x in p.get("parent", "") for x in [ 'projects', 'stuff' ])]
247
     # sort by position
257
     # sort by position
248
     mpages.sort(key=lambda p: [int(p.get("position", "999"))])
258
     mpages.sort(key=lambda p: [int(p.get("position", "999"))])
259
+
260
+    print("<ul id='menulist'>")
261
+
249
     # print all pages
262
     # print all pages
250
     for p in mpages:
263
     for p in mpages:
251
         printMenuItem(p)
264
         printMenuItem(p)
252
 
265
 
253
         # print subpages for these top-level items
266
         # print subpages for these top-level items
254
         subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
267
         subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
255
-        for sp in subpages:
256
-            printMenuItem(sp, False, True, True, False, "0", "", False, True, 1)
268
+        if len(subpages) > 0:
269
+            print("<ul>")
270
+            for sp in subpages:
271
+                printMenuItem(sp, False, True, True, False, "0", "", False, True)
272
+            print("</ul>")
257
 
273
 
258
     # slect pages with a date
274
     # slect pages with a date
259
     dpages = [p for p in enpages if p.get("date", "") != ""]
275
     dpages = [p for p in enpages if p.get("date", "") != ""]
270
         # print subpages for these top-level items
286
         # print subpages for these top-level items
271
         subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
287
         subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
272
         subpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
288
         subpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
273
-        for sp in subpages:
274
-            printMenuItem(sp, False, True, True, False, "0", "", False, True, 1)
289
+        if len(subpages) > 0:
290
+            print("<ul>")
291
+            for sp in subpages:
292
+                printMenuItem(sp, False, True, True, False, "0", "", False, True)
293
+            print("</ul>")
294
+
295
+    print("</ul>")
275
 
296
 
276
 def print3DPrintingMenu():
297
 def print3DPrintingMenu():
277
     mpages = [p for p in pages if p.get("parent", "") == "3d-printing" and p.lang == "en"]
298
     mpages = [p for p in pages if p.get("parent", "") == "3d-printing" and p.lang == "en"]
278
     mpages.sort(key=lambda p: int(p["position"]))
299
     mpages.sort(key=lambda p: int(p["position"]))
300
+
301
+    print("<ul id='menulist'>")
279
     for p in mpages:
302
     for p in mpages:
280
         printMenuItem(p, False, True, True)
303
         printMenuItem(p, False, True, True)
304
+    print("</ul>")
281
 
305
 
282
 def printInputDevicesMenu():
306
 def printInputDevicesMenu():
283
     mpages = [p for p in pages if p.get("parent", "") == "input_devices" and p.lang == "en"]
307
     mpages = [p for p in pages if p.get("parent", "") == "input_devices" and p.lang == "en"]
284
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
308
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
309
+
310
+    print("<ul id='menulist'>")
285
     for p in mpages:
311
     for p in mpages:
286
         printMenuItem(p, False, True, True)
312
         printMenuItem(p, False, True, True)
313
+    print("</ul>")
287
 
314
 
288
 def printInputDevicesRelatedMenu():
315
 def printInputDevicesRelatedMenu():
289
     mpages = [p for p in pages if p.get("show_in_input_devices", "false") == "true"]
316
     mpages = [p for p in pages if p.get("show_in_input_devices", "false") == "true"]
290
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
317
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
318
+
319
+    print("<ul id='menulist'>")
291
     for p in mpages:
320
     for p in mpages:
292
         printMenuItem(p, False, True, True)
321
         printMenuItem(p, False, True, True)
322
+    print("</ul>")
293
 
323
 
294
 def printSmarthomeMenu():
324
 def printSmarthomeMenu():
295
     mpages = [p for p in pages if p.get("parent", "") == "smarthome" and p.lang == "en"]
325
     mpages = [p for p in pages if p.get("parent", "") == "smarthome" and p.lang == "en"]
296
     mpages.sort(key=lambda p: int(p["position"]))
326
     mpages.sort(key=lambda p: int(p["position"]))
327
+
328
+    print("<ul id='menulist'>")
297
     for p in mpages:
329
     for p in mpages:
298
         printMenuItem(p, False, True, True)
330
         printMenuItem(p, False, True, True)
331
+    print("</ul>")
299
 
332
 
300
 def printQuadcopterMenu():
333
 def printQuadcopterMenu():
301
     mpages = [p for p in pages if p.get("parent", "") == "quadcopters" and p.lang == "en"]
334
     mpages = [p for p in pages if p.get("parent", "") == "quadcopters" and p.lang == "en"]
302
     mpages.sort(key=lambda p: int(p["position"]))
335
     mpages.sort(key=lambda p: int(p["position"]))
336
+
337
+    print("<ul id='menulist'>")
303
     for p in mpages:
338
     for p in mpages:
304
         printMenuItem(p, False, True, True)
339
         printMenuItem(p, False, True, True)
340
+    print("</ul>")
305
 
341
 
306
 def printQuadcopterRelatedMenu():
342
 def printQuadcopterRelatedMenu():
307
     mpages = [p for p in pages if p.get("show_in_quadcopters", "false") == "true"]
343
     mpages = [p for p in pages if p.get("show_in_quadcopters", "false") == "true"]
308
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
344
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
345
+
346
+    print("<ul id='menulist'>")
309
     for p in mpages:
347
     for p in mpages:
310
         printMenuItem(p, False, True, True)
348
         printMenuItem(p, False, True, True)
349
+    print("</ul>")
311
 
350
 
312
 def printRobotMenuEnglish():
351
 def printRobotMenuEnglish():
313
     mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "en"]
352
     mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "en"]
314
     mpages.sort(key=lambda p: int(p["position"]))
353
     mpages.sort(key=lambda p: int(p["position"]))
354
+
355
+    print("<ul id='menulist'>")
315
     for p in mpages:
356
     for p in mpages:
316
         printMenuItem(p)
357
         printMenuItem(p)
358
+    print("</ul>")
317
 
359
 
318
 def printRobotMenuDeutsch():
360
 def printRobotMenuDeutsch():
319
     mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "de"]
361
     mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "de"]
320
     mpages.sort(key=lambda p: int(p["position"]))
362
     mpages.sort(key=lambda p: int(p["position"]))
363
+
364
+    print("<ul id='menulist'>")
321
     for p in mpages:
365
     for p in mpages:
322
         printMenuItem(p, False, False, False, False, "0", "de")
366
         printMenuItem(p, False, False, False, False, "0", "de")
367
+    print("</ul>")
323
 
368
 
324
 def printSteamMenuEnglish():
369
 def printSteamMenuEnglish():
325
     mpages = [p for p in pages if p.get("parent", "") == "steam" and p.lang == "en"]
370
     mpages = [p for p in pages if p.get("parent", "") == "steam" and p.lang == "en"]
326
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
371
     mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
372
+
373
+    print("<ul id='menulist'>")
327
     for p in mpages:
374
     for p in mpages:
328
         printMenuItem(p, False, False, False, True)
375
         printMenuItem(p, False, False, False, True)
376
+    print("</ul>")
329
 
377
 
330
 def printSteamMenuDeutsch():
378
 def printSteamMenuDeutsch():
331
     # TODO show german pages, or english pages when german not available
379
     # TODO show german pages, or english pages when german not available

+ 1
- 1
static/css/style.css View File

183
     margin-right: 0.5em;
183
     margin-right: 0.5em;
184
 }
184
 }
185
 
185
 
186
-ul ul {
186
+#menulist ul {
187
     font-size: 0.75em;
187
     font-size: 0.75em;
188
     margin-bottom: 1em;
188
     margin-bottom: 1em;
189
 }
189
 }

Loading…
Cancel
Save