Permalink
Browse files

give a 'saving' hint & better getting 'title'

  • Loading branch information...
1 parent 41d4f55 commit 3edd80cfa44f5bb144b3d0b16e5b47efcdc90acd @ydoovv ydoovv committed Oct 17, 2010
Showing with 13 additions and 8 deletions.
  1. +7 −3 freejump.py
  2. +6 −5 templates/main.html
View
@@ -26,9 +26,13 @@ def get_title(self, url):
"""Get the title of the url."""
f = urlopen(url)
- res = f.read(500)
- title_raw = re.findall('<title>.*</title>', res)
- if not title_raw: return "No title found of the page..."
+ for i in range(4): # no 'title' tag in the beginning 4k of a page? WTF
+ res = f.read(1024)
+ title_raw = re.findall('<title>.*</title>', res)
+ if title_raw: break
+
+ if i == 3: return "No title found in your web page..."
+
title = title_raw[0][7:-8] # strip 'title' tag
for enc in ("utf-8", "gbk", "big5"):
try:
View
@@ -148,7 +148,7 @@
// get the origin url and title of the shortened url.
var xmlHttp;
-var obj = document.getElementById("flashes");
+var obj;// = document.getElementById("flashes");
function createXMLHttpRequest()
{
@@ -191,17 +191,18 @@
}
}
else {
- obj.textContent = "Please wait...... We are getting the original url and title of the shortened url.";
+ //obj.textContent = "Please wait...... We are getting the original url and title of the shortened url.";
+ obj.textContent = "Saving..."
}
}
-function readlater(url)
+function readlater(o, url)
{
+ obj = o;
createXMLHttpRequest();
xmlHttp.onreadystatechange = longurl_handler;
xmlHttp.open("GET", "/freejump?nojump=1&title=1&url=" + url, true);
xmlHttp.send(null);
-
}
</script>
@@ -220,7 +221,7 @@
<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('{{ tweet.inlineurl }}');">Read Later</a>
+ <a class="bookmarklet" href="javascript:void(0);" onClick="alert('{{ tweet.inlineurl }}');readlater(this, '{{ tweet.inlineurl }}');">Read Later</a>
{% endfor %}
</ul>

0 comments on commit 3edd80c

Please sign in to comment.