#!/usr/bin/env  python

__license__ = 'GPL v3'
__author__ = 'Mori'
__version__ = 'v. 0.1'
'''
www.runa.pl/blog
'''

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

class FantazmatyRecipe(BasicNewsRecipe):
	__author__ = 'Mori'
	language = 'pl'

	title = u'Fantazmaty'
	publisher = u'Agencja Wydawnicza Runa'
	description = u'Blog Agencji Wydawniczej Runa'
	
	no_stylesheets = True
	remove_javascript = True
	encoding = 'utf-8'
	
	oldest_article = 100
	max_articles_per_feed = 100
	
	extra_css = '''
		img{float: left; padding-right: 10px; padding-bottom: 5px;}
	'''
	
	feeds = [
		(u'Fantazmaty', u'http://www.runa.pl/blog/rss.xml')
	]
	
	remove_tags = [
		dict(name = 'div', attrs = {'class' : 'path'}),
		dict(name = 'div', attrs = {'class' : 'drdot'}),
		dict(name = 'div', attrs = {'class' : 'picture'})
	]
	
	remove_tags_after = [
		dict(name = 'div', attrs = {'class' : 'content'})
	]
	
	preprocess_regexps = [
		(re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) for i in 
		[
			(r'<body>.*?<div id="primary"', lambda match: '<body><div id="primary"'),
			(r'<!--.*?-->', lambda match: '')
		]
	]