Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrey Sokolov
committed
Nov 29, 2011
1 parent
b277e04
commit b79334b
Showing
43 changed files
with
1,435 additions
and
1,474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
# -*- coding: UTF-8 -*- | ||
|
||
from django.contrib.syndication.views import Feed | ||
from django.core.urlresolvers import reverse | ||
from techblog.services.articles import ArticleService | ||
from django.utils.feedgenerator import Rss201rev2Feed | ||
|
||
class TextXmlFeedType(Rss201rev2Feed): | ||
mime_type = 'text/xml' | ||
|
||
class ArticlesFeed(Feed): | ||
|
||
title = u"Блог Progressors.org.ua" | ||
link = "/rss/" | ||
description = u"Новые статьи на Progressors.org.ua" | ||
feed_type = TextXmlFeedType | ||
|
||
def items(self): | ||
blog_articles = ArticleService.get_feed_articles() | ||
return blog_articles | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_link(self, item): | ||
return reverse('view_article', kwargs={'article_id':item.id}) | ||
|
||
def item_description(self, item): | ||
return item.short | ||
|
||
def item_pubdate(self, item): | ||
return item.date | ||
# -*- coding: UTF-8 -*- | ||
|
||
from django.contrib.syndication.views import Feed | ||
from django.core.urlresolvers import reverse | ||
from techblog.services.articles import ArticleService | ||
from django.utils.feedgenerator import Rss201rev2Feed | ||
|
||
class TextXmlFeedType(Rss201rev2Feed): | ||
mime_type = 'text/xml' | ||
|
||
class ArticlesFeed(Feed): | ||
|
||
title = u"Blog Progressors.org.ua" | ||
link = "/rss/" | ||
description = u"New articles on Progressors.org.ua" | ||
feed_type = TextXmlFeedType | ||
|
||
def items(self): | ||
blog_articles = ArticleService.get_feed_articles() | ||
return blog_articles | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_link(self, item): | ||
return reverse('view_article', kwargs={'article_id':item.id}) | ||
|
||
def item_description(self, item): | ||
return item.short | ||
|
||
def item_pubdate(self, item): | ||
return item.date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
#!/usr/bin/python | ||
# -*- coding: UTF-8 -*- | ||
|
||
# For code highlight | ||
import re | ||
from pygments import highlight | ||
from pygments.lexers import get_lexer_by_name | ||
from pygments.styles import get_style_by_name | ||
from pygments.formatters import HtmlFormatter | ||
|
||
def html_parser(value): | ||
value = re.sub('(?is)(<script[^>]*>.*?</script[^>]*>|<link[^>/]*/?>)', '', value).strip() # cleaning | ||
if value: | ||
formatter = HtmlFormatter(nowrap=True, lineseparator='<br/>', style=get_style_by_name('native')) | ||
def render_raw(match): | ||
lexer = get_lexer_by_name(match.groups()[0]) | ||
return '<code class="highlight">%s</code>' % highlight(match.groups()[1], lexer, formatter) | ||
value = re.sub('(?is)<code[^>]*language="(\w+)"[^>]*>(.*?)</code[^>]*>', render_raw, value) | ||
return value | ||
|
||
def int2bin(num): | ||
res = [] | ||
while num: | ||
res.append(num % 2) | ||
num = num / 2 | ||
return res | ||
|
||
def binary_date(date): | ||
res = '<div class="day-line">' | ||
for i in int2bin(date.day): | ||
res += '<span class="bit-%d"></span>' % i | ||
res += '</div><div class="month-line">' | ||
for i in int2bin(date.month): | ||
res += '<span class="bit-%d"></span>' % i | ||
res += '</div><div class="year-line">' | ||
for i in int2bin(date.year % 100): | ||
res += '<span class="bit-%d"></span>' % i | ||
res += '</div>' | ||
return res | ||
|
||
def formatted_date(date): | ||
res = u""" | ||
<span class="date-day">%d</span> | ||
<span class="date-month">%s</span> | ||
<span class="date-year">%d</span> | ||
<span class="date-time">%s</span> | ||
""" % ( | ||
date.day, | ||
[u'Янв', u'Фев', u'Мар', u'Апр', u'Май', u'Июн', u'Июл', u'Авг', u'Сен', u'Окт', u'Ноя', u'Дек'][date.month - 1], | ||
date.year, | ||
date.time().strftime('%H:%M') | ||
) | ||
return res | ||
#!/usr/bin/python | ||
# -*- coding: UTF-8 -*- | ||
|
||
# For code highlight | ||
import re | ||
from pygments import highlight | ||
from pygments.lexers import get_lexer_by_name | ||
from pygments.styles import get_style_by_name | ||
from pygments.formatters import HtmlFormatter | ||
|
||
def html_parser(value): | ||
value = re.sub('(?is)(<script[^>]*>.*?</script[^>]*>|<link[^>/]*/?>)', '', value).strip() # cleaning | ||
if value: | ||
formatter = HtmlFormatter(nowrap=True, lineseparator='<br/>', style=get_style_by_name('native')) | ||
def render_raw(match): | ||
lexer = get_lexer_by_name(match.groups()[0]) | ||
return '<code class="highlight">%s</code>' % highlight(match.groups()[1], lexer, formatter) | ||
value = re.sub('(?is)<code[^>]*language="(\w+)"[^>]*>(.*?)</code[^>]*>', render_raw, value) | ||
return value | ||
|
||
def int2bin(num): | ||
res = [] | ||
while num: | ||
res.append(num % 2) | ||
num = num / 2 | ||
return res | ||
|
||
def binary_date(date): | ||
res = '<div class="day-line">' | ||
for i in int2bin(date.day): | ||
res += '<span class="bit-%d"></span>' % i | ||
res += '</div><div class="month-line">' | ||
for i in int2bin(date.month): | ||
res += '<span class="bit-%d"></span>' % i | ||
res += '</div><div class="year-line">' | ||
for i in int2bin(date.year % 100): | ||
res += '<span class="bit-%d"></span>' % i | ||
res += '</div>' | ||
return res | ||
|
||
def formatted_date(date): | ||
res = u""" | ||
<span class="date-day">%d</span> | ||
<span class="date-month">%s</span> | ||
<span class="date-year">%d</span> | ||
<span class="date-time">%s</span> | ||
""" % ( | ||
date.day, | ||
[u'Jan', u'Feb', u'Mar', u'Apr', u'May', u'Jun', u'Jul', u'Aug', u'Sep', u'Oct', u'Nov', u'Dec'][date.month - 1], | ||
date.year, | ||
date.time().strftime('%H:%M') | ||
) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.