diff --git a/cps/static/js/get_meta.js b/cps/static/js/get_meta.js index 14317da4..e10b83ed 100644 --- a/cps/static/js/get_meta.js +++ b/cps/static/js/get_meta.js @@ -15,13 +15,15 @@ * along with this program. If not, see . */ /* - * Get Metadata from Douban Books api and Google Books api + * Get Metadata from Douban Books api and Google Books api and ComicVine * Google Books api document: https://developers.google.com/books/docs/v1/using * Douban Books api document: https://developers.douban.com/wiki/?title=book_v2 (Chinese Only) + * ComicVine api document: https://comicvine.gamespot.com/api/documentation */ /* global _, i18nMsg, tinymce */ var dbResults = []; var ggResults = []; +var cvResults = []; $(function () { var msg = i18nMsg; @@ -33,6 +35,10 @@ $(function () { var ggSearch = "/books/v1/volumes"; var ggDone = false; + var comicvine = "https://comicvine.gamespot.com"; + var cvSearch = "/api/search/"; + var cvDone = false; + var showFlag = 0; var templates = { @@ -164,6 +170,52 @@ $(function () { }); dbDone = false; } + if (cvDone && cvResults.length > 0) { + cvResults.forEach(function(result) { + var seriesTitle = ""; + if (result.volume.name) { + seriesTitle = result.volume.name; + } + var dateFomers = ""; + if (result.store_date) { + dateFomers = result.store_date.split("-"); + }else{ + dateFomers = result.date_added.split("-"); + } + var publishedYear = parseInt(dateFomers[0]); + var publishedMonth = parseInt(dateFomers[1]); + var publishedDate = new Date(publishedYear, publishedMonth - 1, 1); + + publishedDate = formatDate(publishedDate); + + var book = { + id: result.id, + title: seriesTitle + ' #' +('00' + result.issue_number).slice(-3) + ' - ' + result.name, + authors: result.author || [], + description: result.description, + publisher: "", + publishedDate: publishedDate || "", + tags: ['Comics', seriesTitle], + rating: 0, + series: seriesTitle || "", + cover: result.image.original_url, + url: result.site_detail_url, + source: { + id: "comicvine", + description: "ComicVine Books", + url: "https://comicvine.gamespot.com/" + } + }; + + var $book = $(templates.bookResult(book)); + $book.find("img").on("click", function () { + populateForm(book); + }); + + $("#book-list").append($book); + }); + cvDone = false; + } } function ggSearchBook (title) { @@ -207,12 +259,35 @@ $(function () { }); } + function cvSearchBook (title) { + var apikey = "57558043c53943d5d1e96a9ad425b0eb85532ee6"; + title = encodeURIComponent(title); + $.ajax({ + url: comicvine + cvSearch + "?api_key=" + apikey + "&resources=issue&query=" + title + "&sort=name:desc&format=jsonp", + type: "GET", + dataType: "jsonp", + jsonp: "json_callback", + success: function success(data) { + cvResults = data.results; + }, + error: function error() { + $("#meta-info").html("

" + msg.search_error + "!

" + $("#meta-info")[0].innerHTML); + }, + complete: function complete() { + cvDone = true; + showResult(); + $("#show-comics").trigger("change"); + } + }); + } + function doSearch (keyword) { showFlag = 0; $("#meta-info").text(msg.loading); if (keyword) { dbSearchBook(keyword); ggSearchBook(keyword); + cvSearchBook(keyword); } } diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index d3619060..9d6dac7d 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -222,6 +222,9 @@ + + +
@@ -267,7 +270,7 @@ var i18nMsg = { 'loading': {{_('Loading...')|safe|tojson}}, 'search_error': {{_('Search error!')|safe|tojson}}, - 'no_result': {{_('No Result(s) found! Please try aonther keyword.')|safe|tojson}}, + 'no_result': {{_('No Result(s) found! Please try another keyword.')|safe|tojson}}, 'author': {{_('Author')|safe|tojson}}, 'publisher': {{_('Publisher')|safe|tojson}}, 'description': {{_('Description')|safe|tojson}}, diff --git a/cps/translations/cs/LC_MESSAGES/messages.po b/cps/translations/cs/LC_MESSAGES/messages.po index c9720d90..c17769e3 100644 --- a/cps/translations/cs/LC_MESSAGES/messages.po +++ b/cps/translations/cs/LC_MESSAGES/messages.po @@ -1323,7 +1323,7 @@ msgid "Search error!" msgstr "Chyba vyhledávání!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Nebyly nalezeny žádné výsledky! Zadejte jiné klíčové slovo." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/de/LC_MESSAGES/messages.po b/cps/translations/de/LC_MESSAGES/messages.po index c3fae97a..e3f3ad3d 100644 --- a/cps/translations/de/LC_MESSAGES/messages.po +++ b/cps/translations/de/LC_MESSAGES/messages.po @@ -1324,7 +1324,7 @@ msgid "Search error!" msgstr "Fehler bei der Suche!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Keine Ergebnisse gefunden! Bitte ein anderes Schlüsselwort benutzen." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/es/LC_MESSAGES/messages.po b/cps/translations/es/LC_MESSAGES/messages.po index 682bea27..c85be3b6 100644 --- a/cps/translations/es/LC_MESSAGES/messages.po +++ b/cps/translations/es/LC_MESSAGES/messages.po @@ -1326,7 +1326,7 @@ msgid "Search error!" msgstr "¡Error en la búsqueda!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "¡No se encontraron resultados! Por favor intenta con otra palabra clave." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/fi/LC_MESSAGES/messages.po b/cps/translations/fi/LC_MESSAGES/messages.po index 52ac75fc..2dbd9be5 100644 --- a/cps/translations/fi/LC_MESSAGES/messages.po +++ b/cps/translations/fi/LC_MESSAGES/messages.po @@ -1324,7 +1324,7 @@ msgid "Search error!" msgstr "Hakuvirhe!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Ei osumia! Kokeile jotain tosita hakusanaa." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/fr/LC_MESSAGES/messages.po b/cps/translations/fr/LC_MESSAGES/messages.po index a4ea73c8..64557a6a 100644 --- a/cps/translations/fr/LC_MESSAGES/messages.po +++ b/cps/translations/fr/LC_MESSAGES/messages.po @@ -1337,7 +1337,7 @@ msgid "Search error!" msgstr "Rechercher les erreur!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Aucun résultat. Veuillez essayer avec un nouveau mot clé." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/hu/LC_MESSAGES/messages.po b/cps/translations/hu/LC_MESSAGES/messages.po index 877eef6b..2e57f1fd 100644 --- a/cps/translations/hu/LC_MESSAGES/messages.po +++ b/cps/translations/hu/LC_MESSAGES/messages.po @@ -1324,7 +1324,7 @@ msgid "Search error!" msgstr "Keresési hiba!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Nincs találat! Próbálj másik kulcsszót." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/it/LC_MESSAGES/messages.po b/cps/translations/it/LC_MESSAGES/messages.po index 3a1e3ade..000f2e5a 100644 --- a/cps/translations/it/LC_MESSAGES/messages.po +++ b/cps/translations/it/LC_MESSAGES/messages.po @@ -1323,7 +1323,7 @@ msgid "Search error!" msgstr "Errore di ricerca!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Nessun risultato! Prova con un altro criterio di ricerca." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/ja/LC_MESSAGES/messages.po b/cps/translations/ja/LC_MESSAGES/messages.po index 351399ce..a5d8973a 100644 --- a/cps/translations/ja/LC_MESSAGES/messages.po +++ b/cps/translations/ja/LC_MESSAGES/messages.po @@ -1324,7 +1324,7 @@ msgid "Search error!" msgstr "検索エラー" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "検索結果が見つかりません。別のキーワードで検索してみてください。" #: cps/templates/config_edit.html:12 diff --git a/cps/translations/km/LC_MESSAGES/messages.po b/cps/translations/km/LC_MESSAGES/messages.po index fe33e345..74e80c05 100644 --- a/cps/translations/km/LC_MESSAGES/messages.po +++ b/cps/translations/km/LC_MESSAGES/messages.po @@ -1325,7 +1325,7 @@ msgid "Search error!" msgstr "ការស្វែងរកមានកំហុស!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "" #: cps/templates/config_edit.html:12 diff --git a/cps/translations/nl/LC_MESSAGES/messages.po b/cps/translations/nl/LC_MESSAGES/messages.po index f28eeee9..a3558a3c 100644 --- a/cps/translations/nl/LC_MESSAGES/messages.po +++ b/cps/translations/nl/LC_MESSAGES/messages.po @@ -1325,7 +1325,7 @@ msgid "Search error!" msgstr "Zoekfout!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Geen resultaten gevonden! Gebruik een ander trefwoord." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/pl/LC_MESSAGES/messages.po b/cps/translations/pl/LC_MESSAGES/messages.po index 1476cc5d..4ea55bb9 100644 --- a/cps/translations/pl/LC_MESSAGES/messages.po +++ b/cps/translations/pl/LC_MESSAGES/messages.po @@ -1337,7 +1337,7 @@ msgid "Search error!" msgstr "Błąd wyszukiwania!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Nie znaleziono! Spróbuj użyć innego kluczowego słowa." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/ru/LC_MESSAGES/messages.po b/cps/translations/ru/LC_MESSAGES/messages.po index 9ccfc230..9745e727 100644 --- a/cps/translations/ru/LC_MESSAGES/messages.po +++ b/cps/translations/ru/LC_MESSAGES/messages.po @@ -1325,7 +1325,7 @@ msgid "Search error!" msgstr "Ошибка поиска!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Результат(ы) не найдены! Попробуйте другое ключевое слово." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/sv/LC_MESSAGES/messages.po b/cps/translations/sv/LC_MESSAGES/messages.po index 2dfd8bac..2322833c 100644 --- a/cps/translations/sv/LC_MESSAGES/messages.po +++ b/cps/translations/sv/LC_MESSAGES/messages.po @@ -1324,7 +1324,7 @@ msgid "Search error!" msgstr "Sökningsfel!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "Inga resultat hittades! Försök med ett annat sökord." #: cps/templates/config_edit.html:12 diff --git a/cps/translations/uk/LC_MESSAGES/messages.po b/cps/translations/uk/LC_MESSAGES/messages.po index fae7614c..0b4a4f56 100644 --- a/cps/translations/uk/LC_MESSAGES/messages.po +++ b/cps/translations/uk/LC_MESSAGES/messages.po @@ -1323,7 +1323,7 @@ msgid "Search error!" msgstr "Помилка пошуку!" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "" #: cps/templates/config_edit.html:12 diff --git a/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po b/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po index 6a507bf7..6cf28693 100644 --- a/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po +++ b/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po @@ -1324,7 +1324,7 @@ msgid "Search error!" msgstr "搜索错误" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "找不到结果。请尝试另一个关键字" #: cps/templates/config_edit.html:12 diff --git a/messages.pot b/messages.pot index c5ab15d0..36306cd5 100644 --- a/messages.pot +++ b/messages.pot @@ -1323,7 +1323,7 @@ msgid "Search error!" msgstr "" #: cps/templates/book_edit.html:270 -msgid "No Result(s) found! Please try aonther keyword." +msgid "No Result(s) found! Please try another keyword." msgstr "" #: cps/templates/config_edit.html:12