2012-05-28 08:01:33 +03:00
|
|
|
|
= COPS =
|
|
|
|
|
|
2012-07-02 21:27:46 +03:00
|
|
|
|
COPS stands for Calibre OPDS (and HTML) Php Server.
|
2012-05-28 08:01:33 +03:00
|
|
|
|
|
|
|
|
|
COPS output is valid the unofficial OPDS validator :
|
|
|
|
|
http://opds-validator.appspot.com/
|
|
|
|
|
|
|
|
|
|
= Why ? =
|
|
|
|
|
|
|
|
|
|
In my opinion Calibre is a marvelous tool but is too big and has too much
|
2012-05-28 08:05:05 +03:00
|
|
|
|
dependencies to be used for its content server.
|
2012-05-28 08:01:33 +03:00
|
|
|
|
|
|
|
|
|
That's the main reason why I coded this OPDS server. I needed a simple
|
|
|
|
|
tool to be installed on a small server (Seagate Dockstar in my case).
|
|
|
|
|
|
|
|
|
|
I initially thought of Calibre2OPDS but as it generate static file no
|
|
|
|
|
search was possible.
|
|
|
|
|
|
2012-07-22 15:49:57 +03:00
|
|
|
|
Later I added an simple HTML catalog that should be usable on my Kobo.
|
2012-07-02 21:27:46 +03:00
|
|
|
|
|
2012-05-28 08:01:33 +03:00
|
|
|
|
So COPS's main advantages are :
|
2012-05-28 08:05:05 +03:00
|
|
|
|
* No need for many dependencies.
|
2012-05-28 08:01:33 +03:00
|
|
|
|
* No need for a lot of CPU or RAM.
|
|
|
|
|
* Not much code.
|
|
|
|
|
* Search is available.
|
2012-07-02 21:27:46 +03:00
|
|
|
|
* With Dropbox / owncloud it's very easy to have an up to date OPDS server.
|
2012-05-28 08:01:33 +03:00
|
|
|
|
* It was fun to code.
|
|
|
|
|
|
|
|
|
|
= Prerequisites =
|
|
|
|
|
|
2012-07-02 21:27:46 +03:00
|
|
|
|
1. PHP 5.3 or 5.4 with GD image processing & SQLite3 support.
|
|
|
|
|
2. A web server with PHP support. I only tested with various version of Nginx.
|
|
|
|
|
Other people reported it working with Apache and Cherokee.
|
2012-05-28 08:01:33 +03:00
|
|
|
|
3. The path to a calibre library (metadata.db, format, & cover files).
|
|
|
|
|
|
|
|
|
|
On any Debian base Linux you can use :
|
|
|
|
|
aptitude install php5-gd php5-sqlite
|
|
|
|
|
|
|
|
|
|
= Install =
|
|
|
|
|
|
|
|
|
|
1. Extract the zip file to a folder in web space (visible to the web server).
|
|
|
|
|
2. If a first-time install, copy config_default.php to config_local.php
|
|
|
|
|
3. Edit config_local.php to match your config.
|
|
|
|
|
|
|
|
|
|
In my case I installed COPS in a subdomain. Here is my nginx config file :
|
|
|
|
|
server {
|
|
|
|
|
|
|
|
|
|
listen [::]:80;
|
|
|
|
|
|
|
|
|
|
server_name opds.mydomain.com;
|
|
|
|
|
|
|
|
|
|
access_log /var/log/nginx/opds.access.log;
|
|
|
|
|
error_log /var/log/nginx/opds.error.log;
|
|
|
|
|
root /var/www/opds;
|
|
|
|
|
index feed.php;
|
|
|
|
|
|
2012-07-02 21:27:46 +03:00
|
|
|
|
location /download/ {
|
2012-07-08 21:50:08 +03:00
|
|
|
|
rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last;
|
2012-07-02 21:27:46 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/images.*\.(gif|png|ico|jpg)$ {
|
|
|
|
|
expires 31d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ .(js|css)$ {
|
|
|
|
|
expires 31d;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-28 08:01:33 +03:00
|
|
|
|
location ~ \.php$ {
|
|
|
|
|
include /etc/nginx/fastcgi_params;
|
|
|
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
|
|
|
fastcgi_pass unix:/tmp/fcgi.sock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /Calibre {
|
|
|
|
|
root /home/calibre/Dropbox;
|
|
|
|
|
internal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Beware in this case my Calibre database is in /home/calibre/Dropbox/Calibre/ so
|
|
|
|
|
the internal location of nginx has to split like that.
|
|
|
|
|
|
2012-07-02 21:27:46 +03:00
|
|
|
|
I use a Kobo eReader Touch and its browser cannot download through php file (the
|
|
|
|
|
extension has to be known). To allow downloading on my ereader I added some
|
2012-07-02 21:42:55 +03:00
|
|
|
|
url rewriting (location /download/). More on rewriting later.
|
2012-07-02 21:27:46 +03:00
|
|
|
|
|
2012-05-28 08:01:33 +03:00
|
|
|
|
If your Calibre database is inside your web directory then there is no need for
|
|
|
|
|
an internal location.
|
|
|
|
|
|
|
|
|
|
If you choose to put your Calibre directory inside your web directory then you
|
|
|
|
|
will have to edit /etc/nginx/mime.types to add this line :
|
|
|
|
|
application/epub+zip epub;
|
|
|
|
|
|
2012-05-28 08:06:12 +03:00
|
|
|
|
= Notes on Opensearch =
|
|
|
|
|
|
|
|
|
|
Opensearch allow searching through an OPDS catalog. After many tests, I've been
|
2012-10-11 22:14:28 +03:00
|
|
|
|
able to make it work Mantano Reader.
|
2012-05-28 08:06:12 +03:00
|
|
|
|
|
|
|
|
|
It seems that Aldiko didn't implement it properly so it won't work with COPS or
|
|
|
|
|
any other custom OPDS catalog.
|
|
|
|
|
|
2013-01-02 21:53:17 +02:00
|
|
|
|
Moon+ Reader will only work if you change the default
|
2012-10-11 22:14:28 +03:00
|
|
|
|
configuration (cops_generate_invalid_opds_stream).
|
|
|
|
|
|
2012-07-02 21:42:55 +03:00
|
|
|
|
= URL rewriting =
|
|
|
|
|
|
|
|
|
|
* Nginx :
|
|
|
|
|
|
|
|
|
|
location /download/ {
|
2012-07-08 21:50:08 +03:00
|
|
|
|
rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last;
|
2012-07-02 21:42:55 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
* Apache (Thanks to gaspine : http://www.mobileread.com/forums/showpost.php?p=2120724&postcount=48) :
|
|
|
|
|
the .htaccess :
|
|
|
|
|
RewriteEngine on
|
|
|
|
|
RewriteOptions inherit
|
2012-07-08 21:50:08 +03:00
|
|
|
|
RewriteRule ^download/(.*)/.*\.(.*)$ fetch.php?data=$1&type=$2 [L]
|
2012-07-02 21:42:55 +03:00
|
|
|
|
if you have not mod_xsendfile, in the config file simply set :
|
|
|
|
|
$config['cops_x_accel_redirect'] = "location";
|
|
|
|
|
|
|
|
|
|
* Cherokee (Thanks to Christophe) :
|
|
|
|
|
* Add a Behavior of type Regular Expression : /cops/download/(.*)/.*\.(.*)$
|
|
|
|
|
* Choose the handler Redirection
|
2012-07-08 21:50:08 +03:00
|
|
|
|
* Add the substitution regexp : "/cops/download/(.*)/.*\.(.*)$" --> "/cops/fetch.php?data=$1&type=$2"
|
2012-07-02 21:42:55 +03:00
|
|
|
|
|
2012-05-28 08:01:33 +03:00
|
|
|
|
= Known problems =
|
|
|
|
|
|
2012-07-02 21:27:46 +03:00
|
|
|
|
* Only tested by me with Nginx but confirmed to work with Apache and Cherokee.
|
2012-05-28 08:05:05 +03:00
|
|
|
|
* Contain Nginx specific code (that could be changed with a config item).
|
2012-05-28 08:01:33 +03:00
|
|
|
|
* certainly many many more.
|
|
|
|
|
|
|
|
|
|
= Disclaimer =
|
|
|
|
|
|
|
|
|
|
I only tested on Debian with Nginx so I have stricly no idea if it works
|
|
|
|
|
with Apache or any other web server.
|
|
|
|
|
|
|
|
|
|
On the OPDS client side I mainly tested with FBReader and Aldiko on Android.
|
|
|
|
|
|
2012-05-28 08:05:05 +03:00
|
|
|
|
It also seems to work with Stanza.
|
|
|
|
|
|
2012-05-29 21:10:41 +03:00
|
|
|
|
= Credits =
|
|
|
|
|
|
|
|
|
|
* All localization informations come from Calibre2OPDS (http://calibre2opds.com/)
|
|
|
|
|
* Locale message handling is inspired of http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
|
|
|
|
|
* str_format function come from http://tmont.com/blargh/2010/1/string-format-in-php
|
2012-10-20 06:41:19 +03:00
|
|
|
|
* All icons come from the package Web0 by naf1971 : http://naf1971.deviantart.com/art/Web0-182067054
|
2012-05-29 21:10:41 +03:00
|
|
|
|
* All testers
|
2012-10-20 06:41:19 +03:00
|
|
|
|
|
|
|
|
|
External libraries used :
|
|
|
|
|
* JQuery : http://jquery.com/
|
|
|
|
|
* Fancyapps : http://fancyapps.com/fancybox/
|
2012-05-29 21:10:41 +03:00
|
|
|
|
|
2012-05-28 08:01:33 +03:00
|
|
|
|
= Copyright & License =
|
|
|
|
|
|
2013-01-02 21:53:17 +02:00
|
|
|
|
COPS - 2012-2013 (c) S<>bastien Lucas <sebastien@slucas.fr>
|
2012-05-28 08:01:33 +03:00
|
|
|
|
|
|
|
|
|
See COPYING and file headers for license info
|
|
|
|
|
|