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

View file

@ -79,7 +79,8 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(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) { function initiateAjax (url, theme) {
$.when($.get('templates/default/header.html'), $.when($.get('templates/' + theme + '/header.html'),
$.get('templates/default/footer.html'), $.get('templates/' + theme + '/footer.html'),
$.get('templates/default/bookdetail.html'), $.get('templates/' + theme + '/bookdetail.html'),
$.get('templates/default/main.html'), $.get('templates/' + theme + '/main.html'),
$.get('templates/default/page.html'), $.get('templates/' + theme + '/page.html'),
$.get('templates/default/suggestion.html'), $.get('templates/' + theme + '/suggestion.html'),
$.getJSON(url)).done(function(header, footer, bookdetail, main, page, suggestion, data){ $.getJSON(url)).done(function(header, footer, bookdetail, main, page, suggestion, data){
templateBookDetail = doT.template (bookdetail [0]); templateBookDetail = doT.template (bookdetail [0]);