• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

news4 - RSS aggrigation system


Commit MetaInfo

Révisiona1e1dee1d22c0a254102bfa148e50990e190df35 (tree)
l'heure2012-10-18 22:18:59
Auteurhylom <hylom@hylo...>
Commiterhylom

Message de Log

fix for public release:

  • update site logo
  • add story counter to keyword list
  • sort keyword list by counter
  • add footer
  • fix some designs

Change Summary

Modification

--- a/css/gnews.css
+++ b/css/gnews.css
@@ -4,8 +4,12 @@ a {
44 color: #1155CC;
55 }
66
7-.entry-header{}
8-.entry-body{}
7+.entry-header {}
8+
9+.entry-body {
10+ margin-bottom: 1em;
11+}
12+
913 .entry-continue {
1014 margin-bottom: 1em;
1115 }
@@ -13,11 +17,21 @@ a {
1317 color: gray;
1418 }
1519
16-header {
20+#site-header {
1721 border-bottom: 1px solid gray;
1822 margin-bottom: 10px;
1923 }
2024
25+#site-footer {
26+ margin-top: 10px;
27+ color: gray;
28+ text-align: center;
29+}
30+
31+#sitelogo {
32+ margin: 2px 0;
33+}
34+
2135 .main-contents h3 {
2236 font-size: 130%;
2337 }
@@ -53,7 +67,7 @@ header {
5367 }
5468 .sidebar li {
5569 line-height: 10px;
56- height: 20px;
70+/* height: 20px;*/
5771 }
5872
5973 .sidebar li a {
--- a/gnews.py
+++ b/gnews.py
@@ -8,12 +8,14 @@ import os.path
88 import urllib
99
1010 def _log(*args):
11+ "log helper function"
1112 print ' '.join(args)
1213
1314 def main():
14- "TODO: argv check"
15+ "gnews's main function"
16+ # TODO: argv check
1517
16- # fetch rss feed
18+ # fetch RSS feed
1719 entries = []
1820 for feed in target_rss:
1921 f = fetcher.FeedFetcher(feed)
@@ -31,6 +33,14 @@ def main():
3133 tags[tag]['entry'] = [entry,]
3234 tags[tag]['quoted_name'] = urllib.quote(tag.encode('utf-8'))
3335
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+
3444 # sort by date
3545 cmp_entries = (lambda x,y: 1 if (x["date"] < y["date"]) else -1)
3646 entries.sort(cmp_entries)
@@ -38,8 +48,8 @@ def main():
3848 for e in entries:
3949 print e["date"]
4050
41- # Do rendering
42- params = {'tags':tags, 'page':{}}
51+ # do rendering
52+ params = {'tags':tags, 'page':{}, 'sorted_tags':sorted_tags}
4353
4454 # render index page
4555 do_rendering('index', 'index%s.html', entries, params)
@@ -52,18 +62,23 @@ def main():
5262
5363
5464 def do_rendering(page_type, filename, entries, params):
65+ "rendering page"
66+
5567 r = renderer.Renderer()
5668 tmpl = config[page_type]['template']
5769 output_dir = config[page_type]['output_directory']
70+
5871 # 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
6174 params['page']['total'] = total_page
6275 params['page']['filename'] = filename
76+
77+ # rendering each page
6378 for page in range(1, total_page + 1):
6479 params['page']['current'] = page
65- start = punit * (page - 1)
66- end = punit * page
80+ start = pageunit * (page - 1)
81+ end = pageunit * page
6782 if page == 1:
6883 output_fullpath = os.path.join(output_dir, filename % '')
6984 else:
@@ -75,7 +90,6 @@ def do_rendering(page_type, filename, entries, params):
7590 f.write(html)
7691 f.close()
7792
78-
7993
8094 if __name__ == '__main__':
8195 main()
Binary files /dev/null and b/img/themesjp.png differ
--- a/templates/index.tmpl.html
+++ b/templates/index.tmpl.html
@@ -14,9 +14,9 @@
1414 <!-- タイトル -->
1515 <div class="row">
1616 <div class="span12">
17- <header>
17+ <header id="site-header">
1818 <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"> α
2020 </a>
2121 </header>
2222 </div>
@@ -30,8 +30,8 @@
3030 <div class="keywords">
3131 <h3>キーワード:</h3>
3232 <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>
3535 % endfor
3636 </ul>
3737 </div>
@@ -111,6 +111,15 @@
111111
112112 </div><!-- .row -->
113113
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+
114123 </div><!-- .container -->
115124 </body>
116125 </html>