Add (again) server side rendering ! the list of user agent need to be completed but it should work.
This commit is contained in:
parent
9ff4bd2476
commit
9c8ec7fb8a
5
base.php
5
base.php
|
@ -10,6 +10,11 @@ define ("VERSION", "0.6.1");
|
||||||
define ("DB", "db");
|
define ("DB", "db");
|
||||||
date_default_timezone_set($config['default_timezone']);
|
date_default_timezone_set($config['default_timezone']);
|
||||||
|
|
||||||
|
function useServerSideRendering () {
|
||||||
|
global $config;
|
||||||
|
return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']);
|
||||||
|
}
|
||||||
|
|
||||||
function getURLParam ($name, $default = NULL) {
|
function getURLParam ($name, $default = NULL) {
|
||||||
if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
|
if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
|
||||||
return $_GET[$name];
|
return $_GET[$name];
|
||||||
|
|
|
@ -197,3 +197,19 @@
|
||||||
*/
|
*/
|
||||||
$config['cops_html_tag_filter'] = "0";
|
$config['cops_html_tag_filter'] = "0";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Thumbnails are generated on-the-fly so it can be problematic on servers with slow CPU (Raspberry Pi, Dockstar, Piratebox, ...).
|
||||||
|
* This configuration item allow to customize how thumbnail will be generated
|
||||||
|
* "" : Generate thumbnail (CPU hungry)
|
||||||
|
* "1" : always send the full size image (Network hungry)
|
||||||
|
* any url : Send a constant image as the thumbnail (you can try "images/bookcover.svg")
|
||||||
|
*/
|
||||||
|
$config['cops_thumbnail_handling'] = "images/bookcover.svg";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contains a list of user agent for browsers not compatible with client side rendering
|
||||||
|
* For now : Kindle, Sony PRS-T1
|
||||||
|
* This item is used as regular expression so "." will force server side rendering for all devices
|
||||||
|
*/
|
||||||
|
$config['cops_server_side_render'] = ".";//"Kindle|EBRD1101";
|
||||||
|
|
||||||
|
|
25
index.php
25
index.php
|
@ -17,6 +17,7 @@
|
||||||
require_once ("language.php");
|
require_once ("language.php");
|
||||||
require_once ("customcolumn.php");
|
require_once ("customcolumn.php");
|
||||||
require_once ("book.php");
|
require_once ("book.php");
|
||||||
|
require_once ("resources/doT-php/doT.php");
|
||||||
|
|
||||||
// If we detect that an OPDS reader try to connect try to redirect to feed.php
|
// If we detect that an OPDS reader try to connect try to redirect to feed.php
|
||||||
if (preg_match("/(MantanoReader|FBReader|Stanza|Aldiko|Moon+ Reader)/", $_SERVER['HTTP_USER_AGENT'])) {
|
if (preg_match("/(MantanoReader|FBReader|Stanza|Aldiko|Moon+ Reader)/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
|
||||||
|
<?php if (!useServerSideRendering ()) { ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
@ -90,7 +92,30 @@
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<?php } ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<?php
|
||||||
|
if (useServerSideRendering ()) {
|
||||||
|
// 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');
|
||||||
|
|
||||||
|
// Get the data
|
||||||
|
$data = getJson (true);
|
||||||
|
|
||||||
|
// Generate the function for the template
|
||||||
|
$template = new doT ();
|
||||||
|
$dot = $template->template ($page, array ("bookdetail" => $bookdetail,
|
||||||
|
"header" => $header,
|
||||||
|
"footer" => $footer,
|
||||||
|
"main" => $main));
|
||||||
|
// Execute the template
|
||||||
|
echo $dot ($data);
|
||||||
|
}
|
||||||
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue