1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 22:05:09 +01:00

Use different favicon service, 60x60 icons, cleaner cards, refresh

favicons admin endpoint
This commit is contained in:
2016-08-05 12:36:10 +02:00
parent 8a28d841e3
commit 0271a9339d
3 changed files with 50 additions and 17 deletions

View File

@@ -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('/<systemkey>/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)

View File

@@ -57,3 +57,14 @@
{
padding-top: 10px;
}
.card-image i
{
padding-top: 5px;
}
.card.horizontal .card-image img.favicon
{
height: 60px;
width: 60px;
}

View File

@@ -68,7 +68,19 @@
<p>{{ bookmark.created_date.strftime("%m/%d/%Y %H:%M") }}</p>
</div>
#}
<div class="card tiny green darken-3">
<div class="card horizontal tiny green darken-3">
<div class="card-image">
{% if bookmark.favicon %}
<img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" class="favicon" />&nbsp;
{% endif %}
{% if bookmark.http_status != 200 %}
<i class="small material-icons red-text" title="HTTP status {{ bookmark.http_status }}">report_problem</i>
{% endif %}
{% if bookmark.starred == True %}
<i class="small material-icons yellow-text">star</i>
{% endif %}
</div>
<div class="card-stacked">
<div class="card-content white-text">
<span class="digimark-card-header activator">
{% for tag in bookmark.tags_list %}
@@ -78,26 +90,17 @@
{% endfor %}
<i class="material-icons right">more_vert</i>
</span>
<div class="valign-wrapper digimark-card-content">
<div class="valign">
{% if bookmark.http_status != 200 %}
<i class="tiny material-icons" title="HTTP status {{ bookmark.http_status }}">report_problem</i>
{% endif %}
{% if bookmark.favicon %}
<img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" />&nbsp;
{% endif %}
<a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
{% if bookmark.starred == True %}
<i class="tiny material-icons yellow-text">star</i>
{% endif %}
<div class="digimark-card-content">
<a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
{% if bookmark.title %}
{{ bookmark.title }}
{% else %}
[ no title ]
{% endif %}
</a></div>
</a>
</div>
</div>
</div>
<div class="card-reveal green darken-3">
<span class="card-title white-text valign-wrapper">Added @ {{ bookmark.created_date.strftime('%Y-%m-%d %H:%M') }}<i class="material-icons right">close</i></span>
<div class="white-text valign">