mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 23:05:10 +01:00
Use different favicon service, 60x60 icons, cleaner cards, refresh
favicons admin endpoint
This commit is contained in:
25
digimarks.py
25
digimarks.py
@@ -145,7 +145,8 @@ class Bookmark(db.Model):
|
|||||||
domain = u.netloc
|
domain = u.netloc
|
||||||
filename = os.path.join(MEDIA_ROOT, 'favicons/' + domain + '.png')
|
filename = os.path.join(MEDIA_ROOT, 'favicons/' + domain + '.png')
|
||||||
# if file exists, don't re-download it
|
# 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:
|
with open(filename, 'wb') as out_file:
|
||||||
shutil.copyfileobj(response.raw, out_file)
|
shutil.copyfileobj(response.raw, out_file)
|
||||||
del response
|
del response
|
||||||
@@ -488,8 +489,25 @@ def adduser(systemkey):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
# Initialise
|
@app.route('/<systemkey>/refreshfavicons')
|
||||||
# create the bookmark, user and public tag tables if they do not exist
|
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)
|
Bookmark.create_table(True)
|
||||||
User.create_table(True)
|
User.create_table(True)
|
||||||
PublicTag.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)
|
all_tags[user.key] = get_tags_for_user(user.key)
|
||||||
print(user.key)
|
print(user.key)
|
||||||
|
|
||||||
|
# Run when called standalone
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# run the application
|
# run the application
|
||||||
app.run(port=9999, debug=True)
|
app.run(port=9999, debug=True)
|
||||||
|
|||||||
@@ -57,3 +57,14 @@
|
|||||||
{
|
{
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-image i
|
||||||
|
{
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card.horizontal .card-image img.favicon
|
||||||
|
{
|
||||||
|
height: 60px;
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -68,7 +68,19 @@
|
|||||||
<p>{{ bookmark.created_date.strftime("%m/%d/%Y %H:%M") }}</p>
|
<p>{{ bookmark.created_date.strftime("%m/%d/%Y %H:%M") }}</p>
|
||||||
</div>
|
</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" />
|
||||||
|
{% 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">
|
<div class="card-content white-text">
|
||||||
<span class="digimark-card-header activator">
|
<span class="digimark-card-header activator">
|
||||||
{% for tag in bookmark.tags_list %}
|
{% for tag in bookmark.tags_list %}
|
||||||
@@ -78,26 +90,17 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
<i class="material-icons right">more_vert</i>
|
<i class="material-icons right">more_vert</i>
|
||||||
</span>
|
</span>
|
||||||
<div class="valign-wrapper digimark-card-content">
|
<div class="digimark-card-content">
|
||||||
<div class="valign">
|
<a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
|
||||||
{% 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) }}" />
|
|
||||||
{% endif %}
|
|
||||||
<a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
|
|
||||||
{% if bookmark.starred == True %}
|
|
||||||
<i class="tiny material-icons yellow-text">star</i>
|
|
||||||
{% endif %}
|
|
||||||
{% if bookmark.title %}
|
{% if bookmark.title %}
|
||||||
{{ bookmark.title }}
|
{{ bookmark.title }}
|
||||||
{% else %}
|
{% else %}
|
||||||
[ no title ]
|
[ no title ]
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a></div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="card-reveal green darken-3">
|
<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>
|
<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">
|
<div class="white-text valign">
|
||||||
|
|||||||
Reference in New Issue
Block a user