Permalink
Browse files

Adding Technorati ping.

  • Loading branch information...
1 parent 1c3808d commit 173147cfd7f8c72b9a3bddd736ee8f810b2075d5 @bmc committed Aug 23, 2008
Showing with 940 additions and 5 deletions.
  1. +3 −0 .gitignore
  2. +18 −5 admin.py
  3. +18 −0 defs.py
  4. +24 −0 index.yaml
  5. +748 −0 picoblog.wpr
  6. +129 −0 technorati.py
View
@@ -0,0 +1,3 @@
+# Ignore files that match these wildcards
+
+*.pyc
View
@@ -6,6 +6,7 @@
"""
import cgi
+import logging
from google.appengine.api import users
from google.appengine.ext import webapp
@@ -67,6 +68,7 @@ def post(self):
article = Article.get(id) if id else None
if article:
# It's an edit of an existing item.
+ just_published = article.draft and (not draft)
article.title = title
article.body = body
article.tags = tags
@@ -77,13 +79,19 @@ def post(self):
body=body,
tags=tags,
draft=draft)
+ just_published = not draft
article.save()
+ if just_published:
+ logging.debug('Article %d just went from draft to published. '
+ 'Alerting the media.' % article.id)
+ alert_the_media()
+
edit_again = cgi.escape(self.request.get('edit_again'))
edit_again = edit_again and (edit_again.lower() == 'true')
if edit_again:
- self.redirect('/admin/article/edit/?id=%s' % id)
+ self.redirect('/admin/article/edit/?id=%s' % article.id)
else:
self.redirect('/admin/')
@@ -118,6 +126,15 @@ def get(self):
# Functions
# -----------------------------------------------------------------------------
+def alert_the_media():
+ # Right now, we only alert Technorati
+ import technorati
+ technorati.ping_technorati()
+
+# -----------------------------------------------------------------------------
+# Main program
+# -----------------------------------------------------------------------------
+
application = webapp.WSGIApplication(
[('/admin/?', ShowArticlesHandler),
('/admin/article/new/?', NewArticleHandler),
@@ -128,10 +145,6 @@ def get(self):
debug=True)
-# -----------------------------------------------------------------------------
-# Main program
-# -----------------------------------------------------------------------------
-
def main():
util.run_wsgi_app(application)
View
18 defs.py
@@ -2,7 +2,18 @@
#
# Constants used by this application
+# -----------------------------------------------------------------------------
+# Imports
+# -----------------------------------------------------------------------------
+
+import os
+
+# -----------------------------------------------------------------------------
+# Constants
+# -----------------------------------------------------------------------------
+
BLOG_NAME = 'PicoBlog'
+CANONICAL_BLOG_URL = 'http://picoblog.appspot.com/'
BLOG_OWNER = 'Joe Example'
TEMPLATE_SUBDIR = 'templates'
@@ -17,3 +28,10 @@
MAX_ARTICLES_PER_PAGE = 5
TOTAL_RECENT = 10
+
+_server_software = os.environ.get('SERVER_SOFTWARE','').lower()
+if _server_software.startswith('goog'):
+ ON_GAE = True
+else:
+ ON_GAE = False
+del _server_software
View
@@ -0,0 +1,24 @@
+indexes:
+
+# AUTOGENERATED
+
+# This index.yaml is automatically updated whenever the dev_appserver
+# detects that a new type of query is run. If you want to manage the
+# index.yaml file manually, remove the above marker line (the line
+# saying "# AUTOGENERATED"). If you want to manage some indexes
+# manually, move them above the marker line. The index.yaml file is
+# automatically uploaded to the admin console when you next deploy
+# your application using appcfg.py.
+
+# Used 6 times in query history.
+- kind: Article
+ properties:
+ - name: draft
+ - name: published_when
+ direction: desc
+
+# Used 2 times in query history.
+- kind: Article
+ properties:
+ - name: published_when
+ direction: desc
Oops, something went wrong.

0 comments on commit 173147c

Please sign in to comment.