Begin the templating

This commit is contained in:
Sébastien Lucas 2014-02-06 21:26:20 +01:00
parent 8fc7479a33
commit 0cf1383db0
3 changed files with 19 additions and 13 deletions

View file

@ -18,11 +18,12 @@ function useServerSideRendering () {
function serverSideRender ($data) {
// Get the templates
$header = file_get_contents('templates/default/header.html');
$footer = file_get_contents('templates/default/footer.html');
$main = file_get_contents('templates/default/main.html');
$bookdetail = file_get_contents('templates/default/bookdetail.html');
$page = file_get_contents('templates/default/page.html');
$theme = getCurrentTemplate ();
$header = file_get_contents('templates/' . $theme . '/header.html');
$footer = file_get_contents('templates/' . $theme . '/footer.html');
$main = file_get_contents('templates/' . $theme . '/main.html');
$bookdetail = file_get_contents('templates/' . $theme . '/bookdetail.html');
$page = file_get_contents('templates/' . $theme . '/page.html');
// Generate the function for the template
$template = new doT ();
@ -76,6 +77,10 @@ function getCurrentCss () {
return "styles/style-" . getCurrentOption ("style") . ".css";
}
function getCurrentTemplate () {
return "default";
}
function getUrlWithVersion ($url) {
return $url . "?v=" . VERSION;
}

View file

@ -79,7 +79,8 @@
<script type="text/javascript">
$(document).ready(function() {
initiateAjax ("<?php echo "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1); ?>");
initiateAjax ("<?php echo "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1); ?>",
"<?php echo getCurrentTemplate (); ?>");
});

14
util.js
View file

@ -441,13 +441,13 @@ $(document).keydown(function(e){
}
});
function initiateAjax (url) {
$.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'),
$.get('templates/default/suggestion.html'),
function initiateAjax (url, theme) {
$.when($.get('templates/' + theme + '/header.html'),
$.get('templates/' + theme + '/footer.html'),
$.get('templates/' + theme + '/bookdetail.html'),
$.get('templates/' + theme + '/main.html'),
$.get('templates/' + theme + '/page.html'),
$.get('templates/' + theme + '/suggestion.html'),
$.getJSON(url)).done(function(header, footer, bookdetail, main, page, suggestion, data){
templateBookDetail = doT.template (bookdetail [0]);