From 2029ab7d0144f91ae5208ad12409116492e212f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Mon, 17 Jun 2013 22:23:58 +0200 Subject: [PATCH] Simplify a little the JSON, a little more to do. re # 73 --- base.php | 2 -- book.php | 4 ++-- getJSON.php | 40 ++++++++++++++++++++----------------- templates/default/main.html | 6 ++++-- util.js | 9 +++++++++ 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/base.php b/base.php index 36f8f0f..9a47436 100644 --- a/base.php +++ b/base.php @@ -311,8 +311,6 @@ class EntryBook extends Entry public function getContentArray () { $entry = array ( "title" => $this->title); - $entry ["coverurl"] = $this->getCover (); - $entry ["thumbnailurl"] = $this->getCoverThumbnail (); $entry ["book"] = $this->book->getContentArray (); return $entry; } diff --git a/book.php b/book.php index 55d19f9..65c0a53 100644 --- a/book.php +++ b/book.php @@ -126,9 +126,9 @@ class Book extends Base { $su = $link->hrefXhtml (); } - return array ("hasCover" => $this->hasCover, + return array ("id" => $this->id, + "hasCover" => $this->hasCover, "preferedData" => $preferedData, - "detailUrl" => $this->getDetailUrl (), "rating" => $this->getRating (), "pubDate" => $this->getPubDate (), "languagesName" => $this->getLanguages (), diff --git a/getJSON.php b/getJSON.php index 24dc92e..bcda031 100644 --- a/getJSON.php +++ b/getJSON.php @@ -56,24 +56,28 @@ } if (!is_null (getURLParam ("complete"))) { $out ["const"] = array ("version" => VERSION, "i18n" => array ( - "coverAlt" => localize("i18n.coversection"), - "authorsTitle" => localize("authors.title"), - "bookwordTitle" => localize("bookword.title"), - "tagsTitle" => localize("tags.title"), - "seriesTitle" => localize("series.title"), - "customizeTitle" => localize ("customize.title"), - "aboutTitle" => localize ("about.title"), - "previousAlt" => localize ("paging.previous.alternate"), - "nextAlt" => localize ("paging.next.alternate"), - "searchAlt" => localize ("search.alternate"), - "sortAlt" => localize ("sort.alternate"), - "homeAlt" => localize ("home.alternate"), - "permalinkAlt" => localize ("permalink.alternate"), - "pubdateTitle" => localize("pubdate.title"), - "languagesTitle" => localize("language.title"), - "contentTitle" => localize("content.summary"), - "sortorderAsc" => localize("search.sortorder.asc"), - "sortorderDesc" => localize("search.sortorder.desc"))); + "coverAlt" => localize("i18n.coversection"), + "authorsTitle" => localize("authors.title"), + "bookwordTitle" => localize("bookword.title"), + "tagsTitle" => localize("tags.title"), + "seriesTitle" => localize("series.title"), + "customizeTitle" => localize ("customize.title"), + "aboutTitle" => localize ("about.title"), + "previousAlt" => localize ("paging.previous.alternate"), + "nextAlt" => localize ("paging.next.alternate"), + "searchAlt" => localize ("search.alternate"), + "sortAlt" => localize ("sort.alternate"), + "homeAlt" => localize ("home.alternate"), + "permalinkAlt" => localize ("permalink.alternate"), + "pubdateTitle" => localize("pubdate.title"), + "languagesTitle" => localize("language.title"), + "contentTitle" => localize("content.summary"), + "sortorderAsc" => localize("search.sortorder.asc"), + "sortorderDesc" => localize("search.sortorder.desc")), + "url" => array ( + "detailUrl" => "index.php?page=13&id={0}&db={1}", + "coverUrl" => "fetch.php?id={0}&db={1}", + "thumbnailUrl" => "fetch.php?height=70&id={0}&db={1}")); } $out ["containsBook"] = 0; diff --git a/templates/default/main.html b/templates/default/main.html index d650241..4476845 100644 --- a/templates/default/main.html +++ b/templates/default/main.html @@ -16,7 +16,9 @@
{{? entry.book.hasCover == 1}} - {{=it.const.i18n.coverAlt}} + + {{=it.const.i18n.coverAlt}} + {{?}}

@@ -24,7 +26,7 @@ {{=data.name}}
{{~}}

- +

{{=htmlEscape (entry.title)}} {{? entry.book.pubDate != ""}}({{=entry.book.pubDate}}){{?}} diff --git a/util.js b/util.js index 5ab7e71..f2a8fdb 100644 --- a/util.js +++ b/util.js @@ -14,6 +14,15 @@ function fancyBoxObject (title, type) { return out; } +function strformat () { + var s = arguments[0]; + for (var i = 0; i < arguments.length - 1; i++) { + var reg = new RegExp("\\{" + i + "\\}", "gm"); + s = s.replace(reg, arguments[i + 1]); + } + return s; +} + function getCurrentOption (option) { return $.cookie (option); }