How to style gitiles

483 views
Skip to first unread message

Goerler, Adrian

unread,
Oct 15, 2015, 8:10:14 AM10/15/15
to dbor...@google.com, repo-d...@googlegroups.com
Hi Dave, others,

I am looking into options how to adapt the gitiles' look to our company's look. 

Ideally, I'd add a CSS to override the styles that need to be tweaked.

We plan to run gitiles using the the gerrit-gitiles plugin (which we forked). In the plugin it seems to be possible to register a CSS programatically using 

BaseServlet.putSoyData(req"css", sinletonList(<my css>)) 

Would there be an easier option?

Moreover, I'd like to exchange the default header by a custom header. 

This seems to be possible somehow using the "headerVariant" parameter of the soy templates. But so far I wasn't able to figure out how to properly use this parameter. Should I add my own template for my custom header and refer to it's variant name using the "headerVariant" parameter?

-Adrian 





Dave Borowitz

unread,
Oct 15, 2015, 9:10:59 AM10/15/15
to Goerler, Adrian, repo-d...@googlegroups.com
On Thu, Oct 15, 2015 at 8:10 AM, Goerler, Adrian <adrian....@sap.com> wrote:
Hi Dave, others,

I am looking into options how to adapt the gitiles' look to our company's look. 

Ideally, I'd add a CSS to override the styles that need to be tweaked.

We plan to run gitiles using the the gerrit-gitiles plugin (which we forked). In the plugin it seems to be possible to register a CSS programatically using 

BaseServlet.putSoyData(req"css", sinletonList(<my css>)) 

If you want to replace the base stylesheet instead of adding another one (which might require overriding with !important or whatever), you can pass the gitiles.BASE_CSS_URL key in the globals map in the constructor to Renderer. But that just tells it to stick that URL in the output HTML; you'd still be responsible for ensuring the stylesheet actually gets served up at the right location.
 
Would there be an easier option?

There is not an option that is not programmatic, if that's what you're asking. Although I wouldn't object to adding a configuration in gitiles.config for that.
 
Moreover, I'd like to exchange the default header by a custom header. 

This seems to be possible somehow using the "headerVariant" parameter of the soy templates. But so far I wasn't able to figure out how to properly use this parameter. Should I add my own template for my custom header and refer to it's variant name using the "headerVariant" parameter?

Yes, that's how it's supposed to work.

{deltemplate gitiles.customHeader variant="'myvariantname'"}
 
Note the weird quoting: ["][']myvariantname[']["]. Thanks, Soy.

-Adrian 






Björn Pedersen

unread,
Oct 15, 2015, 5:47:18 PM10/15/15
to Repo and Gerrit Discussion
I just submitted a patch as the headerVariant feature was broken in the gerrit plugin. You can also override the soy templates in a custom directory.

Björn

Björn Pedersen

unread,
Oct 16, 2015, 2:28:40 AM10/16/15
to Repo and Gerrit Discussion
To elaborate a bit more on this:

put in etc/gitiles.config:
[gitiles]
customTemplates
= path-to-soy-file



In the soy file you can put a template just containing the deltemplate part with your variant.

Then together with: https://gerrit-review.googlesource.com/#/c/71522/
you can put a gitiles.config per repo in ref/meta/config, where you set
[template]
 customHeader
= <your-variant>


Björn

Adrian Görler

unread,
Oct 16, 2015, 5:31:33 AM10/16/15
to Repo and Gerrit Discussion
Hi Björn,

would this work as well with 

[template]
 customHeader 
= <your-variant>

in the global gitiles config?

-Adrian

Adrian Görler

unread,
Oct 16, 2015, 6:26:24 AM10/16/15
to Repo and Gerrit Discussion, adrian....@sap.com


Am Donnerstag, 15. Oktober 2015 15:10:59 UTC+2 schrieb Dave Borowitz:


On Thu, Oct 15, 2015 at 8:10 AM, Goerler, Adrian <adrian....@sap.com> wrote:
Hi Dave, others,

I am looking into options how to adapt the gitiles' look to our company's look. 

Ideally, I'd add a CSS to override the styles that need to be tweaked.

We plan to run gitiles using the the gerrit-gitiles plugin (which we forked). In the plugin it seems to be possible to register a CSS programatically using 

BaseServlet.putSoyData(req"css", sinletonList(<my css>)) 

If you want to replace the base stylesheet instead of adding another one (which might require overriding with !important or whatever), you can pass the gitiles.BASE_CSS_URL key in the globals map in the constructor to Renderer. But that just tells it to stick that URL in the output HTML; you'd still be responsible for ensuring the stylesheet actually gets served up at the right location.
 
Would there be an easier option?

There is not an option that is not programmatic, if that's what you're asking. Although I wouldn't object to adding a configuration in gitiles.config for that.

This would be very convenient. 

Björn Pedersen

unread,
Oct 16, 2015, 7:32:43 AM10/16/15
to Repo and Gerrit Discussion
Not yet. I still need some help how  get this data in GerritGitilesAccess (see inline comment in patch :()

With the unpatched version you currently just get an empty config back (so id does not matter what you have inside the config...)

Björn

Adrian Görler

unread,
Oct 16, 2015, 9:03:16 AM10/16/15
to Repo and Gerrit Discussion
Hi,

programatically I was able to activate a global the header variant like this.

BaseServlet.putSoyData(req"headerVariant"<my-variant>)

Adam Yi

unread,
Jan 2, 2018, 1:32:47 AM1/2/18
to Repo and Gerrit Discussion
Hi Björn,

I just found this post and managed to get this data in GerritGitilesAccess. I submitted a patch at https://gerrit-review.googlesource.com/#/c/plugins/gitiles/+/150390/

Please take a look and see if there's anything you want to change. Thanks~
Reply all
Reply to author
Forward
0 new messages