mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-27 06:23:06 +02:00
Add option to serve User Manual on localhost after building it
This commit is contained in:
parent
0c98870eff
commit
bad59c4ed7
1 changed files with 22 additions and 0 deletions
|
|
@ -84,6 +84,8 @@ class Manual(Command):
|
|||
def add_options(self, parser):
|
||||
parser.add_option('-l', '--language', action='append', default=[],
|
||||
help='Build translated versions for only the specified languages (can be specified multiple times)')
|
||||
parser.add_option('--serve', action='store_true', default=False,
|
||||
help='Run a webserver on the built manual files')
|
||||
|
||||
def run(self, opts):
|
||||
tdir = self.j(tempfile.gettempdir(), 'user-manual-build')
|
||||
|
|
@ -121,6 +123,26 @@ def run(self, opts):
|
|||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
if opts.serve:
|
||||
self.serve_manual(self.j(tdir, 'en', 'html'))
|
||||
|
||||
def serve_manual(self, root):
|
||||
os.chdir(root)
|
||||
import BaseHTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
HandlerClass = SimpleHTTPRequestHandler
|
||||
ServerClass = BaseHTTPServer.HTTPServer
|
||||
Protocol = "HTTP/1.0"
|
||||
server_address = ('127.0.0.1', 8000)
|
||||
|
||||
HandlerClass.protocol_version = Protocol
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
|
||||
print ("Serving User Manual on localhost:8000")
|
||||
from calibre.gui2 import open_url
|
||||
open_url('http://localhost:8000')
|
||||
httpd.serve_forever()
|
||||
|
||||
def replace_with_symlinks(self, lang_dir):
|
||||
' Replace all identical files with symlinks to save disk space/upload bandwidth '
|
||||
from calibre import walk
|
||||
|
|
|
|||
Loading…
Reference in a new issue