From 044f507aa291e05c65fce79e2df12bc7bf0975e9 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 15 Apr 2017 09:01:49 +0200 Subject: [PATCH 1/9] Started with theming support --- digimarks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/digimarks.py b/digimarks.py index 6482743..da46880 100644 --- a/digimarks.py +++ b/digimarks.py @@ -103,6 +103,7 @@ class User(db.Model): """ User account """ username = CharField() key = CharField() + theme = CharField() created_date = DateTimeField(default=datetime.datetime.now) def generate_key(self): @@ -670,6 +671,7 @@ users = User.select() print('Current user keys:') for user in users: all_tags[user.key] = get_tags_for_user(user.key) + all_themes[user.key] = get_tags_for_user(user.key) print(user.key) # Run when called standalone From d5d71b4f515ca0003d52c3506376021a19876855 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Fri, 28 Apr 2017 16:33:42 +0200 Subject: [PATCH 2/9] Cache User settings --- digimarks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/digimarks.py b/digimarks.py index da46880..a57c30b 100644 --- a/digimarks.py +++ b/digimarks.py @@ -45,6 +45,7 @@ except AttributeError: # Cache the tags all_tags = {} +settings = {} def ifilterfalse(predicate, iterable): @@ -671,7 +672,7 @@ users = User.select() print('Current user keys:') for user in users: all_tags[user.key] = get_tags_for_user(user.key) - all_themes[user.key] = get_tags_for_user(user.key) + settings[user.key] = {'theme': user.theme} print(user.key) # Run when called standalone From 590095659e6fd9d2af3e28d109160644b58713c5 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 15 Jun 2017 08:41:01 +0200 Subject: [PATCH 3/9] 20170519: default to 'green' --- digimarks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digimarks.py b/digimarks.py index a57c30b..8dce350 100644 --- a/digimarks.py +++ b/digimarks.py @@ -104,7 +104,7 @@ class User(db.Model): """ User account """ username = CharField() key = CharField() - theme = CharField() + theme = CharField(default='green') created_date = DateTimeField(default=datetime.datetime.now) def generate_key(self): From b5569786404fdb1671c83a7cabc7e5c5f5bc8314 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 22 Jul 2017 19:39:52 +0200 Subject: [PATCH 4/9] Updated MaterializeCSS --- templates/base.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/base.html b/templates/base.html index 88d8516..79fa28d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -17,7 +17,7 @@ - + @@ -56,7 +56,7 @@ - + From 652e3a89af913698b0efdcac7b659e5ec209f89d Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 22 Jul 2017 21:11:09 +0200 Subject: [PATCH 5/9] Theme support, with default 'green' --- CHANGELOG.md | 1 + digimarks.py | 48 ++++++++++++++++++++++++++++++++++------ templates/base.html | 6 ++--- templates/bookmarks.html | 28 +++++++++++------------ templates/edit.html | 8 +++---- 5 files changed, 63 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e099a2..ed1b227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Show 404 page if bookmark is not found when editing - Cache buster to force loading of the latest styling +- Theming support, default is 'green' ### Changed - Make running in a virtualenv optional diff --git a/digimarks.py b/digimarks.py index 8dce350..09993ac 100644 --- a/digimarks.py +++ b/digimarks.py @@ -15,6 +15,25 @@ from flask_peewee.db import Database #from flask_peewee.utils import get_object_or_404 from peewee import * # noqa +themes = { + 'green': { + 'BODY': 'grey lighten-4', + 'NAV': 'green darken-3', + 'PAGEHEADER': 'grey-text lighten-5', + 'MESSAGE_BACKGROUND': 'orange lighten-2', + 'MESSAGE_TEXT': 'white-text', + 'ERRORMESSAGE_BACKGROUND': 'red darken-1', + 'ERRORMESSAGE_TEXT': 'white-text', + 'CARD_BACKGROUND': 'green darken-3', + 'CARD_TEXT': 'white-text', + 'FAB': 'red', + + 'STAR': 'yellow-text', + 'PROBLEM': 'red-text', + 'COMMENT': '', + } +} + try: import settings except ImportError: @@ -294,6 +313,14 @@ def get_cached_tags(userkey): return [] +def get_theme(userkey): + try: + usertheme = settings[userkey]['theme'] + return themes[usertheme] + except KeyError: + return themes['green'] # default + + def make_external(url): return urljoin(request.url_root, url) @@ -306,7 +333,8 @@ def page_not_found(e): @app.route('/') def index(): """ Homepage, point visitors to project page """ - return render_template('index.html') + default_theme = themes['green'] + return render_template('index.html', theme=default_theme) @app.route('/', methods=['GET', 'POST']) @@ -355,7 +383,8 @@ def bookmarks(userkey, filtermethod = None, sortmethod = None): else: bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.status == Bookmark.VISIBLE).order_by(Bookmark.created_date.desc()) - return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, filter_text=filter_text, message=message) + theme = get_theme(userkey) + return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, filter_text=filter_text, message=message, theme=theme) @@ -387,7 +416,8 @@ def editbookmark(userkey, urlhash): if not bookmark.note: # Workaround for when an existing bookmark has a null note bookmark.note = '' - return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark, message=message, formaction='edit', tags=tags) + theme = get_theme(userkey) + return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark, message=message, formaction='edit', tags=tags, theme=theme) @app.route('//add') @@ -401,7 +431,8 @@ def addbookmark(userkey): bookmark = Bookmark(title='', url=url, tags='') message = request.args.get('message') tags = get_cached_tags(userkey) - return render_template('edit.html', action='Add bookmark', userkey=userkey, bookmark=bookmark, tags=tags, message=message) + theme = get_theme(userkey) + return render_template('edit.html', action='Add bookmark', userkey=userkey, bookmark=bookmark, tags=tags, message=message, theme=theme) def updatebookmark(userkey, request, urlhash = None): @@ -529,9 +560,10 @@ def tags(userkey): totaldeleted = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.status == Bookmark.DELETED).count() totalnotes = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.note != '').count() totalhttperrorstatus = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.http_status != 200).count() + theme = get_theme(userkey) return render_template('tags.html', tags=alltags, totaltags=totaltags, totalpublic=totalpublic, totalbookmarks=totalbookmarks, totaldeleted=totaldeleted, totalstarred=totalstarred, totalhttperrorstatus=totalhttperrorstatus, - totalnotes=totalnotes, userkey=userkey) + totalnotes=totalnotes, userkey=userkey, theme=theme) @app.route('//tag/') @@ -547,7 +579,8 @@ def tag(userkey, tag): except PublicTag.DoesNotExist: publictag = None - return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, tag=tag, publictag=publictag, action=pageheader, message=message) + theme = get_theme(userkey) + return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, tag=tag, publictag=publictag, action=pageheader, message=message, theme=theme) @app.route('/pub/') @@ -557,7 +590,8 @@ def publictag(tagkey): try: this_tag = PublicTag.get(PublicTag.tagkey == tagkey) bookmarks = Bookmark.select().where(Bookmark.userkey == this_tag.userkey, Bookmark.tags.contains(this_tag.tag), Bookmark.status == Bookmark.VISIBLE).order_by(Bookmark.created_date.desc()) - return render_template('publicbookmarks.html', bookmarks=bookmarks, tag=tag, action=this_tag.tag, tagkey=tagkey) + theme = get_theme(userkey) + return render_template('publicbookmarks.html', bookmarks=bookmarks, tag=tag, action=this_tag.tag, tagkey=tagkey, theme=theme) except PublicTag.DoesNotExist: abort(404) diff --git a/templates/base.html b/templates/base.html index 79fa28d..87aee7f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -21,8 +21,8 @@ - -
- From 1545c174725430d834b8dd679c326fa95174718e Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 22 Jul 2017 21:42:12 +0200 Subject: [PATCH 7/9] Moved label colours to template/theme; added freshgreen and dark --- digimarks.py | 38 ++++++++++++++++++++++++++++++++++++++ static/css/digimarks.css | 10 ---------- templates/base.html | 16 ++++++++++++++-- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/digimarks.py b/digimarks.py index 09993ac..5434bd0 100644 --- a/digimarks.py +++ b/digimarks.py @@ -18,6 +18,8 @@ from peewee import * # noqa themes = { 'green': { 'BODY': 'grey lighten-4', + 'TEXT': 'black-text', + 'TEXTHEX': '#000', 'NAV': 'green darken-3', 'PAGEHEADER': 'grey-text lighten-5', 'MESSAGE_BACKGROUND': 'orange lighten-2', @@ -28,6 +30,42 @@ themes = { 'CARD_TEXT': 'white-text', 'FAB': 'red', + 'STAR': 'yellow-text', + 'PROBLEM': 'red-text', + 'COMMENT': '', + }, + 'freshgreen': { + 'BODY': 'grey lighten-5', + 'TEXT': 'black-text', + 'TEXTHEX': '#000', + 'NAV': 'green darken-1', + 'PAGEHEADER': 'grey-text lighten-5', + 'MESSAGE_BACKGROUND': 'orange lighten-2', + 'MESSAGE_TEXT': 'white-text', + 'ERRORMESSAGE_BACKGROUND': 'red darken-1', + 'ERRORMESSAGE_TEXT': 'white-text', + 'CARD_BACKGROUND': 'green darken-1', + 'CARD_TEXT': 'white-text', + 'FAB': 'red', + + 'STAR': 'yellow-text', + 'PROBLEM': 'red-text', + 'COMMENT': '', + }, + 'dark': { + 'BODY': 'grey darken-4', + 'TEXT': 'grey-text lighten-1', + 'TEXTHEX': '#bdbdbd', + 'NAV': 'grey darken-3', + 'PAGEHEADER': 'grey-text lighten-1', + 'MESSAGE_BACKGROUND': 'orange lighten-2', + 'MESSAGE_TEXT': 'white-text', + 'ERRORMESSAGE_BACKGROUND': 'red darken-1', + 'ERRORMESSAGE_TEXT': 'white-text', + 'CARD_BACKGROUND': 'grey darken-3', + 'CARD_TEXT': 'grey-text lighten-1', + 'FAB': 'red', + 'STAR': 'yellow-text', 'PROBLEM': 'red-text', 'COMMENT': '', diff --git a/static/css/digimarks.css b/static/css/digimarks.css index a675a8e..505e71b 100644 --- a/static/css/digimarks.css +++ b/static/css/digimarks.css @@ -18,16 +18,6 @@ nav .button-collapse i /** Form input fields **/ -/* label color */ -.input-field label -{ - color: #000; -} -/* label focus color */ -.input-field input[type=text]:focus + label -{ - color: #000; -} /* label underline focus color */ .input-field input[type=text]:focus { diff --git a/templates/base.html b/templates/base.html index dc95b0b..1334420 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,10 +18,22 @@ - + + - +