diff --git a/src/calibre/library/static/av.jpg b/resources/content_server/av.jpg similarity index 100% rename from src/calibre/library/static/av.jpg rename to resources/content_server/av.jpg diff --git a/src/calibre/library/static/bg_search_box.png b/resources/content_server/bg_search_box.png similarity index 100% rename from src/calibre/library/static/bg_search_box.png rename to resources/content_server/bg_search_box.png diff --git a/src/calibre/library/static/btn_search_box.png b/resources/content_server/btn_search_box.png similarity index 100% rename from src/calibre/library/static/btn_search_box.png rename to resources/content_server/btn_search_box.png diff --git a/src/calibre/library/static/calibre.png b/resources/content_server/calibre.png similarity index 100% rename from src/calibre/library/static/calibre.png rename to resources/content_server/calibre.png diff --git a/src/calibre/library/static/calibre_banner.png b/resources/content_server/calibre_banner.png similarity index 100% rename from src/calibre/library/static/calibre_banner.png rename to resources/content_server/calibre_banner.png diff --git a/src/calibre/library/static/date.js b/resources/content_server/date.js similarity index 100% rename from src/calibre/library/static/date.js rename to resources/content_server/date.js diff --git a/src/calibre/library/static/default_cover.jpg b/resources/content_server/default_cover.jpg similarity index 100% rename from src/calibre/library/static/default_cover.jpg rename to resources/content_server/default_cover.jpg diff --git a/src/calibre/library/static/first.png b/resources/content_server/first.png similarity index 100% rename from src/calibre/library/static/first.png rename to resources/content_server/first.png diff --git a/src/calibre/library/static/gui.css b/resources/content_server/gui.css similarity index 100% rename from src/calibre/library/static/gui.css rename to resources/content_server/gui.css diff --git a/src/calibre/library/static/gui.js b/resources/content_server/gui.js similarity index 100% rename from src/calibre/library/static/gui.js rename to resources/content_server/gui.js diff --git a/src/calibre/library/static/index.html b/resources/content_server/index.html similarity index 100% rename from src/calibre/library/static/index.html rename to resources/content_server/index.html diff --git a/src/calibre/gui2/viewer/jquery.js b/resources/content_server/jquery.js similarity index 100% rename from src/calibre/gui2/viewer/jquery.js rename to resources/content_server/jquery.js diff --git a/src/calibre/library/static/last.png b/resources/content_server/last.png similarity index 100% rename from src/calibre/library/static/last.png rename to resources/content_server/last.png diff --git a/src/calibre/library/static/loading.gif b/resources/content_server/loading.gif similarity index 100% rename from src/calibre/library/static/loading.gif rename to resources/content_server/loading.gif diff --git a/src/calibre/library/static/next.png b/resources/content_server/next.png similarity index 100% rename from src/calibre/library/static/next.png rename to resources/content_server/next.png diff --git a/src/calibre/library/static/previous.png b/resources/content_server/previous.png similarity index 100% rename from src/calibre/library/static/previous.png rename to resources/content_server/previous.png diff --git a/src/calibre/library/metadata_sqlite.sql b/resources/metadata_sqlite.sql similarity index 100% rename from src/calibre/library/metadata_sqlite.sql rename to resources/metadata_sqlite.sql diff --git a/src/calibre/ebooks/fb2/fb2.xsl b/resources/templates/fb2.xsl similarity index 100% rename from src/calibre/ebooks/fb2/fb2.xsl rename to resources/templates/fb2.xsl diff --git a/src/calibre/ebooks/oeb/html.css b/resources/templates/html.css similarity index 100% rename from src/calibre/ebooks/oeb/html.css rename to resources/templates/html.css diff --git a/src/calibre/ebooks/metadata/ncx.xml b/resources/templates/ncx.xml similarity index 100% rename from src/calibre/ebooks/metadata/ncx.xml rename to resources/templates/ncx.xml diff --git a/src/calibre/ebooks/metadata/opf.xml b/resources/templates/opf.xml similarity index 100% rename from src/calibre/ebooks/metadata/opf.xml rename to resources/templates/opf.xml diff --git a/src/calibre/gui2/viewer/hyphenate/Hyphenator.js b/resources/viewer/hyphenate/Hyphenator.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/Hyphenator.js rename to resources/viewer/hyphenate/Hyphenator.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/bn.js b/resources/viewer/hyphenate/patterns/bn.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/bn.js rename to resources/viewer/hyphenate/patterns/bn.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/cs.js b/resources/viewer/hyphenate/patterns/cs.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/cs.js rename to resources/viewer/hyphenate/patterns/cs.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/da.js b/resources/viewer/hyphenate/patterns/da.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/da.js rename to resources/viewer/hyphenate/patterns/da.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/de.js b/resources/viewer/hyphenate/patterns/de.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/de.js rename to resources/viewer/hyphenate/patterns/de.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/en.js b/resources/viewer/hyphenate/patterns/en.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/en.js rename to resources/viewer/hyphenate/patterns/en.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/es.js b/resources/viewer/hyphenate/patterns/es.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/es.js rename to resources/viewer/hyphenate/patterns/es.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/fi.js b/resources/viewer/hyphenate/patterns/fi.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/fi.js rename to resources/viewer/hyphenate/patterns/fi.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/fr.js b/resources/viewer/hyphenate/patterns/fr.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/fr.js rename to resources/viewer/hyphenate/patterns/fr.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/gu.js b/resources/viewer/hyphenate/patterns/gu.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/gu.js rename to resources/viewer/hyphenate/patterns/gu.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/hi.js b/resources/viewer/hyphenate/patterns/hi.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/hi.js rename to resources/viewer/hyphenate/patterns/hi.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/hu.js b/resources/viewer/hyphenate/patterns/hu.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/hu.js rename to resources/viewer/hyphenate/patterns/hu.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/it.js b/resources/viewer/hyphenate/patterns/it.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/it.js rename to resources/viewer/hyphenate/patterns/it.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/kn.js b/resources/viewer/hyphenate/patterns/kn.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/kn.js rename to resources/viewer/hyphenate/patterns/kn.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/ml.js b/resources/viewer/hyphenate/patterns/ml.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/ml.js rename to resources/viewer/hyphenate/patterns/ml.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/nl.js b/resources/viewer/hyphenate/patterns/nl.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/nl.js rename to resources/viewer/hyphenate/patterns/nl.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/or.js b/resources/viewer/hyphenate/patterns/or.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/or.js rename to resources/viewer/hyphenate/patterns/or.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/pa.js b/resources/viewer/hyphenate/patterns/pa.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/pa.js rename to resources/viewer/hyphenate/patterns/pa.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/pl.js b/resources/viewer/hyphenate/patterns/pl.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/pl.js rename to resources/viewer/hyphenate/patterns/pl.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/pt.js b/resources/viewer/hyphenate/patterns/pt.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/pt.js rename to resources/viewer/hyphenate/patterns/pt.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/ru.js b/resources/viewer/hyphenate/patterns/ru.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/ru.js rename to resources/viewer/hyphenate/patterns/ru.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/sv.js b/resources/viewer/hyphenate/patterns/sv.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/sv.js rename to resources/viewer/hyphenate/patterns/sv.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/ta.js b/resources/viewer/hyphenate/patterns/ta.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/ta.js rename to resources/viewer/hyphenate/patterns/ta.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/te.js b/resources/viewer/hyphenate/patterns/te.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/te.js rename to resources/viewer/hyphenate/patterns/te.js diff --git a/src/calibre/gui2/viewer/hyphenate/patterns/uk.js b/resources/viewer/hyphenate/patterns/uk.js similarity index 100% rename from src/calibre/gui2/viewer/hyphenate/patterns/uk.js rename to resources/viewer/hyphenate/patterns/uk.js diff --git a/src/calibre/gui2/viewer/jquery_scrollTo.js b/resources/viewer/jquery_scrollTo.js similarity index 100% rename from src/calibre/gui2/viewer/jquery_scrollTo.js rename to resources/viewer/jquery_scrollTo.js diff --git a/src/calibre/ebooks/fb2/input.py b/src/calibre/ebooks/fb2/input.py index 651b3a62f6..efe2606141 100644 --- a/src/calibre/ebooks/fb2/input.py +++ b/src/calibre/ebooks/fb2/input.py @@ -38,7 +38,6 @@ class FB2Input(InputFormatPlugin): def convert(self, stream, options, file_ext, log, accelerators): - from calibre.resources import fb2_xsl from calibre.ebooks.metadata.opf2 import OPFCreator from calibre.ebooks.metadata.meta import get_metadata from calibre.ebooks.oeb.base import XLINK_NS @@ -49,7 +48,7 @@ class FB2Input(InputFormatPlugin): doc = etree.parse(stream, parser) self.extract_embedded_content(doc) log.debug('Converting XML to HTML...') - ss = fb2_xsl + ss = open(P('templates/fb2.xsl'), 'rb').read() if options.no_inline_fb2_toc: log('Disabling generation of inline FB2 TOC') ss = re.compile(r'.*', diff --git a/src/calibre/ebooks/metadata/opf.py b/src/calibre/ebooks/metadata/opf.py index 701de1e116..9f1d12d6d1 100644 --- a/src/calibre/ebooks/metadata/opf.py +++ b/src/calibre/ebooks/metadata/opf.py @@ -503,8 +503,8 @@ class OPFCreator(MetaInformation): self.guide.set_basedir(self.base_path) def render(self, opf_stream, ncx_stream=None, ncx_manifest_entry=None): - from calibre.resources import opf_template from calibre.utils.genshi.template import MarkupTemplate + opf_template = open(P('templates/opf.xml'), 'rb').read() template = MarkupTemplate(opf_template) if self.manifest: self.manifest.set_basedir(self.base_path) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index e9bd4b35f3..d0056b2deb 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -930,8 +930,8 @@ class OPFCreator(MetaInformation): def render(self, opf_stream=sys.stdout, ncx_stream=None, ncx_manifest_entry=None, encoding=None): - from calibre.resources import opf_template from calibre.utils.genshi.template import MarkupTemplate + opf_template = open(P('templates/opf.xml'), 'rb').read() if encoding is None: encoding = 'utf-8' template = MarkupTemplate(opf_template) diff --git a/src/calibre/ebooks/metadata/toc.py b/src/calibre/ebooks/metadata/toc.py index 8f9edde011..770ee905e3 100644 --- a/src/calibre/ebooks/metadata/toc.py +++ b/src/calibre/ebooks/metadata/toc.py @@ -207,8 +207,8 @@ class TOC(list): self.add_item(href, fragment, txt) def render(self, stream, uid): - from calibre.resources import ncx_template from calibre.utils.genshi.template import MarkupTemplate + ncx_template = open(P('templates/ncx.xml'), 'rb').read() doctype = ('ncx', "-//NISO//DTD ncx 2005-1//EN", "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd") template = MarkupTemplate(ncx_template) raw = template.generate(uid=uid, toc=self, __appname__=__appname__) diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py index db8152b8fe..7e4643dac1 100644 --- a/src/calibre/ebooks/mobi/output.py +++ b/src/calibre/ebooks/mobi/output.py @@ -51,14 +51,13 @@ class MOBIOutput(OutputFormatPlugin): found = 'masthead' in self.oeb.guide if not found: self.oeb.log.debug('No masthead found, generating default one...') - from calibre.resources import server_resources try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage - raw = StringIO(server_resources['calibre_banner.png']) + raw = open(P('content_server/calibre_banner.png'), 'rb') im = PILImage.open(raw) of = StringIO() im.save(of, 'GIF') diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index 2a0a5fb242..4c0b8a1573 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -24,8 +24,8 @@ from lxml.cssselect import css_to_xpath, ExpressionError, SelectorSyntaxError from calibre.ebooks.oeb.base import XHTML, XHTML_NS, CSS_MIME, OEB_STYLES from calibre.ebooks.oeb.base import XPNSMAP, xpath, urlnormalize from calibre.ebooks.oeb.profile import PROFILES -from calibre.resources import html_css +html_css = open(P('templates/html.css'), 'rb').read() XHTML_CSS_NAMESPACE = '@namespace "%s";\n' % XHTML_NS HTML_CSS_STYLESHEET = cssutils.parseString(html_css) HTML_CSS_STYLESHEET.namespaces['h'] = XHTML_NS diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 19c9f3b612..f6e6e2972d 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -8,11 +8,12 @@ __docformat__ = 'restructuredtext en' import os, math, re, glob from PyQt4.Qt import QWidget, QSize, QSizePolicy, QUrl, SIGNAL, Qt, QTimer, \ QPainter, QPalette, QBrush, QFontDatabase, QDialog, \ - QColor, QPoint, QImage, QRegion, \ + QColor, QPoint, QImage, QRegion, QVariant, \ QFont, QObject, QApplication, pyqtSignature from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings from calibre.utils.config import Config, StringConfig +from calibre.utils.localization import get_language from calibre.gui2.viewer.config_ui import Ui_Dialog from calibre.gui2.viewer.js import bookmarks, referencing, hyphenation from calibre.ptempfile import PersistentTemporaryFile @@ -86,12 +87,19 @@ class ConfigDialog(QDialog, Ui_Dialog): self.css.setPlainText(opts.user_css) self.css.setToolTip(_('Set the user CSS stylesheet. This can be used to customize the look of all books.')) self.max_view_width.setValue(opts.max_view_width) - from calibre.resources import hyphenate - for x in sorted(hyphenate['languages'].split(',')): - self.hyphenate_default_lang.addItem(x) - idx = self.hyphenate_default_lang.findText(opts.hyphenate_default_lang) - if idx == -1: - idx = self.hyphenate_default_lang.findText('en') + pats = [os.path.basename(x).split('.')[0] for x in + glob.glob(P('viewer/hyphenate/patterns/*.js'))] + names = list(map(get_language, pats)) + pmap = {} + for i in range(len(pats)): + pmap[names[i]] = pats[i] + for x in sorted(names): + self.hyphenate_default_lang.addItem(x, QVariant(pmap[x])) + try: + idx = pats.index(opts.hyphenate_default_lang) + except ValueError: + idx = pats.index('en') + idx = self.hyphenate_default_lang.findText(names[idx]) self.hyphenate_default_lang.setCurrentIndex(idx) self.hyphenate.setChecked(opts.hyphenate) self.hyphenate_default_lang.setEnabled(opts.hyphenate) @@ -109,8 +117,9 @@ class ConfigDialog(QDialog, Ui_Dialog): c.set('remember_window_size', self.opt_remember_window_size.isChecked()) c.set('max_view_width', int(self.max_view_width.value())) c.set('hyphenate', self.hyphenate.isChecked()) + idx = self.hyphenate_default_lang.currentIndex() c.set('hyphenate_default_lang', - self.hyphenate_default_lang.currentText()) + str(self.hyphenate_default_lang.itemData(idx).toString())) return QDialog.accept(self, *args) @@ -184,7 +193,10 @@ class Document(QWebPage): def load_javascript_libraries(self): self.mainFrame().addToJavaScriptWindowObject("py_bridge", self) - from calibre.resources import jquery, jquery_scrollTo, hyphenate + jquery = open(P('content_server/jquery.js'), 'rb').read() + jquery_scrollTo = open(P('viewer/jquery_scrollTo.js'), 'rb').read() + hyphenator = open(P('viewer/hyphenate/Hyphenator.js'), + 'rb').read().decode('utf-8') self.javascript(jquery) self.javascript(jquery_scrollTo) self.javascript(bookmarks) @@ -195,11 +207,14 @@ class Document(QWebPage): if not lang: lang = default_lang lang = lang.lower()[:2] - if lang not in hyphenate['languages']: + self.javascript(hyphenator) + p = P('viewer/hyphenate/patterns/%s.js'%lang) + if not os.path.exists(p): lang = default_lang + p = P('viewer/hyphenate/patterns/%s.js'%lang) + self.javascript(open(p, 'rb').read().decode('utf-8')) self.loaded_lang = lang - self.javascript(hyphenate['Hyphenator.js'].decode('utf-8')) - self.javascript(hyphenate[lang+'.js'].decode('utf-8')) + @pyqtSignature("") def animated_scroll_done(self): diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index df7cdc7fd6..081aeabaf0 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -16,7 +16,6 @@ from PyQt4.Qt import QWizard, QWizardPage, QPixmap, Qt, QAbstractListModel, \ from calibre import __appname__, patheq from calibre.library.database2 import LibraryDatabase2 from calibre.library.move import MoveLibrary -from calibre.resources import server_resources from calibre.constants import filesystem_encoding from calibre.gui2.wizard.send_email import smtp_prefs from calibre.gui2.wizard.device_ui import Ui_WizardPage as DeviceUI @@ -528,7 +527,7 @@ class Wizard(QWizard): QWizard.__init__(self, parent) self.setWindowTitle(__appname__+' '+_('welcome wizard')) p = QPixmap() - p.loadFromData(server_resources['calibre.png']) + p.loadFromData(open(P('content_server/calibre.png'), 'rb').read()) self.setPixmap(self.LogoPixmap, p.scaledToHeight(80, Qt.SmoothTransformation)) self.setPixmap(self.WatermarkPixmap, diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 81fb4d79fe..cdf1894ab6 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -453,7 +453,7 @@ class LibraryDatabase2(LibraryDatabase): loc=FIELD_MAP['comments' if prop == 'comment' else prop])) def initialize_database(self): - from calibre.resources import metadata_sqlite + metadata_sqlite = open(P('metadata_sqlite.sql'), 'rb').read() self.conn.executescript(metadata_sqlite) self.user_version = 1 diff --git a/src/calibre/library/server.py b/src/calibre/library/server.py index b3ddd0110b..8ca8f627ff 100644 --- a/src/calibre/library/server.py +++ b/src/calibre/library/server.py @@ -25,7 +25,6 @@ from calibre.constants import __version__, __appname__ from calibre.utils.genshi.template import MarkupTemplate from calibre import fit_image, guess_type, prepare_string_for_xml, \ strftime as _strftime -from calibre.resources import jquery, server_resources, build_time from calibre.library import server_config as config from calibre.library.database2 import LibraryDatabase2, FIELD_MAP from calibre.utils.config import config_dir @@ -33,9 +32,6 @@ from calibre.utils.mdns import publish as publish_zeroconf, \ stop_server as stop_zeroconf from calibre.ebooks.metadata import fmt_sidx, title_sort -build_time = datetime.strptime(build_time, '%d %m %Y %H%M%S') -server_resources['jquery.js'] = jquery - def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None): if not hasattr(dt, 'timetuple'): dt = datetime.now() @@ -208,6 +204,9 @@ class LibraryServer(object): self.opts = opts self.max_cover_width, self.max_cover_height = \ map(int, self.opts.max_cover.split('x')) + path = P('content_server') + self.build_time = datetime.fromtimestamp(os.stat(path).st_mtime) + self.default_cover = open(P('content_server/default_cover.jpg'), 'rb').read() cherrypy.config.update({ 'log.screen' : opts.develop, @@ -280,10 +279,11 @@ class LibraryServer(object): def get_cover(self, id, thumbnail=False): cover = self.db.cover(id, index_is_id=True, as_file=False) if cover is None: - cover = server_resources['default_cover.jpg'] + cover = self.default_cover cherrypy.response.headers['Content-Type'] = 'image/jpeg' path = getattr(cover, 'name', False) - updated = datetime.utcfromtimestamp(os.stat(path).st_mtime) if path and os.access(path, os.R_OK) else build_time + updated = datetime.utcfromtimestamp(os.stat(path).st_mtime) if path and \ + os.access(path, os.R_OK) else self.build_time cherrypy.response.headers['Last-Modified'] = self.last_modified(updated) try: f = cStringIO.StringIO(cover) @@ -571,17 +571,14 @@ class LibraryServer(object): 'html' : 'text/html', '' : 'application/octet-stream', }[name.rpartition('.')[-1].lower()] - cherrypy.response.headers['Last-Modified'] = self.last_modified(build_time) - if self.opts.develop and not getattr(sys, 'frozen', False) and \ - name in ('gui.js', 'gui.css', 'index.html'): - path = os.path.join(os.path.dirname(__file__), 'static', name) + cherrypy.response.headers['Last-Modified'] = self.last_modified(self.build_time) + path = P('content_server/'+name) + if not os.path.exists(path): + raise cherrypy.HTTPError(404, '%s not found'%name) + if self.opts.develop: lm = datetime.fromtimestamp(os.stat(path).st_mtime) cherrypy.response.headers['Last-Modified'] = self.last_modified(lm) - return open(path, 'rb').read() - else: - if server_resources.has_key(name): - return server_resources[name] - raise cherrypy.HTTPError(404, '%s not found'%name) + return open(path, 'rb').read() def start_threaded_server(db, opts): server = LibraryServer(db, opts, embedded=True)