Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle with 'string indices must be integers' & 'Read Later' hovers b…

…ecoming a hand.
  • Loading branch information...
commit 0c2910783825b33bd6b3550a456716dd9ec0aca9 1 parent 802b8f8
@ydoovv ydoovv authored
Showing with 12 additions and 9 deletions.
  1. +7 −5 main.py
  2. +5 −4 templates/main.html
View
12 main.py
@@ -40,16 +40,18 @@ def get(self):
res = urlfetch.fetch(url)
favs = json.loads(res.content)
template_values = {"tweets": [], "id": id_, "page": int(page) + 1}
- #self.response.out.write(favs)
for fav in favs:
- tweet = fav["text"]
+ if "text" not in fav:
+ self.response.out.write("%s" % favs)
+ return
+ else:
+ tweet = fav["text"]
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', tweet)
url = ""
- for url in urls:
+ for url in urls: # not safe, what if have same urls?
tweet = tweet.replace(url, '<a href="%s">%s</a>' % (url, url))
- #dd = urlfetch.fetch('http://api.longurl.org/v2/expand?url=%s&title=1&format=json' % url)
- #meta = json.loads(dd.content)
template_values["tweets"].append({"content":"%s" % tweet, "inlineurl": "%s" % url})
+# "longurl": "%s" % longurl, "title": "%s" % title})
flashes = "Here is %s's favorites." % id_
template_values["next"] = "yes"
template_values["flashes"] = flashes
View
9 templates/main.html
@@ -4,9 +4,9 @@
{% block body %}
<script type="text/javascript">
-function _rlipb337145(url, title)
-{var title=title,d=document,l=d.location,href=url;
-d.title = title = d.title.substring(12);
+function _rlipb337145(inlineurl, inlinetitle)
+{var title=inlinetitle,d=document,l=d.location,href=inlineurl;
+//d.title = title = d.title.substring(12);
if (href == 'http://www.instapaper.com/i4' || typeof iptstbt != 'undefined') { alert("The bookmarklet is correctly installed."); throw(0); }
/* Google Reader parsing code by Pascal Laliberté */
@@ -161,7 +161,8 @@
{% for tweet in tweets %}
<li><p>
<span>{{ tweet.content }}</span>
- <span class="bookmarklet" onClick="alert('{{ tweet.inlineurl }}');_rlipb337145('{{ tweet.inlineurl }}, {{ tweet.title }}');void(0)">Read Later</span>
+ <!--<span class="bookmarklet" onClick="alert('{{ tweet.inlineurl }}');_rlipb337145('{{ tweet.inlineurl }}, {{ tweet.title }}');void(0)">Read Later</span>-->
+ <a class="bookmarklet" href="javascript:void(0);" onClick="alert('{{ tweet.inlineurl }}');_rlipb337145('{{ tweet.inlineurl }}', '{{ tweet.title }}');void(0)">Read Later</a>
{% endfor %}
</ul>
Please sign in to comment.
Something went wrong with that request. Please try again.