From ca2c41516af57e1c036e87e1caf8bd1f0ccb0ef0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 18 Jul 2011 17:53:26 -0600 Subject: [PATCH] Content server: Add a link at the bottom of the mobile interface to switch tot he full interface. Fixes #812525 ([Enhancement] Web app) --- resources/content_server/browse/browse.html | 1 + src/calibre/ebooks/mobi/debug.py | 45 +++++++++++++++++++-- src/calibre/library/server/mobile.py | 12 +++++- src/calibre/manual/faq.rst | 4 +- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/resources/content_server/browse/browse.html b/resources/content_server/browse/browse.html index 6a9697dc06..cf17742c87 100644 --- a/resources/content_server/browse/browse.html +++ b/resources/content_server/browse/browse.html @@ -11,6 +11,7 @@ + diff --git a/src/calibre/ebooks/mobi/debug.py b/src/calibre/ebooks/mobi/debug.py index ce7d78303e..884311617d 100644 --- a/src/calibre/ebooks/mobi/debug.py +++ b/src/calibre/ebooks/mobi/debug.py @@ -10,7 +10,7 @@ __docformat__ = 'restructuredtext en' import struct, datetime, sys, os from calibre.utils.date import utc_tz from calibre.ebooks.mobi.langcodes import main_language, sub_language -from calibre.ebooks.mobi.writer2.utils import decode_hex_number +from calibre.ebooks.mobi.writer2.utils import decode_hex_number, decint # PalmDB {{{ class PalmDOCAttributes(object): @@ -498,9 +498,45 @@ class IndexHeader(object): # {{{ class IndexEntry(object): # {{{ + TYPES = { + # Present in book type files + 0x0f : 'chapter', + 0x6f : 'chapter_with_subchapters', + 0x1f : 'subchapter', + # Present in periodicals + 0xdf : 'periodical', + 0xff : 'section', + 0x3f : 'article', + } + def __init__(self, ident, entry_type, raw): self.id = ident - self.entry_type = entry_type + self.fields = [] + self.sub_type = None + + try: + self.entry_type = self.TYPES[entry_type] + except KeyError: + raise ValueError('Unknown IndexEntry type: %s'%hex(entry_type)) + + if self.entry_type in (0xdf, 0xff): + self.subtype = ord(raw[0]) + raw = raw[1:] + while True: + val, consumed = decint(raw) + raw = raw[consumed:] + if val == 0: + break + else: + self.fields.append(val) + + + def __str__(self): + ans = ['Index Entry(id=%s, entry_type=%s, sub_type=%s)'%( + self.id, self.entry_type, self.sub_type)] + ans.append('\tFields: %r'%self.fields) + return '\n'.join(ans) + # }}} class IndexRecord(object): # {{{ @@ -538,7 +574,7 @@ class IndexRecord(object): # {{{ index = indxt[off:] ident, consumed = decode_hex_number(index) index = index[consumed:] - entry_type = u(b'>B', index[0]) + entry_type, = u(b'>B', index[0]) self.indices.append(IndexEntry(ident, entry_type, index[1:])) @@ -557,6 +593,9 @@ class IndexRecord(object): # {{{ u(self.unknown3) u(self.unknown4) a('Index offsets: %r'%self.index_offsets) + a('\nIndex Entries:') + for entry in self.indices: + a(str(entry)+'\n') return '\n'.join(ans) diff --git a/src/calibre/library/server/mobile.py b/src/calibre/library/server/mobile.py index ad5ee4af96..3ce96a2b49 100644 --- a/src/calibre/library/server/mobile.py +++ b/src/calibre/library/server/mobile.py @@ -153,12 +153,22 @@ def build_index(books, num, search, sort, order, start, total, url_base, CKEYS, bookt.append(TR(thumbnail, data)) # }}} + body.append(HR()) + body.append(DIV( + A(_('Switch to the full interface (non-mobile interface)'), + href="/browse", + style="text-decoration: none; color: blue", + title=_('The full interface gives you many more features, ' + 'but it may not work well on a small screen')), + style="text-align:center")) return HTML( HEAD( TITLE(__appname__ + ' Library'), LINK(rel='icon', href='http://calibre-ebook.com/favicon.ico', type='image/x-icon'), - LINK(rel='stylesheet', type='text/css', href=prefix+'/mobile/style.css') + LINK(rel='stylesheet', type='text/css', + href=prefix+'/mobile/style.css'), + LINK(rel='apple-touch-icon', href="/static/calibre.png") ), # End head body ) # End html diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index 5601407282..556f508880 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -405,9 +405,9 @@ To those of you that claim that you need access to the filesystem to so that you If you are worried that someday |app| will cease to be developed, leaving all your books marooned in its folder structure, explore the powerful "Save to Disk" feature in |app| that lets you export all your files into a folder structure of arbitrary complexity based on their metadata. -Since I keep getting asked why there are numbers at the end of the title folder name, the reason is for *robustness*. That number is the id number of the book record in the |app| database. The presence of the number allows you to have multiple records with the same title and author names. More importantly, it is part of what allows |app| to magically regenerate the database with all metadata if the database file gets corrupted. Given that |app|'s mission is to get you to stop storing metadata in filenames and stop using the filesystem to find things, the increased robustness afforded by the id numbers is well worth the uglier folder names. +Finally, the reason there are numbers at the end of every title folder, is for *robustness*. That number is the id number of the book record in the |app| database. The presence of the number allows you to have multiple records with the same title and author names. It is also part of what allows |app| to magically regenerate the database with all metadata if the database file gets corrupted. Given that |app|'s mission is to get you to stop storing metadata in filenames and stop using the filesystem to find things, the increased robustness afforded by the id numbers is well worth the uglier folder names. -Finally, if you are irrevocably wedded to using the filesystem to store your metadata, feel free to patch your local copy of |app| to use whatever storage scheme you like. But, do not bother me with requests to change the directory structure, **they will be ignored**. +If you are still not convinced, then I'm afraid |app| is not for you. Look elsewhere for your book cataloguing needs. Just so we're clear, **this is not going to change**. Kindly do not contact us in an attempt to get us to change this. Why doesn't |app| have a column for foo? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~