|
@@ -10,6 +10,92 @@ DEFAULT_LANG = "en"
|
10
|
10
|
BASE_URL = "https://www.xythobuz.de"
|
11
|
11
|
|
12
|
12
|
# -----------------------------------------------------------------------------
|
|
13
|
+# menu helper macro
|
|
14
|
+# -----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+def printMenuItem(p, yearsAsHeading = False, showDateSpan = False, showOnlyStartDate = False, nicelyFormatFullDate = False, lastyear = "0", lang = ""):
|
|
17
|
+ title = p.title
|
|
18
|
+ if lang != "":
|
|
19
|
+ if p.get("title_" + lang, "") != "":
|
|
20
|
+ title = p.get("title_" + lang, "")
|
|
21
|
+ if p.title == "Blog":
|
|
22
|
+ title = p.post
|
|
23
|
+
|
|
24
|
+ year = p.get("date", "")[0:4]
|
|
25
|
+ if year != lastyear:
|
|
26
|
+ lastyear = year
|
|
27
|
+ if yearsAsHeading:
|
|
28
|
+ print "\n\n#### %s\n" % (year)
|
|
29
|
+
|
|
30
|
+ dateto = ""
|
|
31
|
+ if p.get("date", "" != ""):
|
|
32
|
+ year = p.get("date", "")[0:4]
|
|
33
|
+ if showOnlyStartDate:
|
|
34
|
+ dateto = " (%s)" % (year)
|
|
35
|
+
|
|
36
|
+ if p.get("update", "") != "" and p.get("update", "")[0:4] != year:
|
|
37
|
+ if showDateSpan:
|
|
38
|
+ dateto = " (%s - %s)" % (year, p.get("update", "")[0:4])
|
|
39
|
+
|
|
40
|
+ if nicelyFormatFullDate:
|
|
41
|
+ dateto = " - " + datetime.strptime(p.date, "%Y-%m-%d").strftime("%B %d, %Y")
|
|
42
|
+
|
|
43
|
+ print " * **[%s](%s)**%s" % (title, p.url, dateto)
|
|
44
|
+
|
|
45
|
+ if p.get("description", "") != "":
|
|
46
|
+ description = p.get("description", "")
|
|
47
|
+ if lang != "":
|
|
48
|
+ if p.get("description_" + lang, "") != "":
|
|
49
|
+ description = p.get("description_" + lang, "")
|
|
50
|
+ print "<br><span class=\"listdesc\">" + description + "</span>"
|
|
51
|
+
|
|
52
|
+ return lastyear
|
|
53
|
+
|
|
54
|
+def printRecentMenu(count = 5):
|
|
55
|
+ posts = [p for p in pages if "date" in p]
|
|
56
|
+ posts.sort(key=lambda p: p.get("date"), reverse=True)
|
|
57
|
+ for p in posts[0:count]:
|
|
58
|
+ printMenuItem(p, False, False, False, True)
|
|
59
|
+
|
|
60
|
+def printBlogMenu():
|
|
61
|
+ posts = [p for p in pages if "post" in p]
|
|
62
|
+ posts.sort(key=lambda p: p.get("date", "9999-01-01"), reverse=True)
|
|
63
|
+ lastyear = "0"
|
|
64
|
+ for p in posts:
|
|
65
|
+ lastyear = printMenuItem(p, True, False, False, True, lastyear)
|
|
66
|
+
|
|
67
|
+def printProjectsMenu():
|
|
68
|
+ # prints all pages with parent 'projects' or 'stuff'.
|
|
69
|
+ # first the ones without date, sorted by position.
|
|
70
|
+ # then afterwards those with date, split by year.
|
|
71
|
+ # also supports blog posts with parent.
|
|
72
|
+ enpages = [p for p in pages if p.lang == "en"]
|
|
73
|
+
|
|
74
|
+ dpages = [p for p in enpages if p.get("date", "") == ""]
|
|
75
|
+ mpages = [p for p in dpages if any(x in p.get("parent", "") for x in [ 'projects', 'stuff' ])]
|
|
76
|
+ mpages.sort(key=lambda p: [int(p.get("position", "999"))])
|
|
77
|
+ for p in mpages:
|
|
78
|
+ printMenuItem(p)
|
|
79
|
+
|
|
80
|
+ dpages = [p for p in enpages if p.get("date", "") != ""]
|
|
81
|
+ mpages = [p for p in dpages if any(x in p.get("parent", "") for x in [ 'projects', 'stuff' ])]
|
|
82
|
+ mpages.sort(key=lambda p: [p.get("date", "9999-01-01")], reverse = True)
|
|
83
|
+ lastyear = "0"
|
|
84
|
+ for p in mpages:
|
|
85
|
+ lastyear = printMenuItem(p, True, True, False, False, lastyear)
|
|
86
|
+
|
|
87
|
+def print3DPrintingMenu():
|
|
88
|
+ mpages = [p for p in pages if p.get("parent", "") == "3d-printing" and p.lang == "en"]
|
|
89
|
+ mpages.sort(key=lambda p: int(p["position"]))
|
|
90
|
+ for p in mpages:
|
|
91
|
+ printMenuItem(p, False, True, True)
|
|
92
|
+
|
|
93
|
+def printQuadcopterMenu():
|
|
94
|
+ mpages = [p for p in pages if p.get("parent", "") == "quadcopters" and p.lang == "en"]
|
|
95
|
+ mpages.sort(key=lambda p: int(p["position"]))
|
|
96
|
+ for p in mpages:
|
|
97
|
+ printMenuItem(p, False, True, True)
|
|
98
|
+# -----------------------------------------------------------------------------
|
13
|
99
|
# lightgallery helper macro
|
14
|
100
|
# -----------------------------------------------------------------------------
|
15
|
101
|
|