Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
4.8KB

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <?php
  4. /**
  5. * COPS (Calibre OPDS PHP Server) HTML main script
  6. *
  7. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  8. * @author Sébastien Lucas <sebastien@slucas.fr>
  9. *
  10. */
  11. require_once ("config.php");
  12. require_once ("base.php");
  13. require_once ("author.php");
  14. require_once ("serie.php");
  15. require_once ("tag.php");
  16. require_once ("language.php");
  17. require_once ("customcolumn.php");
  18. require_once ("book.php");
  19. // If we detect that an OPDS reader try to connect try to redirect to feed.php
  20. if (preg_match("/(MantanoReader|FBReader|Stanza|Aldiko|Moon+ Reader)/", $_SERVER['HTTP_USER_AGENT'])) {
  21. header("location: feed.php");
  22. exit ();
  23. }
  24. header ("Content-Type:text/html;charset=utf-8");
  25. $page = getURLParam ("page", Base::PAGE_INDEX);
  26. $query = getURLParam ("query");
  27. $qid = getURLParam ("id");
  28. $n = getURLParam ("n", "1");
  29. $database = GetUrlParam (DB);
  30. ?>
  31. <head>
  32. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  33. <meta name="apple-mobile-web-app-capable" content="yes" />
  34. <meta name="apple-mobile-web-app-status-bar-style" content="default" />
  35. <link rel="apple-touch-icon" href="./icons/icon57.png" />
  36. <link rel="apple-touch-icon" sizes="72x72" href="./icons/icon72.png" />
  37. <link rel="apple-touch-icon" sizes="114x114" href="./icons/icon114.png" />
  38. <link rel="apple-touch-icon" sizes="144x144" href="./icons/icon144.png" />
  39. <title>COPS</title>
  40. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jQuery/jquery-1.10.2.min.js") ?>"></script>
  41. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jquery-cookie/jquery.cookies.js") ?>"></script>
  42. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/Magnific-Popup/jquery.magnific-popup.min.js") ?>"></script>
  43. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/Magnific-Popup/magnific-popup.css") ?>" media="screen" />
  44. <script type="text/javascript" src="<?php echo getUrlWithVersion("js/jquery.sortElements.js") ?>"></script>
  45. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/doT/doT.min.js") ?>"></script>
  46. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/lru/lru.js") ?>"></script>
  47. <script type="text/javascript" src="<?php echo getUrlWithVersion("util.js") ?>"></script>
  48. <link rel="related" href="<?php echo $config['cops_full_url'] ?>feed.php" type="application/atom+xml;profile=opds-catalog" title="<?php echo $config['cops_title_default']; ?>" />
  49. <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
  50. <link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Open+Sans:400,300italic,800,300,400italic,600,600italic,700,700italic,800italic' />
  51. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
  52. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
  53. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
  54. <script type="text/javascript">
  55. $(document).ready(function() {
  56. // Handler for .ready() called.
  57. var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
  58. $.when($.get('templates/default/header.html'),
  59. $.get('templates/default/footer.html'),
  60. $.get('templates/default/bookdetail.html'),
  61. $.get('templates/default/main.html'),
  62. $.get('templates/default/page.html'),
  63. $.getJSON(url)).done(function(header, footer, bookdetail, main, page, data){
  64. templateBookDetail = doT.template (bookdetail [0]);
  65. var defMain = {
  66. bookdetail: bookdetail [0]
  67. };
  68. templateMain = doT.template (main [0], undefined, defMain);
  69. var defPage = {
  70. header: header [0],
  71. footer: footer [0],
  72. main : main [0],
  73. bookdetail: bookdetail [0]
  74. };
  75. templatePage = doT.template (page [0], undefined, defPage);
  76. currentData = data [0];
  77. updatePage (data [0]);
  78. cache.put (url, data [0]);
  79. history.replaceState(url, "", window.location);
  80. handleLinks ();
  81. });
  82. });
  83. </script>
  84. </head>
  85. <body>
  86. </body>
  87. </html>