Skip to content

Commit

Permalink
Add tocky button to edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrini committed Sep 3, 2024
1 parent 6e27575 commit fb4b7ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
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,
'input_book.ia_id': book.ocaid,
'submit': ''
}
<a href="$(get_tocky_url())/submit?$(urlencode(tocky_params))" target="_blank">
$_('✨ Auto-extract from Internet Archive book')
</a>
</div>
</div>

Expand Down

0 comments on commit fb4b7ba

Please sign in to comment.