Fix #1191 (Please support cutomized font-family css in "Section Menu", "Main Menu" and "Date") and improve Atlantic recipe

This commit is contained in:
Kovid Goyal 2008-10-23 17:37:03 -07:00
parent 7ef3101084
commit eff9f9b106
6 changed files with 14 additions and 7 deletions

View File

@ -19,7 +19,7 @@ class DefaultProfile(object):
class PRS505(DefaultProfile):
flow_size = 300000
flow_size = 270000
screen_size = (600, 775)
remove_special_chars = re.compile(u'[\u200b\u00ad]')

View File

@ -719,6 +719,7 @@ class Processor(Parser):
return id
self.external_stylesheets, self.stylesheet = [], self.css_parser.parseString('')
self.specified_override_css = []
for link in self.root.xpath('//link'):
if 'css' in link.get('type', 'text/css').lower():
file = os.path.join(self.tdir, *(link.get('href', '').split('/')))
@ -743,6 +744,7 @@ class Processor(Parser):
for style in self.root.xpath('//style'):
if 'css' in style.get('type', 'text/css').lower():
override_css = style.get('title', '') == 'override_css'
raw = '\n'.join(style.xpath('./text()'))
css = self.preprocess_css(raw)
try:
@ -751,7 +753,10 @@ class Processor(Parser):
self.log_debug('Failed to parse style element')
else:
for rule in sheet:
self.stylesheet.add(rule)
if override_css:
self.specified_override_css.append(rule)
else:
self.stylesheet.add(rule)
style.getparent().remove(style)
cache = {}
class_counter = 0
@ -806,6 +811,8 @@ class Processor(Parser):
if self.opts.remove_paragraph_spacing:
css += '\n\np {text-indent: 2em; margin-top:1pt; margin-bottom:1pt; padding:0pt; border:0pt;}'
self.override_css = self.css_parser.parseString(self.preprocess_css(css))
for rule in reversed(self.specified_override_css):
self.override_css.insertRule(rule, index=0)
def config(defaults=None, config_name='html',

View File

@ -11,7 +11,7 @@
<dc:contributor opf:role="bkp" py:with="attrs={'opf:files-as':__appname__}" py:attrs="attrs">${'%s (%s)'%(__appname__, __version__)} [http://${__appname__}.kovidgoyal.net]</dc:contributor>
<dc:identifier opf:scheme="${__appname__}" id="${__appname__}_id">${mi.application_id}</dc:identifier>
<dc:language>${mi.language if mi.language else 'Unknown'}</dc:language>
<dc:language>${mi.language if mi.language else 'UND'}</dc:language>
<dc:type py:if="mi.category">${mi.category}</dc:type>
<dc:description py:if="mi.comments">${mi.comments}</dc:description>
<dc:publisher py:if="mi.publisher">${mi.publisher}</dc:publisher>

View File

@ -474,7 +474,7 @@ class BasicNewsRecipe(object, LoggingInterface):
if self.extra_css is not None:
head = soup.find('head')
if head:
style = BeautifulSoup(u'<style type="text/css">%s</style>'%self.extra_css).find('style')
style = BeautifulSoup(u'<style type="text/css" title="override_css">%s</style>'%self.extra_css).find('style')
head.insert(len(head.contents), style)
if first_fetch and job_info:
url, f, a, feed_len = job_info

View File

@ -16,8 +16,8 @@ class TheAtlantic(BasicNewsRecipe):
INDEX = 'http://www.theatlantic.com/doc/current'
remove_tags_before = dict(name='div', id='storytop')
remove_tags = [dict(name='div', id='seealso')]
extra_css = '#bodytext {line-height: 1}'
remove_tags = [dict(name='div', id=['seealso', 'storybottom', 'footer'])]
no_stylesheets = True
def parse_index(self):
articles = []

View File

@ -102,7 +102,7 @@ def build_osx(shutdown=True):
def build_linux(shutdown=True):
installer = installer_name('tar.bz2')
vm = '/vmware/linux/libprs500-gentoo.vmx'
start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '), sleep=100)
start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '), sleep=120)
subprocess.check_call(('scp', 'linux:/tmp/%s'%os.path.basename(installer), 'dist'))
if not os.path.exists(installer):
raise Exception('Failed to build installer '+installer)