Ron Huang avatar Ron Huang committed 0a51f47

Added admin page.

Comments (0)

Files changed (3)

+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>Ron's Private Mirror Service</title>
+    <meta name="description" content="Mirrors the content of URLs you supply">
+    <meta name="author" content="Ron Huang">
+
+    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
+    <!--[if lt IE 9]>
+      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+    <![endif]-->
+
+    <!-- Le styles -->
+    <link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
+    <link rel="stylesheet" href="static/base.css" type="text/css">
+
+    <!-- Le fav and touch icons -->
+    <link rel="shortcut icon" href="/favicon.ico">
+
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-7044154-11']);
+      _gaq.push(['_trackPageview']);
+
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
+  </head>
+
+  <body>
+
+    <div class="topbar">
+      <div class="fill">
+        <div class="container">
+          <a class="brand" href="/">Mirror</a>
+          <ul class="nav">
+            <li><a href="/">Home</a></li>
+            <li class="active"><a href="/admin">Admin</a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+
+    <div class="container">
+
+      <div class="content">
+        <div class="page-header">
+          <h1>Home <small>Mirrors the content of URLs you supply</small></h1>
+        </div>
+        <div class="row">
+          <div class="span9">
+            <h2>Add Users</h2>
+            <form action="" method="post" accept-charset="utf-8">
+              <fieldset>
+                <div class="clearfix">
+                  <label for="username">Username</label>
+                  <div class="input">
+                    <input class="xlarge" id="username" name="username" size="30" type="text" placeholder="Type username here...">
+                  </div>
+                </div>
+                <div class="clearfix">
+                  <label for="role">Role</label>
+                  <div class="input">
+                    <select name="role" id="role">
+                      <option>user</option>
+                      <option>admin</option>
+                    </select>
+                  </div>
+                </div>
+                <div class="actions">
+                  <input type="submit" class="btn" value="Add">
+                </div>
+              </fieldset>
+            </form>
+          </div>
+          <div class="span5">
+            <h3>Actions</h3>
+            <div>
+              <a class="btn" href="/dump">Dump</a>
+              <a class="btn" href="/cleanup">Cleanup</a>
+              <a class="btn" href="/kaboom">Kaboom</a>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <footer>
+        <p>&copy; Ron Huang 2011</p>
+      </footer>
+
+    </div> <!-- /container -->
+
+  </body>
+</html>
   login: admin
   script: mirror.py
 
+- url: /dump
+  login: admin
+  script: mirror.py
+
 - url: /cleanup
   login: admin
   script: mirror.py
     self.response.out.write(template.render("main.html", context))
 
 
+class AdminHandler(BaseHandler):
+  def get(self):
+    # Do this dictionary construction here, to decouple presentation from
+    # how we store data.
+    context = {
+    }
+    self.response.out.write(template.render("admin.html", context))
+
+  def post(self):
+    username = self.request.get("username")
+    role = self.request.get("role")
+    if not username or not role:
+      return self.redirect("/admin")
+
+    # check if exist
+    
+
+    return self.redirect("/admin")
+
+
 class MirrorHandler(BaseHandler):
   def get(self, base_url):
     assert base_url
     self.response.out.write(content.data)
 
 
-class AdminHandler(webapp.RequestHandler):
+class DumpHandler(webapp.RequestHandler):
   def get(self):
     self.response.headers['content-type'] = 'text/plain'
     self.response.out.write(str(memcache.get_stats()))
   (r"/main", HomeHandler),
   (r"/kaboom", KaboomHandler),
   (r"/admin", AdminHandler),
+  (r"/dump", DumpHandler),
   (r"/cleanup", CleanupHandler),
   (r"/([^/]+).*", MirrorHandler)
 ], debug=DEBUG)
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.