Increased control over tag categories

This commit is contained in:
rr- 2015-08-05 18:03:16 +02:00
parent 42f37d8fee
commit 58768acc1c
6 changed files with 34 additions and 23 deletions

View file

@ -99,10 +99,10 @@ usersPerPage = 20
postsPerPage = 40 postsPerPage = 40
[tags] [tags]
categories[] = meta categories[] = 'meta, meta, #aaa'
categories[] = artist categories[] = 'artist, artist, #a00'
categories[] = character categories[] = 'character, character, #0a0'
categories[] = copyright categories[] = 'copyright, copyright, #a0a'
[misc] [misc]
thumbnailCropStyle = outside thumbnailCropStyle = outside

View file

@ -137,7 +137,7 @@ module.exports = function(grunt) {
templates: readTemplates(grunt), templates: readTemplates(grunt),
timestamp: grunt.template.today('isoDateTime'), timestamp: grunt.template.today('isoDateTime'),
maxPostSize: config.database.maxPostSize, maxPostSize: config.database.maxPostSize,
tagCategories: config.tags.categories, tagCategories: config.tags.categories.map(function(s) { return s.split(/,\s*/); }),
} }
}, },
dist: { dist: {

View file

@ -78,19 +78,6 @@
word-break: break-all; word-break: break-all;
} }
.tag-category-character, *[class*='tag-category-']:not(.tag-category-default) a {
.tag-category-character a { color: inherit;
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;
} }

View file

@ -5,7 +5,7 @@
data-version="dev" data-version="dev"
data-build-time="" data-build-time=""
data-max-post-size="10485760" 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"]]'>
<!-- /build --> <!-- /build -->
<!-- build:template <!-- build:template
<head <head
@ -24,8 +24,23 @@
<title><%= serviceName %></title> <title><%= serviceName %></title>
/build --> /build -->
<!-- build:remove -->
<style type="text/css">
.tag-category-character { color: #0a0; }
.tag-category-copyright { color: #a0a; }
.tag-category-artist { color: #a00; }
.tag-category-meta { color: #aaa; }
</style>
<!-- /build -->
<!-- build:template <!-- build:template
<link rel="stylesheet" type="text/css" href="app.min.css?<%= timestamp %>"/> <link rel="stylesheet" type="text/css" href="app.min.css?<%= timestamp %>"/>
<style type="text/css">
<% _.each(tagCategories, function(item) {
var type = item[0];
var color = item[2];
%>.tag-category-<%= type %>{color:<%=color%>;}<%
}); %>
</style>
/build --> /build -->
<link rel="stylesheet" type="text/css" href="/lib/font-awesome/css/font-awesome.min.css"/> <link rel="stylesheet" type="text/css" href="/lib/font-awesome/css/font-awesome.min.css"/>

View file

@ -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() { function render() {
$el.html(templates.tag({ $el.html(templates.tag({
privileges: privileges, privileges: privileges,
tag: tag, tag: tag,
siblings: siblings, siblings: siblings,
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')), tagCategories: getTagCategories(),
util: util, util: util,
historyTemplate: templates.history, historyTemplate: templates.history,
})); }));

View file

@ -41,7 +41,7 @@
<div class="form-row"> <div class="form-row">
<label class="form-label" for="tag-category">Category:</label> <label class="form-label" for="tag-category">Category:</label>
<div class="form-input"> <div class="form-input">
<% _.each(_.extend({'default': 'default'}, _.object(tagCategories, tagCategories)), function(v, k) { %> <% _.each(_.extend({'default': 'default'}, tagCategories), function(v, k) { %>
<input name="category" type="radio" value="<%= k %>" id="category-<%= k %>" <% print(tag.category === k ? 'checked="checked"' : '') %>> <input name="category" type="radio" value="<%= k %>" id="category-<%= k %>" <% print(tag.category === k ? 'checked="checked"' : '') %>>
<label for="category-<%= k %>"> <label for="category-<%= k %>">
<% print(tag.category === k ? v + ' (current)' : v) %> <% print(tag.category === k ? v + ' (current)' : v) %>