From bd4462cfb7c6d5ff3e6d04e0099cdc818b278354 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 29 Jun 2011 16:07:20 -0600 Subject: [PATCH] Athens News by DM. Fixes #803663 (New recipe for Greek newspaper in English - Athens News) --- recipes/athens_news.recipe | 70 ++++++++++++++++++++++++++++++ recipes/icons/athens_news.png | Bin 0 -> 514 bytes src/calibre/db/tables.py | 19 ++++++++ src/calibre/utils/localization.py | 1 + 4 files changed, 90 insertions(+) create mode 100644 recipes/athens_news.recipe create mode 100644 recipes/icons/athens_news.png diff --git a/recipes/athens_news.recipe b/recipes/athens_news.recipe new file mode 100644 index 0000000000..6667faaf0c --- /dev/null +++ b/recipes/athens_news.recipe @@ -0,0 +1,70 @@ +__license__ = 'GPL v3' +__copyright__ = '2011, Darko Miletic ' +''' +www.athensnews.gr +''' + +from calibre.web.feeds.news import BasicNewsRecipe + +class AthensNews(BasicNewsRecipe): + title = 'Athens News' + __author__ = 'Darko Miletic' + description = 'Greece in English since 1952' + publisher = 'NEP Publishing Company SA' + category = 'news, politics, Greece, Athens' + oldest_article = 1 + max_articles_per_feed = 200 + no_stylesheets = True + encoding = 'utf8' + use_embedded_content = False + language = 'en_GR' + remove_empty_feeds = True + publication_type = 'newspaper' + masthead_url = 'http://www.athensnews.gr/sites/athensnews/themes/athensnewsv3/images/logo.jpg' + extra_css = """ + body{font-family: Arial,Helvetica,sans-serif } + img{margin-bottom: 0.4em; display:block} + .big{font-size: xx-large; font-family: Georgia,serif} + .articlepubdate{font-size: small; color: gray; font-family: Georgia,serif} + .lezanta{font-size: x-small; font-weight: bold; text-align: left; margin-bottom: 1em; display: block} + """ + + conversion_options = { + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language + , 'linearize_tables' : True + } + + remove_tags = [ + dict(name=['meta','link']) + ] + keep_only_tags=[ + dict(name='span',attrs={'class':'big'}) + ,dict(name='td', attrs={'class':['articlepubdate','text']}) + ] + remove_attributes=['lang'] + + + feeds = [ + (u'News' , u'http://www.athensnews.gr/category/1/feed' ) + ,(u'Politics' , u'http://www.athensnews.gr/category/8/feed' ) + ,(u'Business' , u'http://www.athensnews.gr/category/2/feed' ) + ,(u'Economy' , u'http://www.athensnews.gr/category/11/feed') + ,(u'Community' , u'http://www.athensnews.gr/category/5/feed' ) + ,(u'Arts' , u'http://www.athensnews.gr/category/3/feed' ) + ,(u'Living in Athens', u'http://www.athensnews.gr/category/7/feed' ) + ,(u'Sports' , u'http://www.athensnews.gr/category/4/feed' ) + ,(u'Travel' , u'http://www.athensnews.gr/category/6/feed' ) + ,(u'Letters' , u'http://www.athensnews.gr/category/44/feed') + ,(u'Media' , u'http://www.athensnews.gr/multimedia/feed' ) + ] + + def print_version(self, url): + return url + '?action=print' + + def preprocess_html(self, soup): + for item in soup.findAll(style=True): + del item['style'] + return soup diff --git a/recipes/icons/athens_news.png b/recipes/icons/athens_news.png new file mode 100644 index 0000000000000000000000000000000000000000..499a11dbe24f8c806fe4bee918a01d9a2d875b13 GIT binary patch literal 514 zcmV+d0{#7oP)f#j5ZzrP%$Mzgi4V{oIB=*B70SKJk54a&gmNJy2jnQKFdXa}Yz+8gcl*e;4lsw+ zv-iE3H#19xEGW?kp;Ain5df4@0Ck>+AO$=B1~rPJIF99IoO3P&NNJkpa=GN3&*$?X z2mr2Rw6atcK?Q)_Zr5x!arSz>R;#7bNm5=5gb>H$vC(KCx29<-MUo_CS=zP@0aMkg zibYX`VF&=WqI%xjVzKCUyZ?KTB+D}866wK)6JX!>@9%$wLG=FqdpsUj6Qi7GQIvoL z8~gp<^E}seaj{yhEz5#?v}BqFEY)f?rb)_0P9*dF)n>C%P7K4W*Xy&{%(A}R-cHm2 z*6a0XG@=j)kxQwaCLkp)0A5~R<2V5iz9*9(j4@Qk3=G4N6iuJ)0nMao>bl?W?ta>K z4<_LRjVaB=;*cQEbNq#4OomYg9{xiBZ`dGas`_Ttn|Xf5YX1OtIvoz9d5MMSdc$#? z;c$qKub+ml>tPVK+nu5)r_-mwVBk167&ZNf&*y_p6M5Rv;c$3-mn(nvTEiU1qe{W|47sN_U-(C=1djJ3c07*qoM6N<$ Ef+Otj6#xJL literal 0 HcmV?d00001 diff --git a/src/calibre/db/tables.py b/src/calibre/db/tables.py index 735d2f69a0..edca43528a 100644 --- a/src/calibre/db/tables.py +++ b/src/calibre/db/tables.py @@ -48,6 +48,12 @@ class Table(object): class OneToOneTable(Table): + ''' + Represents data that is unique per book (it may not actually be unique) but + each item is assigned to a book in a one-to-one mapping. For example: uuid, + timestamp, size, etc. + ''' + def read(self, db): self.book_col_map = {} idcol = 'id' if self.metadata['table'] == 'books' else 'book' @@ -66,6 +72,13 @@ class SizeTable(OneToOneTable): class ManyToOneTable(Table): + ''' + Represents data where one data item can map to many books, for example: + series or publisher. + + Each book however has only one value for data of this type. + ''' + def read(self, db): self.id_map = {} self.extra_map = {} @@ -91,6 +104,12 @@ class ManyToOneTable(Table): class ManyToManyTable(ManyToOneTable): + ''' + Represents data that has a many-to-many mapping with books. i.e. each book + can have more than one value and each value can be mapped to more than one + book. For example: tags or authors. + ''' + def read_maps(self, db): for row in db.conn.execute( 'SELECT book, {0} FROM books_{1}_link'.format( diff --git a/src/calibre/utils/localization.py b/src/calibre/utils/localization.py index f14858c3b6..cdb20b4d6e 100644 --- a/src/calibre/utils/localization.py +++ b/src/calibre/utils/localization.py @@ -109,6 +109,7 @@ _extra_lang_codes = { 'en_AU' : _('English (Australia)'), 'en_NZ' : _('English (New Zealand)'), 'en_CA' : _('English (Canada)'), + 'en_GR' : _('English (Greece)'), 'en_IN' : _('English (India)'), 'en_TH' : _('English (Thailand)'), 'en_CY' : _('English (Cyprus)'),