Diffstat (limited to 'templates/macros.html')
1 file changed, 236 insertions(+)
@@ -1,0 +1,236 @@
{% macro header(repo: Option<&Repository> = None, branches: Vec<String> = Vec::new(), current_ref: Option<&Ref> = None) %}
{% if let Some(repo) = repo && let Some(current_ref) = current_ref %}
<tr>
<td class="logo" rowspan="2"><a href="/"><img src="/static/logo.png" alt="logo"></a></td>
<td class="main"><a href="/">index</a> : <a title="{{ repo.name }}" href="/{{ repo.name }}/">{{ repo.name }}</a></td>
<td class="form">
<form method="get">
<select name="h" onchange="this.form.submit();">
{% for branch in branches %}
<option value="{{ branch }}" {% if branch == ¤t_ref.name %}selected{% endif %}>{{ branch }}</option>
{% endfor %}
</select>
<input type="submit" value="switch">
</form>
</td>
</tr>
<tr>
<td class="sub" colspan="2">{{ repo.description }}</td>
</tr>
{% else %}
<tr>
<td class="logo" rowspan="2"><a href="/"><img src="/static/logo.png" alt="logo"></a></td>
<td class="main">y2w8 Repos</td>
</tr>
<tr>
<td class="sub">y2w8 git repositories, powered by rsgit</td>
</tr>
{% endif %}
{% endmacro %}
{% macro repo_tabs(repo: Repository, current_ref: Ref, query: PageQuery, active: str) %}
<tr>
<td>
{% decl parameters %}
{% if let Some(id) = query.id %}
{% let parameters %}?id={{ id }}{% endlet %}
<a href="/{{ repo.name }}/about/" class="{% if active == "about" %}active{% endif %}">about</a>
<a href="/{{ repo.name }}/" class="{% if active == "summary" %}active{% endif %}">summary</a>
<a href="/{{ repo.name }}/refs/{{ parameters }}" class="{% if active == "refs" %}active{% endif %}">refs</a>
<a href="/{{ repo.name }}/log/" class="{% if active == "log" %}active{% endif %}">log</a>
<a href="/{{ repo.name }}/tree/{{ parameters }}" class="{% if active == "tree" %}active{% endif %}">tree</a>
<a href="/{{ repo.name }}/commit/{{ parameters }}" class="{% if active == "commit" %}active{% endif %}">commit</a>
<a href="/{{ repo.name }}/diff/{{ parameters }}" class="{% if active == "diff" %}active{% endif %}">diff</a>
{% else if let Some(head) = query.head %}
{% let parameters %}?h={{ head }}{% endlet %}
<a href="/{{ repo.name }}/about/{{ parameters }}" class="{% if active == "about" %}active{% endif %}">about</a>
<a href="/{{ repo.name }}/" class="{% if active == "summary" %}active{% endif %}">summary</a>
<a href="/{{ repo.name }}/refs/" class="{% if active == "refs" %}active{% endif %}">refs</a>
<a href="/{{ repo.name }}/log/{{ parameters }}" class="{% if active == "log" %}active{% endif %}">log</a>
<a href="/{{ repo.name }}/tree/{{ parameters }}" class="{% if active == "tree" %}active{% endif %}">tree</a>
<a href="/{{ repo.name }}/commit/{{ parameters }}" class="{% if active == "commit" %}active{% endif %}">commit</a>
<a href="/{{ repo.name }}/diff/{{ parameters }}" class="{% if active == "diff" %}active{% endif %}">diff</a>
{% else %}
<a href="/{{ repo.name }}/about/" class="{% if active == "about" %}active{% endif %}">about</a>
<a href="/{{ repo.name }}/" class="{% if active == "summary" %}active{% endif %}">summary</a>
<a href="/{{ repo.name }}/refs/" class="{% if active == "refs" %}active{% endif %}">refs</a>
<a href="/{{ repo.name }}/log/" class="{% if active == "log" %}active{% endif %}">log</a>
<a href="/{{ repo.name }}/tree/" class="{% if active == "tree" %}active{% endif %}">tree</a>
<a href="/{{ repo.name }}/commit/" class="{% if active == "commit" %}active{% endif %}">commit</a>
<a href="/{{ repo.name }}/diff/" class="{% if active == "diff" %}active{% endif %}">diff</a>
{% endif %}
</td>
<td class="form">
<form method="get" action="/{{ repo.name }}/log/">
<select name="qt">
<option value="msg" selected>msg</option>
<option value="author" >author</option>
<option value="committer">committer</option>
</select>
<input type="search" name="v" size="10" value="">
<input type="submit" value="search">
</form>
</td>
</tr>
{% endmacro %}
{% macro branches(branches, branches_has_more, has_prev, page, mode) %}
<thead>
<tr>
<th>Branch</th>
<th>Commit message</th>
<th>Author</th>
<th>Age</th>
</tr>
</thead>
<tbody>
{% for branch in branches %}
<tr>
<td>
<a href="/{{ repo.name }}/log/?h={{ branch.name }}">{{ branch.name }}</a>
</td>
<td class="msg"><span class="msg-text">{{ branch.last_commit.summary()? }}</span></td>
<td class="author">
<span class="avatar">
<img class="inline" src="{{ branch.author.avatar_url(20) }}">
<img class="onhover" src="{{ branch.author.avatar_url(128) }}">
</span>
{{ branch.author.name }}
</td>
{% let time = branch.author.time.format_relative() %}
<td class="{{ time.1 }}" title="{{ branch.author.time.format() }}">{{ time.0 }}</td>
</tr>
{% endfor %}
<tr class="no-background">
{% if mode == "heads" %}
<td colspan="4" class="pagination">
{% if has_prev %}
{% let offset = offset.saturating_sub(PAGE_SIZE) %}
{% if offset > 0 %}
<a href="/{{ repo.name }}/refs/heada/?ofs={{ offset }}">[prev]</a>
{% else %}
<a href="/{{ repo.name }}/refs/heada/">[prev]</a>
{% endif %}
{% endif %}
{% if branches_has_more %}
<a href="/{{ repo.name }}/refs/heads?ofs={{ offset.saturating_add(PAGE_SIZE) }}">[next]</a>
{% endif %}
</td>
{% else if branches_has_more %}
<td class="show_more">
<a href="/{{ repo.name }}/refs/heads">[...]</a>
</td>
{% endif %}
</tr>
</tbody>
{% endmacro %}
{% macro tags(tags, tags_has_more, has_prev, page, mode) %}
<thead>
<tr>
<th>Tag</th>
<th>Download</th>
<th>Author</th>
<th>Age</th>
</tr>
</thead>
<tbody>
{% for tag in tags %}
<tr>
<td><a href="/{{ repo.name }}/tag/?h={{ tag.name }}">{{ tag.name }}</a></td>
<td>
<a href="/{{ repo.name }}/snapshot/?h={{ tag.name }}">{{ tag.name }}.tar.gz</a>
</td>
<td>
{% if let Some(tagger) = tag.tagger %}
<span class="avatar">
<img class="inline" src="{{ tagger.avatar_url(20) }}">
<img class="onhover" src="{{ tagger.avatar_url(128) }}">
</span>
{{ tagger.name }}
{% endif %}
</td>
{% let time = tag.time.format_relative() %}
<td class="
{{ time.1 }}" title="{{ tag.time.format() }}">{{ time.0 }}</td>
</tr>
{% endfor %}
<tr class="no-background">
{% if mode == "tags" %}
<td colspan="4" class="pagination">
{% if has_prev %}
{% let offset = offset.saturating_sub(PAGE_SIZE) %}
{% if offset > 0 %}
<a href="/{{ repo.name }}/refs/tags/?ofs={{ offset }}">[prev]</a>
{% else %}
<a href="/{{ repo.name }}/refs/tags/">[prev]</a>
{% endif %}
{% endif %}
{% if tags_has_more %}
<a href="/{{ repo.name }}/refs/tags?ofs={{ offset.saturating_add(PAGE_SIZE) }}">[next]</a>
{% endif %}
</td>
{% else if tags_has_more %}
<td class="show_more">
<a href="/{{ repo.name }}/refs/tags">[...]</a>
</td>
{% endif %}
</tr>
</tbody>
{% endmacro %}
{% macro commits(commits, commits_has_more, has_prev, page, mode) %}
<thead>
<tr>
<th>Age</th>
<th>Commit message</th>
<th>Author</th>
</tr>
</thead>
<tbody>
{% for commit in commits %}
<tr>
{% let time = commit.author.time.format_relative() %}
<td class="{{ time.1 }}" title="{{ commit.author.time.format() }}">{{ time.0 }}</td>
<td>
<a href="/{{ repo.name }}/commit/?id={{ commit.id }}">{{ commit.summary()? | truncate(80)}}</a>
{% if commit.is_head(repo)? %}<a href="/{{ repo.name }}/commit/?id={{ commit.id }}" class="badge_head">HEAD</a>{% endif %}
{% for branch in commit.branch_tips(repo)? %}
<a href="/{{ repo.name }}/log/?h={{ branch }}" class="badge_branch">{{ branch }}</a>
{% endfor %}
</td>
<td>
<span class="avatar">
<img class="inline" src="{{ commit.author.avatar_url(20) }}">
<img class="onhover" src="{{ commit.author.avatar_url(128) }}">
</span>
{{ commit.author.name }}
</td>
</tr>
{% endfor %}
<tr class="no-background">
{% if mode == "log" %}
<td colspan="3" class="pagination">
{% if has_prev %}
{% let offset = offset.saturating_sub(PAGE_SIZE) %}
{% if offset > 0 %}
<a href="/{{ repo.name }}/log/?ofs={{ offset }}">[prev]</a>
{% else %}
<a href="/{{ repo.name }}/log/">[prev]</a>
{% endif %}
{% endif %}
{% if commits_has_more %}
<a href="/{{ repo.name }}/log/?ofs={{ offset.saturating_add(PAGE_SIZE) }}">[next]</a>
{% endif %}
</td>
{% else if commits_has_more %}
<td class="show_more">
<a href="/{{ repo.name }}/log/">[...]</a>
</td>
{% endif %}
</tr>
</tbody>
{% endmacro %}