Where can I get the theme color?


#1

I see .navbar-inner.orange, .navbar-inner.red and so on, but I can't see what causes a theme color to be selected, either in the html or in the jinja2 template. How can I access that?


#2

Depending on which side of the programming side you're using you could get it from the global settings under appearance > color. So a call like self._settings.global_get(["appearance","color"]) in python should work.


#3

I need it at Jinja or JS, but that gives me a starting point.


#4

Hmm. There's a call to the /settings endpoint, which has the appearance dict, but I can't figure out how to call it from JS in the initscript.jinja2 page. I see the data bindings that reference it as css/html/knockout, but that's where I get lost. @foosel can you weigh in?


#5

From the js side if you include the settingsViewModel dependency you should be able to access it via settingsViewModel.settings.appearance.color() I think.


#6

I can confirm that this works. I did a quick test and you can see it here. Basically you include settingsViewModel as one of your dependencies like this and then at the beginning of your code you create a reference to that dependency like this.


#7

OMG, thanks! I couldn't do what I wanted in initscript, but I could (easily) do it in appearance.js. Here it is- basically painting the favicon to match the theme color.


#8

Hmm. Hey @jneilliii, I'm doing something wrong here, no matter how much I try, I'm getting a closure back. I can't execute the closure. I can see appearance_color is stuffed inside a Symbol, but I can't figure out how to actually access it. Grrrrrr.


#9

Not really sure. I personally would approach this as a plugin instead of a change to the core, but not sure without digging deeper if it would even be possible as a plugin.


#10

If I'm assuming your intention correctly, try using the following.

ThemeFavicon(self.color());

You may also want to move all your code inside the AppearanceViewModel altogether. The issues you are running into are more than likely the biggest thing I struggle with when developing plugins, knockout binding.