Skip to content

Commit

Permalink
1. Use twitter's api as proxy; 2. Handle with two same links in a twe…
Browse files Browse the repository at this point in the history
…et; 3. Remove alert when click 'Read Later'.
  • Loading branch information
ydoovv committed Oct 17, 2010
1 parent 3edd80c commit 9f7287c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions main.py
Expand Up @@ -36,7 +36,7 @@ def get(self):
else:
page = self.request.get("p")
if page == "": page = "1"
proxy = 'http://ydoovv.appspot.com/'
proxy = 'http://api.twitter.com/1/'
url = '%s/favorites/%s.json?page=%s' % (proxy, id_, page)
res = urlfetch.fetch(url)
favs = json.loads(res.content)
Expand All @@ -49,15 +49,17 @@ def get(self):
tweet = fav["text"]
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', tweet)
url = ""
replaced_urls = {}
for url in urls: # not safe, what if have same urls?
if url in replaced_urls: continue
tweet = tweet.replace(url, '<a href="%s">%s</a>' % (url, url))
replaced_urls[url] = True
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
self.render(template_values)
#self.response.out.write(template_values["tweets"])

def main():
application = webapp.WSGIApplication(
Expand Down
2 changes: 1 addition & 1 deletion templates/main.html
Expand Up @@ -221,7 +221,7 @@ <h3>Your twitter id?</h3>
<li><p>
<span>{{ tweet.content }}</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 }}');readlater(this, '{{ tweet.inlineurl }}');">Read Later</a>
<a class="bookmarklet" href="javascript:void(0);" onClick="readlater(this, '{{ tweet.inlineurl }}');">Read Later</a>
{% endfor %}
</ul>

Expand Down

0 comments on commit 9f7287c

Please sign in to comment.