|
|
@@ -9,6 +9,7 @@ from . import db
|
|
|
import string, secrets
|
|
|
import csv
|
|
|
import subprocess as sp
|
|
|
+from .iconfetch import *
|
|
|
|
|
|
logic = Blueprint('logic', __name__)
|
|
|
|
|
|
@@ -41,6 +42,7 @@ def home():
|
|
|
# owned bookmarks
|
|
|
bmarks = Bookmark.query.filter_by(owner=current_user.id).all()
|
|
|
|
|
|
+ # populate bookmark dict for show
|
|
|
bb_dic = dict() # dict of lists
|
|
|
for bg in bgroups:
|
|
|
inter_list = list()
|
|
|
@@ -49,7 +51,7 @@ def home():
|
|
|
inter_list.append(bm)
|
|
|
bb_dic[bg.group] = inter_list
|
|
|
|
|
|
- # request method
|
|
|
+ # POST request method
|
|
|
if request.method == "POST":
|
|
|
username = request.form.get('username')
|
|
|
passwd = request.form.get('password')
|
|
|
@@ -109,11 +111,11 @@ def shared():
|
|
|
|
|
|
return render_template('shared.html', user=current_user, bdic=bb_dic)
|
|
|
|
|
|
-# Account management
|
|
|
@logic.route('/create', methods=['GET', 'POST'])
|
|
|
@login_required
|
|
|
def create():
|
|
|
|
|
|
+ # load bookmark groups
|
|
|
bgroups = Groups.query.filter_by(owner=current_user.id).all()
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
@@ -124,13 +126,21 @@ def create():
|
|
|
wstatus = request.form.get('share_public_private')
|
|
|
|
|
|
if wlink and wname and wstatus:
|
|
|
+
|
|
|
+ # fetch/check icon
|
|
|
+ sitecon = check_icon(wlink)
|
|
|
+ if not sitecon:
|
|
|
+ sitecon = fetch_icon(wlink)
|
|
|
+
|
|
|
+ # add bookmark to database
|
|
|
if wgroup == 'cng-555' and ngroup != '':
|
|
|
wgroup = ngroup
|
|
|
new_link = Bookmark(owner=current_user.id,
|
|
|
status=wstatus,
|
|
|
name=wname,
|
|
|
group=wgroup,
|
|
|
- link=wlink
|
|
|
+ link=wlink,
|
|
|
+ icon=sitecon
|
|
|
)
|
|
|
group_check = Groups.query.filter_by(group=wgroup).first()
|
|
|
if not group_check:
|
|
|
@@ -142,6 +152,7 @@ def create():
|
|
|
|
|
|
return render_template('create_bookmark.html', user=current_user, bgroups=bgroups)
|
|
|
|
|
|
+# Account management
|
|
|
@logic.route('/login', methods=['GET', 'POST'])
|
|
|
def login():
|
|
|
if request.method == 'POST':
|