Explorar el Código

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

Thomas B hace 1 mes
padre
commit
3a76416a97
Se han modificado 2 ficheros con 58 adiciones y 10 borrados
  1. 57
    9
      macros.py
  2. 1
    1
      static/css/style.css

+ 57
- 9
macros.py Ver fichero

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

+ 1
- 1
static/css/style.css Ver fichero

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

Loading…
Cancelar
Guardar