Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client API: read/write tag presentation details #360

Open
novakda opened this issue Jul 8, 2020 · 6 comments
Open

Client API: read/write tag presentation details #360

novakda opened this issue Jul 8, 2020 · 6 comments
Labels
feature-request system:api API related issues system:tag-management system:user-interface Looks and actions of the user interface

Comments

@novakda
Copy link

novakda commented Jul 8, 2020

If nothing else, getting the color definitions would be useful for CSS.

@cinnamon-rolls
Copy link

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......"
}

@cinnamon-rolls
Copy link

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

@floogulinc
Copy link
Collaborator

floogulinc commented Jul 2, 2021

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

@Zweibach
Copy link
Collaborator

Zweibach commented Jul 2, 2021

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.

@cinnamon-rolls
Copy link

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 range 0 to 255 (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

@Zweibach Zweibach added system:tag-management system:user-interface Looks and actions of the user interface labels Aug 21, 2021
@floogulinc
Copy link
Collaborator

#1460 adds the ability to get tag namespace colors along with almost everything else in the client options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request system:api API related issues system:tag-management system:user-interface Looks and actions of the user interface
Projects
None yet
Development

No branches or pull requests

5 participants