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

Show tags

This commit is contained in:
2016-07-20 22:22:19 +02:00
parent 12bfa2352b
commit 2adf3392b5
3 changed files with 22 additions and 6 deletions

View File

@@ -131,17 +131,20 @@ class Bookmark(db.Model):
def set_tags(self, tags): def set_tags(self, tags):
""" Set tags from `tags`, strip and sort them """ """ Set tags from `tags`, strip and sort them """
tags_split = tags.split(',') tags_split = tags.split(',')
print tags_split
#map(str.strip, tags_split)
tags_split = [x.strip() for x in tags_split] tags_split = [x.strip() for x in tags_split]
tags_split = list(unique_everseen(tags_split)) tags_split = list(unique_everseen(tags_split))
tags_split.sort() tags_split.sort()
print tags_split if tags_split[0] == '':
del tags_split[0]
self.tags = ','.join(tags_split) self.tags = ','.join(tags_split)
print self.tags
def get_tags(self): @property
return self.tags.split(',') 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): def to_dict(self):

View File

@@ -1,4 +1,12 @@
.tag
{
color: #1b5e20; /* green darken-4 */
background-color: #c8e6c9; /* green lighten-3 */
padding: 2px;
border-radius: 5px;
}
/* label color */ /* label color */
.input-field label { .input-field label {
color: #000; color: #000;

View File

@@ -24,6 +24,10 @@
{% if bookmark.favicon %} {% if bookmark.favicon %}
<img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" />&nbsp;&nbsp;&nbsp; <img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" />&nbsp;&nbsp;&nbsp;
{% endif %} {% endif %}
{% for tag in bookmark.tags_list %}
<span class="tag">{{ tag }}</span>
{% endfor %}
<p>
{% if bookmark.starred == True %} {% if bookmark.starred == True %}
<i class="material-icons">star</i> <i class="material-icons">star</i>
{% endif %} {% endif %}
@@ -32,6 +36,7 @@
{% else %} {% else %}
[ no title ] [ no title ]
{% endif %} {% endif %}
</p>
</a> </a>
</div> </div>
<div class="card-reveal green darken-3"> <div class="card-reveal green darken-3">