Simplify book detail. re #73

This commit is contained in:
Sébastien Lucas 2013-06-17 21:41:59 +02:00
parent 8de878fa94
commit 23267e37fa
3 changed files with 8 additions and 114 deletions

View file

@ -169,11 +169,7 @@ class Book extends Base {
$urlParam = $this->getUri (); $urlParam = $this->getUri ();
if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
$urlParam = str_replace ("&", "&", $urlParam); $urlParam = str_replace ("&", "&", $urlParam);
if ($permalink || getCurrentOption ('use_fancyapps') == 0) {
return 'index.php' . $urlParam; return 'index.php' . $urlParam;
} else {
return 'bookdetail.php' . $urlParam;
}
} }
public function getTitle () { public function getTitle () {

View file

@ -1,103 +0,0 @@
<?php
/**
* COPS (Calibre OPDS PHP Server) book detail script
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas <sebastien@slucas.fr>
*
*/
require_once ("config.php");
require_once ("book.php");
$book = Book::getBookById($_GET["id"]);
$authors = $book->getAuthors ();
$tags = $book->getTags ();
$serie = $book->getSerie ();
$book->getLinkArray ();
?>
<article class="bookpopup">
<span class="cover">
<?php
if ($book->hasCover) {
?>
<a href="<?php echo Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml () ?>">
<img src="<?php echo Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, 150)->hrefXhtml () ?>" alt="<?php echo localize("i18n.coversection") ?>" />
</a>
<?php
}
?>
</span>
<?php
foreach ($book->getDatas() as $data)
{
?>
<h2 class="download"><a href="<?php echo $data->getHtmlLink () ?>"><?php echo $data->format ?></a></h2>
<?php
}
?>
<h1><a rel="bookmark" href="<?php echo $book->getDetailUrl (true) ?>"><img src="<?php echo getUrlWithVersion("images/Link.png") ?>" alt="<?php echo localize ("permalink.alternate") ?>" /></a><?php echo htmlspecialchars ($book->title) ?></h1>
<p class="popupless">
<h3><?php echo localize("authors.title") ?>: </h3>
<?php
$i = 0;
foreach ($authors as $author) {
if ($i > 0) echo ", ";
?>
<a href="<?php $link = new LinkNavigation ($author->getUri ()); echo $link->hrefXhtml () ?>"><?php echo htmlspecialchars ($author->name) ?></a>
<?php
}
?>
</p>
<?php
if (count ($tags) > 0) {
?>
<p class="popupless">
<h3><?php echo localize("tags.title") ?>: </h3>
<?php
$i = 0;
foreach ($tags as $tag) {
if ($i > 0) echo ", ";
?>
<a href="<?php $link = new LinkNavigation ($tag->getUri ()); echo $link->hrefXhtml () ?>"><?php echo htmlspecialchars ($tag->name) ?></a>
<?php
}
?>
</p>
<?php
}
if (!is_null ($serie))
{
?>
<p class="popupless">
<h3><a href="index.php<?php $link = new LinkNavigation ($serie->getUri ()); echo $link->hrefXhtml () ?>"><?php echo localize("series.title") ?></a>: </h3>
<?php echo str_format (localize ("content.series.data"), $book->seriesIndex, htmlspecialchars ($serie->name)) ?>
</p>
<?php
}
if ($book->getPubDate() != "")
{
?>
<p class="popupless">
<h3><?php echo localize("pubdate.title") ?>: </h3>
<?php echo $book->getPubDate() ?>
</p>
<?php
}
if ($book->getLanguages () != "")
{
?>
<p class="popupless">
<h3><?php echo localize("language.title") ?>: </h3>
<?php echo $book->getLanguages () ?>
</p>
<?php
}
?>
<br />
<h4><?php echo localize("content.summary") ?></h4>
<div <?php if (!isset ($page)) echo 'style="max-width:700px;"' ?> ><?php echo $book->getComment (false) ?></div>
</article>

13
util.js
View file

@ -71,14 +71,13 @@ function updatePage (data) {
$(".fancydetail").click(function(event){ $(".fancydetail").click(function(event){
event.preventDefault(); event.preventDefault();
var url = $(this).attr("href"); var url = $(this).attr("href");
var jsonurl = url.replace ("bookdetail", "getJSON"); var jsonurl = url.replace ("index", "getJSON");
$.getJSON(jsonurl, function(data) { $.getJSON(jsonurl, function(data) {
data ["const"] = currentData ["const"]; data ["const"] = currentData ["const"];
var detail = templateBookDetail (data); var detail = templateBookDetail (data);
$.fancybox( { var fancyparams = fancyBoxObject (data.title, null);
content: detail, fancyparams ["content"] = detail;
autoSize: true $.fancybox(fancyparams);
});
}); });
}); });
@ -91,7 +90,9 @@ function updatePage (data) {
function ajaxifyLinks () { function ajaxifyLinks () {
if (history.pushState) { if (history.pushState) {
$("a[href^='index']").click (function (event) { var links = $("a[href^='index']");
if (getCurrentOption ("use_fancyapps") == 1) links = links.not (".fancydetail");
links.click (function (event) {
event.preventDefault(); event.preventDefault();
var url = $(this).attr('href'); var url = $(this).attr('href');