blob: 29f328f627c200be994ec5d6a5d3823489ed6cff [file] [log] [blame] [view]
David Pursehouse240fbff2016-08-25 09:58:15 +09001# Configuration
2
3The `gitiles.config` file supporting the site contains several configuration
4options.
5
6[TOC]
7
David Pursehousef7018102016-08-25 10:10:23 +09008## Core configuration
9
Antoine Musso0b4abb42022-06-30 22:12:26 +020010### Site Title
11
12The title of the site. Default: `Gitiles`.
13
14```
15[gitiles]
16 siteTitle = Acme Inc. Git Browser
17```
18
Matthias Sohn8c3d87d2026-01-28 11:09:47 +010019### Base Path
20
21The file system path gitiles will scan for git repositories to serve when started
22in dev mode using `./tools/dev_run.sh`. By default the current working directory
23where the gitiles process was started from.
24
25```
26[gitiles]
27 basePath = /git/
28```
29
Antoine Musso68f511a2022-06-30 22:13:36 +020030### URLs
31
32`canonicalHostName`.
33Default: `null`, determine the hostname from the local host.
34
35`baseGitUrl` the base URL for git repositories.
36
Ilmari Lauhakangasace68b42024-11-29 12:07:17 +020037`gerritUrl`, URL prefix that when set is used to create:
38* Links from the `Change-Id` headers in commit messages to the corresponding
39 Gerrit change.
40* An edit link in file views that opens a new change in Gerrit in online edit
41 mode for that file. The link will only appear when you are browsing the file
42 at a branch, so the commitish must start with `refs/heads/`.
43
Matthias Sohn8c3d87d2026-01-28 11:09:47 +010044`contextPath` the base path for the gitiles urls. Only applicable for dev mode started using `./tools/dev_run.sh`.
Adithya Chakilamb1b8c4a2025-08-06 23:12:38 -050045
Ilmari Lauhakangasace68b42024-11-29 12:07:17 +020046> If you are using the Gerrit Gitiles plugin, this is set based on Gerrit's configuration.
47> Default: `null`, do not link `Change-Id` or show edit links.
Antoine Musso68f511a2022-06-30 22:13:36 +020048
49```
50[gitiles]
51 canonicalHostName = gitiles.example.org
52 gerritUrl = https://gerrit.example.org/r/
53 baseGitUrl = git://git.example.org/
Matthias Sohn8c3d87d2026-01-28 11:09:47 +010054 contextPath = /additional/basepath/for/gitiles/
Antoine Musso68f511a2022-06-30 22:13:36 +020055```
56
Antoine Musso33d4c132022-06-30 22:14:13 +020057### Repositories export
58
59Set `exportAll` to instruct jGit to export all repositories, ignoring the check
60for existence of `git-daemon-export-ok` file at the root of the repository.
61
62Default: `false`, repositories need to be explicitly marked for export.
63
64```
65[gitiles]
66exportAll = true
67```
68
Antoine Mussoda9134f2022-06-30 22:14:33 +020069### Custom templating
70
71The web views are defined via Soy templates, you inject your own version which
72will be passed to the renderer. See `.soy` files in the source code for
73available templates
74
75```
76[gitiles]
77customTemplates = path/to/somefile.soy
78customTemplates = path/to/another.soy
79```
80
Daniele Sassoliacf2a192023-03-06 20:32:56 +000081### Custom styling
82
83It's possible to inject custom styles within the template. To do this add
84the following to `gitiles.config`:
85```
86[gitiles]
87 customTemplates = path/to/afile.soy
88[template]
89 customVariant=aVariant
90```
91Where `customVariant` is the variable defined in the default
92templates themselves. Then you can define `afile.soy` as follows:
93```
94{namespace gitiles}
95{deltemplate gitiles.customHeadTagPart variant="'aVariant'"}
96
97<link rel="stylesheet" type="text/css" href="/static/file.css" />
98
99{/deltemplate}
100```
101It is also possible to define a `<style>` tag there if desired.
102
Dave Borowitzed97b7f2022-06-30 20:28:03 +0200103### Fixed time zone
104
105By default dates are formatted including the local user time zone as that
106matches git tools. Some users/administrators may prefer normalizing to a
107particular timezone so times are directly comparable without doing timezone
108arithmetic.
109
110Setting `fixedTimeZone` to a valid Java TimeZone ID causes all dates in the UI
111to be implicitly converted to this timezone, and the now-redundant timezone
112offset to be dropped from the output.
113
114```
115[gitiles]
116 fixedTimeZone = UTC
117```
118
David Pursehousef7018102016-08-25 10:10:23 +0900119### Cross-Origin Resource Sharing (CORS)
120
121Gitiles sets the `Access-Control-Allow-Origin` header to the
122HTTP origin of the client if the client's domain matches a regular
123expression defined in `allowOriginRegex`.
124
125```
126[gitiles]
127 allowOriginRegex = http://localhost
128```
129
130By default `allowOriginRegex` is unset, denying all cross-origin requests.
131
Antoine Musso07e21422022-06-30 22:14:59 +0200132### Gitweb redirector
133
134Redirect requests to old gitweb URLs after having migrated to Gitiles. Matching
135URLs will be redirected permanently to their Gitiles equivalent.
136Default: `true`.
137
138```
139[gitiles]
140redirectGitweb = false
141```
142
David Pursehouse240fbff2016-08-25 09:58:15 +0900143## Markdown
144
145### Disabling markdown
146
147Markdown can be completely disabled by setting render to false.
148
149```
150[markdown]
151 render = false
152```
153
154### Markdown size
155
156Markdown files are limited by default to 5 MiB of input text
157per file. This limit is configurable, but should not be raised
158beyond available memory.
159
160```
161[markdown]
162 inputLimit = 5M
163```
164
165### Image size
166
167Referenced [images are inlined](#Images) as base64 encoded URIs.
168The image limit places an upper bound on the byte size of input.
169
170```
171[markdown]
172 imageLimit = 256K
173```
174
Shawn Pearceb55cf2b2017-06-29 21:56:37 -0700175### Extensions
176
177The following extensions can be enabled/disabled in the markdown
178section:
179
180* `githubFlavor`: enable extensions that mirror GitHub Flavor
181 Markdown behavior. Default is true.
182
183* `autolink`: automatically convert plain URLs and email
David Pursehouse0c122622017-07-02 13:33:58 +0900184 addresses into links. Default follows `githubFlavor`.
Shawn Pearceb55cf2b2017-06-29 21:56:37 -0700185
186* `blocknote`: Gitiles style note/promo/aside blocks to raise
187 awareness to important content. Default false.
188
189* `ghthematicbreak`: accept `--` for `<hr>`, like GitHub Flavor
190 Markdown. Default follows `githubFlavor`.
191
192* `multicolumn`: Gitiles extension to layout content in a 12 cell
193 grid, delinated by section headers. Default false.
194
195* `namedanchor`: Gitiles extension to extract named anchors using
196 `#{id}` syntax. Default false.
197
198* `safehtml`: Gitiles extension to accept very limited HTML; for
199 security reasons all other HTML is dropped regardless of this
200 setting. Default follows `githubFlavor`.
201
202* `smartquote`: Gitiles extension to convert single and double quote
203 ASCII characters to Unicode smart quotes when in prose. Default
204 false.
205
206* `strikethrough`: strikethrough text with GitHub Flavor Markdown
207 style `~~`. Default follows `githubFlavor`.
208
209* `tables`: format tables with GitHub Flavor Markdown. Default
210 follows `githubFlavor`.
211
212* `toc`: Gitiles extension to replace `[TOC]` in a paragraph by itself
213 with a server-side generated table of contents extracted from section
214 headers. Default true.
215
David Pursehousebbcc5132016-08-26 13:26:13 +0900216### IFrames
217
Shawn Pearceb55cf2b2017-06-29 21:56:37 -0700218IFrame support requires `markdown.safehtml` to be true.
219
David Pursehousebbcc5132016-08-26 13:26:13 +0900220IFrame source URLs can be whitelisted by providing a list of allowed
221URLs. URLs ending with a `/` are treated as prefixes, allowing any source
222URL beginning with that prefix.
223
224```
225[markdown]
226 allowiframe = https://google.com/
227```
228
229URLs not ending with a `/` are treated as exact matches, and only those
230source URLs will be allowed.
231
232
233```
234[markdown]
235 allowiframe = https://example.com
236 allowiframe = https://example.org
237```
238
239If the list has a single entry with the value `true`, all source URLs
240will be allowed.
241
242
243```
244[markdown]
245 allowiframe = true
246```
247
David Pursehouse240fbff2016-08-25 09:58:15 +0900248## Google Analytics
249
250[Google Analytics](https://www.google.com/analytics/) can be
251enabled on every rendered markdown page by adding the Property ID
252to the configuration file:
253
254```
255[google]
256 analyticsId = UA-XXXX-Y
257```