mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix class level network access in a few recipes
This commit is contained in:
parent
9bdd47c6af
commit
c64c8fe69e
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class AttacEspanaRecipe (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -17,7 +16,14 @@ class AttacEspanaRecipe (BasicNewsRecipe):
|
||||
oldest_article = 7
|
||||
remove_empty_feeds = True
|
||||
no_stylesheets = True
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
cover_url = u'http://www.attac.es/wp-content/themes/attacweb/images/attaces.jpg'
|
||||
|
||||
feeds = [
|
||||
|
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class GrandesCorresponsalesRecipe (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -16,7 +15,13 @@ class GrandesCorresponsalesRecipe (BasicNewsRecipe):
|
||||
oldest_article = 30
|
||||
remove_empty_feeds = True
|
||||
no_stylesheets = True
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'Rafael Poch', u'http://blogs.lavanguardia.com/berlin/feed'),
|
||||
|
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class HistoriasDelMundo (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -18,7 +17,13 @@ class HistoriasDelMundo (BasicNewsRecipe):
|
||||
remove_empty_feeds = True
|
||||
no_stylesheets = True
|
||||
cover_url = u'http://www.marcbusque.org/wp-content/uploads/2011/12/cuchitril.png'
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'Historias del Mundo', u'http://www.marcbusque.org/?feed=rss'),
|
||||
|
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class HistoriesDelMon (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -18,7 +17,13 @@ class HistoriesDelMon (BasicNewsRecipe):
|
||||
remove_empty_feeds = True
|
||||
no_stylesheets = True
|
||||
cover_url = u'http://www.marcbusque.org/wp-content/uploads/2011/12/cuchitril.png'
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'Històries del Món', u'http://www.marcbusque.org/ca/feed/'),
|
||||
|
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class LaVanguardiaCorresponsalesRecipe (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -17,7 +16,13 @@ class LaVanguardiaCorresponsalesRecipe (BasicNewsRecipe):
|
||||
oldest_article = 30
|
||||
remove_empty_feeds = True
|
||||
no_stylesheets = True
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'Marc Bassets - Diario de Washington', u'http://blogs.lavanguardia.com/washington/feed'),
|
||||
|
@ -2,7 +2,6 @@
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import re
|
||||
import urllib
|
||||
|
||||
class AListApart (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -18,7 +17,13 @@ class AListApart (BasicNewsRecipe):
|
||||
remove_empty_feeds = True
|
||||
encoding = 'utf8'
|
||||
cover_url = u'http://alistapart.com/pix/alalogo.gif'
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'A List Apart', u'http://feeds.feedburner.com/alistapart/abridged'),
|
||||
|
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class PeriodismoHumanoRecipe (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -16,7 +15,13 @@ class PeriodismoHumanoRecipe (BasicNewsRecipe):
|
||||
language = u'es'
|
||||
tags = u'información, contrainformación, información alternativa'
|
||||
remove_empty_feeds = True
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'Periodismo Humano', u'http://periodismohumano.com/feed'),
|
||||
|
@ -1,7 +1,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import unicode_literals
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
import urllib
|
||||
|
||||
class SmashingMagazine (BasicNewsRecipe):
|
||||
__author__ = 'Marc Busqué <marc@lamarciana.com>'
|
||||
@ -19,7 +18,13 @@ class SmashingMagazine (BasicNewsRecipe):
|
||||
encoding = 'utf8'
|
||||
cover_url = u'http://media.smashingmagazine.com/themes/smashingv4/images/logo.png'
|
||||
remove_attributes = ['border', 'cellspacing', 'align', 'cellpadding', 'colspan', 'valign', 'vspace', 'hspace', 'alt', 'width', 'height', 'style']
|
||||
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
|
||||
def get_extra_css(self):
|
||||
if not self.extra_css:
|
||||
br = self.get_browser()
|
||||
self.extra_css = br.open_novisit(
|
||||
'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '')
|
||||
return self.extra_css
|
||||
|
||||
feeds = [
|
||||
(u'Smashing Magazine', u'http://rss1.smashingmagazine.com/feed/'),
|
||||
|
@ -162,6 +162,8 @@ class BasicNewsRecipe(Recipe):
|
||||
#: It will be inserted into `<style>` tags, just before the closing
|
||||
#: `</head>` tag thereby overriding all :term:`CSS` except that which is
|
||||
#: declared using the style attribute on individual :term:`HTML` tags.
|
||||
#: Note that if you want to programmatically generate the extra_css override
|
||||
#: the :meth:`get_extra_css()` method instead.
|
||||
#: For example::
|
||||
#:
|
||||
#: extra_css = '.heading { font: serif x-large }'
|
||||
@ -400,6 +402,13 @@ class BasicNewsRecipe(Recipe):
|
||||
'''
|
||||
raise NotImplementedError
|
||||
|
||||
def get_extra_css(self):
|
||||
'''
|
||||
By default returns `self.extra_css`. Override if you want to programmatically generate the
|
||||
extra_css.
|
||||
'''
|
||||
return self.extra_css
|
||||
|
||||
def get_cover_url(self):
|
||||
'''
|
||||
Return a :term:`URL` to the cover image for this issue or `None`.
|
||||
@ -932,7 +941,7 @@ class BasicNewsRecipe(Recipe):
|
||||
if not head:
|
||||
head = soup.find(True)
|
||||
style = BeautifulSoup(u'<style type="text/css" title="override_css">%s</style>'%(
|
||||
self.template_css +'\n\n'+(self.extra_css if self.extra_css else ''))).find('style')
|
||||
self.template_css +'\n\n'+(self.get_extra_css() or ''))).find('style')
|
||||
head.insert(len(head.contents), style)
|
||||
if first_fetch and job_info:
|
||||
url, f, a, feed_len = job_info
|
||||
@ -942,7 +951,7 @@ class BasicNewsRecipe(Recipe):
|
||||
not self.has_single_feed,
|
||||
url, __appname__,
|
||||
center=self.center_navbar,
|
||||
extra_css=self.extra_css)
|
||||
extra_css=self.get_extra_css() or '')
|
||||
elem = BeautifulSoup(templ.render(doctype='xhtml').decode('utf-8')).find('div')
|
||||
body.insert(0, elem)
|
||||
if self.remove_javascript:
|
||||
@ -1021,7 +1030,7 @@ class BasicNewsRecipe(Recipe):
|
||||
templ = (templates.TouchscreenIndexTemplate if self.touchscreen else
|
||||
templates.IndexTemplate)
|
||||
templ = templ(lang=self.lang_for_html)
|
||||
css = self.template_css + '\n\n' +(self.extra_css if self.extra_css else '')
|
||||
css = self.template_css + '\n\n' +(self.get_extra_css() or '')
|
||||
timefmt = self.timefmt
|
||||
return templ.generate(self.title, "mastheadImage.jpg", timefmt, feeds,
|
||||
extra_css=css).render(doctype='xhtml')
|
||||
@ -1076,7 +1085,7 @@ class BasicNewsRecipe(Recipe):
|
||||
templ = (templates.TouchscreenFeedTemplate if self.touchscreen else
|
||||
templates.FeedTemplate)
|
||||
templ = templ(lang=self.lang_for_html)
|
||||
css = self.template_css + '\n\n' +(self.extra_css if self.extra_css else '')
|
||||
css = self.template_css + '\n\n' +(self.get_extra_css() or '')
|
||||
|
||||
return templ.generate(f, feeds, self.description_limiter,
|
||||
extra_css=css).render(doctype='xhtml')
|
||||
|
Loading…
x
Reference in New Issue
Block a user