|
@@ -265,6 +265,11 @@ def printProjectsMenu():
|
265
|
265
|
|
266
|
266
|
# print subpages for these top-level items
|
267
|
267
|
subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
|
|
268
|
+ order = p.get("sort-order", "date")
|
|
269
|
+ if order == "position":
|
|
270
|
+ subpages.sort(key=lambda p: p["position"])
|
|
271
|
+ else:
|
|
272
|
+ subpages.sort(key=lambda p: p["date"], reverse = True)
|
268
|
273
|
if len(subpages) > 0:
|
269
|
274
|
print("<ul>")
|
270
|
275
|
for sp in subpages:
|
|
@@ -285,7 +290,11 @@ def printProjectsMenu():
|
285
|
290
|
|
286
|
291
|
# print subpages for these top-level items
|
287
|
292
|
subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
|
288
|
|
- subpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
|
|
293
|
+ order = p.get("sort-order", "date")
|
|
294
|
+ if order == "position":
|
|
295
|
+ subpages.sort(key=lambda p: p["position"])
|
|
296
|
+ else:
|
|
297
|
+ subpages.sort(key=lambda p: p["date"], reverse = True)
|
289
|
298
|
if len(subpages) > 0:
|
290
|
299
|
print("<ul>")
|
291
|
300
|
for sp in subpages:
|
|
@@ -294,59 +303,31 @@ def printProjectsMenu():
|
294
|
303
|
|
295
|
304
|
print("</ul>")
|
296
|
305
|
|
297
|
|
-def print3DPrintingMenu():
|
298
|
|
- mpages = [p for p in pages if p.get("parent", "") == "3d-printing" and p.lang == "en"]
|
299
|
|
- mpages.sort(key=lambda p: int(p["position"]))
|
300
|
|
-
|
301
|
|
- print("<ul id='menulist'>")
|
302
|
|
- for p in mpages:
|
303
|
|
- printMenuItem(p, False, True, True)
|
304
|
|
- print("</ul>")
|
305
|
|
-
|
306
|
|
-def printInputDevicesMenu():
|
307
|
|
- mpages = [p for p in pages if p.get("parent", "") == "input_devices" and p.lang == "en"]
|
308
|
|
- mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
|
309
|
|
-
|
310
|
|
- print("<ul id='menulist'>")
|
311
|
|
- for p in mpages:
|
312
|
|
- printMenuItem(p, False, True, True)
|
313
|
|
- print("</ul>")
|
314
|
|
-
|
315
|
|
-def printInputDevicesRelatedMenu():
|
316
|
|
- mpages = [p for p in pages if p.get("show_in_input_devices", "false") == "true"]
|
317
|
|
- mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
|
318
|
|
-
|
319
|
|
- print("<ul id='menulist'>")
|
320
|
|
- for p in mpages:
|
321
|
|
- printMenuItem(p, False, True, True)
|
322
|
|
- print("</ul>")
|
323
|
|
-
|
324
|
|
-def printSmarthomeMenu():
|
325
|
|
- mpages = [p for p in pages if p.get("parent", "") == "smarthome" and p.lang == "en"]
|
326
|
|
- mpages.sort(key=lambda p: int(p["position"]))
|
327
|
|
-
|
328
|
|
- print("<ul id='menulist'>")
|
329
|
|
- for p in mpages:
|
330
|
|
- printMenuItem(p, False, True, True)
|
331
|
|
- print("</ul>")
|
332
|
|
-
|
333
|
|
-def printQuadcopterMenu():
|
334
|
|
- mpages = [p for p in pages if p.get("parent", "") == "quadcopters" and p.lang == "en"]
|
335
|
|
- mpages.sort(key=lambda p: int(p["position"]))
|
336
|
|
-
|
337
|
|
- print("<ul id='menulist'>")
|
338
|
|
- for p in mpages:
|
339
|
|
- printMenuItem(p, False, True, True)
|
340
|
|
- print("</ul>")
|
341
|
|
-
|
342
|
|
-def printQuadcopterRelatedMenu():
|
343
|
|
- mpages = [p for p in pages if p.get("show_in_quadcopters", "false") == "true"]
|
344
|
|
- mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
|
345
|
|
-
|
346
|
|
- print("<ul id='menulist'>")
|
347
|
|
- for p in mpages:
|
348
|
|
- printMenuItem(p, False, True, True)
|
349
|
|
- print("</ul>")
|
|
306
|
+def printMenuGeneric(mpages = None, sortKey = None, sortReverse = True):
|
|
307
|
+ if mpages == None:
|
|
308
|
+ mpages = [p for p in pages if p.get("parent", "__none__") == page["child-id"] and p.lang == "en"]
|
|
309
|
+ if sortKey != None:
|
|
310
|
+ mpages.sort(key = sortKey, reverse = sortReverse)
|
|
311
|
+
|
|
312
|
+ if len(mpages) > 0:
|
|
313
|
+ print("<ul id='menulist'>")
|
|
314
|
+ for p in mpages:
|
|
315
|
+ printMenuItem(p, False, True, True)
|
|
316
|
+ print("</ul>")
|
|
317
|
+
|
|
318
|
+def printMenuDate(mpages = None, sortReverse = True):
|
|
319
|
+ sortKey = lambda p: p["date"]
|
|
320
|
+ printMenuGeneric(mpages, sortKey, sortReverse)
|
|
321
|
+
|
|
322
|
+def printMenuPositional(mpages = None):
|
|
323
|
+ printMenuGeneric(mpages, lambda p: int(p["position"]), False)
|
|
324
|
+
|
|
325
|
+def printMenu(mpages = None):
|
|
326
|
+ order = page.get("sort-order", "date")
|
|
327
|
+ if order == "position":
|
|
328
|
+ printMenuPositional(mpages)
|
|
329
|
+ else:
|
|
330
|
+ printMenuDate(mpages)
|
350
|
331
|
|
351
|
332
|
def printRobotMenuEnglish():
|
352
|
333
|
mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "en"]
|