Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some initial codenothing functional yet, just boilerplate

  • Loading branch information...
commit dbf8eee8d3470cd66376fe9b256b896ab04bfeab 0 parents
@fabricio2345 fabricio2345 authored
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
8 app.yaml
@@ -0,0 +1,8 @@
+application: quoteurl
+version: 1
+runtime: python
+api_version: 1
+
+handlers:
+- url: .*
+ script: main.py
11 index.yaml
@@ -0,0 +1,11 @@
+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.
102 main.py
@@ -0,0 +1,102 @@
+# QuoteURL - URL for Twitter Dialogues
+#
+# Copyright (c) 2008, Fabricio Zuardi
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of the author nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+__author__ = ('Fabricio Zuardi', 'fabricio@fabricio.org', 'http://fabricio.org')
+
+import os
+import cgi
+import wsgiref.handlers
+import urllib
+
+from google.appengine.api import users
+from google.appengine.ext import db
+from google.appengine.api import urlfetch
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp import template
+
+class Dialogue(db.Model):
+ title = db.StringProperty()
+ alias = db.StringProperty()
+ status_id_list = db.StringListProperty()
+ authors = db.StringProperty()
+ author_list = db.StringListProperty()
+ quoter = db.UserProperty()
+ quoter_ip = db.StringProperty()
+ quoter_user_agent = db.StringProperty()
+ created_date = db.DateTimeProperty(auto_now_add=True)
+ content_json = db.TextProperty()
+
+class MainPage(webapp.RequestHandler):
+ def get(self):
+ template_values = {}
+ path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
+ self.response.out.write(template.render(path, template_values))
+
+class CreateQuote(webapp.RequestHandler):
+ def post(self):
+ status_list = cgi.escape(self.request.get('statuses')).replace(',',' ').split()
+ authors_list = cgi.escape(self.request.get('authors')).replace(',',' ').split()
+ content_json = cgi.escape(self.request.get('content_json'))
+ # status_list.sort()
+ user = users.get_current_user()
+ ip = os.environ['REMOTE_ADDR']
+ ua = os.environ['HTTP_USER_AGENT']
+ content = []
+ dialogue = Dialogue()
+ dialogue.title = ', '.join(status_list)
+ dialogue.status_id_list = status_list
+ dialogue.quoter = user
+ dialogue.quoter_ip = ip
+ dialogue.quoter_user_agent = ua
+ dialogue.alias = None
+ dialogue.authors = None
+ dialogue.author_list = []
+ dialogue.content_json = content_json
+ template_values = {
+ 'dialogue' : dialogue
+ }
+ path = os.path.join(os.path.dirname(__file__), 'templates/show.html')
+ # self.response.out.write(template.render(path, template_values))
+
+class SignIn(webapp.RequestHandler):
+ def get(self):
+ user = users.get_current_user()
+ self.redirect(users.create_login_url('/'))
+
+def main():
+ application = webapp.WSGIApplication(
+ [
+ ('/', MainPage),
+ ('/a/create', CreateQuote)
+ ], debug=True)
+ wsgiref.handlers.CGIHandler().run(application)
+
+if __name__ == "__main__":
+ main()
17 templates/index.html
@@ -0,0 +1,17 @@
+<html>
+ <body>
+ <form action="a/create" method="post" onsubmit="return createQuote();">
+ <input type="hidden" name="statuses" />
+ </form>
+ <!-- <form action="/a/create" method="post">
+ <label>Tweets<input type="text" name="statues" /></label>
+ <p class="field-help">Enter a list of the status IDs you want to quote.</p>
+ <ul class="field-examples" id="examples" style="display:none;" >
+ <li>1145408853, 1145501753</li>
+ <li>1140235467-1140275762</li>
+ <li>1140729344-1140809532 marcogomes,fczuardi</li>
+ </ul>
+ <div><input type="submit" value="Quote!"></div>
+ </form> -->
+ </body>
+</html>
16 templates/show.html
@@ -0,0 +1,16 @@
+<html>
+ <body>
+ <p>
+ You submitted:
+ </p>
+ <ul>
+ <li>{{dialogue.title}}</li>
+ <li>{{dialogue.quoter}}</li>
+ <li>{{dialogue.quoter_ip}}</li>
+ <li>{{dialogue.quoter_user_agent}}</li>
+ <li>{{dialogue.content_json}}</li>
+ </ul>
+ <hr />
+
+ </body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.