52
52
---
53
53
"""
54
54
55
- TAG_SORT_STARS_MD_FRONTMATTER = """---
55
+ TAG_SORT_MD_FRONTMATTER = """---
56
56
layout: assetportal
57
57
tag: {}
58
58
title: {}
59
- sort: stars
59
+ sort: {}
60
60
---
61
61
"""
62
62
@@ -472,10 +472,6 @@ def process_assets(download = False):
472
472
author_collection_dir = "authors"
473
473
rmmkdir (author_collection_dir )
474
474
475
- # Jekyll tags collection
476
- tag_collection_dir = "tags"
477
- rmmkdir (tag_collection_dir )
478
-
479
475
# Jekyll asset data
480
476
asset_data_dir = os .path .join ("_data" , "assets" )
481
477
rmmkdir (asset_data_dir )
@@ -519,7 +515,8 @@ def process_assets(download = False):
519
515
"id" : asset_id ,
520
516
"tags" : asset ["tags" ],
521
517
"platforms" : asset ["platforms" ],
522
- "stars" : asset .get ("stars" ) or 0
518
+ "stars" : asset .get ("stars" ) or 0 ,
519
+ "timestamp" : asset .get ("timestamp" ) or 0
523
520
})
524
521
525
522
# build tag index
@@ -532,7 +529,8 @@ def process_assets(download = False):
532
529
}
533
530
tagindex [tag ]["assets" ].append ({
534
531
"id" : asset_id ,
535
- "stars" : asset .get ("stars" ) or 0
532
+ "stars" : asset .get ("stars" ) or 0 ,
533
+ "timestamp" : asset .get ("timestamp" ) or 0
536
534
})
537
535
538
536
# build platform index
@@ -591,14 +589,25 @@ def process_assets(download = False):
591
589
platformlist .sort (key = lambda x : x .get ("id" ).lower ())
592
590
write_as_json (PLATFORMINDEX_JSON , platformlist )
593
591
592
+ # Jekyll tags collection (one subdirectory per sort order)
593
+ tag_collection_dir = "tags"
594
+ sort_orders = ["stars" , "timestamp" ]
595
+ for sort_order in sort_orders :
596
+ rmmkdir (os .path .join (tag_collection_dir , sort_order ))
597
+
594
598
# write tag data
595
599
for tag in taglist :
596
600
tag ["assets" ].sort (key = lambda x : x .get ("id" ))
601
+
602
+ # _data/tags
597
603
filename = os .path .join (tag_data_dir , tag ["id" ] + ".json" )
598
604
with open (filename , "w" ) as f :
599
605
f .write (json .dumps (tag , indent = 2 , sort_keys = True ))
600
- with open (os .path .join (tag_collection_dir , tag ["id" ] + ".md" ), "w" ) as f :
601
- f .write (TAG_SORT_STARS_MD_FRONTMATTER .format (tag ["id" ], tag ["name" ]))
606
+
607
+ # tags/stars, tags/timestamp
608
+ for sort_order in sort_orders :
609
+ with open (os .path .join (tag_collection_dir , sort_order , tag ["id" ] + ".md" ), "w" ) as f :
610
+ f .write (TAG_SORT_MD_FRONTMATTER .format (tag ["id" ], tag ["name" ], sort_order ))
602
611
603
612
604
613
0 commit comments