__license__   = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
'''
evz.ro
'''

import re
from calibre.web.feeds.news import BasicNewsRecipe

class EVZ_Ro(BasicNewsRecipe):
    title                 = 'evz.ro'
    __author__            = 'Darko Miletic'
    description           = 'News from Romania'
    publisher             = 'evz.ro'
    category              = 'news, politics, Romania'
    oldest_article        = 2
    max_articles_per_feed = 200
    no_stylesheets        = True
    encoding              = 'utf8'
    use_embedded_content  = False
    language              = 'ro'
    masthead_url          = 'http://www.evz.ro/fileadmin/images/logo.gif'
    extra_css             = ' body{font-family: Georgia,Arial,Helvetica,sans-serif } .firstP{font-size: 1.125em} .author,.articleInfo{font-size: small} '

    conversion_options = {
                          'comment'   : description
                        , 'tags'      : category
                        , 'publisher' : publisher
                        , 'language'  : language
                        }

    preprocess_regexps = [
         (re.compile(r'<head>.*?<title>', re.DOTALL|re.IGNORECASE),lambda match: '<head><title>')
        ,(re.compile(r'</title>.*?</head>', re.DOTALL|re.IGNORECASE),lambda match: '</title></head>')
    ]

    remove_tags       = [
                          dict(name=['form','embed','iframe','object','base','link','script','noscript'])
                         ,dict(attrs={'class':['section','statsInfo','email il']})
                         ,dict(attrs={'id'   :'gallery'})
                        ]

    remove_tags_after = dict(attrs={'class':'section'})
    keep_only_tags    = [dict(attrs={'class':'single'})]
    remove_attributes = ['height','width']

    feeds = [(u'Articles', u'http://www.evz.ro/rss.xml')]

    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        return soup
