-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap_cards_report.py
111 lines (82 loc) · 3.2 KB
/
bootstrap_cards_report.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
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/local/bin/python3
"""Support for library reports as a list of bootstrap cards.
Bootstrap is basically HTML + Bootstrap.
"""
import html_report
def gen_header():
"""
Generate a header for Bootstrap Cards. Use HTML header,
followed by a Bootstrap Card-deck
"""
header = []
header.append(html_report.gen_header())
header.append('\n<div class="card-deck">\n')
return("".join(header))
def gen_footer():
"""Generate a footer for Bootstrap. Use HTML footer."""
footer = []
footer.append("</div>\n")
footer.append(html_report.gen_footer())
return("".join(footer))
def gen_year_report(lib, years_ordered):
"""Generate a year report showing the number of published papers in each
year passed in.
If you want a color scale then call the HTML version of this routine.
"""
return "Can't generate a gen_year_report in bootstrap-cards format."
def gen_journal_report(lib):
"""Generate a report showing the number of published papers in each journal
"""
return "Can't generate a gen_journal_report in bootstrap-cards format."
def gen_tag_year_report(lib, tags_ordered, n_papers_w_tag, years_ordered):
"""
Generate a tagyear report in Markdown format.
Can't do this with buttons. Nope. This report is a table. Full stop.
"""
return "Can't generate a gen_tag_year_report in bootstrap-buttons format."
def gen_tag_count_date_range_report(tags_in_count_order, n_total_papers,
lib, num_tag_column_groups,
start_date, end_date):
"""
Generate a list of Bootstrap buttons with with each entry showing the
tag name preceded by the number of papers tagged with that tag during
the given date range.
num_tag_column_groups is ignored.
"""
return(
"Can't generate a gen_tag_count_date_report in bootstrap-cards format.")
def gen_pubs_date_range_report(lib, entry_start_date, entry_end_date):
"""
Generate a Bootstrap card deck listing pubs in the library.
"""
tags = lib.get_tags()
pubs = set()
for tag in tags:
pubs = pubs.union(
set(
lib.get_pubs(
tag=tag,
start_entry_date=entry_start_date,
end_entry_date=entry_end_date)))
pubs_report = []
pubs_report.append(gen_header())
for pub in pubs:
# create a card header
pubs_report.append(
'<div class="card border-info" '
+ 'style="min-width: 16rem; max-width: 24rem">\n')
pubs_report.append('<div class="card-header">')
pubs_report.append('[' + pub.title + '](' + pub.url + ')')
pubs_report.append('</div>\n\n')
pubs_report.append(pub.authors)
if pub.journal_name:
pubs_report.append(', *' + pub.journal_name + '*')
if pub.ref:
pubs_report.append(', ' + pub.ref)
if pub.canonical_doi:
pubs_report.append(
'. doi: [' + pub.canonical_doi + '](https://doi.org/'
+ pub.canonical_doi + ')')
pubs_report.append('\n</div>\n\n')
pubs_report.append(gen_footer())
return(u"".join(pubs_report))