-
Notifications
You must be signed in to change notification settings - Fork 0
/
publication_page.py
executable file
·96 lines (85 loc) · 4.12 KB
/
publication_page.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python
# encoding: utf-8
import bibparse
import sys
import os
def tidy(string):
replacements = [("{", ""), ("}", ""),
("\\'a", "á"),
("\\'e", "é"), ('\\"e', "ë"), ("\\`e", "è"),
("\\'i", "í"), ('\\"i', "ï"), ('\\`i', "ì"),
("\\'o", "ó"),
("\\'u", "ú"), ]
for old, new in replacements:
string = string.replace(old, new)
return string
def print_tab_title(f, title, papers):
href = ''.join(title.split())
f.write('<li><a href="#%s" data-toggle="tab">%s (%d)</a></li>\n' % (href, title, len(papers)))
def print_tab_content(f, title, papers, active=False):
previous_year = ''
href = ''.join(title.split())
papers = reversed(sorted(papers, key=lambda paper: int(paper.data['Year'])))
if active:
f.write('<div class="tab-pane fade in active" id="%s">\n' % href)
else:
f.write('<div class="tab-pane fade in" id="%s">\n' % href)
f.write('<div class="accordion" id="accordion%s">\n' % href)
for paper in papers:
if paper.data['Year'] != previous_year:
f.write('<h3>%s</h3>\n' % paper.data['Year'])
previous_year = paper.data['Year']
f.write('<div class="accordion-group">\n')
f.write(' <div class="accordion-heading">\n')
f.write(' <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion%s" href="#collapse%s_%s" onClick="_gaq.push([\'_trackEvent\', \'Publications\', \'Abstract\', \'%s\']);">\n' % (href, paper.key, href, paper.key))
f.write(' %s\n' % tidy(paper.data['Title']))
f.write(' </a>\n')
f.write(' </div>\n')
f.write(' <div id="collapse%s_%s" class="accordion-body collapse">\n' % (paper.key, href))
f.write(' <div class="accordion-inner">\n')
f.write(' %s\n' % tidy(', '.join(paper.data['Author'].split(' and '))))
if 'Booktitle' in paper.data:
f.write('<p><em>%s</em></p>\n' % tidy(paper.data['Booktitle']))
if 'Journal' in paper.data:
f.write('<p><em>%s</em></p>\n' % tidy(paper.data['Journal']))
if 'Abstract' in paper.data:
f.write('<blockquote><p>%s</p></blockquote>\n' % tidy(paper.data['Abstract']))
f.write('<i class="icon-tags"></i> <a href="/laurent.bib" onClick="_gaq.push([\'_trackEvent\', \'Publications\', \'Bibtex\', \'%s\']);">.bib</a> [%s] | ' % (paper.key, paper.key))
fichier="download/pdfs/%s.pdf"% (paper.key)
if os.path.isfile(fichier):
f.write('<i class="icon-book"></i> <a href="/download/pdfs/%s.pdf" onClick="_gaq.push([\'_trackEvent\', \'Publications\', \'Download\', \'%s\']);">.pdf</a>' % (paper.key, paper.key))
else:
print "Ne trouve pas %s !!" % fichier
f.write(' </div>\n')
f.write(' </div>\n')
f.write('</div>\n')
f.write('</div>\n')
f.write('</div>\n')
papers = bibparse.parse_bib('laurent.bib')
inproceedings = [paper for paper in papers if paper.btype == 'inproceedings']
articles = [paper for paper in papers if paper.btype == 'article']
chapters = [paper for paper in papers if paper.btype == 'inbook']
f = open('research/publications.html', 'w')
f.write('---\n')
f.write('layout: page\n')
f.write('title: "Publications"\n')
f.write('description: ""\n')
from datetime import date
f.write('tagline: "last updated on %s"\n' % date.today().strftime("%B %d, %Y"))
f.write('group: research\n')
f.write('---\n')
f.write('{% include JB/setup %}\n')
f.write('<ul class="nav nav-tabs">\n')
print_tab_title(f, 'All', papers)
print_tab_title(f, 'Journal articles', articles)
print_tab_title(f, 'Book chapters', chapters)
print_tab_title(f, 'Conference and workshop proceedings', inproceedings)
f.write('</ul>\n')
f.write('<div id="myTabContent" class="tab-content">\n')
print_tab_content(f, 'All', papers, active=True)
print_tab_content(f, 'Journal articles', articles)
print_tab_content(f, 'Book chapters', chapters)
print_tab_content(f, 'Conference and workshop proceedings', inproceedings)
f.write('</div>\n')
f.close()
os.system("cat analytics.js >> research/publications.html")