diff --git a/digimarks.py b/digimarks.py index 4b1133b..398c6a9 100644 --- a/digimarks.py +++ b/digimarks.py @@ -94,24 +94,41 @@ class Bookmark(db.Model): return result +def get_tags_for_user(userkey): + """ Extract all tags from the bookmarks """ + bookmarks = Bookmark.select(Bookmark.userkey==userkey) + for bookmark in bookmarks: + these_tags = bookmark.tags.split(',') + print these_tags + + @app.route('/') def index(): """ Homepage, point visitors to project page """ - return object_list('index.html', Bookmark.select()) + return render_template('index.html') @app.route('//') @app.route('/') def bookmarks(userkey): """ User homepage, list their (unfiltered) bookmarks """ - return object_list('bookmarks.html', Bookmark.select()) + #return object_list('bookmarks.html', Bookmark.select()) + #user = User.select(key=userkey) + #if user: + # bookmarks = Bookmark.select(User=user) + # return render_template('bookmarks.html', bookmarks) + #else: + # abort(404) + bookmarks = Bookmark.select(Bookmark.userkey==userkey) + return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey) + @app.route('//') def viewbookmark(urlhash): """ Bookmark detail view """ # bookmark = getbyurlhash() - return render_template('viewbookmark.html') + return render_template('viewbookmark.html', userkey=userkey) @app.route('///json') @@ -122,17 +139,17 @@ def viewbookmarkjson(urlhash): @app.route('//edit/') -def editbookmark(urlhash): +def editbookmark(userkey, urlhash): """ Bookmark edit form """ # bookmark = getbyurlhash() - return render_template('edit.html') + bookmark = Bookmark(Bookmark.url_hash==urlhash) + return render_template('edit.html', userkey=userkey) @app.route('//add') -def addbookmark(): +def addbookmark(userkey): """ Bookmark add form """ - bookmark = Bookmark() - return render_template('edit.html') + return render_template('edit.html', userkey=userkey) @app.route('//add/') @@ -153,6 +170,13 @@ def adding(userkey): abort(404) +@app.route('//tags') +def tags(userkey): + """ Overview of all tags used by user """ + tags = get_tags_for_user(userkey) + return render_template('tags.html', tags=tags, userkey=userkey) + + @app.route('//adduser') def adduser(systemkey): """ Add user endpoint, convenience """ diff --git a/templates/base.html b/templates/base.html index bfde7b3..45a6b67 100644 --- a/templates/base.html +++ b/templates/base.html @@ -19,22 +19,24 @@ - -