tags: move tag category definitions out of the config file.

Move all the code for defining tag categories from the config file to
TagCategory. It didn't belong in the config because it's not possible to
add new tag categories purely in the config without editing other things
like the CSS.

Also change it so that tag colors are hardcoded in the CSS instead of
generated using ERB. Generating the CSS in ERB meant that the Docker
build had to recompile the CSS on every commit, even when it didn't
change, because it relied on Ruby code outside the CSS that we couldn't
guarantee didn't change.
This commit is contained in:
evazion
2021-09-30 10:03:33 -05:00
parent e72446463e
commit 587a9d0c8f
4 changed files with 152 additions and 159 deletions

View File

@@ -1,13 +1,64 @@
<% TagCategory.css_mapping.each do |category,cssmap| %>
.tag-type-<%= category %> a, a.tag-type-<%= category %> {
color: <%= cssmap["color"] %>;
.tag-type-0 a, a.tag-type-0 {
color: var(--general-tag-color);
color: var(--general-tag-hover-color);
&:link, &:visited {
color: <%= cssmap["color"] %>;
}
&:hover {
color: <%= cssmap["hover"] %>;
}
&:link, &:visited {
color: var(--general-tag-color);
}
<% end %>
&:hover {
color: var(--general-tag-hover-color);
}
}
.tag-type-1 a, a.tag-type-1 {
color: var(--artist-tag-color);
color: var(--artist-tag-hover-color);
&:link, &:visited {
color: var(--artist-tag-color);
}
&:hover {
color: var(--artist-tag-hover-color);
}
}
.tag-type-3 a, a.tag-type-3 {
color: var(--copyright-tag-color);
color: var(--copyright-tag-hover-color);
&:link, &:visited {
color: var(--copyright-tag-color);
}
&:hover {
color: var(--copyright-tag-hover-color);
}
}
.tag-type-4 a, a.tag-type-4 {
color: var(--character-tag-color);
color: var(--character-tag-hover-color);
&:link, &:visited {
color: var(--character-tag-color);
}
&:hover {
color: var(--character-tag-hover-color);
}
}
.tag-type-5 a, a.tag-type-5 {
color: var(--meta-tag-color);
color: var(--meta-tag-hover-color);
&:link, &:visited {
color: var(--meta-tag-color);
}
&:hover {
color: var(--meta-tag-hover-color);
}
}