public
Description: minimalist blog app using Google App Engine
Homepage: http://teh.appspot.com
Clone URL: git://github.com/btbytes/teh.git
disqus enabled commenting works; configuration works
btbytes (author)
Wed Apr 30 21:32:14 -0700 2008
commit  d428f76f0ad8e6d85320fc35239383ff9ff266e0
tree    17ceb54f9297ea472a235158d8bc8bdf5d1c0512
parent  e638a455ff4e6a854dbedfff8d75a0bdbcb58dc9
...
10
11
12
13
14
15
16
17
18
 
19
...
10
11
12
 
 
 
 
 
 
13
14
0
@@ -10,9 +10,4 @@ handlers:
0
   script: webapp.py
0
 - url: /new
0
   script: webapp.py
0
- login: admin
0
-- url: /shooin
0
- script: shooin.py
0
- login: admin
0
-
0
-
0
+ login: admin
0
\ No newline at end of file
...
15
16
17
18
 
19
20
21
...
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
...
15
16
17
 
18
19
20
21
...
35
36
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
39
40
0
@@ -15,7 +15,7 @@ from google.appengine.api import users
0
 import functools
0
 import os
0
 from lib import utils, markdown2, BeautifulSoup
0
-from requesthandler import TehRequestHandler
0
+from utils import TehRequestHandler, administrator
0
 import shooin
0
 
0
 class Entry(db.Model):
0
@@ -35,20 +35,6 @@ class Entry(db.Model):
0
         if self.static == False: return '/entry/'+self.slug
0
         else: return '/'+self.slug
0
     
0
-def administrator(method):
0
- @functools.wraps(method)
0
- def wrapper(self, *args, **kwargs):
0
- user = users.get_current_user()
0
- if not user:
0
- if self.request.method == "GET":
0
- self.redirect(users.create_login_url(self.request.uri))
0
- return
0
- if not users.is_current_user_admin():
0
- raise webapp.Error(403)
0
- else:
0
- return method(self, *args, **kwargs)
0
- return wrapper
0
-
0
 class EntryIndexHandler(TehRequestHandler):
0
     def get(self):
0
         entries = Entry.all().filter("static =", False)
...
16
17
18
19
 
20
21
22
...
16
17
18
 
19
20
21
22
0
@@ -16,7 +16,7 @@ from google.appengine.api import users
0
 from google.appengine.api import urlfetch
0
 import os
0
 from lib import utils, markdown2, BeautifulSoup
0
-from requesthandler import TehRequestHandler
0
+from utils import TehRequestHandler
0
 from blog import Entry
0
 from lib import demjson
0
 from StringIO import StringIO
...
56
57
58
 
 
 
 
 
 
59
60
61
...
98
99
100
101
 
 
 
 
102
103
104
...
56
57
58
59
60
61
62
63
64
65
66
67
...
104
105
106
 
107
108
109
110
111
112
113
0
@@ -56,6 +56,12 @@ form {
0
   top: 15px;
0
 }
0
 
0
+#logo a span{
0
+ font-size:1.5em;
0
+ color:#fff;
0
+ text-decoration:none;
0
+}
0
+
0
 #feed {
0
   position: absolute;
0
   top: 12px;
0
@@ -98,7 +104,10 @@ form {
0
 }
0
 
0
 .full .entry h1 a,
