Anonymous avatar Anonymous committed 585a62d

improved admin access

Comments (0)

Files changed (6)

handlers/about.py

             'title': 'About',
             'content': 
                 '''
-                Hi. My name is Adam Bernier.<br /><br />
-                
-                This site contains my opinions; <br />
+                Disclaimer: This site contains my opinions; <br />
                 not those of my employer.<br /><br />
                 
+                You can find some of my hobby projects on 
+                <a href="http://bitbucket.org/abernier/">BitBucket</a>.<br /><br />
+                
+                And here is <a href="http://careers.stackoverflow.com/abernier">a very short version of my CV</a>.<br /><br />
+                
                 I hope you enjoy your stay here.<br />
-                Thanks for stopping by. <img alt="oh, hai!" src="/static/img/s.gif" /><br /><br />
+                Thanks for stopping by. <img src="/static/img/s.gif" /><br /><br />
                 
                 <script src="http://stackoverflow.com/users/flair/42346.js?theme=clean" type="text/javascript"></script>
                 '''
 admin_email: adam.c.bernier@gmail.com
 
 [settings]
-page_size: 10
+page_size: 5

templates/admin.html

 
 <br />
 <form action="/admin/edit" method="get">
+    <div>
+      <input type="submit" name="submit" value="Edit" />
+    </div>
     {% for blog_post in results %}
         <div>
             <input type="radio" name="blog_key" value={{ blog_post.key }} />
     {% endfor %}
     <br />
     <div>
-        <input type="submit" name="submit" value="Edit" />
+      <input type="submit" name="submit" value="Edit" />
     </div>
 </form>
 <br />

templates/base.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-    <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-        <title>
-            {%block title%}{%endblock%} | in-beta.appspot.com
-        </title>
-        <link rel="stylesheet" href="/static/css/style.css" type="text/css" />
-        <link rel="alternate" type="application/rss+xml" title="RSS" href="http://in-beta.appspot.com/feed" />
-    </head>
-    <body>
-        <div id="wrapper">
-            <h3>
-                <a href="/">in-beta.appspot.com</a>
-                <a class="no_u" href="http://in-beta.appspot.com/feed"><img alt="RSS feed" src="/static/img/feed-icon-14x14.png" /></a>
-            </h3>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="google-site-verification" content="yhfAoe96VINVrXBshKVfO64V0yHQXolZVTOca3LS8gk" />
+    <title>
+        {%block title%}{%endblock%} | in-beta.appspot.com
+    </title>
+    <link rel="stylesheet" href="/static/css/style.css" type="text/css" />
+    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://in-beta.appspot.com/feed" />
+  </head>
+  <body>
+    <div id="wrapper">
+      <h3>
+        <a href="/">in-beta.appspot.com</a>
+        <a class="no_u" href="http://in-beta.appspot.com/feed"><img alt="RSS feed" src="/static/img/feed-icon-14x14.png" /></a>
+      </h3>
+        
+      <div id="content">{% block content %}{% endblock %}</div>
+
+      <div id="nav">
+        <p class="loud"><a href="/about">about</a></p>
+
+        {% if tag_list %}
+          <strong>tags:</strong>
+          <div>
+            {% for tag in tag_list %}
+              <div>
+                <span class="small quiet">({{ tag.count }})</span>
+                <a href="{{ tag.url }}">{{ tag.tag }}</a>
+              </div>
+            {% endfor %}
+          </div>
+        {% endif %}
+
+        <p class="small">{{ greeting }}</p>
+
+        {% if is_admin %}
+          <p class="loud">
+            <a href="/admin">admin</a>
+          </p>
+          <p class="loud">
+            <a href="/admin/create">create</a>
+          </p>
+        {% endif %}
             
-            <div id="content">
-                {% block content %}{% endblock %}
-            </div>
+        <br />
+            
+        <p>
+          <a class="no_u" href="http://code.google.com/appengine/"><img src="/static/img/appengine-silver-120x30.gif" alt="Powered by Google App Engine" /></a>
+          <a class="no_u" href="http://validator.w3.org/check?uri=referer"><img src="/static/img/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
+        </p>
+      </div>
+    </div>
 
