Coverage for bookie.views.bmarks : 68%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Controllers related to viewing lists of bookmarks"""
route_name="bmark_recent", renderer="/bmark/recent.mako") route_name="bmark_recent_tags", renderer="/bmark/recent.mako") route_name="user_bmark_recent", renderer="/bmark/recent.mako") route_name="user_bmark_recent_tags", renderer="/bmark/recent.mako") def recent(request): """Testing a JS driven ui with backbone/etc"""
# Make sure we generate a url to feed our rss link.
# check for auth related stuff # are we looking for a specific user
# do we have any tags to filter upon
tags = [tags]
'username': username, 'tags': tags, 'rss_url': current_route.replace('recent', 'rss') }
# if we've got url parameters for the page/count then use those to help # feed the init of the ajax script
route_name="bmark_recent_rss", renderer="/bmark/rss.mako") route_name="bmark_recent_rss_tags", renderer="/bmark/rss.mako") route_name="user_bmark_rss", renderer="/bmark/rss.mako") route_name="user_bmark_rss_tags", renderer="/bmark/rss.mako") def recent_rss(request):
route_name="user_bmark_edit", renderer="/bmark/edit.mako") route_name="user_bmark_new", renderer="/bmark/edit.mako") def edit(request): """Manual add a bookmark to the user account
Can pass in params (say from a magic bookmarklet later) url description extended tags
"""
hash_id = rdict['hash_id'] hash_id = params['hash_id'] else:
bmark = BmarkMgr.get_by_hash(hash_id, request.user.username)
if bmark is None: return HTTPNotFound() else: # hash the url and make sure that it doesn't exist new_url_hash = generate_hash(url)
test_exists = BmarkMgr.get_by_hash(new_url_hash, request.user.username)
if test_exists: location = request.route_url( 'user_bmark_edit', hash_id=new_url_hash, username=request.user.username) return HTTPFound(location)
url=bmark.hashed.url, username=request.user.username )
'new': new, 'bmark': bmark, 'user': request.user, 'tag_suggest': tag_suggest, }
def edit_error(request):
post['url'], request.user.username, post['description'], post['extended'], post['tags'])
# Assign a task to fetch this pages content and parse it out # for storage and indexing. DBSession.flush() tasks.fetch_bmark_content.delay(bmark.bid)
# There was an issue using the supplied data to create a new # bookmark. Send the data back to the user with the error # message. post['url'], request.user.username, desc=post['description'], ext=post['extended'], tags=post['tags'])
'new': True, 'bmark': bmark, 'message': exc.message, 'user': request.user, }
else: if 'hash_id' in rdict: hash_id = rdict['hash_id'] elif 'hash_id' in params: hash_id = params['hash_id']
bmark = BmarkMgr.get_by_hash(hash_id, request.user.username) if bmark is None: return HTTPNotFound()
bmark.fromdict(post) bmark.update_tags(post['tags'])
# if this is a new bookmark from a url, offer to go back to that url # for the user. if 'go_back' in params and params['comes_from'] != "": return HTTPFound(location=params['comes_from']) else: return HTTPFound( location=request.route_url('user_bmark_recent', username=request.user.username))
route_name="bmark_readable", renderer="/bmark/readable.mako") def readable(request): """Display a readable version of this url if we can""" rdict = request.matchdict bid = rdict.get('hash_id', None) username = rdict.get('username', None)
if bid: found = BmarkMgr.get_by_hash(bid, username=username) if found: return { 'bmark': found, 'username': username, } else: return HTTPNotFound() |