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.

96 lines
4.4KB

  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. <title>COPS</title>
  34. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jQuery/jquery-1.10.2.min.js") ?>"></script>
  35. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jquery-cookie/jquery.cookies.js") ?>"></script>
  36. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/Magnific-Popup/jquery.magnific-popup.min.js") ?>"></script>
  37. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/Magnific-Popup/magnific-popup.css") ?>" media="screen" />
  38. <script type="text/javascript" src="<?php echo getUrlWithVersion("js/jquery.sortElements.js") ?>"></script>
  39. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/doT/doT.min.js") ?>"></script>
  40. <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/lru/lru.js") ?>"></script>
  41. <script type="text/javascript" src="<?php echo getUrlWithVersion("util.js") ?>"></script>
  42. <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']; ?>" />
  43. <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
  44. <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' />
  45. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
  46. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
  47. <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
  48. <script type="text/javascript">
  49. $(document).ready(function() {
  50. // Handler for .ready() called.
  51. var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
  52. $.when($.get('templates/default/header.html'),
  53. $.get('templates/default/footer.html'),
  54. $.get('templates/default/bookdetail.html'),
  55. $.get('templates/default/main.html'),
  56. $.get('templates/default/page.html'),
  57. $.getJSON(url)).done(function(header, footer, bookdetail, main, page, data){
  58. templateBookDetail = doT.template (bookdetail [0]);
  59. var defMain = {
  60. bookdetail: bookdetail [0]
  61. };
  62. templateMain = doT.template (main [0], undefined, defMain);
  63. var defPage = {
  64. header: header [0],
  65. footer: footer [0],
  66. main : main [0],
  67. bookdetail: bookdetail [0]
  68. };
  69. templatePage = doT.template (page [0], undefined, defPage);
  70. currentData = data [0];
  71. updatePage (data [0]);
  72. cache.put (url, data [0]);
  73. history.replaceState(url, "", window.location);
  74. handleLinks ();
  75. });
  76. });
  77. </script>
  78. </head>
  79. <body>
  80. </body>
  81. </html>