-            <div id="nav">
-                <p class="loud">
-                    <a href="/about">about</a>
-                </p>
-
-                {% if is_admin %}
-                    <p class="loud">
-                        <a href="/admin">admin</a>
-                    </p>
-                    <p class="loud">
-                        <a href="/admin/create">create</a>
-                    </p>
-                {% endif %}
-
-                {% if tag_list %}
-                    <strong>tags:</strong>
-                    <div>
-                        {% for tag in tag_list %}
-                            <div>
-                                <span class="small quiet">({{ tag.count }})</span>
-                                <a href="{{ tag.url }}">{{ tag.tag }}</a>
-                            </div>
-                        {% endfor %}
-                    </div>
-                {% endif %}
-                
-                <br />
-                
-                <p>
-                    <a class="no_u" href="http://code.google.com/appengine/"><img src="/static/img/appengine-silver-120x30.gif" alt="Powered by Google App Engine" /></a>
-                    <a class="no_u" href="http://validator.w3.org/check?uri=referer"><img src="/static/img/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
-                </p>
-            </div>
-        </div>
 <script type="text/javascript">
 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
 var pageTracker = _gat._getTracker("UA-16291963-1");
 pageTracker._trackPageview();
 } catch(err) {}</script>
-    </body>
+
+  </body>
 </html>
 

templates/edit.html

 {% block content %}
 
 <div class="content">
-    <form action="/admin/edit" method="post">
-        <div>
-            Title:
-        </div>
-        <div>
-            <input name="title" type="text" value="{{ blog_post.title }}" />
-        </div>
-        <div>
-            Content <span class="small quiet">(Markdown ok)</span>:
-        </div>
-        <div>
-            <textarea name="content" rows="25" cols="70">{{ blog_post.content }}</textarea>
-        </div>
-        <div>
-            Tags:
-        </div>
-            <input name="tags" type="text" value="{{ tag_str }}" />
-        </div>
-        <br />
-        <div>
-            <input type="submit" name="submit" value="Update" />
-        </div>
-        <input type="hidden" name="blog_key" value="{{ blog_post.key }}" />
+  <form action="/admin/edit" method="post">
+    <div>Title:</div>
+    <div>
+      <input name="title" type="text" value="{{ blog_post.title }}" />
+    </div>
+    <div>
+      Content <span class="small quiet">(Markdown ok)</span>:
+    </div>
+    <div>
+<textarea name="content" rows="25" cols="70">{{ blog_post.content }}</textarea>
+    </div>
+    <div>Tags:</div>
+    <div>
+      <input name="tags" type="text" value="{{ tag_str }}" />
+    </div>
+    <br />
+    <div>
+      <input type="submit" name="submit" value="Update" />
+    </div>
+      <input type="hidden" name="blog_key" value="{{ blog_post.key }}" />
     </form>
 </div>
 
             template_filename: template path (relative to this file)
             template_args: argument dict for the template
         '''
+        user = users.get_current_user()
+        if user:
+            greeting = ("<a href=\"%s\">logout</a>" %
+                        users.create_logout_url("/"))
+        else:
+            greeting = ("<a href=\"%s\">login</a>" %
+                        users.create_login_url("/"))
+        
         tag_list = get_tag_list()
         
         template_args['current_uri'] = self.request.uri
         template_args['tag_list'] = tag_list
-        template_args['user'] = users.get_current_user()
+        template_args['user'] = user
         template_args['is_admin'] = users.is_current_user_admin()
+        template_args['greeting'] = greeting
         
         self.response.out.write(
             template.render(self.template_path(template_filename), 
 
     def render_paginated(self, query, template_filename, template_args):
         ''' Rodrigo Moraes' paginated query.
+        
             PagerQuery wraps db.Query / has same methods (w00t!).
             
             Example:
             template_filename: template path (relative to this file)
             template_args: argument dict for the template
         '''
-        
         bookmark = self.request.get('bookmark')
 
         prev, results, next = query.fetch(self.page_size, bookmark)
         template_args['results'] = results
         template_args['next_page'] = next
         
-        # calls method above; passing some additional keyword args
+        # passing some additional keyword args
         self.render(self.template_path(template_filename), template_args)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.