__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

'''
Fetch heise.
'''

from calibre.web.feeds.news import BasicNewsRecipe


class heiseDe(BasicNewsRecipe):
    title = 'heise'
    description = 'Computernews from Germany'
    __author__ = 'Oliver Niesner'
    use_embedded_content = False
    language = 'de'
    timefmt = ' [%d %b %Y]'
    max_articles_per_feed = 40
    no_stylesheets = True

    extra_css = '''
    .bild_links, .bild_bu_links {
        float:left;
        line-height:105%;
        margin:12px 1.4em 12px 0;
    }

    .bild_rechts, .bild_bu {
            float:right;
            line-height:105%;
            margin:12px 0 12px 1em;
            text-align:right;
    }

    .bild_zentriert {
            clear:both;
            line-height:105%;
            margin:.2em auto;
            text-align:center;
    }

    span.bild_links, span.bild_rechts, span.bild_zentriert {
            display:block;
    }
    '''

    remove_tags = [
        dict(id='navi_bottom'),
        dict(id='software_tabbox'),
        dict(id='heisetopnavi_sub_container'),
        dict(id='navi_login'),
        dict(id='heisetopnavi_search'),
        dict(id='themen_aktuell'),
        dict(id='navi_top'),
        dict(id='logo_bereich'),
        dict(name='div', attrs={'class': 'news_logo'}),
        dict(name='div', attrs={'class': 'heisetopnavi_header'}),
        dict(name='p', attrs={'class': 'teasermitbildundtext'}),
        dict(name='div', attrs={'class': 'news_foren'}),
        dict(name='p', attrs={'class': 'news_navi'}),
    ]

    remove_tags_after = [dict(name='div', attrs={'class': 'news_foren'})]

    feeds = [
        ('heise online', 'http://www.heise.de/newsticker/heise.rdf'),
        ('heise Developer', 'http://www.heise.de/developer/rss/news-atom.xml'),
        ('heise open', 'http://www.heise.de/open/news/news-atom.xml'),
    ]

    def get_article_url(self, article):
        return article.link + '&view=print'
