Пример #1
0
def get_all_bookmarks(request, api):
	print "foo"
	bookmarks = list(app.db.get_bookmarks())
	bookmarks.sort()
	return render('bookmarks', api,
		tags = [],
		bookmarks = bookmarks,
	)
Пример #2
0
def process_isolated_lines():
    for line in sys.stdin:
        line = line.decode('utf-8').strip()
        sent = nlp(line)
        # print " ".join(str(token)+"/"+str(token.tag_) for token in sent)
        extracted_token = process_isolated_sent(nlp, sent)
        print "<p>\n" + frontend.render(sent,
                                        positions_to_bold=[extracted_token.i],
                                        show_icon=True) + "\n</p>\n"
Пример #3
0
def frontend_render(items):
    html_lines = []
    for item in items:
        sent = nlp(item)
        extracted_token = process_isolated_sent(nlp, sent)
        html_lines.append("<p>\n" + frontend.render(
            sent, positions_to_bold=[extracted_token.i], show_icon=True) +
                          "\n</p>\n")
    return "".join(html_lines)
Пример #4
0
def get_bookmarks(request, api, tags):
	"""
	"""
	print "bar"
	tags = list(set((x for x in tags.split('/') if x)))
	tags.sort()
	bookmarks = list(app.db.get_bookmarks(tags=tags))
	bookmarks.sort()
	return render('bookmarks', api,
		tags = tags,
		bookmarks = bookmarks,
	)
Пример #5
0
def edit_bookmark(request, api, id):
	print("----------------")
	action = request.form['action']
	
	print(request.form)
	if action == 'delete':
		print("deleting")
		app.db.delete_bookmark(id)
		print("deleted")
		return render('status', api,
			status = 'acknowledged',
			operation = 'delete',
			bookmark_id = id,
		)
Пример #6
0
def edit_bookmarks(request, api, tags):
	action = request.form['action']
	tags = set((x for x in tags.split('/') if x))
	
	if action == 'add':
		b = {
			'url': request.form['url'],
			'title': request.form['title'],
			'tags': tags,
			'quickmark': request.form.get('quickmark', ''),
		}
		app.db.update(b)
		return render('status', api,
			status = 'acknowledged',
			#force_plain = True,
			operation = 'add',
			subject = 'bookmark',
			detail_id = '',        # <- TODO
			detail_url = b['url'],
			detail_title = b['title']
		)
Пример #7
0
def get_tags(request, api, tags):
	"""
	"""
	tags = set((x for x in tags.split('/') if x))
	
	bookmarks = list(app.db.get_bookmarks(tags=tags))
	bookmarks.sort()
	
	subtags = {} # tag -> bookmark
	for bm in bookmarks:
		for t in bm['tags']:
			if t not in tags:
				subtags[t] = subtags.get(t, 0) + 1
	
	tags = list(tags)
	tags.sort()
	def iter_subtags():
		ks = list(subtags.keys())
		ks.sort()
		for tag in ks:
			count = subtags[tag]
			d = dict(
				tags = set2path(tags, tag),
				api = api
			)
			yield dict(
				name = tag,
				bookmark_count = count,
				bookmarks_url = url_for('get_bookmarks', **d),
				tags_url = url_for('get_tags', **d)
			)
	
	return render('subtags', api,
		bookmark_count = len(bookmarks),
		tags = tags,
		subtags = iter_subtags(),
	)