]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/webapp/handlers_news.py
5 from handlers_base
import *
7 class NewsRedirectHandler(BaseHandler
):
9 This handler redirects (with a given slug) to news.ipfire.org.
11 We do not show full news items on the main page and so need a simple
12 way to redirect. Here it is.
15 self
.redirect("http://news.ipfire.org/news/%s" % slug
)
18 class NewsIndexHandler(BaseHandler
):
20 This handler fetches the content that is show on the news portal.
23 offset
= int(self
.get_argument("offset", 0))
24 limit
= int(self
.get_argument("limit", 4))
26 news
= self
.news
.get_latest(
32 return self
.render("news.html", news
=news
,
33 offset
=offset
+ limit
, limit
=limit
)
36 class NewsItemHandler(BaseHandler
):
38 This handler displays a whole page full of a single news item.
41 news
= self
.news
.get_by_slug(slug
)
43 raise tornado
.web
.HTTPError(404)
45 # Find the name of the author
46 author
= self
.get_account(news
.author_id
)
48 news
.author
= author
.cn
50 _
= self
.locale
.translate
51 news
.author
= _("Unknown author")
53 return self
.render("news-item.html", item
=news
)
56 class NewsAuthorHandler(BaseHandler
):
58 This page displays information about the news author.
60 def get(self
, author
):
61 author
= self
.get_account(author
)
63 raise tornado
.web
.HTTPError(404)
65 latest_news
= self
.news
.get_latest(author
=author
.uid
,
66 locale
=self
.locale
, limit
=3)
68 self
.render("news-author.html",
69 author
=author
, latest_news
=latest_news
)