hydrus
hydrus copied to clipboard
Client API: read/write tag presentation details
If nothing else, getting the color definitions would be useful for CSS.
I opened a duplicate feature request by accident. I'll put in my ideas in a comment here since this issue came first. I hope you don't mind me piggy-backing off your idea you had first.
Context
In file -> options -> tag presentation
, we have the option to give a color/colour to each namespace. For example, the character namespace is green by default. The creator namespace is red. This Client API addition would allow for a third party application to query the tag colors that the client has set.
Motivation (Why?)
Querying the tag namespace colors set in the client allows for third party applications using the API to have a more consistent look and feel. If the user recolors the creator
namespace to hot pink, then 3rd party apps can detect it and adjust themselves accordingly. Similarly, if the user adds some weird personal namespaces, then 3rd party apps can work with them just as seamlessly as Hydrus does.
What it might look like
In response to a GET request, the client API might return an object. Each key corresponds to a namespace, and each value corresponds to a color. There might also have to be some "magic" for unnamespaced tags.
Hypothetical response:
{
"none": "#0000FF",
"character": "#00FF00",
"creator": "#FF0000",
"meta": "and so on......"
}
As a workaround for the time being, I compiled the default colors. You can use this as a stand-in resource until this feature is added.
character #00AA00
creator #AA0000
meta #000000
person #008000
series #AA00AA
studio #800000
system #996515
other #72A0C1
unnamespaced #006FFA
I had actually already done that for Hydrus Web. If anyone finds it useful here is the SCSS:
// Original tag colors from Hydrus source code
$tag-colors: (
system: rgb(153, 101, 21),
meta: rgb(0, 0, 0),
creator: rgb(170, 0, 0),
studio: rgb(128, 0, 0),
character: rgb(0, 170, 0),
person: rgb(0, 128, 0),
series: rgb(170, 0, 170),
default-namespace: rgb(114, 160, 193),
no-namespace: rgb(0, 111, 250)
);
https://github.com/floogulinc/hydrus-web/blob/master/src/_variables.scss#L18-L29
If tag colours became part of the Qt stylesheets as suggested in #371 it would then be possible to just parse the .qss for the details as an option.
After some discussion in the server, I think this is the best way to go about sending the data to the user (using made up data as an example):
"tag_presentation":
{
"default": [0,0,255],
"namespaces":
{
"": [128, 128, 128],
"creator": [0, 255, 0],
"character": [255, 0, 0 ]
}
}
where ...
-
default
is the color for namespaces with no color defined in 'tag presentation' (light blue by default) -
namespaces.""
is the value for unnamespaced tags. Note that a tag with an empty string for a namespace name is by definition a tag with no namespace - And each value is an array of 3 integers,
[ red, green, blue ]
(in that order), which should be interpreted as a single RGB8 color. Each integer is in the range0
to255
(inclusive).
If a namespace isn't present in the namespaces
object (or is otherwise null
or undefined
), then its color is assumed to be the "default"
value
#1460 adds the ability to get tag namespace colors along with almost everything else in the client options.