2 Commits

Author SHA1 Message Date
  Thomas B 768b3a956a fix ordering of subprojects in project list 1 month ago
  Thomas B 5346ee55e3 generic menu printing functions 1 month ago

+ 2
- 1
input/projects/3d-printing.md View File

3
 parent: projects
3
 parent: projects
4
 position: 10
4
 position: 10
5
 child-id: 3d-printing
5
 child-id: 3d-printing
6
+sort-order: position
6
 ---
7
 ---
7
 
8
 
8
 In 2016 I've started experimenting with 3D printers.
9
 In 2016 I've started experimenting with 3D printers.
10
 Here are all the articles that are part of my 3D printing series:
11
 Here are all the articles that are part of my 3D printing series:
11
 
12
 
12
 <!--%
13
 <!--%
13
-print3DPrintingMenu()
14
+printMenu()
14
 %-->
15
 %-->
15
 
16
 
16
 If you're interested in my 3D print designs, take a look [at my Thingiverse account](https://www.thingiverse.com/xythobuz/designs) or my [Git Repository](https://git.xythobuz.de/thomas/3d-print-designs).
17
 If you're interested in my 3D print designs, take a look [at my Thingiverse account](https://www.thingiverse.com/xythobuz/designs) or my [Git Repository](https://git.xythobuz.de/thomas/3d-print-designs).

+ 4
- 2
input/projects/input_devices.md View File

3
 parent: projects
3
 parent: projects
4
 position: 15
4
 position: 15
5
 child-id: input_devices
5
 child-id: input_devices
6
+sort-order: date
6
 ---
7
 ---
7
 
8
 
8
 One of the recurring topics in my projects are different kind of input devices.
9
 One of the recurring topics in my projects are different kind of input devices.
9
 Here you can find all pages in this category.
10
 Here you can find all pages in this category.
10
 
11
 
11
 <!--%
12
 <!--%
12
-printInputDevicesMenu()
13
+printMenu()
13
 %-->
14
 %-->
14
 
15
 
15
 The following pages are also related to this topic.
16
 The following pages are also related to this topic.
16
 
17
 
17
 <!--%
18
 <!--%
18
-printInputDevicesRelatedMenu()
19
+mpages = [p for p in pages if p.get("show_in_input_devices", "false") == "true"]
20
+printMenuDate(mpages)
19
 %-->
21
 %-->

+ 4
- 2
input/projects/quadcopters.md View File

3
 parent: projects
3
 parent: projects
4
 position: 20
4
 position: 20
5
 child-id: quadcopters
5
 child-id: quadcopters
6
+sort-order: position
6
 ---
7
 ---
7
 
8
 
8
 In the last couple of years I built multiple quadcopters and some other related flying remote-controlled model vehicles.
9
 In the last couple of years I built multiple quadcopters and some other related flying remote-controlled model vehicles.
12
 Of course I'm not flying illegally, I have a model flight insurance and I am a registered UAV pilot in the European Union! 👮
13
 Of course I'm not flying illegally, I have a model flight insurance and I am a registered UAV pilot in the European Union! 👮
13
 
14
 
14
 <!--%
15
 <!--%
15
-printQuadcopterMenu()
16
+printMenu()
16
 %-->
17
 %-->
17
 
18
 
18
 The following projects and blog posts are also related to my Quadcopter endeavours.
19
 The following projects and blog posts are also related to my Quadcopter endeavours.
19
 
20
 
20
 <!--%
21
 <!--%
21
-printQuadcopterRelatedMenu()
22
+mpages = [p for p in pages if p.get("show_in_quadcopters", "false") == "true"]
23
+printMenuDate(mpages)
22
 %-->
24
 %-->
23
 
25
 
24
 You can find all my Betaflight configuration dumps and related files [here](https://git.xythobuz.de/thomas/copter-configs).
26
 You can find all my Betaflight configuration dumps and related files [here](https://git.xythobuz.de/thomas/copter-configs).

+ 2
- 1
input/projects/smarthome.md View File

3
 parent: projects
3
 parent: projects
4
 position: 50
4
 position: 50
5
 child-id: smarthome
5
 child-id: smarthome
6
+sort-order: position
6
 ---
7
 ---
7
 
8
 
8
 With the appearance of cheap WiFi-capable microcontrollers in recent years, like the ESP8266 and the ESP32, the Internet of Things and Smart Home automation have been on my mind.
9
 With the appearance of cheap WiFi-capable microcontrollers in recent years, like the ESP8266 and the ESP32, the Internet of Things and Smart Home automation have been on my mind.
12
 The pages in this category document different parts of my setup at home.
13
 The pages in this category document different parts of my setup at home.
13
 
14
 
14
 <!--%
15
 <!--%
15
-printSmarthomeMenu()
16
+printMenu()
16
 %-->
17
 %-->

+ 1
- 0
input/projects/xyrobot.md View File

10
 date: 2011-07-28
10
 date: 2011-07-28
11
 update: 2012-08-30
11
 update: 2012-08-30
12
 child-id: xyrobot
12
 child-id: xyrobot
13
+sort-order: position
13
 ---
14
 ---
14
 
15
 
15
 This is my robot project. A self-made PCB with an AtMega2560 controls everything. The robot has a [Bluetooth module][1], a [Gameboy Camera][2] and my [RAM module][3]. I bought the [RN-KeyLCD][4] and the [RN-VN2][5] from [Roboternetz][6].
16
 This is my robot project. A self-made PCB with an AtMega2560 controls everything. The robot has a [Bluetooth module][1], a [Gameboy Camera][2] and my [RAM module][3]. I bought the [RN-KeyLCD][4] and the [RN-VN2][5] from [Roboternetz][6].

+ 35
- 54
macros.py View File

265
 
265
 
266
         # print subpages for these top-level items
266
         # print subpages for these top-level items
267
         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")]
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
         if len(subpages) > 0:
273
         if len(subpages) > 0:
269
             print("<ul>")
274
             print("<ul>")
270
             for sp in subpages:
275
             for sp in subpages:
285
 
290
 
286
         # print subpages for these top-level items
291
         # print subpages for these top-level items
287
         subpages = [sub for sub in enpages if sub.get("parent", "none") == p.get("child-id", "unknown")]
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
         if len(subpages) > 0:
298
         if len(subpages) > 0:
290
             print("<ul>")
299
             print("<ul>")
291
             for sp in subpages:
300
             for sp in subpages:
294
 
303
 
295
     print("</ul>")
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
 def printRobotMenuEnglish():
332
 def printRobotMenuEnglish():
352
     mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "en"]
333
     mpages = [p for p in pages if p.get("parent", "") == "xyrobot" and p.lang == "en"]

Loading…
Cancel
Save