news4 - RSS aggrigation system
Révision | a1e1dee1d22c0a254102bfa148e50990e190df35 (tree) |
---|---|
l'heure | 2012-10-18 22:18:59 |
Auteur | hylom <hylom@hylo...> |
Commiter | hylom |
fix for public release:
@@ -4,8 +4,12 @@ a { | ||
4 | 4 | color: #1155CC; |
5 | 5 | } |
6 | 6 | |
7 | -.entry-header{} | |
8 | -.entry-body{} | |
7 | +.entry-header {} | |
8 | + | |
9 | +.entry-body { | |
10 | + margin-bottom: 1em; | |
11 | +} | |
12 | + | |
9 | 13 | .entry-continue { |
10 | 14 | margin-bottom: 1em; |
11 | 15 | } |
@@ -13,11 +17,21 @@ a { | ||
13 | 17 | color: gray; |
14 | 18 | } |
15 | 19 | |
16 | -header { | |
20 | +#site-header { | |
17 | 21 | border-bottom: 1px solid gray; |
18 | 22 | margin-bottom: 10px; |
19 | 23 | } |
20 | 24 | |
25 | +#site-footer { | |
26 | + margin-top: 10px; | |
27 | + color: gray; | |
28 | + text-align: center; | |
29 | +} | |
30 | + | |
31 | +#sitelogo { | |
32 | + margin: 2px 0; | |
33 | +} | |
34 | + | |
21 | 35 | .main-contents h3 { |
22 | 36 | font-size: 130%; |
23 | 37 | } |
@@ -53,7 +67,7 @@ header { | ||
53 | 67 | } |
54 | 68 | .sidebar li { |
55 | 69 | line-height: 10px; |
56 | - height: 20px; | |
70 | +/* height: 20px;*/ | |
57 | 71 | } |
58 | 72 | |
59 | 73 | .sidebar li a { |
@@ -8,12 +8,14 @@ import os.path | ||
8 | 8 | import urllib |
9 | 9 | |
10 | 10 | def _log(*args): |
11 | + "log helper function" | |
11 | 12 | print ' '.join(args) |
12 | 13 | |
13 | 14 | def main(): |
14 | - "TODO: argv check" | |
15 | + "gnews's main function" | |
16 | + # TODO: argv check | |
15 | 17 | |
16 | - # fetch rss feed | |
18 | + # fetch RSS feed | |
17 | 19 | entries = [] |
18 | 20 | for feed in target_rss: |
19 | 21 | f = fetcher.FeedFetcher(feed) |
@@ -31,6 +33,14 @@ def main(): | ||
31 | 33 | tags[tag]['entry'] = [entry,] |
32 | 34 | tags[tag]['quoted_name'] = urllib.quote(tag.encode('utf-8')) |
33 | 35 | |
36 | + # count stories for each tags | |
37 | + for tag in tags: | |
38 | + tags[tag]['count'] = len(tags[tag]['entry']) | |
39 | + | |
40 | + # sort tag by count | |
41 | + sorted_tags = tags.keys() | |
42 | + sorted_tags.sort(lambda x,y: cmp(tags[y]['count'], tags[x]['count'])) | |
43 | + | |
34 | 44 | # sort by date |
35 | 45 | cmp_entries = (lambda x,y: 1 if (x["date"] < y["date"]) else -1) |
36 | 46 | entries.sort(cmp_entries) |
@@ -38,8 +48,8 @@ def main(): | ||
38 | 48 | for e in entries: |
39 | 49 | print e["date"] |
40 | 50 | |
41 | - # Do rendering | |
42 | - params = {'tags':tags, 'page':{}} | |
51 | + # do rendering | |
52 | + params = {'tags':tags, 'page':{}, 'sorted_tags':sorted_tags} | |
43 | 53 | |
44 | 54 | # render index page |
45 | 55 | do_rendering('index', 'index%s.html', entries, params) |
@@ -52,18 +62,23 @@ def main(): | ||
52 | 62 | |
53 | 63 | |
54 | 64 | def do_rendering(page_type, filename, entries, params): |
65 | + "rendering page" | |
66 | + | |
55 | 67 | r = renderer.Renderer() |
56 | 68 | tmpl = config[page_type]['template'] |
57 | 69 | output_dir = config[page_type]['output_directory'] |
70 | + | |
58 | 71 | # do pagination |
59 | - punit = config['pagination_unit'] | |
60 | - total_page = 1 + (len(entries) - 1) / punit | |
72 | + pageunit = config['pagination_unit'] | |
73 | + total_page = 1 + (len(entries) - 1) / pageunit | |
61 | 74 | params['page']['total'] = total_page |
62 | 75 | params['page']['filename'] = filename |
76 | + | |
77 | + # rendering each page | |
63 | 78 | for page in range(1, total_page + 1): |
64 | 79 | params['page']['current'] = page |
65 | - start = punit * (page - 1) | |
66 | - end = punit * page | |
80 | + start = pageunit * (page - 1) | |
81 | + end = pageunit * page | |
67 | 82 | if page == 1: |
68 | 83 | output_fullpath = os.path.join(output_dir, filename % '') |
69 | 84 | else: |
@@ -75,7 +90,6 @@ def do_rendering(page_type, filename, entries, params): | ||
75 | 90 | f.write(html) |
76 | 91 | f.close() |
77 | 92 | |
78 | - | |
79 | 93 | |
80 | 94 | if __name__ == '__main__': |
81 | 95 | main() |
@@ -14,9 +14,9 @@ | ||
14 | 14 | <!-- タイトル --> |
15 | 15 | <div class="row"> |
16 | 16 | <div class="span12"> |
17 | - <header> | |
17 | + <header id="site-header"> | |
18 | 18 | <a href="${site.root}"> |
19 | - <img src="${site.img_directory}/sfjp.png"> | |
19 | + <img id="sitelogo" src="${site.img_directory}/themesjp.png" alt="Themes.JP"> α | |
20 | 20 | </a> |
21 | 21 | </header> |
22 | 22 | </div> |
@@ -30,8 +30,8 @@ | ||
30 | 30 | <div class="keywords"> |
31 | 31 | <h3>キーワード:</h3> |
32 | 32 | <ul class="nav nav-pills nav-stacked"> |
33 | - % for tag in params.tags: | |
34 | - <li><a href="${site.tag_directory}/${params.tags[tag].quoted_name}.html">${tag}</a></li> | |
33 | + % for tag in params.sorted_tags: | |
34 | + <li><a href="${site.tag_directory}/${params.tags[tag].quoted_name}.html">${tag} (${params.tags[tag].count})</a></li> | |
35 | 35 | % endfor |
36 | 36 | </ul> |
37 | 37 | </div> |
@@ -111,6 +111,15 @@ | ||
111 | 111 | |
112 | 112 | </div><!-- .row --> |
113 | 113 | |
114 | + <!-- フッタ --> | |
115 | + <div class="row"> | |
116 | + <div class="span12"> | |
117 | + <footer id="site-footer"> | |
118 | + Themes.JP, 2012. | |
119 | + </footer> | |
120 | + </div> | |
121 | + </div> | |
122 | + | |
114 | 123 | </div><!-- .container --> |
115 | 124 | </body> |
116 | 125 | </html> |