Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Further work converting from pystache to jinja.

  • Loading branch information...
commit fc8b517344e59522f134df838ec2477f77c6c6d0 1 parent 2b76f92
Joshua Boyd authored
Showing with 18 additions and 39 deletions.
  1. +8 −10 rfrlus.py
  2. +10 −29 tmplt/add_dialog.html
18 rfrlus.py
View
@@ -47,16 +47,19 @@ def get(self):
url = "http://" + url
warn=True
- bid = dbAdd("", url)
+ bid = dbAdd(url)
shortcutUrl = baseUrl + str(bid)
self.response.out.write(showAltAddPage(url, shortcutUrl, warn))
-with open(os.path.join(os.path.dirname(__file__), "tmplt", "add_dialog.html"), "r") as fh:
+add_dialog_tmplt_path = os.path.join(os.path.dirname(__file__), "tmplt", "add_dialog.html")
+with open(add_dialog_tmplt_path, "r") as fh:
add_dialog_tmplt = "".join(fh.readlines())
+#add_dialog_tmplt = jinja_environment.get_template(add_dialog_tmplt_path)
+
def showAltAddPage(url, shortcutUrl, warn, err="", name=""):
aURL = short.shortenAmazonUrl(url)
eURL = short.shortenEbayUrl(url)
@@ -66,13 +69,8 @@ def showAltAddPage(url, shortcutUrl, warn, err="", name=""):
"shortcutUrl": shortcutUrl,
}
-# if
-# "name": {
-# "namedShortcut": baseUrl + "r/" + name
-# }
-
- template = jinja_environment.get_template(add_dialog_tmplt, vals)
- return template.render(vals)
+ return jinja2.Template(add_dialog_tmplt).render(vals)
+#return add_dialog_tmplt.render(vals)
class AltAdd(webapp.RequestHandler):
def POST(self):
@@ -92,7 +90,7 @@ def get(self):
#along with useragent
#u=str(uuid.uuid4())
- bid = dbAdd("", url)
+ bid = dbAdd(url)
shortcutUrl = baseUrl + str(bid)
39 tmplt/add_dialog.html
View
@@ -3,23 +3,6 @@
<head><link rel="stylesheet" type="text/css" href="css/style_iframe.css" title="default"/>
-<!--# h.addHead("""
-# <script type='text/javascript'>
-# var _gaq = _gaq || [];
-# _gaq.push(['_setAccount', 'UA-18857050-3']);
-# _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>""")
--->
-
<title>rfrl.us: Add</title>
<script src='js/name.js'></script>
<script src='js/ajax.js'></script>
@@ -28,17 +11,17 @@
<body>
<h1>rfrl.us</h1>
- {{#aURL}}
+ {% if aURL %}
<p>I noticed that the URL you are shortening is from Amazon. Perhaps would would prefer a shorter Amazon URL to use: <br/>
<a href="{{aURL}}">{{aURL}}</a></p>
- {{/aURL}}
+ {% endif %}
+
- {{#eURL}}
+ {% if eURL %}
<p>I noticed that the URL you are shortening is from eBay. Perhaps would would prefer a shorter eBay URL to use: <br/>
<a href="{{eURL}}">{{eURL}}</a>
</p>
- {{/eURL}}
-
+ {% endif %}
<p>Your shortcut is: <a href="{{shortcutUrl}}">{{shortcutUrl}}</a></p>
<h2>Mail it!</h2>
@@ -53,18 +36,16 @@
<div id="errField"></div>
- {{#name}}
+ {% if name %}
<p><a href="{{namedShortcut}}">{{namedShortcut}}</a></p>
- {{/name}}
- {{^name}}
+ {% endif %}
+ {% if not name %}
<form method="post" action="name" onsubmit="setName(); return false;" id="nameForm">
- <!--if not err=="":
- <p>{{err}}</p> -->
-<!--# h.add('<input type="hidden" name="u" value="' + u + '">\n')-->
{{baseUrl}}r/<input type="text" name="n" value="{{name}}">
<input type="submit" value="Name" />'
</form>
- {{/name}}
+ {% endif %}
+
</div>
<hr/>
Please sign in to comment.
Something went wrong with that request. Please try again.