From 2adf3392b5875d5fd0e573333d9415630679795e Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Wed, 20 Jul 2016 22:22:19 +0200 Subject: [PATCH] Show tags --- digimarks.py | 15 +++++++++------ static/css/digimarks.css | 8 ++++++++ templates/bookmarks.html | 5 +++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/digimarks.py b/digimarks.py index 7c85dc3..e8915da 100644 --- a/digimarks.py +++ b/digimarks.py @@ -131,17 +131,20 @@ class Bookmark(db.Model): def set_tags(self, tags): """ Set tags from `tags`, strip and sort them """ tags_split = tags.split(',') - print tags_split - #map(str.strip, tags_split) tags_split = [x.strip() for x in tags_split] tags_split = list(unique_everseen(tags_split)) tags_split.sort() - print tags_split + if tags_split[0] == '': + del tags_split[0] self.tags = ','.join(tags_split) - print self.tags - def get_tags(self): - return self.tags.split(',') + @property + def tags_list(self): + """ Get the tags as a list, iterable in template """ + if self.tags: + return self.tags.split(',') + else: + return [] def to_dict(self): diff --git a/static/css/digimarks.css b/static/css/digimarks.css index 097b5a1..f1af572 100644 --- a/static/css/digimarks.css +++ b/static/css/digimarks.css @@ -1,4 +1,12 @@ +.tag +{ + color: #1b5e20; /* green darken-4 */ + background-color: #c8e6c9; /* green lighten-3 */ + padding: 2px; + border-radius: 5px; +} + /* label color */ .input-field label { color: #000; diff --git a/templates/bookmarks.html b/templates/bookmarks.html index 44b5fa9..891cc5a 100644 --- a/templates/bookmarks.html +++ b/templates/bookmarks.html @@ -24,6 +24,10 @@ {% if bookmark.favicon %}     {% endif %} + {% for tag in bookmark.tags_list %} + {{ tag }} + {% endfor %} +

{% if bookmark.starred == True %} star {% endif %} @@ -32,6 +36,7 @@ {% else %} [ no title ] {% endif %} +