Skip to content

Commit

Permalink
bookmarklet
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Jones committed Dec 25, 2010
1 parent 23781d3 commit d0b1514
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions psutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def save_bookmark(db, user_id, bookmark):
c.execute('insert or replace into bookmark (bookmark_id, user_id, feed_id, title, created, stale) values (?, ?, ?, ?, ?, ?)',
(bookmark["bookmark_id"], user_id, bookmark["feed_id"], bookmark["title"], int(time.time()), False))
bookmark["bookmark_id"] = c.lastrowid
db.commit()

db.execute("delete from tag where bookmark_id = ?", [ bookmark["bookmark_id"] ])
for tag in bookmark['tags']:
Expand Down
23 changes: 13 additions & 10 deletions pysoso.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import psutil
import werkzeug
import urlparse
import sys
import os
import re
Expand All @@ -38,13 +39,8 @@
DEBUG = True
SECRET_KEY = 'development key'

# create our little application :)
app = Flask(__name__)
app.config.from_object(__name__)
# app.url_map.converters['default'] = werkzeug.routing.PathConverter
# app.url_map.converters['string'] = werkzeug.routing.PathConverter
# app.url_map.converters['any'] = werkzeug.routing.PathConverter


def connect_db():
"""Returns a new connection to the database."""
Expand Down Expand Up @@ -193,13 +189,20 @@ def bookmark_lookup():
if 'user_id' not in session:
abort(401)

if request.method == "GET":
if not request.values.has_key('url') or not request.values['url']:
print "rendered"
return render_template('bookmark/add.html')

url = request.form['url']

if not url:
return render_template('bookmark/add.html')
url = request.values['url']
url_bits = urlparse.urlparse(url)
url_host = url_bits[1].lstrip("www.")

flask_base = url_for("home", _external = True)
flask_base_bits = urlparse.urlparse(flask_base)
flask_base_host = flask_base_bits[1].lstrip("www.")

if (url_host == flask_base_host):
return render_template('bookmark/add.html', error = "Sorry, I can't add myself as a feed.")

url = psutil.url_sanify(url)

Expand Down
2 changes: 2 additions & 0 deletions templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ <h2>About</h2>
rather than presenting you with the most recent content from the sites that you follow, it simply lets you know
when they have been updated. you can then read the content of these sites as it is intended: on the site itself.
</p>
<p>
<a href="javascript:location.href='http://www.ideoforms.com/pysoso/bookmark/lookup/?url='+encodeURIComponent(window.location.href)">bookmark</a>
</div>

{% endblock %}

0 comments on commit d0b1514

Please sign in to comment.