10
10
from urllib .parse import parse_qs
11
11
12
12
from bs4 import BeautifulSoup
13
- from bottle import request , get , response
13
+ from bottle import request , response
14
14
import psycopg2
15
15
import psycopg2 .extras
16
16
@@ -74,7 +74,6 @@ def header0():
74
74
def do_tags ():
75
75
"""Show bookmarks associated with a tag."""
76
76
user_num_bmarks = 15
77
- num_bmarks_menu_offset = 53
78
77
return_data = ''
79
78
tag_id = ''
80
79
tag_get = ''
@@ -87,7 +86,6 @@ def do_tags():
87
86
username = request .get_cookie ('tasti_username' ).lower ()
88
87
if request .query .get ('mine' ) and request .query .get ('mine' ) == 'yes' :
89
88
show_mine = "AND owner='{}'" .format (username )
90
- num_bmarks_menu_offset = 60
91
89
if tag_id :
92
90
tags_sql += "WHERE id='{t}' {m} LIMIT 1" .format (t = tag_id ,
93
91
m = show_mine )
@@ -329,6 +327,7 @@ def show_bmarks():
329
327
url_get_base = 'bmarks?{u}' .format (u = request .environ .get ('QUERY_STRING' ))
330
328
bmarks_sql_base = '''SELECT distinct ON (url) url, id, date(last_update) AS last_update, notes, name, owner
331
329
FROM bmarks'''
330
+ username = '%'
332
331
if hash_check ():
333
332
username = request .get_cookie ('tasti_username' ).lower ()
334
333
if request .query .get ('whose' ) and request .query .get ('whose' ) == mine and hash_check ():
@@ -561,6 +560,7 @@ def edit_bmarks():
561
560
def edit_bmarks_process (username ):
562
561
"""process POST'd bookmark edit data."""
563
562
return_data = ''
563
+ bmark_tags_list = []
564
564
bmark_id = request .forms .get ('id' )
565
565
bmark_name = request .forms .get ('name' ).strip ()
566
566
bmark_url = request .forms .get ('url' ).strip ()
@@ -837,7 +837,6 @@ def bmark_import_file(username, bmark_file_data):
837
837
import_tag = request .forms .get ('import_tag' )
838
838
if import_tag :
839
839
use_import_tag = ['imported' ]
840
- bmark_filename = bmark_file_data .filename
841
840
# parse bookmark data into urls and names
842
841
soup = BeautifulSoup (bmark_file_data .file .read (), 'lxml' )
843
842
parsed_bmark_file_data = soup .find_all ('a' )
@@ -957,7 +956,7 @@ def show_bmarklet():
957
956
sc = request .environ .get ('SCRIPT_NAME' ))
958
957
bmarklet_url = '{}add?url=' .format (base_url )
959
958
bmarklet_string = """javascript:(function(){f='""" + bmarklet_url + """'+encodeURIComponent(window.location.href)+'&name='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text));a=function(){if(!window.open(f+'noui=1&jump=doclose','d','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"""
960
- return_data += '''<BR><span class="huge"> A bookmarklet is a link that you add to your browser's Toolbar.
959
+ return_data += '''<BR><span class="huge"> A bookmarklet is a link that you add to your browser's Toolbar.
961
960
It makes it easy to add a new bookmark to <B>Tasti</B>.</span><BR><BR>
962
961
Drag the link below to your toolbar, and then you can click that link when viewing any web
963
962
page to quickly & easily add it as a bookmark.<BR><BR><BR>
@@ -1021,7 +1020,7 @@ def account_mgmt():
1021
1020
else :
1022
1021
return_data += '<BR>Unknown function<BR><BR>'
1023
1022
else :
1024
- return_data += '''<BR>This page is only accessible to users who have
1023
+ return_data += '''<BR>This page is only accessible to users who have
1025
1024
<A HREF="login?do=0">logged in</a>.<BR><BR>'''
1026
1025
return return_data
1027
1026
@@ -1121,7 +1120,7 @@ def register():
1121
1120
return_data += register_form ()
1122
1121
return return_data
1123
1122
# success
1124
- return_data += '''Your account ( {u} ) has been successfully created.
1123
+ return_data += '''Your account ( {u} ) has been successfully created.
1125
1124
You may now login below or <A HREF="login?do=0">HERE</a>.
1126
1125
<BR><BR>''' .format (u = username )
1127
1126
return_data += login_form ()
@@ -1206,7 +1205,7 @@ def hash_check():
1206
1205
1207
1206
hash_sql = "SELECT id FROM users WHERE username='{u}' AND password='{p}'" .format (u = username , p = password_hash )
1208
1207
hash_qry = db_qry ([hash_sql , None ], 'select' )
1209
- if len (hash_qry ) and hash_qry [0 ]:
1208
+ if len (hash_qry ) > 0 and hash_qry [0 ]:
1210
1209
return hash_qry
1211
1210
1212
1211
@@ -1220,13 +1219,12 @@ def db_qry(sql_pl, operation):
1220
1219
conn = psycopg2 .connect (CONN_STRING )
1221
1220
conn .autocommit = True
1222
1221
except Exception as err :
1223
- print ('Database connection failed due to error:\t {}' . format ( err ) )
1222
+ print (f 'Database connection failed due to error:\t { err } ' )
1224
1223
return ''
1225
1224
cursor = conn .cursor (cursor_factory = psycopg2 .extras .DictCursor )
1226
1225
# invoke the SQL
1227
1226
try :
1228
1227
cursor .execute (sql , sql_vals )
1229
- row_count = cursor .rowcount
1230
1228
except Exception as err :
1231
1229
# query failed
1232
1230
print ('SQL ( {} )\t failed due to error:\t {}' .format (cursor .query , err ))
0 commit comments