0
-.full .entry h1 a:visited {
0
+.full .entry h1 a:visited,
0
+.full .entry h2 a,
0
+.full .entry h2 a:visited,
0
+ {
0
   text-decoration: none;
0
   color: #222222;
0
 }
...
2
3
4
5
 
6
7
 
8
9
10
...
17
18
19
20
 
 
 
 
21
22
23
...
53
54
55
 
 
 
56
57
58
...
2
3
4
 
5
6
 
7
8
9
10
...
17
18
19
 
20
21
22
23
24
25
26
...
56
57
58
59
60
61
62
63
64
0
@@ -2,9 +2,9 @@
0
 <html xmlns="http://www.w3.org/1999/xhtml">
0
 <head>
0
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
0
-<title>
0
+<title>{{config.title}} |
0
   {% block title %}
0
- TEH - minimalist blog tool powered by Google App Engine
0
+ minimalist blog tool powered by Google App Engine
0
   {% endblock %}
0
 </title>
0
 {% block css %}
0
@@ -17,7 +17,10 @@
0
 <body>
0
 <div id="header">
0
   <div id="logo">
0
- <a href="/"><img src="/static/images/logo.png" alt="Teh blog"/></a>
0
+ <a href="/">
0
+ <!-- img src="/static/images/logo.png" alt="Teh blog"/ -->
0
+ <span>{{config.title}}</span>
0
+ </a>
0
   </div><!-- logo -->
0
   <div id="feed"><a href="http://teh.appspot.com/feed">
0
     <img src="/static/images/feed.png" alt="Subscribe to this blog"/></a>
0
@@ -53,6 +56,9 @@
0
 
0
 <div id="footer">
0
   &copy;2008 Teh blog - <a href="/about">About Teh</a> - <a href="http://creativecommons.org/licenses/by/2.5/">Creative Commons License</a>
0
+ {% block extrafooter %}
0
+
0
+ {% endblock %}
0
 </div>
0
 <!--
0
   Layout for Teh blog app - http://teh.appspot.com
...
7
8
9
 
 
 
 
 
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
...
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
0
@@ -7,6 +7,31 @@
0
     <div class="body">
0
       {{entry.body_html}}
0
     </div><!-- body -->
0
+ {% if config.disqus %}
0
+ <div class="entrycomment">
0
+ <a href="{{entry.url}}#disqus_thread">Comments</a>
0
+ </div><!-- entrycomment -->
0
+ {% endif %}
0
     </div><!-- entry -->
0
 {% endfor %}
0
+{% endblock %}
0
+
0
+{% block extrafooter %}
0
+{% if config.disqus %}
0
+ <script type="text/javascript">
0
+ //<![CDATA[
0
+ (function() {
0
+ var links = document.getElementsByTagName('a');
0
+ var query = '?';
0
+ for (var i = 0; i < links.length; i++) {
0
+ if (links[i].href.indexOf('#disqus_thread') >= 0) {
0
+ query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
0
+ }
0
+ }
0
+ document.write('<script type="text/javascript" src="http://disqus.com/forums/{{config.disqus}}/get_num_replies.js' + query + '"></' + 'script>');
0
+ })();
0
+ //]]>
0
+ </script>
0
+
0
+ {% endif %}
0
 {% endblock %}
0
\ No newline at end of file
...
1
 
 
 
2
3
4
...
11
12
13
 
14
15
16
17
18
19
 
 
 
 
 
 
20
21
...
1
2
3
4
5
6
7
...
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -1,4 +1,7 @@
0
 {% extends "base.html" %}
0
+{% block title %}
0
+{{entry.title}}
0
+{% endblock %}
0
 {% block content %}
0
 <div class="entry">
0
 <h1><a href="{{entry.url}}">{{entry.title}}</a></h1>
0
@@ -11,10 +14,17 @@
0
   {% endfor %}
0
 </div><!-- tags -->
0
 </div><!-- body -->
0
+<div id="disqus_thread"></div>
0
 <div id="controls">
0
   {% if users.is_current_user_admin %}
0
   <a href="{{entry.url}}/edit">edit</a> | <a href="{{entry.url}}/del">delete</a>
0
   {% endif %}
0
 </div><!-- controls -->
0
 </div><!-- entry -->
0
+{% endblock %}
0
+
0
+{% block extrafooter %}
0
+ {% if config.disqus %}
0
+ <script type="text/javascript" src="http://disqus.com/forums/{{config.disqus}}/embed.js"></script>
0
+ {% endif %}
0
 {% endblock %}
0
\ No newline at end of file
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-{% extends "base.html" %}
0
+{% extends "formbase.html" %}
0
 {% block title %}  
0
   Data importer
0
 {% endblock %}
...
12
13
14
15
 
16
17
18
 
19
20
21
...
42
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
49
50
51
 
 
52
53
54
...
59
60
61
62
63
64
 
 
 
 
 
 
 
 
65
66
67
...
12
13
14
 
15
16
17
 
18
19
20
21
...
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
...
72
73
74
 
75
76
77
78
79
80
81
82
83
84
85
86
87
0
@@ -12,10 +12,10 @@ from google.appengine.ext import webapp
0
 from google.appengine.ext import db
0
 from google.appengine.ext.webapp import template
0
 from google.appengine.api import users
0
-import functools
0
+
0
 import os
0
 from lib import utils, markdown2, BeautifulSoup
0
-from requesthandler import TehRequestHandler
0
+from utils import TehRequestHandler, administrator, Config
0
 import shooin
0
 import blog
0
 
0
@@ -42,13 +42,26 @@ class HomePageHandler(TehRequestHandler):
0
         entries.order('-published').fetch(limit=5)
0
         self.render("templates/home.html", entries=entries)
0
 
0
-
0
+class ConfigHandler(TehRequestHandler):
0
+ @administrator
0
+ def get(self):
0
+ self.render("templates/config.html")
0
+ @administrator
0
+ def post(self):
0
+ config = Config.all()
0
+ config = config.fetch(1)[0]
0
+ config.title = self.request.get("title")
0
+ config.disqus = self.request.get("disqus")
0
+ config.put()
0
+ self.redirect('/')
0
+
0
 def main():
0
     application = webapp.WSGIApplication([
0
         (r"/", HomePageHandler),
0
         (r"/login", LoginHandler),
0
         (r"/logout", LogoutHandler),
0
-
0
+ (r"/config", ConfigHandler),
0
+
0
         (r"/entries", blog.EntryIndexHandler),
0
         (r"/feed", blog.FeedHandler),
0
         (r"/entry/([^/]+)", blog.EntryHandler),
0
@@ -59,9 +72,16 @@ def main():
0
         (r"/new", blog.NewEntryHandler),
0
         (r"/topic/([^/]+)", blog.TagHandler),
0
         (r"/shooin/([^/]+)", shooin.ShooinHandler),
0
-
0
         (r"/([^/]+)", blog.PageHandler),
0
         ], debug=True)
0
+
0
+ config = Config.all()
0
+ if config.count() > 0:
0
+ config = config.fetch(1)[0]
0
+ else:
0
+ config1 = Config(title="TEH Blog")
0
+ config1.put()
0
+
0
     wsgiref.handlers.CGIHandler().run(application)
0
 
0
 if __name__ == "__main__":

Comments

    No one has commented yet.