-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9418 from rebecca-shoptaw/9333/feature/add-ia-cov…
…er-option Add Internet Archive cover option
- Loading branch information
Showing
6 changed files
with
190 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,81 @@ | ||
$def with (doc, data={}, status=None) | ||
|
||
$ i18n_strings = { | ||
$ "empty_cover_inputs": _("Please choose an image or provide a URL.") | ||
$ } | ||
|
||
$putctx('cssfile', 'form') | ||
$putctx("show_ol_shell", False) | ||
$putctx('robots', 'noindex,nofollow') | ||
|
||
$if doc.type.key == "/type/author": | ||
$ intro = _("There are two ways to put an author's image on Open Library") | ||
$ intro = _("There are two ways to put an author's image on Open Library.") | ||
$ action = doc.url('/add-photo') | ||
$ guideline = _("Image Guidelines") | ||
$else: | ||
$ intro = _("There are two ways to put a cover image on Open Library") | ||
$ intro = _("There are a few ways to put a cover image on Open Library.") | ||
$ action = doc.url('/add-cover') | ||
$ guideline = _("Cover Guidelines") | ||
|
||
<div class="popAlert" id="errors" style="display: $('block' if status else 'none')" data-i18n="$json_encode(i18n_strings)"> | ||
<div class="popAlert" id="errors" style="display: $('block' if status else 'none')"> | ||
$if status: | ||
$if status.code == 1: $_("Please provide a valid image.") | ||
$elif status.code == 2: $_("Please provide an image URL.") | ||
$elif status.code == 3: $_("Please provide a valid image.") | ||
</div> | ||
|
||
<div class="imageIntro">$intro</div> | ||
|
||
<form class="floatform" id="addcover-form" name="bookcover" method="post" enctype="multipart/form-data" action="$action"> | ||
|
||
<div class="floatform__body"> | ||
<div> | ||
$if doc.type.key == "/type/work": | ||
$if doc.get_edition_covers(): | ||
<div class="formElement"> | ||
<div class="label"> | ||
<label>$:_("<strong>Pick one</strong> from the existing covers,")</label> | ||
</div> | ||
<div class="carousel-section"> | ||
<div id="covers" class="carousel-container carousel-container-decorated carousel--minimal"> | ||
<div id="popcovers" class="carousel carousel--progressively-enhanced" | ||
data-config="$json_encode({'booksPerBreakpoint': [3, 3, 3, 3, 2, 1]})"> | ||
$for cover in doc.get_edition_covers(): | ||
<div class="book carousel__item" data-id="$cover.id"> | ||
<div class="book-cover"> | ||
<img src="$cover.url(size='M')" | ||
width="100" class="bookcover"/> | ||
</div> | ||
<div class="imageIntro">$intro $:_('Learn more by reading our <a href="/help/faq/editing#picture" target="blank">%(guidelines)s</a>.', guidelines=guideline)</div> | ||
$if doc.type.key == "/type/work": | ||
$if doc.get_edition_covers(): | ||
<form class="ol-cover-form ol-cover-form--id" method="post" enctype="multipart/form-data" action="$action"> | ||
<div class="formElement"> | ||
<div class="label"> | ||
<label>$:_("<strong>Pick one</strong> from the existing covers")</label> | ||
</div> | ||
<div class="carousel-section"> | ||
<div id="covers" class="carousel-container carousel-container-decorated carousel--minimal"> | ||
<div class="carousel carousel--progressively-enhanced" data-config="$json_encode({'booksPerBreakpoint': [3, 3, 3, 3, 2, 1]})"> | ||
$for cover in doc.get_edition_covers(): | ||
<div class="book carousel__item"> | ||
<div class="book-cover"> | ||
<img src="$cover.url(size='M')" width="100" class="bookcover"/> | ||
<button type="submit" name="coverid" value="$cover.id" class="cta-btn cta-btn--vanilla">$_("Use this image")</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<input type="hidden" id="coverid" name="coverid" value=""/> | ||
</div> | ||
|
||
<div class="formElement"> | ||
<div class="label"> | ||
<label id="imageBrowse" for="coverFile">$_("Choose a JPG, GIF or PNG on your computer,")</label> | ||
</div> | ||
<div class="input"> | ||
<input type="file" name="file" id="coverFile" value="" accept=".jpg, .jpeg, .gif, .png"/> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
<div class="formElement"> | ||
<div class="label"> | ||
<label id="imageWeb" for="imageUrl">$_("Or, paste in the image URL if it's on the web.")</label> | ||
</div> | ||
<div class="input"> | ||
<input type="url" name="url" id="imageUrl" value="$data.get('url', '')" placeholder="https://..." /> | ||
</div> | ||
</div> | ||
|
||
<div class="formElement" style="margin: $('15px 0px 0px 15px;' if doc.type.key == '/type/work' else '0px;')"> | ||
<button type="submit" name="upload" id="imageUpload" value="$_('Submit')" class="largest" data-loading-text='$_("Uploading...")'> | ||
$_("Submit") | ||
</button> | ||
<a class="dialog--close-parent red" href="javascript:;">$_("Cancel")</a> | ||
</div> | ||
<form class="ol-cover-form ol-cover-form--upload" method="post" enctype="multipart/form-data" action="$action"> | ||
<div class="label"> | ||
<label for="coverFile">$_("Choose a JPG, GIF or PNG on your computer")</label> | ||
</div> | ||
<div class="input"> | ||
<input type="file" name="file" id="coverFile" value="" accept=".jpg, .jpeg, .gif, .png" required/> | ||
<button type="submit" class="cta-btn cta-btn--vanilla">$_("Upload")</button> | ||
</div> | ||
</form> | ||
|
||
</div> | ||
<form class="ol-cover-form ol-cover-form--url" method="post" enctype="multipart/form-data" action="$action"> | ||
<div class="label"> | ||
<label id="imageWeb" for="imageUrl">$_("Or, paste in the image URL if it's on the web")</label> | ||
</div> | ||
<div class="input"> | ||
<input type="url" name="url" id="imageUrl" value="$data.get('url', '')" placeholder="https://..." required /> | ||
<button type="submit" class="cta-btn cta-btn--vanilla">$_("Submit")</button> | ||
</div> | ||
</form> | ||
<div class="imageIntro smallest"><a href="/help/faq/editing#picture" target="blank">$guideline</a></div> | ||
|
||
$if doc.type.key == "/type/edition" and doc.ocaid: | ||
$ img_url = "https://archive.org/services/img/%s/full/pct:600/0/default.jpg" % doc.ocaid | ||
<form class="ol-cover-form ol-cover-form--ia" method="post" enctype="multipart/form-data" action="$action"> | ||
<div class="label"> | ||
<label>$_("Or, use the the cover from Internet Archive")</label> | ||
</div> | ||
<div class="input"> | ||
<a href="$img_url" target="_blank"> | ||
<img class="ol-cover-form--ia_image" src="$img_url" style="height: 200px" /> | ||
</a> | ||
<button type="submit" id="coverIA" class="cta-btn cta-btn--vanilla" name="url" value="$img_url">$_("Use this image")</button> | ||
</div> | ||
</form> | ||
|
||
$:macros.LoadingIndicator(_("Uploading...")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.