-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathbooks.html
180 lines (159 loc) · 7.66 KB
/
books.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
$def with (docs, key, shelf_counts, doc_count, lists=None, user=None, logged_in_user=None, public=False, sort_order='desc', owners_page=False, q="", results_per_page=25, ratings=[], checkin_year=None)
$# Displays a user's reading log
$# :param list docs:
$# :param Literal['currently-reading', 'want-to-read', 'already-read', 'sponsorships', 'loans', 'notes', 'observations'] key:
$# :param Dict[str: int] shelf_counts:
$# :param list? lists:
$# :param user:
$# :param bool public:
$# :param str q: search term.
$ component_times = {}
$ component_times['TotalTime'] = time()
$ username = user.key.split('/')[-1]
$ current_page = int(input(page=1).page)
$ total_docs = shelf_counts.get(key, None)
$ userDisplayName = user.displayname or ctx.user.displayname
$ userKey = user.key or ctx.user.key
$ header_title = ""
$ padding = ""
$if key == 'mybooks':
$ header_title = _("My Books")
$ padding = "no-padding"
$elif key == 'currently-reading':
$ header_title = _("Currently Reading")
$elif key == 'want-to-read':
$ header_title = _("Want to Read")
$elif key == 'already-read':
$ header_title = _("Already Read")
$if not header_title:
$if key == 'sponsorships':
$ header_title = _("Sponsorships")
$elif key == 'notes':
$ header_title = _("My Notes")
$elif key == 'observations':
$ header_title = _("My Reviews")
$elif key == 'loans':
$ header_title = _("My Loans")
$elif key == 'imports':
$ header_title = _("Imports and Exports")
$elif key == 'lists':
$ header_title = _("My Lists")
$elif key == 'list':
$ header_title = docs.get('name', 'List')
$else:
$ header_title = key
$var title: $header_title
$ url_prefix = "/people/" + username
$ readlog_url = url_prefix + "/books/%s/"
$ options = [
$ (_("Want to Read (%(count)d)", count=shelf_counts['want-to-read']), readlog_url % "want-to-read"),
$ (_("Currently Reading (%(count)d)", count=shelf_counts['currently-reading']), readlog_url % "currently-reading"),
$ (_("Already Read (%(count)d)", count=shelf_counts['already-read']), readlog_url % "already-read"),
$ (_("My Lists (%(count)d)" if owners_page else "Lists (%(count)d)", count=len(lists)) , url_prefix + "/lists")
$ ]
$if owners_page:
$ options += [
$ (_("My Loans"), "/account/loans"),
$ (_("My Notes"), url_prefix + "/books/notes"),
$ (_("My Reviews"), url_prefix + "/books/observations"),
$ (_("Imports and Exports"), "/account/import")
$ ]
<div class="mybooks">
$:render_template("account/sidebar", user, key=key, public=public, owners_page=owners_page, counts=shelf_counts, lists=lists, component_times=component_times)
<div class="mybooks-details $padding">
$if key == 'mybooks':
$ component_times['Yearly Goal Banner'] = time()
$ year = get_reading_goals_year()
$ current_goal = get_reading_goals(year=year)
$# Is date between 1 Dec and 1 Feb?
$if not current_goal and within_date_range(12, 1, 2, 1):
<div class="page-banner page-banner-body page-banner-mybooks">
$_('Set your %(year)s Yearly Reading Goal:', year=year) <a class="btn primary set-reading-goal-link" data-ol-link-track="MyBooksLandingPage|SetReadingGoal"href="javascript:;">$:_('Set my goal')</a>
</div>
$ component_times['Yearly Goal Banner'] = time() - component_times['Yearly Goal Banner']
$# Start : Persona research banner
$if user:
$if user.is_screener_eligible():
$ banner_key = 'pr2308'
$ hide_banner = user.preferences().get('hidden-banner') == banner_key
$if not hide_banner:
$ announcement = _('Are you a teacher, student, or researcher? Please <a href="https://forms.gle/sR7V2hZFJbavhffy5" class="btn primary">help us improve</a>')
$:render_template('site/banner', announcement, banner_key)
$# End : Persona research banner
$ component_times['Details header'] = time()
<header>
<div>
<div class="sansserif grey account-settings-menu">
$# Only show breadcrumbs when we're not on mybooks
$if key != 'mybooks':
$if not owners_page:
<a href="$userKey">
← <span>$userDisplayName</span></a>
$else:
<a href="/account/books">
← <span>$_("My Books")</span></a>
»
$if key == 'list':
$ list_url = "/account" if owners_page else userKey
<a href="$(list_url)/lists"><span>$(_("%(userDisplayName)s's Lists", userDisplayName=userDisplayName) if not owners_page else _("My Lists"))</span></a>
»
$else:
$:render_template("books/breadcrumb_select", key=key, selected=header_title, options=options)
</div>
<div>
$if key in ['mybooks', 'list']:
<h1 class="details-title">
$header_title
</h1>
$if owners_page and (key in ['currently-reading', 'already-read', 'want-to-read'] and not checkin_year):
<a href="$ctx.path/stats" title="$_('View stats about this shelf')">$_('Stats')</a>
</div>
$if owners_page:
<p>
$if key == 'notes':
$_('Your book notes are private and cannot be viewed by other patrons.')
$elif key == 'observations':
$_('Your book reviews will be shared anonymously with other patrons.')
$elif key in ['currently-reading', 'already-read', 'want-to-read']:
$if public:
$_('Your reading log is currently set to public')
<button onclick="prompt('Copy share link to clipboard:', window.location.protocol + '//' + window.location.hostname + '/people/$(username)/books/$(key)');">Share</button> or
$else:
$_('Your reading log is currently set to private')
—
<a href="/account/privacy">$_('Manage your privacy settings')</a>
</p>
</div>
$if key == 'list':
<div>
$:macros.databarView(docs)
</div>
</header>
$ component_times['Details header'] = time() - component_times['Details header']
$ component_times['Details content'] = time()
<div class="details-content">
$if key == 'mybooks':
$:render_template('account/mybooks', logged_in_user, docs, key=key, public=public, owners_page=owners_page, counts=shelf_counts, lists=lists, component_times=component_times)
$elif key == 'loans':
$:render_template('account/loans', logged_in_user, docs)
$elif key == 'notes':
$:render_template('account/notes', docs, user, shelf_counts['notes'], page=current_page)
$elif key == 'observations':
$:render_template('account/observations', docs, user, shelf_counts['observations'], page=current_page)
$elif key == 'imports':
$:render_template('account/import')
$elif key == 'lists':
$:render_template('lists/lists', docs, lists, show_header=False)
$elif key == 'already-read':
$:render_template('account/reading_log', docs, key, shelf_counts[key], doc_count, owners_page, current_page, sort_order=sort_order, user=user, include_ratings=owners_page, q=q, results_per_page=results_per_page, ratings=ratings, checkin_year=checkin_year)
$elif key in {'currently-reading', 'want-to-read', 'sponsorships'}:
$:render_template('account/reading_log', docs, key, shelf_counts[key], doc_count, owners_page, current_page, sort_order=sort_order, user=user, q=q, results_per_page=results_per_page)
$else:
$:render_template('type/list/view', docs, check_owner=False, owns_page=True)
</div>
$ component_times['Details content'] = time() - component_times['Details content']
</div>
</div>
$ component_times['TotalTime'] = time() - component_times['TotalTime']
$if query_param('debug'):
$:macros.Profile(component_times)