Browse files

seems no need Instapaper's token.

  • Loading branch information...
1 parent 3159a77 commit 802b8f83420baddb9410b444a9bdedafe13e955d @ydoovv ydoovv committed Oct 17, 2010
Showing with 10 additions and 16 deletions.
  1. +5 −11 main.py
  2. +5 −5 templates/main.html
View
16 main.py
@@ -27,34 +27,28 @@ def render(self, template_values):
self.response.out.write(template.render(path, template_values))
def get(self):
- cookies = Cookies(self, max_age=2678400) # one month expiration
template_values = {}
id_ = self.request.get("id")
- instapaper_cookie = "instapaper" in cookies and cookies["instapaper"] or ""
- instapaper_get = self.request.get("instapaper")
- if instapaper_cookie == "" and id_ == "":
- flashes = "First here? 'Howto' page will tell you howto fill up the fields below."
- elif id_ == "":
+ if id_ == "":
flashes = "Please tell us your twitter id."
- elif instapaper_cookie == "" and instapaper_get == "":
- flashes = "Please tell us the link location of your Instapaper's 'Read Later'."
else:
- if "instapaper" not in cookies:
- cookies["instapaper"] = instapaper_get
- template_values["instapaper"] = instapaper_cookie
page = self.request.get("p")
if page == "": page = "1"
proxy = 'http://ydoovv.appspot.com/'
url = '%s/favorites/%s.json?page=%s' % (proxy, id_, page)
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"]
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', tweet)
+ url = ""
for url in 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})
flashes = "Here is %s's favorites." % id_
template_values["next"] = "yes"
View
10 templates/main.html
@@ -4,8 +4,8 @@
{% block body %}
<script type="text/javascript">
-function _rlipb337145(url)
-{var title,d=document,l=d.location,href=url;
+function _rlipb337145(url, title)
+{var title=title,d=document,l=d.location,href=url;
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); }
@@ -113,7 +113,7 @@
s=String(e? e(): (k)? k(): (x?x.createRange().text: '')),
e=encodeURIComponent,
z=d.createElement('scr'+'ipt'),
- p='a=&k={{ instapaper }}&u=' + e(href) + '&t=' + e(title) + '&s=' + e(s.length < 10240 ? s : '');
+ p='a=&k=&u=' + e(href) + '&t=' + e(title) + '&s=' + e(s.length < 10240 ? s : '');
var b = '';
@@ -151,7 +151,7 @@
<h3>Your twitter id?</h3>
<form action="/" method="get">
<p><input id="id" type="text" name="id">
- <input id="instapaper" type="text" name="instapaper">
+<!-- <input id="instapaper" type="text" name="instapaper"> -->
<input type="submit" value="Get favs!">
</form>
</div>
@@ -161,7 +161,7 @@
{% for tweet in tweets %}
<li><p>
<span>{{ tweet.content }}</span>
- <span class="bookmarklet" onClick="alert('{{ tweet.inlineurl }}');_rlipb337145('{{ tweet.inlineurl }}');void(0)">Read Later</span>
+ <span class="bookmarklet" onClick="alert('{{ tweet.inlineurl }}');_rlipb337145('{{ tweet.inlineurl }}, {{ tweet.title }}');void(0)">Read Later</span>
{% endfor %}
</ul>

0 comments on commit 802b8f8

Please sign in to comment.