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

Add tocky button to edit page #9840

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions conf/openlibrary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,6 @@ sentry_cron_jobs:

# Observations cache settings:
observation_cache_duration: 86400

tocky_url: https://testing.openlibrary.org/tocky
tocky_librarian_key: XXX
4 changes: 4 additions & 0 deletions openlibrary/i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,10 @@ msgid ""
"new lines. Like this:"
msgstr ""

#: books/edit/edition.html
msgid "✨ Auto-extract from Internet Archive book"
msgstr ""

#: books/edit/edition.html
msgid "Any notes about this specific edition?"
msgstr ""
Expand Down
10 changes: 10 additions & 0 deletions openlibrary/plugins/openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,16 @@ def get_cover_id(key):
return None


@public
def get_tocky_librarian_key():
return infogami.config.get('tocky_librarian_key')


@public
def get_tocky_url():
return infogami.config.get('tocky_url')


local_ip = None


Expand Down
13 changes: 12 additions & 1 deletion openlibrary/templates/books/edit/edition.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$jsdef render_language_field(i, language, i18n_name):
$ lang_name = i18n_name or language.name
<div class="input ac-input mia__input">
<div class="mia__reorder">≡</div>
<div class="mia__reorder">≡</div> $# detect-missing-i18n-skip-line
<input class="ac-input__visible" name="languages--$i" type="text" value="$lang_name"/>
<input class="ac-input__value" name="edition--languages--$i--key" type="hidden" value="$language.key" />
<a class="mia__remove" href="javascript:;" title="$_('Remove this language')">[x]</a>
Expand Down Expand Up @@ -342,6 +342,17 @@
</div>
<div class="input">
<textarea name="edition--table_of_contents" id="edition-toc" rows="5" cols="50">$book.get_toc_text()</textarea>
$if is_librarian and book.ocaid:
$code:
tocky_params = {
'api_key': get_tocky_librarian_key(),
'submitter': ctx.user.key,
'ia_id': book.ocaid,
'submit': 'true'
}
<a href="$(get_tocky_url())/submit?$(urlencode(tocky_params))" target="_blank">
$_('✨ Auto-extract from Internet Archive book')
</a>
</div>
</div>

Expand Down
Loading