]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blame - www/webapp/handlers_news.py
Add job that updates the file database from the main mirror.
[people/shoehn/ipfire.org.git] / www / webapp / handlers_news.py
CommitLineData
940227cb
MT
1#!/usr/bin/python
2
3import tornado.web
4
5from handlers_base import *
6
940227cb 7class NewsIndexHandler(BaseHandler):
de683d7c
MT
8 rss_url = "/news.rss"
9
940227cb
MT
10 """
11 This handler fetches the content that is show on the news portal.
12 """
13 def get(self):
14 offset = int(self.get_argument("offset", 0))
15 limit = int(self.get_argument("limit", 4))
16
17 news = self.news.get_latest(
18 locale=self.locale,
19 limit=limit,
20 offset=offset,
21 )
22
23 return self.render("news.html", news=news,
24 offset=offset + limit, limit=limit)
25
26
27class NewsItemHandler(BaseHandler):
de683d7c
MT
28 rss_url = "/news.rss"
29
940227cb
MT
30 """
31 This handler displays a whole page full of a single news item.
32 """
33 def get(self, slug):
34 news = self.news.get_by_slug(slug)
35 if not news:
36 raise tornado.web.HTTPError(404)
37
38 # Find the name of the author
39 author = self.get_account(news.author_id)
40 if author:
41 news.author = author.cn
42 else:
43 _ = self.locale.translate
44 news.author = _("Unknown author")
45
46 return self.render("news-item.html", item=news)
47
48
49class NewsAuthorHandler(BaseHandler):
50 """
51 This page displays information about the news author.
52 """
53 def get(self, author):
54 author = self.get_account(author)
55 if not author:
56 raise tornado.web.HTTPError(404)
57
58 latest_news = self.news.get_latest(author=author.uid,
de683d7c 59 locale=self.locale, limit=10)
940227cb
MT
60
61 self.render("news-author.html",
62 author=author, latest_news=latest_news)