forked from I2P_Developers/i2p.www
Implemented 'tag' and 'sort by' for papers
This commit is contained in:
@@ -3,12 +3,28 @@ from flask import render_template
|
||||
from i2p2www import ANONBIB_CFG, ANONBIB_FILE
|
||||
from i2p2www.anonbib import BibTeX, config
|
||||
|
||||
def papers_list():
|
||||
def papers_list(tag=None, choice=None):
|
||||
config.load(ANONBIB_CFG)
|
||||
rbib = BibTeX.parseFile(ANONBIB_FILE)
|
||||
rbib = [ b for b in rbib.entries ]
|
||||
rbib = BibTeX.sortEntriesByDate(rbib)
|
||||
rbib = BibTeX.splitSortedEntriesBy(rbib, 'year')
|
||||
if tag:
|
||||
rbib = [ b for b in rbib.entries if tag in b.get('www_tags', '').split() ]
|
||||
else:
|
||||
rbib = rbib.entries
|
||||
|
||||
if choice == 'topic':
|
||||
rbib = BibTeX.sortEntriesBy(rbib, 'www_section', 'ZZZZZZZZZZZZZZ')
|
||||
rbib = BibTeX.splitSortedEntriesBy(rbib, 'www_section')
|
||||
if rbib[-1][0].startswith("<span class='bad'>"):
|
||||
rbib[-1] = ("Miscellaneous", rbib[-1][1])
|
||||
|
||||
rbib = [ (s, BibTeX.sortEntriesByDate(ents))
|
||||
for s, ents in rbib
|
||||
]
|
||||
elif choice == 'author':
|
||||
rbib, url_map = BibTeX.splitEntriesByAuthor(rbib)
|
||||
else:
|
||||
rbib = BibTeX.sortEntriesByDate(rbib)
|
||||
rbib = BibTeX.splitSortedEntriesBy(rbib, 'year')
|
||||
|
||||
bib = {}
|
||||
bib['title'] = 'Papers on I2P'
|
||||
@@ -27,6 +43,4 @@ def papers_list():
|
||||
sections.append(s)
|
||||
bib['sections'] = sections
|
||||
|
||||
print bib['sections']
|
||||
|
||||
return render_template('papers/list.html', bib=bib)
|
||||
|
Reference in New Issue
Block a user