mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB/MOBI Output plugins for catalog generation
This commit is contained in:
commit
0ae052cd4a
BIN
resources/catalog/DefaultCover.jpg
Normal file
BIN
resources/catalog/DefaultCover.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
resources/catalog/mastheadImage.gif
Normal file
BIN
resources/catalog/mastheadImage.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
62
resources/catalog/stylesheet.css
Normal file
62
resources/catalog/stylesheet.css
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
p.title {
|
||||||
|
margin-top:0em;
|
||||||
|
margin-bottom:1em;
|
||||||
|
text-align:center;
|
||||||
|
font-style:italic;
|
||||||
|
font-size:xx-large;
|
||||||
|
height:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.author {
|
||||||
|
margin-top:0em;
|
||||||
|
margin-bottom:0em;
|
||||||
|
text-align: left;
|
||||||
|
text-indent: 1em;
|
||||||
|
font-size:large;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.tags {
|
||||||
|
margin-top:0em;
|
||||||
|
margin-bottom:0em;
|
||||||
|
text-align: left;
|
||||||
|
text-indent: 1em;
|
||||||
|
font-size:small;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.description {
|
||||||
|
text-align:left;
|
||||||
|
font-style:italic;
|
||||||
|
margin-top: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.letter_index {
|
||||||
|
font-size:x-large;
|
||||||
|
text-align:left;
|
||||||
|
margin-top:0px;
|
||||||
|
margin-bottom:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.author_index {
|
||||||
|
font-size:large;
|
||||||
|
text-align:left;
|
||||||
|
margin-top:0px;
|
||||||
|
margin-bottom:0px;
|
||||||
|
text-indent: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.read_book {
|
||||||
|
text-align:left;
|
||||||
|
margin-top:0px;
|
||||||
|
margin-bottom:0px;
|
||||||
|
margin-left:2em;
|
||||||
|
text-indent:-2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.unread_book {
|
||||||
|
text-align:left;
|
||||||
|
margin-top:0px;
|
||||||
|
margin-bottom:0px;
|
||||||
|
margin-left:2em;
|
||||||
|
text-indent:-2em;
|
||||||
|
}
|
||||||
|
|
@ -1,34 +1,34 @@
|
|||||||
import re
|
import re
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
class EandP(BasicNewsRecipe):
|
class EandP(BasicNewsRecipe):
|
||||||
title = u'Editor and Publisher'
|
title = u'Editor and Publisher'
|
||||||
__author__ = u'Xanthan Gum'
|
__author__ = u'Xanthan Gum'
|
||||||
description = 'News about newspapers and journalism.'
|
description = 'News about newspapers and journalism.'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
|
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
|
|
||||||
# Font formatting code borrowed from kwetal
|
# Font formatting code borrowed from kwetal
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
body{font-family:verdana,arial,helvetica,geneva,sans-serif ;}
|
body{font-family:verdana,arial,helvetica,geneva,sans-serif ;}
|
||||||
h1{font-size: xx-large;}
|
h1{font-size: xx-large;}
|
||||||
h2{font-size: large;}
|
h2{font-size: large;}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Delete everything before the article
|
# Delete everything before the article
|
||||||
|
|
||||||
remove_tags_before = dict(name='font', attrs={'class':'titlebar_black'})
|
remove_tags_before = dict(name='font', attrs={'class':'titlebar_black'})
|
||||||
|
|
||||||
# Delete everything after the article
|
# Delete everything after the article
|
||||||
|
|
||||||
preprocess_regexps = [(re.compile(r'<!--endclickprintinclude-->.*</body>', re.DOTALL|re.IGNORECASE),
|
preprocess_regexps = [(re.compile(r'<!--endclickprintinclude-->.*</body>', re.DOTALL|re.IGNORECASE),
|
||||||
lambda match: '</body>'),]
|
lambda match: '</body>'),]
|
||||||
|
|
||||||
feeds = [(u'Breaking News', u'http://feeds.feedburner.com/EditorAndPublisher-BreakingNews'),
|
feeds = [(u'Breaking News', u'http://feeds.feedburner.com/EditorAndPublisher-BreakingNews'),
|
||||||
(u'Business News', u'http://feeds.feedburner.com/EditorAndPublisher-BusinessNews'),
|
(u'Business News', u'http://feeds.feedburner.com/EditorAndPublisher-BusinessNews'),
|
||||||
(u'Newsroom', u'http://feeds.feedburner.com/EditorAndPublisher-Newsroom'),
|
(u'Newsroom', u'http://feeds.feedburner.com/EditorAndPublisher-Newsroom'),
|
||||||
(u'Technology News', u'http://feeds.feedburner.com/EditorAndPublisher-Technology'),
|
(u'Technology News', u'http://feeds.feedburner.com/EditorAndPublisher-Technology'),
|
||||||
(u'Syndicates News', u'http://feeds.feedburner.com/EditorAndPublisher-Syndicates')]
|
(u'Syndicates News', u'http://feeds.feedburner.com/EditorAndPublisher-Syndicates')]
|
||||||
|
@ -421,8 +421,8 @@ from calibre.devices.binatone.driver import README
|
|||||||
from calibre.devices.hanvon.driver import N516
|
from calibre.devices.hanvon.driver import N516
|
||||||
|
|
||||||
from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon
|
from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon
|
||||||
from calibre.library.catalog import CSV_XML
|
from calibre.library.catalog import CSV_XML, EPUB_MOBI
|
||||||
plugins = [HTML2ZIP, PML2PMLZ, GoogleBooks, ISBNDB, Amazon, CSV_XML]
|
plugins = [HTML2ZIP, PML2PMLZ, GoogleBooks, ISBNDB, Amazon, CSV_XML, EPUB_MOBI]
|
||||||
plugins += [
|
plugins += [
|
||||||
ComicInput,
|
ComicInput,
|
||||||
EPUBInput,
|
EPUBInput,
|
||||||
|
56
src/calibre/gui2/catalog/catalog_epub_mobi.py
Normal file
56
src/calibre/gui2/catalog/catalog_epub_mobi.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import with_statement
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
from calibre.gui2 import gprefs
|
||||||
|
from catalog_epub_mobi_ui import Ui_Form
|
||||||
|
from calibre.ebooks.conversion.config import load_defaults
|
||||||
|
from PyQt4.Qt import QWidget
|
||||||
|
|
||||||
|
class PluginWidget(QWidget,Ui_Form):
|
||||||
|
|
||||||
|
TITLE = _('EPUB/MOBI Options')
|
||||||
|
HELP = _('Options specific to')+' EPUB/MOBI '+_('output')
|
||||||
|
OPTION_FIELDS = [('exclude_genre','\[[\w ]*\]'),
|
||||||
|
('exclude_tags','~'),
|
||||||
|
('read_tag','+'),
|
||||||
|
('note_tag','*')]
|
||||||
|
|
||||||
|
# Output synced to the connected device?
|
||||||
|
sync_enabled = True
|
||||||
|
|
||||||
|
# Formats supported by this plugin
|
||||||
|
formats = set(['epub','mobi'])
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
QWidget.__init__(self, parent)
|
||||||
|
self.setupUi(self)
|
||||||
|
|
||||||
|
def initialize(self, name):
|
||||||
|
self.name = name
|
||||||
|
# Restore options from last use here
|
||||||
|
for opt in self.OPTION_FIELDS:
|
||||||
|
opt_value = gprefs.get(self.name + '_' + opt[0], opt[1])
|
||||||
|
getattr(self, opt[0]).setText(opt_value)
|
||||||
|
|
||||||
|
def options(self):
|
||||||
|
# Save/return the current options
|
||||||
|
# getattr() returns text value of QLineEdit control
|
||||||
|
print "gui2.catalog.catalog_epub_mobi:options(): Saving options"
|
||||||
|
opts_dict = {}
|
||||||
|
for opt in self.OPTION_FIELDS:
|
||||||
|
opt_value = unicode(getattr(self, opt[0]).text())
|
||||||
|
gprefs.set(self.name + '_' + opt[0], opt_value)
|
||||||
|
if opt[0] == 'exclude_tags':
|
||||||
|
opt_value = opt_value.split(',')
|
||||||
|
opts_dict[opt[0]] = opt_value
|
||||||
|
|
||||||
|
opts_dict['output_profile'] = [load_defaults('page_setup')['output_profile']]
|
||||||
|
|
||||||
|
|
||||||
|
return opts_dict
|
96
src/calibre/gui2/catalog/catalog_epub_mobi.ui
Normal file
96
src/calibre/gui2/catalog/catalog_epub_mobi.ui
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>579</width>
|
||||||
|
<height>411</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags to exclude as genres (regex):</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::LogText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>'Don't include this book' tag:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="exclude_tags">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Tooltip comment here"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>'Mark this book as read' tag:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="read_tag">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Tooltip comment here"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Additional note tag prefix:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLineEdit" name="note_tag">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Tooltip comment here"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="exclude_genre">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Tooltip comment here"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -42,6 +42,7 @@ def gui_catalog(fmt, title, dbspec, ids, out_file_name, fmt_options,
|
|||||||
opts, args = parser.parse_args()
|
opts, args = parser.parse_args()
|
||||||
|
|
||||||
# Populate opts
|
# Populate opts
|
||||||
|
opts.catalog_title = title
|
||||||
opts.ids = ids
|
opts.ids = ids
|
||||||
opts.search_text = None
|
opts.search_text = None
|
||||||
opts.sort_by = None
|
opts.sort_by = None
|
||||||
|
@ -49,11 +49,12 @@ class Catalog(QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
name = plugin.name.lower().replace(' ', '_')
|
name = plugin.name.lower().replace(' ', '_')
|
||||||
if type(plugin) in builtin_plugins:
|
if type(plugin) in builtin_plugins:
|
||||||
#info("Adding widget for builtin Catalog plugin %s" % plugin.name)
|
info("Adding widget for builtin Catalog plugin %s" % plugin.name)
|
||||||
try:
|
try:
|
||||||
catalog_widget = __import__('calibre.gui2.catalog.'+name,
|
catalog_widget = __import__('calibre.gui2.catalog.'+name,
|
||||||
fromlist=[1])
|
fromlist=[1])
|
||||||
pw = catalog_widget.PluginWidget()
|
pw = catalog_widget.PluginWidget()
|
||||||
|
info("Initializing %s" % name)
|
||||||
pw.initialize(name)
|
pw.initialize(name)
|
||||||
pw.ICON = I('forward.svg')
|
pw.ICON = I('forward.svg')
|
||||||
self.widgets.append(pw)
|
self.widgets.append(pw)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user