inital cbr support
This commit is contained in:
parent
60ab6a5244
commit
6d19dd5e81
6 changed files with 44 additions and 4 deletions
|
@ -84,6 +84,8 @@ class FileHandler(OMLHandler):
|
||||||
self.set_status(404)
|
self.set_status(404)
|
||||||
return
|
return
|
||||||
mimetype = {
|
mimetype = {
|
||||||
|
'cbr': 'application/x-cbr',
|
||||||
|
'cbz': 'application/x-cbz',
|
||||||
'epub': 'application/epub+zip',
|
'epub': 'application/epub+zip',
|
||||||
'pdf': 'application/pdf',
|
'pdf': 'application/pdf',
|
||||||
'txt': 'text/plain',
|
'txt': 'text/plain',
|
||||||
|
@ -108,7 +110,9 @@ class ReaderHandler(OMLHandler):
|
||||||
if not item:
|
if not item:
|
||||||
self.set_status(404)
|
self.set_status(404)
|
||||||
return
|
return
|
||||||
if item.info['extension'] == 'epub':
|
if item.info['extension'] in ('cbr', 'cbz'):
|
||||||
|
html = 'html/cbr.html'
|
||||||
|
elif item.info['extension'] == 'epub':
|
||||||
html = 'html/epub.html'
|
html = 'html/epub.html'
|
||||||
elif item.info['extension'] == 'pdf':
|
elif item.info['extension'] == 'pdf':
|
||||||
html = 'html/pdf.html'
|
html = 'html/pdf.html'
|
||||||
|
|
|
@ -22,7 +22,7 @@ import state
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger('oml.item.scan')
|
logger = logging.getLogger('oml.item.scan')
|
||||||
|
|
||||||
extensions = ['epub', 'pdf', 'txt']
|
extensions = ['epub', 'pdf', 'txt', 'cbr', 'cbz']
|
||||||
|
|
||||||
def remove_missing():
|
def remove_missing():
|
||||||
dirty = False
|
dirty = False
|
||||||
|
|
|
@ -10,6 +10,7 @@ import codecs
|
||||||
import ox
|
import ox
|
||||||
|
|
||||||
from . import pdf
|
from . import pdf
|
||||||
|
from . import cbr
|
||||||
from . import epub
|
from . import epub
|
||||||
from . import txt
|
from . import txt
|
||||||
from . import opf
|
from . import opf
|
||||||
|
@ -27,10 +28,12 @@ def metadata(f, from_=None):
|
||||||
data['extension'] = ext
|
data['extension'] = ext
|
||||||
data['size'] = os.stat(f).st_size
|
data['size'] = os.stat(f).st_size
|
||||||
|
|
||||||
if ext == 'pdf':
|
if ext == 'cbr':
|
||||||
info = pdf.info(f)
|
info = cbr.info(f)
|
||||||
elif ext == 'epub':
|
elif ext == 'epub':
|
||||||
info = epub.info(f)
|
info = epub.info(f)
|
||||||
|
elif ext == 'pdf':
|
||||||
|
info = pdf.info(f)
|
||||||
elif ext == 'txt':
|
elif ext == 'txt':
|
||||||
info = txt.info(f)
|
info = txt.info(f)
|
||||||
|
|
||||||
|
|
18
oml/media/cbr.py
Normal file
18
oml/media/cbr.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def cover(path):
|
||||||
|
data = None
|
||||||
|
#open rar file and extract first page here
|
||||||
|
return data
|
||||||
|
|
||||||
|
def info(path):
|
||||||
|
data = {}
|
||||||
|
data['title'] = os.path.splitext(os.path.basename(path))[0]
|
||||||
|
#data['pages'] = fixme read rar to count pages
|
||||||
|
return data
|
||||||
|
|
|
@ -58,12 +58,14 @@ def run():
|
||||||
handlers = [
|
handlers = [
|
||||||
(r'/(favicon.ico)', StaticFileHandler, {'path': settings.static_path}),
|
(r'/(favicon.ico)', StaticFileHandler, {'path': settings.static_path}),
|
||||||
(r'/static/oxjs/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'oxjs')}),
|
(r'/static/oxjs/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'oxjs')}),
|
||||||
|
(r'/static/cbr.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'cbr.js')}),
|
||||||
(r'/static/epub.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'epub.js')}),
|
(r'/static/epub.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'epub.js')}),
|
||||||
(r'/static/pdf.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'pdf.js')}),
|
(r'/static/pdf.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'pdf.js')}),
|
||||||
(r'/static/txt.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'txt.js')}),
|
(r'/static/txt.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'txt.js')}),
|
||||||
(r'/static/(.*)', StaticFileHandler, {'path': settings.static_path}),
|
(r'/static/(.*)', StaticFileHandler, {'path': settings.static_path}),
|
||||||
(r'/(.*)/epub/(.*)', EpubHandler),
|
(r'/(.*)/epub/(.*)', EpubHandler),
|
||||||
(r'/(.*?)/reader/', ReaderHandler),
|
(r'/(.*?)/reader/', ReaderHandler),
|
||||||
|
(r'/(.*?)/cbr/', FileHandler),
|
||||||
(r'/(.*?)/pdf/', FileHandler),
|
(r'/(.*?)/pdf/', FileHandler),
|
||||||
(r'/(.*?)/txt/', FileHandler),
|
(r'/(.*?)/txt/', FileHandler),
|
||||||
(r'/(.*?)/get/', FileHandler, {
|
(r'/(.*?)/get/', FileHandler, {
|
||||||
|
|
13
static/html/cbr.html
Normal file
13
static/html/cbr.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<script src="/static/oxjs/build/Ox.js" type="text/javascript"></script>
|
||||||
|
<script src="/static/cbr.js/cbr.js" type="text/javascript"></script>
|
||||||
|
<script src="/static/cbr.js/bitjs/archive.js" type="text/javascript"></script>
|
||||||
|
<script>
|
||||||
|
cbrjs.open(document.location.pathname.replace(/\/reader\//, '/cbr/'));
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue