Template are now cleanly split. Properly handle synchronization with jquery. re #73
--HG-- rename : templates/default/frontpage.html => templates/default/header.html rename : templates/default/frontpage.html => templates/default/main.html
This commit is contained in:
parent
5e1cae2fd8
commit
bf54e6a7b9
35
index.php
35
index.php
|
@ -96,17 +96,34 @@
|
|||
}
|
||||
});
|
||||
|
||||
$.get('templates/default/bookdetail.html', function(data){
|
||||
templateBookDetail = doT.template (data);
|
||||
$.when($.get('templates/default/header.html'),
|
||||
$.get('templates/default/footer.html'),
|
||||
$.get('templates/default/bookdetail.html'),
|
||||
$.get('templates/default/main.html'),
|
||||
$.get('templates/default/page.html'),
|
||||
$.getJSON('<?php echo "getJSON.php?" . str_replace ("&", "&", $_SERVER["QUERY_STRING"]); ?>')).done(function(header, footer, bookdetail, main, page, data){
|
||||
templateBookDetail = doT.template (bookdetail [0]);
|
||||
|
||||
var defMain = {
|
||||
bookdetail: bookdetail [0]
|
||||
};
|
||||
|
||||
templateMain = doT.template (main [0], undefined, defMain);
|
||||
|
||||
var defPage = {
|
||||
header: header [0],
|
||||
footer: footer [0],
|
||||
main : main [0],
|
||||
bookdetail: bookdetail [0]
|
||||
};
|
||||
|
||||
templatePage = doT.template (page [0], undefined, defPage);
|
||||
var toto = "toto";
|
||||
|
||||
updatePage (data [0]);
|
||||
history.replaceState(data [0], "", window.location);
|
||||
});
|
||||
|
||||
$.get('templates/default/frontpage.html', function(data){
|
||||
template = doT.template(data);
|
||||
$.getJSON('<?php echo "getJSON.php?" . str_replace ("&", "&", $_SERVER["QUERY_STRING"]); ?>', function(data) {
|
||||
updatePage (data);
|
||||
history.replaceState(data, "", window.location);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
15
templates/default/footer.html
Normal file
15
templates/default/footer.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<footer>
|
||||
<div class="footleft">
|
||||
<a href="customize.php"><img src="images/theme.png?v={{=it.version}}" alt="{{=it.i18n.customizeTitle}}" /></a>
|
||||
</div>
|
||||
<div class="footright">
|
||||
<a class="fancyabout" href="{{=it.abouturl}}"><img src="images/info.png?v={{=it.version}}" alt="{{=it.i18n.aboutTitle}}" /></a>
|
||||
</div>
|
||||
{{? it.isPaginated == 1}}
|
||||
<div class="footcenter">
|
||||
{{? it.prevLink != ""}}<a id="prevLink" href="{{=it.prevLink}}" ><img src="images/previous.png?v={{=it.version}}" alt="{{=it.i18n.previousAlt}}" /></a>{{?}}
|
||||
<p> {{=it.currentPage}} / {{=it.maxPage}} </p>
|
||||
{{? it.nextLink != ""}}<a id="nextLink" href="{{=it.nextLink}}" ><img src="images/next.png?v={{=it.version}}" alt="{{=it.i18n.nextAlt}}" /></a>{{?}}
|
||||
</div>
|
||||
{{?}}
|
||||
</footer>
|
|
@ -1,130 +0,0 @@
|
|||
<header>
|
||||
<a class="headleft" href="{{=it.homeurl}}">
|
||||
<img src="images/home.png?v={{=it.version}}" alt="{{=it.i18n.homeAlt}}" />
|
||||
</a>
|
||||
<img class="headright" id="searchImage" src="images/setting64.png?v={{=it.version}}" alt="Settings and menu" />
|
||||
<div class="headcenter">
|
||||
<h1>{{=it.title}}</h1>
|
||||
</div>
|
||||
<div id="tool">
|
||||
<div style="float: left; width: 60%">
|
||||
<form action="index.php" method="get">
|
||||
<div style="float: right">
|
||||
<input type="image" src="images/search32.png?v={{=it.version}}" alt="{{=it.i18n.searchAlt}}" />
|
||||
</div>
|
||||
<div class="stop">
|
||||
<input type="hidden" name="current" value="{{=it.page}}" />
|
||||
<input type="hidden" name="page" value="9" />
|
||||
{{? it.databaseId != ""}}
|
||||
<input type="hidden" name="db" value="{{=it.databaseId}}" />
|
||||
{{?}}
|
||||
<input type="search" name="query" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<section>
|
||||
{{? it.page == 13}}
|
||||
<article class="bookpopup">
|
||||
<span class="cover">
|
||||
{{? it.book.hasCover == 1}}
|
||||
<a href="{{=it.book.coverurl}}">
|
||||
<img src="{{=it.book.thumbnailurl}}" alt="{{=it.i18n.coverAlt}}" />
|
||||
</a>
|
||||
{{?}}
|
||||
</span>
|
||||
<h2 class="download">
|
||||
{{~it.book.datas:data:i}}
|
||||
<a href="{{=data.url}}">{{=data.format}}</a><br />
|
||||
{{~}}
|
||||
</h2>
|
||||
<h1><a rel="bookmark" href="{{=it.book.detailurl}}"><img src="images/Link.png?v={{=it.version}}" alt="{{=it.i18n.permalinkAlt}}" /></a>{{=htmlEscape (it.title)}}</h1>
|
||||
<p class="popupless">
|
||||
<h3>{{=it.i18n.authorsTitle}}: </h3>
|
||||
{{~it.book.authors:author:j}}
|
||||
{{? j > 0}}, {{?}}<a href="{{=author.url}}">{{=htmlEscape (author.name)}}</a>
|
||||
{{~}}
|
||||
</p>
|
||||
{{? it.book.tagsName != ""}}
|
||||
<p class="popupless">
|
||||
<h3>{{=it.i18n.tagsTitle}}: </h3>
|
||||
{{~it.book.tags:tag:k}}
|
||||
{{? k > 0}}, {{?}}<a href="{{=tag.url}}">{{=htmlEscape (tag.name)}}</a>
|
||||
{{~}}
|
||||
</p>
|
||||
{{?}}
|
||||
{{? it.book.seriesName != ""}}
|
||||
<p class="popupless">
|
||||
<h3><a href="{{=it.book.seriesurl}}">{{=it.i18n.seriesTitle}}</a> : </h3>{{=htmlEscape (it.book.seriesCompleteName)}}
|
||||
</p>
|
||||
{{?}}
|
||||
{{? it.book.pubDate != ""}}
|
||||
<p class="popupless">
|
||||
<h3>{{=it.i18n.pubdateTitle}}: </h3>{{=it.book.pubDate}}
|
||||
</p>
|
||||
{{?}}
|
||||
{{? it.book.languagesName != ""}}
|
||||
<p class="popupless">
|
||||
<h3>{{=it.i18n.languagesTitle}}: </h3>{{=it.book.languagesName}}
|
||||
</p>
|
||||
{{?}}
|
||||
{{? it.book.content != ""}}
|
||||
<br />
|
||||
<h4>{{=it.i18n.contentTitle}}</h4>
|
||||
<div>{{=it.book.content}}</div>
|
||||
{{?}}
|
||||
</article>
|
||||
{{??}}
|
||||
{{~it.entries:entry:i}}
|
||||
{{? it.containsBook == 0}}
|
||||
<article>
|
||||
<div class="frontpage">
|
||||
<a href="{{=entry.navlink}}">
|
||||
<h2>{{=htmlEscape (entry.title)}}</h2>
|
||||
<h4>{{=entry.content}}</h4>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
{{??}}
|
||||
<article class="books">
|
||||
<span class="cover">
|
||||
{{? entry.book.hasCover == 1}}
|
||||
<a data-fancybox-group="group" class="fancycover" href="{{=entry.coverurl}}"><img src="{{=entry.thumbnailurl}}" alt="{{=it.i18n.coverAlt}}" /></a>
|
||||
{{?}}
|
||||
</span>
|
||||
<h2 class="download">
|
||||
{{~entry.book.preferedData:data:j}}
|
||||
<a href="{{=data.url}}">{{=data.name}}</a><br />
|
||||
{{~}}
|
||||
</h2>
|
||||
<a class="fancydetail" href="{{=entry.book.detailUrl}}">
|
||||
<div class="fullclickpopup">
|
||||
<h2><span class="st">{{=htmlEscape (entry.title)}}</span>
|
||||
{{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}}
|
||||
{{? entry.book.rating != ""}}<span class="sr">{{=entry.book.rating}}</span>{{?}}
|
||||
</h2>
|
||||
<h4>{{=it.i18n.authorsTitle}} : </h4><span class="sa">{{=htmlEscape (entry.book.authorsName)}}</span><br />
|
||||
{{? entry.book.tagsName != ""}}<h4>{{=it.i18n.tagsTitle}} : </h4>{{=htmlEscape (entry.book.tagsName)}}<br />{{?}}
|
||||
{{? entry.book.seriesName != ""}}<h4>{{=it.i18n.seriesTitle}} : </h4>{{=htmlEscape (entry.book.seriesName)}}<br />{{?}}
|
||||
</div></a>
|
||||
</article>
|
||||
{{?}}
|
||||
{{~}}
|
||||
{{?}}
|
||||
</section>
|
||||
<footer>
|
||||
<div class="footleft">
|
||||
<a href="customize.php"><img src="images/theme.png?v={{=it.version}}" alt="{{=it.i18n.customizeTitle}}" /></a>
|
||||
</div>
|
||||
<div class="footright">
|
||||
<a class="fancyabout" href="{{=it.abouturl}}"><img src="images/info.png?v={{=it.version}}" alt="{{=it.i18n.aboutTitle}}" /></a>
|
||||
</div>
|
||||
{{? it.isPaginated == 1}}
|
||||
<div class="footcenter">
|
||||
{{? it.prevLink != ""}}<a id="prevLink" href="{{=it.prevLink}}" ><img src="images/previous.png?v={{=it.version}}" alt="{{=it.i18n.previousAlt}}" /></a>{{?}}
|
||||
<p> {{=it.currentPage}} / {{=it.maxPage}} </p>
|
||||
{{? it.nextLink != ""}}<a id="nextLink" href="{{=it.nextLink}}" ><img src="images/next.png?v={{=it.version}}" alt="{{=it.i18n.nextAlt}}" /></a>{{?}}
|
||||
</div>
|
||||
{{?}}
|
||||
</footer>
|
26
templates/default/header.html
Normal file
26
templates/default/header.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<header>
|
||||
<a class="headleft" href="{{=it.homeurl}}">
|
||||
<img src="images/home.png?v={{=it.version}}" alt="{{=it.i18n.homeAlt}}" />
|
||||
</a>
|
||||
<img class="headright" id="searchImage" src="images/setting64.png?v={{=it.version}}" alt="Settings and menu" />
|
||||
<div class="headcenter">
|
||||
<h1>{{=it.title}}</h1>
|
||||
</div>
|
||||
<div id="tool">
|
||||
<div style="float: left; width: 60%">
|
||||
<form action="index.php" method="get">
|
||||
<div style="float: right">
|
||||
<input type="image" src="images/search32.png?v={{=it.version}}" alt="{{=it.i18n.searchAlt}}" />
|
||||
</div>
|
||||
<div class="stop">
|
||||
<input type="hidden" name="current" value="{{=it.page}}" />
|
||||
<input type="hidden" name="page" value="9" />
|
||||
{{? it.databaseId != ""}}
|
||||
<input type="hidden" name="db" value="{{=it.databaseId}}" />
|
||||
{{?}}
|
||||
<input type="search" name="query" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
41
templates/default/main.html
Normal file
41
templates/default/main.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<section>
|
||||
{{? it.page == 13}}
|
||||
{{#def.bookdetail}}
|
||||
{{??}}
|
||||
{{~it.entries:entry:i}}
|
||||
{{? it.containsBook == 0}}
|
||||
<article>
|
||||
<div class="frontpage">
|
||||
<a href="{{=entry.navlink}}">
|
||||
<h2>{{=htmlEscape (entry.title)}}</h2>
|
||||
<h4>{{=entry.content}}</h4>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
{{??}}
|
||||
<article class="books">
|
||||
<span class="cover">
|
||||
{{? entry.book.hasCover == 1}}
|
||||
<a data-fancybox-group="group" class="fancycover" href="{{=entry.coverurl}}"><img src="{{=entry.thumbnailurl}}" alt="{{=it.i18n.coverAlt}}" /></a>
|
||||
{{?}}
|
||||
</span>
|
||||
<h2 class="download">
|
||||
{{~entry.book.preferedData:data:j}}
|
||||
<a href="{{=data.url}}">{{=data.name}}</a><br />
|
||||
{{~}}
|
||||
</h2>
|
||||
<a class="fancydetail" href="{{=entry.book.detailUrl}}">
|
||||
<div class="fullclickpopup">
|
||||
<h2><span class="st">{{=htmlEscape (entry.title)}}</span>
|
||||
{{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}}
|
||||
{{? entry.book.rating != ""}}<span class="sr">{{=entry.book.rating}}</span>{{?}}
|
||||
</h2>
|
||||
<h4>{{=it.i18n.authorsTitle}} : </h4><span class="sa">{{=htmlEscape (entry.book.authorsName)}}</span><br />
|
||||
{{? entry.book.tagsName != ""}}<h4>{{=it.i18n.tagsTitle}} : </h4>{{=htmlEscape (entry.book.tagsName)}}<br />{{?}}
|
||||
{{? entry.book.seriesName != ""}}<h4>{{=it.i18n.seriesTitle}} : </h4>{{=htmlEscape (entry.book.seriesName)}}<br />{{?}}
|
||||
</div></a>
|
||||
</article>
|
||||
{{?}}
|
||||
{{~}}
|
||||
{{?}}
|
||||
</section>
|
3
templates/default/page.html
Normal file
3
templates/default/page.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{#def.header}}
|
||||
{{#def.main}}
|
||||
{{#def.footer}}
|
4
util.js
4
util.js
|
@ -1,4 +1,4 @@
|
|||
var template, templateBookDetail, result;
|
||||
var templatePage, templateBookDetail, templateMain, result;
|
||||
|
||||
var isEink = /Kobo|Kindle|EBRD1101/i.test(navigator.userAgent);
|
||||
|
||||
|
@ -32,7 +32,7 @@ function navigateTo (url) {
|
|||
}
|
||||
|
||||
function updatePage (data) {
|
||||
result = template (data);
|
||||
result = templatePage (data);
|
||||
document.title = data.title;
|
||||
$(".container").html (result);
|
||||
|
||||
|
|
Loading…
Reference in a new issue