<th1>
set trimmed $home
if {[string first / $home] == 0} {
  set trimmed [string range $home 1 end]
}
set slash [string first / $trimmed]
set owner ""
set repo_slug ""
if {$slash > 0} {
  set owner [string range $trimmed 0 [expr {$slash - 1}]]
  set rest [string range $trimmed [expr {$slash + 1}] end]
  set slash2 [string first / $rest]
  if {$slash2 > 0} {
    set repo_slug [string range $rest 0 [expr {$slash2 - 1}]]
  } else {
    set repo_slug $rest
  }
}
if {[string compare $owner ""] != 0} {
  set hub_root "/"
  set owner_url "/$owner"
} else {
  set hub_root "$home/"
  set owner_url "$home/"
}
set cp "/$current_page/"
set is_code [expr {[string match /dir/* $cp] || [string match /tree/* $cp] || [string match /file/* $cp] || [string match /finfo/* $cp] || [string match /artifact/* $cp] || [string match /fileage/* $cp] || [string match /doc/* $cp] || [string match /home/* $cp] || [string match /annotate/* $cp] || [string match /blame/* $cp]}]
set is_issues [expr {[string match /ticket/* $cp] || [string match /tkt* $cp] || [string match /report* $cp] || [string match /rpt* $cp]}]
set is_commits [expr {[string match /timeline/* $cp] || [string match /info/* $cp] || [string match /vdiff/* $cp] || [string match /ci_* $cp]}]
set is_branches [string match /brlist/* $cp]
set is_tags [string match /taglist/* $cp]
set is_wiki [expr {[string match /wiki* $cp] || [string match /whistory/* $cp]}]
set is_forum [string match /forum* $cp]
set is_chat [string match /chat* $cp]
set is_admin [expr {[string match /setup* $cp] || [string match /admin* $cp] || [string match /shun* $cp]}]
</th1>
<header class="gh-repo-header">
  <div class="gh-repo-global-bar">
    <div class="gh-repo-global-left">
      <a class="gh-brand" href="<th1>html $hub_root</th1>" title="Porjay Hub">
        <img src="$logo_image_url" alt="Porjay" width="26" height="26">
      </a>
      <nav class="gh-breadcrumbs" aria-label="Repository path">
        <th1>
          if {[string compare $owner ""] != 0} {
            html "<a class='gh-bc-owner' href='$owner_url'>$owner</a>"
            html "<span class='gh-bc-sep'>/</span>"
          }
          html "<a class='gh-bc-repo' href='$home/dir?ci=tip'>$project_name</a>"
        </th1>
      </nav>
    </div>
    <div class="gh-repo-global-right">
      <a class="gh-top-link" href="/explore">Explore</a>
      <a class="gh-top-link" href="/docs">Docs</a>
      <a class="gh-top-link" href="/new" title="New repository">+ New</a>
      <button type="button" class="gh-icon-btn" id="repo-theme-toggle" title="Toggle light/dark theme" aria-label="Toggle light/dark theme">
        <svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M9.598 1.591a.749.749 0 0 1 .785-.175 7.001 7.001 0 1 1-8.967 8.967.75.75 0 0 1 .961-.96 5.5 5.5 0 0 0 7.046-7.046.75.75 0 0 1 .175-.786Z"></path></svg>
      </button>
      <div class="status">
        <th1>
          if {[info exists login]} {
            html "<a class='gh-user-pill' href='$home/login'>$login</a>"
          } else {
            html "<a class='gh-btn gh-btn-sm' href='$home/login'>Sign in</a>"
          }
        </th1>
      </div>
    </div>
  </div>

  <div class="gh-repo-subhead">
    <div class="gh-repo-title-row">
      <div class="gh-repo-id">
        <svg class="octicon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg>
        <span class="gh-repo-name"><th1>if {[string compare $owner ""] != 0} { html "<a href='$owner_url'>$owner</a> / " }</th1><a href="$home/dir?ci=tip"><strong>$project_name</strong></a></span>
        <th1>
          if {[anycap o]} {
            html "<span class='gh-vis-badge'>Public</span>"
          } else {
            html "<span class='gh-vis-badge gh-vis-priv'>Private</span>"
          }
        </th1>
      </div>

      <div class="gh-repo-actions">
        <th1>
          if {[string compare $owner ""] != 0 && [capexpr {a s}]} {
            html "<a class='gh-btn gh-btn-sm' href='/u/repo/$owner/$repo_slug/settings'>Hub Settings</a>"
          }
        </th1>
        <div class="gh-code-wrap">
          <button type="button" class="gh-btn gh-btn-sm gh-btn-primary" id="gh-code-btn" aria-expanded="false">
            &lt;&gt; Code ▾
          </button>
          <div class="gh-code-popover" id="gh-code-popover" hidden>
            <div class="gh-pop-title">Clone with Porjay CLI</div>
            <div class="gh-clone-row">
              <input id="gh-clone-cmd" type="text" readonly value="porjay clone $baseurl">
              <button type="button" class="gh-btn gh-btn-sm" id="gh-clone-copy">Copy</button>
            </div>
            <div class="gh-pop-links">
              <a href="$home/zip/$project_name.zip">Download ZIP</a>
              <a href="$home/tarball/$project_name.tar.gz">Download Tarball</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <th1>
      if {[string compare $project_description ""] != 0} {
        html "<p class='gh-repo-desc'>$project_description</p>"
      }
    </th1>

    <nav class="mainmenu gh-repo-tabs" title="Main Menu">
      <th1>
        builtin_request_js hbmenu.js
        proc tabcls {flag} { if {$flag} { return "active" }; return "" }
        set c_code [tabcls $is_code]
        set c_iss [tabcls $is_issues]
        set c_com [tabcls $is_commits]
        set c_br [tabcls $is_branches]
        set c_tag [tabcls $is_tags]
        set c_wiki [tabcls $is_wiki]
        set c_for [tabcls $is_forum]
        set c_chat [tabcls $is_chat]
        set c_adm [tabcls $is_admin]
        html "<a href='$home/dir?ci=tip' class='$c_code'>Code</a>\n"
        if {[capexpr r]} { html "<a href='$home/ticket' class='$c_iss'>Issues</a>\n" }
        if {[capexpr {o r j}]} { html "<a href='$home/timeline' class='$c_com'>Commits</a>\n" }
        if {[capexpr o]} {
          html "<a href='$home/brlist' class='$c_br'>Branches</a>\n"
          html "<a href='$home/taglist' class='$c_tag'>Tags</a>\n"
        }
        if {[capexpr j]} { html "<a href='$home/wiki' class='$c_wiki'>Wiki</a>\n" }
        if {[capexpr {2 3 4 5 6}]} { html "<a href='$home/forum' class='$c_for'>Forum</a>\n" }
        if {[capexpr C]} { html "<a href='$home/chat' class='$c_chat'>Chat</a>\n" }
        if {[capexpr {a s}]} { html "<a href='$home/setup' class='$c_adm'>Admin</a>\n" }
        html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776; More</a>\n"
      </th1>
    </nav>
    <nav id="hbdrop" class="hbdrop" title="sitemap"></nav>
  </div>
</header>
<div class="gh-page-title-bar">
  <h1 class="page-title">$<title></h1>
</div>
