This repository has been archived by the owner on Sep 4, 2019. It is now read-only.
/
categoryview.py
71 lines (70 loc) · 2.96 KB
/
categoryview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from main import *
class CategoryView(TemplatePage):
cacheName = "CategoryView"
def generateSection(self,pair):
caption = pair[0]
categorylabel = pair[1]
output = []
output.append("""
<h2 id="%(category)s"> %(caption)s <a href="#"> (Back to top) </a> </h2>
<ul class="feedbox-list">
""" % {'category': categorylabel, 'caption': caption})
for feed in Feed.gql("WHERE category = :1 ORDER BY listtitle", categorylabel):
output.append("""
<li>
<div class="feedbox">
<h3> <a href="%(homepage)s">%(title)s </a> </h3>
<ul>
""" % { 'homepage': feed.homepage, 'title': feed.title })
for entry in Post.gql("WHERE service = :1 ORDER BY timestamp_created DESC LIMIT 7", feed.title):
output.append("""
<li><a href="%(link)s" title="%(title)s">%(title)s</a></li>
""" % {'link': entry.link, 'title': entry.title})
output.append("""
</ul> </div> </li>
""")
output.append("""
</ul>
""")
return "".join(output)
def generateContent(self):
s = """
<p> The categories represent what we see as roughly the primary focus of each blog -- this supplements <a href="/planettag">PlanetTAG</a>.</p>
<div class="tocbox">
<ul>
<li> <a href="#pure">Pure</a></li>
<li> <a href="#applied">Applied</a></li>
<li> <a href="#teacher">Teachers</a></li>
<li> <a href="#visual">Visualization</a></li>
<li> <a href="#history">History</a></li>
<li> <a href="#art">Art</a></li>
<li> <a href="#fun">Fun</a></li>
<li> <a href="#general">General</a></li>
<li> <a href="#journalism">Journalism</a></li>
<li> <a href="#journal">Journals</a></li>
<li> <a href="#commercial">Commercial</a></li>
<li> <a href="#community">Communities</a></li>
<li> <a href="#institution">Institutions</a></li>
<li> <a href="#news">News</a></li>
<li> <a href="#carnivals">Carnivals</a></li>
</ul>
</div>
"""
thelist = [
['Pure mathematics', 'pure'],
['Applied mathematics','applied'],
['Teachers and Educators','teacher'],
['Visualizations','visual'],
['History','history'],
['Art','art'],
['Comics, recreational mathematics and other fun','fun'],
['General scientific interest','general'],
['Journalistic Writers','journalism'],
['Journals, Publishers and similar feeds','journal'],
['Commercial blogs','commercial'],
['Communities','community'],
['Institutions','institution'],
['News','news'],
['Carnivals','carnival'],
]
return s + " ".join([self.generateSection(pair) for pair in thelist])