| /** |
| * Copyright (C) 2016 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| {namespace com.google.gerrit.server.mail.template} |
| |
| /* |
| * Private templates that cannot be overridden. |
| */ |
| |
| /** |
| * Private template to generate "View Change" buttons. |
| */ |
| {template ViewChangeButton} |
| {@param email: ?} |
| <a href="{$email.changeUrl}">View Change</a> |
| {/template} |
| |
| /** |
| * Private template to render PRE block with consistent font-sizing. |
| */ |
| {template Pre} |
| {@param content: ?} |
| {let $preStyle kind="css"} |
| font-family: monospace,monospace; // Use this to avoid browsers scaling down |
| // monospace text. |
| white-space: pre-wrap; |
| {/let} |
| <pre class="blocks" style="{$preStyle}">{$content|changeNewlineToBr}</pre> |
| {/template} |
| |
| /** |
| * Take a list of unescaped comment blocks and emit safely escaped HTML to |
| * render it nicely with wiki-like format. |
| * |
| * Each block is a map with a type key. When the type is 'paragraph', or 'pre', |
| * it also has a 'text' key that maps to the unescaped text content for the |
| * block. If the type is 'list', the map will have a 'items' key which maps to |
| * list of unescaped list item strings. If the type is quote, the map will have |
| * a 'quotedBlocks' key which maps to the blocks contained within the quote. |
| * |
| * This mechanism encodes as little structure as possible in order to depend on |
| * the Soy autoescape mechanism for all of the content. |
| */ |
| {template WikiFormat} |
| {@param content: ?} |
| {let $blockquoteStyle kind="css"} |
| border-left: 1px solid #aaa; |
| margin: 10px 0; |
| padding: 0 10px; |
| {/let} |
| |
| {let $pStyle kind="css"} |
| white-space: pre-wrap; |
| word-wrap: break-word; |
| {/let} |
| |
| {for $block in $content} |
| {if $block.type == 'paragraph'} |
| <p class="blocks" style="{$pStyle}">{$block.text|changeNewlineToBr}</p> |
| {elseif $block.type == 'quote'} |
| <blockquote class="blocks" style="{$blockquoteStyle}"> |
| {call WikiFormat}{param content: $block.quotedBlocks /}{/call} |
| </blockquote> |
| {elseif $block.type == 'pre'} |
| {call Pre}{param content: $block.text /}{/call} |
| {elseif $block.type == 'list'} |
| <ul class="blocks"> |
| {for $item in $block.items} |
| <li>{$item}</li> |
| {/for} |
| </ul> |
| {/if} |
| {/for} |
| {/template} |
| |
| {template UnifiedDiff} |
| {@param diffLines: ?} |
| {let $addStyle kind="css"} |
| color: hsl(120, 100%, 40%); |
| {/let} |
| |
| {let $removeStyle kind="css"} |
| color: hsl(0, 100%, 40%); |
| {/let} |
| |
| {let $preStyle kind="css"} |
| font-family: monospace,monospace; // Use this to avoid browsers scaling down |
| // monospace text. |
| white-space: pre-wrap; |
| {/let} |
| |
| <pre style="{$preStyle}"> |
| {for $line in $diffLines} |
| {if $line.type == 'add'} |
| <span style="{$addStyle}"> |
| {elseif $line.type == 'remove'} |
| <span style="{$removeStyle}"> |
| {else} |
| <span> |
| {/if} |
| {$line.text} |
| </span><br> |
| {/for} |
| </pre> |
| {/template} |