Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Books page integration #6323

Merged
merged 27 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a13745b
rm dupe work first published year, title, subtitle
mekarpeles Mar 8, 2022
c80b4a2
Moving subjects up, show more, nojs
mekarpeles Mar 8, 2022
43f34b0
js fixes
mekarpeles Mar 8, 2022
83d03cd
Swap tabs with spaces
jimchamp Mar 9, 2022
2395be6
Remove work-level classifications
jimchamp Mar 8, 2022
dc0b818
Deduplicate work descriptions
jimchamp Mar 8, 2022
f5d6edb
Compare edition and work descriptions
jimchamp Mar 10, 2022
aa40034
Provide visual feedback for subject clamp
jimchamp Mar 15, 2022
bd30298
Update navbar link
jimchamp Mar 10, 2022
bb564af
Consolidate edition and work components
jimchamp Mar 10, 2022
ca4c6c4
Move lists section into main content div
jimchamp Mar 14, 2022
f70163d
Add anchor for jump link
jimchamp Mar 14, 2022
82d1085
Update openlibrary/templates/type/edition/view.html
mekarpeles Mar 18, 2022
d5c7986
Add above-fold identifiers for librarians
jimchamp Mar 10, 2022
ba4f3cd
Style above-fold book identifiers
jimchamp Mar 10, 2022
e087a3d
Restyle omnibar
mekarpeles Mar 17, 2022
492ae12
Correct ISBN logic
jimchamp Mar 17, 2022
24e4992
Restyle for mobile
jimchamp Mar 17, 2022
8aa54fc
Update overflow-x for omnibar
jimchamp Mar 17, 2022
4099075
Tidy editions table
jimchamp Mar 18, 2022
0942b1d
Remove OLID from omnibar
jimchamp Mar 18, 2022
023486b
Increase featured edition message margin
jimchamp Mar 18, 2022
21c05d3
Add border around lists section
jimchamp Mar 18, 2022
a7d7ba3
Initialize clampers independently
jimchamp Mar 21, 2022
2b2c7a6
Update openlibrary/templates/type/work/editions_datatable.html
mekarpeles Mar 21, 2022
af80cc2
Simplify first publish year
jimchamp Mar 22, 2022
17bad4d
Replace "Publishers" with singular form
jimchamp Mar 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openlibrary/macros/EditionNavBar.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</a>
</li>
<li>
<a href="#edition-details">$_("This Edition")</a>
<a href="#details">$_("Details")</a>
</li>
<li>
<a href="#reader-observations">$_("Reviews")</a>
Expand Down
21 changes: 9 additions & 12 deletions openlibrary/macros/SubjectTags.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$def with(work,location,tags=[])
$def with(work, tags=[])

$def render_subjects(label, subjects, track_value, prefix=""):
$if subjects:
<div class="section link-box">
<span class="clamp" data-before="+ ">
<h6>$label</h6>
<span>
$for subject in subjects:
<a href="/subjects/$prefix$utf8(subject.lower().replace(' ', '_').replace(',', '').replace('/', ''))" data-ol-link-track="$track_value">$subject</a>$cond(not loop.last, ",", "")
</span>
Expand All @@ -13,13 +13,10 @@ <h6>$label</h6>
$if work:
$for tag in tags:
$if tag=="Subjects":
$if location=="work":
$:render_subjects(_("Subjects"), work.get_subjects(),"WorkSection|SubjectClick")
$else:
$:render_subjects(_("Subjects"), work.get_subjects(),"BookOverview|SubjectClick")
$elif tag=="People":
$:render_subjects(_("People"), work.subject_people,"WorkSection|SubjectPeopleClick", prefix="person:")
$elif tag=="Places":
$:render_subjects(_("Places"), work.subject_places,"WorkSection|SubjectPlacesClick", prefix="place:")
$elif tag=="Times":
$:render_subjects(_("Times"), work.subject_times,"WorkSection|SubjectTimesClick", prefix="time:")
$:render_subjects(_("Subjects"), work.get_subjects(),"BookOverview|SubjectClick")
$if tag=="People":
$:render_subjects(_("People"), work.subject_people,"BookOverview|SubjectPeopleClick", prefix="person:")
$if tag=="Places":
$:render_subjects(_("Places"), work.subject_places,"BookOverview|SubjectPlacesClick", prefix="place:")
$if tag=="Times":
$:render_subjects(_("Times"), work.subject_times,"BookOverview|SubjectTimesClick", prefix="time:")
13 changes: 11 additions & 2 deletions openlibrary/plugins/openlibrary/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,18 @@ jQuery(function () {
.then(module => module.initRealTimeValidation());
}
// conditionally load readmore button based on class in the page
if (document.getElementsByClassName('read-more-button').length) {
const readMoreButtons = document.getElementsByClassName('read-more-button');
const clampers = document.getElementsByClassName('clamp');
if (readMoreButtons.length || clampers.length) {
import(/* webpackChunkName: "readmore" */ './readmore.js')
.then(module => module.initReadMoreButton());
.then(module => {
if (readMoreButtons.length) {
module.initReadMoreButton();
}
if (clampers.length) {
module.initClampers();
}
});
}
// conditionally loads Goodreads import based on class in the page
if (document.getElementsByClassName('import-table').length) {
Expand Down
19 changes: 19 additions & 0 deletions openlibrary/plugins/openlibrary/js/readmore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ export function initReadMoreButton() {
}
});
}

export function initClampers() {
/*
Clamper shows used to show more/less by toggling `hidden`
style on parent .clamp tag
*/
$('.clamp').on('click', function(){
const up = $(this);
if (up.hasClass('clamp')) {
up.css({display: up.css('display') === '-webkit-box' ? 'unset' : '-webkit-box'});

if (up.attr('data-before') === '+ ') {
up.attr('data-before', '- ')
} else {
up.attr('data-before', '+ ')
}
}
});
}
5 changes: 4 additions & 1 deletion openlibrary/templates/site/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
$ style = 'build/page-%s.css'%ctx.get('cssfile', 'user')
<link href="$static_url(style)" rel="stylesheet" type="text/css" />


<!-- Don't hide content with clamp if no js to show more/less -->
<noscript>
<style>.clamp { -webkit-line-clamp: unset !important; }</style>
</noscript>
<script>

/* @licstart The following is the entire license notice for the
Expand Down
Loading