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