16
16
SITE_SECOND_TITLE = " Publications"
17
17
18
18
19
+ ############################################################
20
+ # Sort an input list of papers by the sort parameter
21
+ ############################################################
22
+ def sort_hashes_by (papers , hashes , sort_by ):
23
+ temp_papers = {}
24
+ for this_paper in papers :
25
+ if this_paper ['IDs' ]['hash' ] in hashes :
26
+ if sort_by == 'year' :
27
+ temp_papers [this_paper ['IDs' ]['hash' ]] = (this_paper ['clean' ]['clean_date' ]['year' ])
28
+ sorted_hashes = [k for k , v in sorted (temp_papers .items (), key = lambda item : item [1 ], reverse = True )]
29
+ return sorted_hashes
30
+
19
31
############################################################
20
32
# Build common head for all pages
21
33
############################################################
@@ -295,7 +307,11 @@ def draw_paper(this_paper, nav_path="./"):
295
307
html += escape ('; ' .join (authors ))
296
308
html += '<br/>'
297
309
298
- html += this_paper ['clean' ]['journal' ]['journal_name' ]
310
+ try :
311
+ if this_paper ['clean' ]['journal' ]['journal_name' ] != "" :
312
+ html += this_paper ['clean' ]['journal' ]['journal_name' ]
313
+ except :
314
+ pass
299
315
300
316
try :
301
317
if this_paper ['clean' ]['journal' ]['volume' ] != "" :
@@ -308,6 +324,12 @@ def draw_paper(this_paper, nav_path="./"):
308
324
html += ', Issue ' + this_paper ['clean' ]['journal' ]['issue' ]
309
325
except :
310
326
pass
327
+
328
+ try :
329
+ if this_paper ['clean' ]['clean_date' ]['year' ] != "" :
330
+ html += " (" + str (this_paper ['clean' ]['clean_date' ]['year' ]) + ")"
331
+ except :
332
+ pass
311
333
312
334
html += '<br/>'
313
335
@@ -348,8 +370,10 @@ def draw_paper(this_paper, nav_path="./"):
348
370
try :
349
371
if len (this_paper ['clean' ]['zotero_tags' ]) > 0 :
350
372
html += '<br/>Tags: '
373
+ html_tags = []
351
374
for this_tag in this_paper ['clean' ]['zotero_tags' ]:
352
- html += '<a href="' + nav_path + 'tags/' + this_tag ['tag' ] + '/index.html">' + this_tag ['tag' ] + '</a> '
375
+ html_tags .append ('<a href="' + nav_path + 'tags/' + this_tag ['tag' ] + '/index.html">' + this_tag ['tag' ] + '</a>' )
376
+ html += ' | ' .join (html_tags )
353
377
except :
354
378
pass
355
379
@@ -744,9 +768,9 @@ def build_zotero_tags(papers):
744
768
745
769
zotero_tags = {}
746
770
zotero_tags_counts = {}
747
- html_file = open (config .html_dir + '/tags/index.html' , 'w' )
771
+ html_file = open (config .html_dir + '/tags/index.html' , 'w' , encoding = 'utf-8' )
748
772
749
- # Build a dict of ALL zotero tags with a list of each hash (paper) that has this tag, also count the citations while we are here .
773
+ # Build a dict of ALL zotero tags with a list of each hash (paper) that has this tag.
750
774
for this_paper in papers :
751
775
try :
752
776
# Look at all the zotero tags for this paper
@@ -873,8 +897,10 @@ def build_zotero_tags(papers):
873
897
874
898
fo .write (html )
875
899
900
+
876
901
# Build the text needed for each paper
877
- for this_paper in zotero_tags [this_tag ]:
902
+ #for this_paper in zotero_tags[this_tag]:
903
+ for this_paper in sort_hashes_by (papers , zotero_tags [this_tag ], 'year' ):
878
904
879
905
try :
880
906
# Get paper object
0 commit comments