From 0271a9339d623b8622a510ecad95592697deb68b Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Fri, 5 Aug 2016 12:36:10 +0200 Subject: [PATCH] Use different favicon service, 60x60 icons, cleaner cards, refresh favicons admin endpoint --- digimarks.py | 25 ++++++++++++++++++++++--- static/css/digimarks.css | 11 +++++++++++ templates/bookmarks.html | 31 +++++++++++++++++-------------- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/digimarks.py b/digimarks.py index a88ebde..ea9b627 100644 --- a/digimarks.py +++ b/digimarks.py @@ -145,7 +145,8 @@ class Bookmark(db.Model): domain = u.netloc filename = os.path.join(MEDIA_ROOT, 'favicons/' + domain + '.png') # if file exists, don't re-download it - response = requests.get('http://www.google.com/s2/favicons?domain=' + domain, stream=True) + #response = requests.get('http://www.google.com/s2/favicons?domain=' + domain, stream=True) + response = requests.get('http://icons.better-idea.org/icon?size=60&url=' + domain, stream=True) with open(filename, 'wb') as out_file: shutil.copyfileobj(response.raw, out_file) del response @@ -488,8 +489,25 @@ def adduser(systemkey): abort(404) -# Initialise -# create the bookmark, user and public tag tables if they do not exist +@app.route('//refreshfavicons') +def refreshfavicons(systemkey): + """ Add user endpoint, convenience """ + if systemkey == settings.SYSTEMKEY: + bookmarks = Bookmark.select() + for bookmark in bookmarks: + if bookmark.favicon: + try: + filename = os.path.join(MEDIA_ROOT, 'favicons/' + bookmark.favicon) + os.remove(filename) + except OSError as e: + print(e) + bookmark.set_favicon() + return redirect('/') + else: + abort(404) + + +# Initialisation == create the bookmark, user and public tag tables if they do not exist Bookmark.create_table(True) User.create_table(True) PublicTag.create_table(True) @@ -500,6 +518,7 @@ for user in users: all_tags[user.key] = get_tags_for_user(user.key) print(user.key) +# Run when called standalone if __name__ == '__main__': # run the application app.run(port=9999, debug=True) diff --git a/static/css/digimarks.css b/static/css/digimarks.css index 356f6b8..3f4f229 100644 --- a/static/css/digimarks.css +++ b/static/css/digimarks.css @@ -57,3 +57,14 @@ { padding-top: 10px; } + + .card-image i + { + padding-top: 5px; + } + + .card.horizontal .card-image img.favicon + { + height: 60px; + width: 60px; + } diff --git a/templates/bookmarks.html b/templates/bookmarks.html index 3d101ae..3983ba1 100644 --- a/templates/bookmarks.html +++ b/templates/bookmarks.html @@ -68,7 +68,19 @@

{{ bookmark.created_date.strftime("%m/%d/%Y %H:%M") }}

#} -
+
+
+ {% if bookmark.favicon %} +   + {% endif %} + {% if bookmark.http_status != 200 %} + report_problem + {% endif %} + {% if bookmark.starred == True %} + star + {% endif %} +
+
{% for tag in bookmark.tags_list %} @@ -78,26 +90,17 @@ {% endfor %} more_vert -
-
- {% if bookmark.http_status != 200 %} - report_problem - {% endif %} - {% if bookmark.favicon %} -   - {% endif %} - - {% if bookmark.starred == True %} - star - {% endif %} + +
+
Added @ {{ bookmark.created_date.strftime('%Y-%m-%d %H:%M') }}close