mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
KG revisions 0.7
This commit is contained in:
commit
da62165b52
@ -201,6 +201,7 @@ class CSSFlattener(object):
|
|||||||
tag = barename(node.tag)
|
tag = barename(node.tag)
|
||||||
style = stylizer.style(node)
|
style = stylizer.style(node)
|
||||||
cssdict = style.cssdict()
|
cssdict = style.cssdict()
|
||||||
|
font_size = style['font-size']
|
||||||
if 'align' in node.attrib:
|
if 'align' in node.attrib:
|
||||||
cssdict['text-align'] = node.attrib['align']
|
cssdict['text-align'] = node.attrib['align']
|
||||||
del node.attrib['align']
|
del node.attrib['align']
|
||||||
@ -219,13 +220,16 @@ class CSSFlattener(object):
|
|||||||
esize = 1
|
esize = 1
|
||||||
if esize > 7:
|
if esize > 7:
|
||||||
esize = 7
|
esize = 7
|
||||||
cssdict['font-size'] = fnums[esize]
|
font_size = fnums[esize]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
cssdict['font-size'] = fnums[force_int(size)]
|
font_size = fnums[force_int(size)]
|
||||||
except:
|
except:
|
||||||
cssdict['font-size'] = fnums[3]
|
font_size = fnums[3]
|
||||||
|
cssdict['font-size'] = '%.1fpt'%font_size
|
||||||
del node.attrib['size']
|
del node.attrib['size']
|
||||||
|
if 'face' in node.attrib:
|
||||||
|
del node.attrib['face']
|
||||||
if 'color' in node.attrib:
|
if 'color' in node.attrib:
|
||||||
cssdict['color'] = node.attrib['color']
|
cssdict['color'] = node.attrib['color']
|
||||||
del node.attrib['color']
|
del node.attrib['color']
|
||||||
@ -244,7 +248,7 @@ class CSSFlattener(object):
|
|||||||
cssdict['font-size'] = '%0.5fem'%(fsize/psize)
|
cssdict['font-size'] = '%0.5fem'%(fsize/psize)
|
||||||
psize = fsize
|
psize = fsize
|
||||||
elif 'font-size' in cssdict or tag == 'body':
|
elif 'font-size' in cssdict or tag == 'body':
|
||||||
fsize = self.fmap[style['font-size']]
|
fsize = self.fmap[font_size]
|
||||||
cssdict['font-size'] = "%0.5fem" % (fsize / psize)
|
cssdict['font-size'] = "%0.5fem" % (fsize / psize)
|
||||||
psize = fsize
|
psize = fsize
|
||||||
if cssdict:
|
if cssdict:
|
||||||
|
@ -25,7 +25,7 @@ BASE_HREFS = {
|
|||||||
1 : '/opds',
|
1 : '/opds',
|
||||||
}
|
}
|
||||||
|
|
||||||
STANZA_FORMATS = frozenset(['epub', 'pdb'])
|
STANZA_FORMATS = frozenset(['epub', 'pdb', 'pdf', 'cbr', 'cbz', 'djvu'])
|
||||||
|
|
||||||
def url_for(name, version, **kwargs):
|
def url_for(name, version, **kwargs):
|
||||||
if not name.endswith('_'):
|
if not name.endswith('_'):
|
||||||
@ -121,7 +121,7 @@ def CATALOG_GROUP_ENTRY(item, category, base_href, version, updated):
|
|||||||
TITLE(item.text),
|
TITLE(item.text),
|
||||||
ID(id_),
|
ID(id_),
|
||||||
UPDATED(updated),
|
UPDATED(updated),
|
||||||
E.content(_('%d books')%item.count, type='text'),
|
E.content(_('%d items')%item.count, type='text'),
|
||||||
link
|
link
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -135,29 +135,18 @@ turned into a collection on the reader. Note that the PRS-500 does not support c
|
|||||||
How do I use |app| with my iPad/iPhone/iTouch?
|
How do I use |app| with my iPad/iPhone/iTouch?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
You can access your calibre library on a iPad/iPhone/iTouch over the air using the calibre content server.
|
The easiest way to browse your |app| collection on your Apple device (iPad/iPhone/iPod) is by using the *free* Stanza app, available from the Apple app store. You need at least Stanza version 3.0. Stanza allows you to access your |app| collection wirelessly, over the air.
|
||||||
|
|
||||||
First perform the following steps in |app|
|
First perform the following steps in |app|
|
||||||
|
|
||||||
* Set the Preferred Output Format in |app| to EPUB (The output format can be set under Preferences->General)
|
* Set the Preferred Output Format in |app| to EPUB (The output format can be set under Preferences->General)
|
||||||
|
* Set the output profile to iPad (this will work for iPhone/iPods as well), under Preferences->Conversion->Page Setup
|
||||||
* Convert the books you want to read on your iPhone to EPUB format by selecting them and clicking the Convert button.
|
* Convert the books you want to read on your iPhone to EPUB format by selecting them and clicking the Convert button.
|
||||||
* Turn on the Content Server in |app|'s preferences and leave |app| running.
|
* Turn on the Content Server in |app|'s preferences and leave |app| running.
|
||||||
|
|
||||||
For an iPad:
|
Install the free Stanza reader app on your iPad/iPhone/iTouch using iTunes.
|
||||||
|
|
||||||
Install the ReadMe app on your iPad using iTunes. Open the Readme builtin browser and browse to::
|
Now you should be able to access your books on your iPhone by opening Stanza. Go to "Get Books" and then click the "Shared" tab. Under Shared you will see an entry "Books in calibre". If you don't, make sure your iPad/iPhone is connected using the WiFi network in your house, not 3G. If the |app| catalog is still not detected in Stanza, you can add it manually in Stanza. To do this, click the "Shared" tab, then click the "Edit" button and then click "Add book source" to add a new book source. In the Add Book Source screen enter whatever name you like and in the URL field, enter the following::
|
||||||
|
|
||||||
http://192.168.1.2:8080/
|
|
||||||
|
|
||||||
Replace ``192.168.1.2`` with the local IP address of the computer running |app|. If you have changed the port the |app| content server is running on, you will have to change ``8080`` as well to the new port. The local IP address is the IP address you computer is assigned on your home network. A quick Google search will tell you how to find out your local IP address.
|
|
||||||
|
|
||||||
The books in your |app| library will be presented as a list, 25 entries at a time. Click the right arrow to go to the next 25. You can also type in the search box to find specific books. Just click on the EPUB link of the book you want and it will be downloaded into your ReadMe library.
|
|
||||||
|
|
||||||
For an iPhone/iTouch:
|
|
||||||
|
|
||||||
Install the free Stanza reader app on your iPhone/iTouch using iTunes.
|
|
||||||
|
|
||||||
Now you should be able to access your books on your iPhone by opening Stanza. Go to "Get Books" and then click the "Shared" tab. Under Shared you will see an entry "Books in calibre". If you don't, make sure your iPhone is connected using the WiFi network in your house, not 3G. If the |app| catalog is still not detected in Stanza, you can add it manually in Stanza. To do this, click the "Shared" tab, then click the "Edit" button and then click "Add book source" to add a new book source. In the Add Book Source screen enter whatever name you like and in the URL field, enter the following::
|
|
||||||
|
|
||||||
http://192.168.1.2:8080/
|
http://192.168.1.2:8080/
|
||||||
|
|
||||||
@ -165,7 +154,10 @@ Replace ``192.168.1.2`` with the local IP address of the computer running |app|.
|
|||||||
|
|
||||||
If you get timeout errors while browsing the calibre catalog in Stanza, try increasing the connection timeout value in the stanza settings. Go to Info->Settings and increase the value of Download Timeout.
|
If you get timeout errors while browsing the calibre catalog in Stanza, try increasing the connection timeout value in the stanza settings. Go to Info->Settings and increase the value of Download Timeout.
|
||||||
|
|
||||||
Note that neither the Stanza, nor the ReadMe apps are in anyway associated with |app|.
|
Alternative for the iPad
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
As of |app| version 0.7.0, on windows and OS X you can plugin your iPad into the computer using its charging cable, and |app| will detect it and show you a list of books on the iPad. You can then use the Send to device button to send books directly to iBooks on the iPad.
|
||||||
|
|
||||||
How do I use |app| with my Android phone?
|
How do I use |app| with my Android phone?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -283,15 +283,6 @@ class BasicNewsRecipe(Recipe):
|
|||||||
#: Override this in your recipe to provide a url to use as a masthead.
|
#: Override this in your recipe to provide a url to use as a masthead.
|
||||||
masthead_url = None
|
masthead_url = None
|
||||||
|
|
||||||
#: By default, the cover image returned by get_cover_url() will be used as
|
|
||||||
#: the cover for the periodical. Overriding this in your recipe instructs
|
|
||||||
#: calibre to render the downloaded cover into a frame whose width and height
|
|
||||||
#: are expressed as a percentage of the downloaded cover.
|
|
||||||
#: For example,
|
|
||||||
#: cover_margins = (10,15)
|
|
||||||
#: would pad the downloaded cover 10px on the left and right, 15px on the top and bottom.
|
|
||||||
cover_margins = (0,0)
|
|
||||||
|
|
||||||
#: Set to a non empty string to disable this recipe
|
#: Set to a non empty string to disable this recipe
|
||||||
#: The string will be used as the disabled message
|
#: The string will be used as the disabled message
|
||||||
recipe_disabled = None
|
recipe_disabled = None
|
||||||
@ -547,8 +538,8 @@ class BasicNewsRecipe(Recipe):
|
|||||||
Intended to be used to get article metadata like author/summary/etc.
|
Intended to be used to get article metadata like author/summary/etc.
|
||||||
from the parsed HTML (soup).
|
from the parsed HTML (soup).
|
||||||
:param article: A object of class :class:`calibre.web.feeds.Article`.
|
:param article: A object of class :class:`calibre.web.feeds.Article`.
|
||||||
If you change the summary, remember to also change the
|
If you change the summary, remember to also change the
|
||||||
text_summary
|
text_summary
|
||||||
:param soup: Parsed HTML belonging to this article
|
:param soup: Parsed HTML belonging to this article
|
||||||
:param first: True iff the parsed HTML is the first page of the article.
|
:param first: True iff the parsed HTML is the first page of the article.
|
||||||
'''
|
'''
|
||||||
@ -981,50 +972,8 @@ class BasicNewsRecipe(Recipe):
|
|||||||
cfile.write(open(cu, 'rb').read())
|
cfile.write(open(cu, 'rb').read())
|
||||||
else:
|
else:
|
||||||
self.report_progress(1, _('Downloading cover from %s')%cu)
|
self.report_progress(1, _('Downloading cover from %s')%cu)
|
||||||
|
with nested(open(cpath, 'wb'), closing(self.browser.open(cu))) as (cfile, r):
|
||||||
if self.cover_margin[0] == 0 and self.cover_margin[1] == 0:
|
cfile.write(r.read())
|
||||||
with nested(open(cpath, 'wb'), closing(self.browser.open(cu))) as (cfile, r):
|
|
||||||
cfile.write(r.read())
|
|
||||||
else:
|
|
||||||
ccpath = os.path.join(self.output_dir, 'cover_contents.'+ext)
|
|
||||||
with nested(open(ccpath, 'wb'), closing(self.browser.open(cu))) as (cfile, r):
|
|
||||||
cfile.write(r.read())
|
|
||||||
|
|
||||||
import calibre.utils.PythonMagickWand as pw
|
|
||||||
with pw.ImageMagick():
|
|
||||||
img = pw.NewMagickWand()
|
|
||||||
img2 = pw.NewMagickWand()
|
|
||||||
frame = pw.NewMagickWand()
|
|
||||||
p = pw.NewPixelWand()
|
|
||||||
if img < 0 or img2 < 0 or p < 0 or frame < 0:
|
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
if not pw.MagickReadImage(img, ccpath):
|
|
||||||
severity = pw.ExceptionType(0)
|
|
||||||
msg = pw.MagickGetException(img, byref(severity))
|
|
||||||
raise IOError('Failed to read image from: %s: %s'
|
|
||||||
%(ccpath, msg))
|
|
||||||
#pw.PixelSetColor(p, 'white')
|
|
||||||
pw.PixelSetColor(p, 'rgb(252,252,252)')
|
|
||||||
width = pw.MagickGetImageWidth(img) + self.cover_margin[0]*2
|
|
||||||
height = pw.MagickGetImageHeight(img) + self.cover_margin[1]*2
|
|
||||||
if not pw.MagickNewImage(img2, width, height, p):
|
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
if not pw.MagickNewImage(frame, width, height, p):
|
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
if not pw.MagickCompositeImage(img2, img, pw.OverCompositeOp, 0, 0):
|
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
left = self.cover_margin[0]
|
|
||||||
top = self.cover_margin[1]
|
|
||||||
if not pw.MagickCompositeImage(frame, img2, pw.OverCompositeOp,
|
|
||||||
left, top):
|
|
||||||
raise RuntimeError('Out of memory')
|
|
||||||
if not pw.MagickWriteImage(frame, cpath):
|
|
||||||
raise RuntimeError('Failed to save image to %s'%cpath)
|
|
||||||
pw.DestroyPixelWand(p)
|
|
||||||
for x in (img, img2, frame):
|
|
||||||
pw.DestroyMagickWand(x)
|
|
||||||
os.remove(ccpath)
|
|
||||||
|
|
||||||
if ext.lower() == 'pdf':
|
if ext.lower() == 'pdf':
|
||||||
from calibre.ebooks.metadata.pdf import get_metadata
|
from calibre.ebooks.metadata.pdf import get_metadata
|
||||||
stream = open(cpath, 'rb')
|
stream = open(cpath, 'rb')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user