From 58768acc1cbbda41ef530125a1a1247cb862f3c5 Mon Sep 17 00:00:00 2001 From: rr- Date: Wed, 5 Aug 2015 18:03:16 +0200 Subject: [PATCH] Increased control over tag categories --- data/config.ini | 8 ++++---- gruntfile.js | 2 +- public_html/css/tag-list.css | 17 ++--------------- public_html/index.html | 17 ++++++++++++++++- public_html/js/Presenters/TagPresenter.js | 11 ++++++++++- public_html/templates/tag.tpl | 2 +- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/data/config.ini b/data/config.ini index 18d02357..8ff3aa9b 100644 --- a/data/config.ini +++ b/data/config.ini @@ -99,10 +99,10 @@ usersPerPage = 20 postsPerPage = 40 [tags] -categories[] = meta -categories[] = artist -categories[] = character -categories[] = copyright +categories[] = 'meta, meta, #aaa' +categories[] = 'artist, artist, #a00' +categories[] = 'character, character, #0a0' +categories[] = 'copyright, copyright, #a0a' [misc] thumbnailCropStyle = outside diff --git a/gruntfile.js b/gruntfile.js index ac392f06..8fa14c66 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -137,7 +137,7 @@ module.exports = function(grunt) { templates: readTemplates(grunt), timestamp: grunt.template.today('isoDateTime'), maxPostSize: config.database.maxPostSize, - tagCategories: config.tags.categories, + tagCategories: config.tags.categories.map(function(s) { return s.split(/,\s*/); }), } }, dist: { diff --git a/public_html/css/tag-list.css b/public_html/css/tag-list.css index ca34a614..919bd3c9 100644 --- a/public_html/css/tag-list.css +++ b/public_html/css/tag-list.css @@ -78,19 +78,6 @@ word-break: break-all; } -.tag-category-character, -.tag-category-character a { - color: #0a0; -} -.tag-category-copyright, -.tag-category-copyright a { - color: #a0a; -} -.tag-category-artist, -.tag-category-artist a { - color: #a00; -} -.tag-category-meta, -.tag-category-meta a { - color: #aaa; +*[class*='tag-category-']:not(.tag-category-default) a { + color: inherit; } diff --git a/public_html/index.html b/public_html/index.html index b89dd6c1..0e66b3b9 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -5,7 +5,7 @@ data-version="dev" data-build-time="" data-max-post-size="10485760" - data-tag-categories='["meta","character","artist","copyright"]'> + data-tag-categories='[["meta","meta","#aaa"],["character","character","#0a0"],["artist","artist","#a00"],["copyright","copyright","#a0a"]]'> + + + diff --git a/public_html/js/Presenters/TagPresenter.js b/public_html/js/Presenters/TagPresenter.js index d663fa44..1108cdca 100644 --- a/public_html/js/Presenters/TagPresenter.js +++ b/public_html/js/Presenters/TagPresenter.js @@ -81,12 +81,21 @@ App.Presenters.TagPresenter = function( }); } + function getTagCategories() { + var tagCategories = JSON.parse(jQuery('head').attr('data-tag-categories')); + var result = {}; + jQuery.each(tagCategories, function(i, item) { + result[item[0]] = item[1]; + }); + return result; + } + function render() { $el.html(templates.tag({ privileges: privileges, tag: tag, siblings: siblings, - tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')), + tagCategories: getTagCategories(), util: util, historyTemplate: templates.history, })); diff --git a/public_html/templates/tag.tpl b/public_html/templates/tag.tpl index 3d1ae2e8..8ebd08df 100644 --- a/public_html/templates/tag.tpl +++ b/public_html/templates/tag.tpl @@ -41,7 +41,7 @@
- <% _.each(_.extend({'default': 'default'}, _.object(tagCategories, tagCategories)), function(v, k) { %> + <% _.each(_.extend({'default': 'default'}, tagCategories), function(v, k) { %> >