kitgit

tirbofish/kitgit

main / templates / partials / branch_bar.html · 3282 bytes

templates/partials/branch_bar.html
{# Expects: owner, repo, branch, latest_commit: Option<CommitView>, access, upload_path, commit_count #}
<div class="kg-toolbar">
  <a class="kg-btn kg-btn--ghost kg-toolbar__branch" href="/{{ owner.username }}/{{ repo.name }}/branches">
    <span class="kg-icon" style="--icon:url('/static/icons/git-branch.svg')"></span>
    {{ branch }}
  </a>
  <div class="kg-toolbar__actions">
    {% if upload_path != "" %}
    <a class="kg-btn kg-btn--ghost" href="/{{ owner.username }}/{{ repo.name }}/archive.zip?ref={{ branch }}&path={{ upload_path }}" title="Download this folder as ZIP">
      <span class="kg-icon" style="--icon:url('/static/icons/download.svg')"></span>
      download folder
    </a>
    {% else %}
    <a class="kg-btn kg-btn--ghost" href="/{{ owner.username }}/{{ repo.name }}/archive.zip?ref={{ branch }}" title="Download repository as ZIP">
      <span class="kg-icon" style="--icon:url('/static/icons/download.svg')"></span>
      download
    </a>
    {% endif %}
    {% if access.can_write() %}
    <details class="kg-dropdown">
      <summary class="kg-btn kg-btn--ghost">
        <span class="kg-icon" style="--icon:url('/static/icons/upload.svg')"></span>
        upload
        <span class="kg-icon" style="--icon:url('/static/icons/chevron-down.svg')"></span>
      </summary>
      <div class="kg-dropdown__panel kg-dropdown__panel--upload">
        <form class="kg-upload" method="post" action="/{{ owner.username }}/{{ repo.name }}/upload" enctype="multipart/form-data">
          <input type="hidden" name="branch" value="{{ branch }}" />
          <input type="hidden" name="path" value="{{ upload_path }}" />
          <label class="kg-upload__file">
            <span class="kg-meta">File</span>
            <input type="file" name="file" required />
          </label>
          <label class="kg-upload__message">
            <span class="kg-meta">Commit message</span>
            <input type="text" name="message" placeholder="Commit message" value="Upload file" />
          </label>
          <button class="kg-btn" type="submit">
            <span class="kg-icon" style="--icon:url('/static/icons/upload.svg')"></span>
            commit file
          </button>
        </form>
      </div>
    </details>
    {% endif %}
  </div>
</div>

{% if let Some(c) = latest_commit %}
<div class="kg-latest">
  <div class="kg-latest__main">
    {% if let Some(uname) = c.author_username %}
      <a class="kg-latest__author" href="/{{ uname }}">{{ c.author }}</a>
    {% else %}
      <span class="kg-latest__author">{{ c.author }}</span>
    {% endif %}
    <a class="kg-latest__msg" href="/{{ owner.username }}/{{ repo.name }}/commit/{{ c.id }}" title="{{ c.message }}">{{ c.message }}</a>
  </div>
  <div class="kg-latest__meta">
    <a class="kg-latest__sha" href="/{{ owner.username }}/{{ repo.name }}/commit/{{ c.id }}" title="{{ c.id }}">
      <code>{{ c.short_id }}</code>
    </a>
    {% let show_unverified = false %}
    {% include "partials/verified_badge.html" %}
    <time class="kg-meta kg-latest__time">{{ c.time_display() }}</time>
    <a class="kg-latest__count kg-meta" href="/{{ owner.username }}/{{ repo.name }}/commits" title="{{ commit_count }} commits">
      {{ commit_count }} commits
    </a>
  </div>
</div>
{% endif %}