Permalink
Browse files

Initial commit of public Bloog branch. Provides base RESTful app that…

… can be initialized using uploader but this commit does NOT have AJAX clients for web-based editing.
  • Loading branch information...
0 parents commit 91fbf7d481555b5d53993c3c5346c253a3cc0175 @DocSavage committed May 20, 2008
Showing with 5,469 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +33 −0 app.yaml
  3. +68 −0 authorized.py
  4. +339 −0 blog.py
  5. +64 −0 config.py
  6. +56 −0 contact.py
  7. 0 external/__init__.py
  8. 0 external/libs/__init__.py
  9. +2,873 −0 external/libs/textile.py
  10. +45 −0 index.yaml
  11. +4 −0 legacy_aliases.py
  12. +75 −0 main.py
  13. +75 −0 model.py
  14. +88 −0 restful.py
  15. BIN static/favicon.ico
  16. BIN static/images/appengine-noborder-120x30.gif
  17. BIN static/images/architecture1.png
  18. BIN static/images/architecture2.png
  19. BIN static/images/arrow_next.gif
  20. BIN static/images/arrow_nextno.gif
  21. BIN static/images/arrow_prev.gif
  22. BIN static/images/arrow_prevno.gif
  23. BIN static/images/avatar.png
  24. BIN static/images/btn_search.gif
  25. BIN static/images/btn_submit.gif
  26. BIN static/images/chat_grey.gif
  27. BIN static/images/dot.gif
  28. BIN static/images/guide/grid_focus_531.gif
  29. BIN static/images/guide/is.gif
  30. BIN static/images/lgrey_diag.gif
  31. BIN static/images/li.gif
  32. BIN static/images/li_dark.gif
  33. BIN static/images/meetup-bw.png
  34. BIN static/images/meetup.png
  35. +7 −0 static/js/toggle.js
  36. BIN static/screenshot.png
  37. +172 −0 static/style.css
  38. +31 −0 tests/test.py
  39. +122 −0 timings.py
  40. +180 −0 utilities/clear_datastore.py
  41. +389 −0 utilities/drupal_uploader.py
  42. +174 −0 view.py
  43. +12 −0 views/_shared/article_excerpt.html
  44. +44 −0 views/_shared/base.admin.html
  45. +249 −0 views/_shared/base.html
  46. +34 −0 views/_shared/bloog_intro.html
  47. +64 −0 views/blog/article.html
  48. +39 −0 views/blog/atom.xml
  49. +22 −0 views/blog/month.html
  50. +19 −0 views/blog/notfound.html
  51. +1 −0 views/blog/page.admin.html
  52. +2 −0 views/blog/page.html
  53. +1 −0 views/blog/root.html
  54. +24 −0 views/blog/search.html
  55. +23 −0 views/blog/tag.html
  56. +21 −0 views/blog/unauthorized.html
  57. +22 −0 views/blog/year.html
  58. +31 −0 views/contact/contact.get.html
  59. +10 −0 views/contact/contact.post.html
  60. +51 −0 views/timings/timing.admin.html
@@ -0,0 +1,5 @@
+*.pyc
+.DS_Store
+.project
+.pydevproject
+*~
@@ -0,0 +1,33 @@
+application: bloog
+version: 1
+runtime: python
+api_version: 1
+
+handlers:
+- url: /static
+ static_dir: static
+
+- url: /images
+ static_dir: static/images
+
+- url: /favicon\.ico
+ static_files: static/favicon.ico
+ upload: static/favicon.ico
+
+- url: .*
+ script: main.py
+
+skip_files: |
+ ^(.*/)?(
+ (app\.yaml)|
+ (app\.yml)|
+ (index\.yaml)|
+ (index\.yml)|
+ (#.*#)|
+ (.*~)|
+ (.*\.py[co])|
+ (.*/RCS/.*)|
+ (\..*)|
+ (utilities/.*)|
+ (tests/.*)|
+ )$
@@ -0,0 +1,68 @@
+# The MIT License
+#
+# Copyright (c) 2008 Publishare LLC
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+"""
+authorized.py
+
+Created by William Katz on 2008-05-04.
+Copyright (c) 2008 Publishare LLC. Distributed under MIT License.
+"""
+__author__ = 'William T. Katz'
+
+from google.appengine.api import users
+
+def role(role):
+ """A decorator to enforce user roles, currently 'user' (logged in) and 'admin'.
+
+ To use it, decorate your handler methods like this:
+
+ import authorized
+ @authorized.role("admin")
+ def get(self):
+ user = users.GetCurrentUser(self)
+ self.response.out.write('Hello, ' + user.nickname())
+
+ If this decorator is applied to a GET handler, we check if the user is logged in and
+ redirect her to the create_login_url() if not.
+
+ For HTTP verbs other than GET, we cannot do redirects to the login url because the
+ return redirects are done as GETs (not the original HTTP verb for the handler).
+ So if the user is not logged in, we return an error.
+ """
+ def wrapper(handler_method):
+ def check_login(self, *args, **kwargs):
+ user = users.get_current_user()
+ if not user:
+ if self.request.method != 'GET':
+ self.error(403)
+ else:
+ self.redirect(users.create_login_url(self.request.uri))
+ elif role == "user" or (role == "admin" and users.is_current_user_admin()):
+ handler_method(self, *args, **kwargs)
+ else:
+ if self.request.method == 'GET':
+ self.redirect("/403.html")
+ else:
+ self.error(403) # User didn't meet role. TODO: Give better feedback/status code.
+ return check_login
+ return wrapper
+
+
Oops, something went wrong.

0 comments on commit 91fbf7d

Please sign in to comment.