github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/layout/Nav.html (about)

     1  <!-- Content managed by Project Forge, see [projectforge.md] for details. -->
     2  {% import (
     3    "github.com/kyleu/dbaudit/app"
     4    "github.com/kyleu/dbaudit/app/controller/cutil"
     5    "github.com/kyleu/dbaudit/app/lib/menu"
     6    "github.com/kyleu/dbaudit/app/util"
     7    "github.com/kyleu/dbaudit/views/components"
     8  ) %}
     9  
    10  {% func Nav(as *app.State, ps *cutil.PageState) %}
    11  <nav id="navbar">
    12    <a class="logo" href="{%s ps.RootPath %}" title="{%s util.AppName %} {%s as.BuildInfo.String() %}">{%= components.SVGRef(ps.RootIcon, 32, 32, ``, ps) %}</a>
    13    <div class="breadcrumbs">
    14      <a href="{%s ps.RootPath %}" class="nav-root-icon" title="{%s util.AppName %}">{%= components.SVGRef(ps.RootIcon, 18, 28, "breadcrumb-icon", ps) %}</a>
    15      <a class="link nav-root-item" href="{%s ps.RootPath %}">{%s ps.RootTitle %}</a>{%= NavItems(ps) %}
    16    </div>
    17    {%- if ps.SearchPath != "-" -%}
    18    <form action="{%s ps.SearchPath %}" class="search" title="search">
    19      <input id="search-input" type="search" name="q" placeholder=" " />
    20      <div class="search-image" style="display: none;"><svg><use xlink:href="#svg-searchbox" /></svg></div>
    21    </form>
    22    {%- endif -%}
    23    {%= ProfileLink(as, ps) %}
    24    {%- if !ps.HideMenu -%}
    25    <input type="checkbox" id="menu-toggle-input" style="display: none;" />
    26    <label class="menu-toggle" for="menu-toggle-input"><div class="spinner diagonal part-1"></div><div class="spinner horizontal"></div><div class="spinner diagonal part-2"></div></label>
    27    {%= Menu(ps) %}
    28    {%- endif -%}
    29  </nav>{% endfunc %}
    30  
    31  {% func NavItem(link string, title string, icon string, last bool, ps *cutil.PageState) %}{% stripspace %}
    32    {% if link != "" || last %}
    33    <a class="link{% if last %}{% space %}last{% endif %}" href="{%s link %}">
    34    {% endif %}
    35      <span title="{%s title %}">{%= components.SVGRef(icon, 18, 28, "breadcrumb-icon", ps) %}</span>
    36      <span class="nav-item-title">{%s title %}</span>
    37    {% if link != "" || last %}
    38    </a>
    39    {% endif %}
    40  {% endstripspace %}{% endfunc %}
    41  
    42  {% func NavItems(ps *cutil.PageState) %}{% stripspace %}
    43    {% for idx, bc := range ps.Breadcrumbs %}
    44      {% code
    45        i := ps.Menu.GetByPath(ps.Breadcrumbs[:idx + 1])
    46        if i == nil {
    47          i = menu.ItemFromString(bc, ps.DefaultNavIcon)
    48        }
    49      %}
    50      {%= components.Indent(true, 2) %}
    51      <span class="separator">/</span>
    52      {%= components.Indent(true, 2) %}
    53      {%= NavItem(i.Route, i.Title, i.Icon, idx == len(ps.Breadcrumbs) - 1, ps) %}
    54    {% endfor %}
    55  {% endstripspace %}{% endfunc %}
    56  
    57  {% func ProfileLink(as *app.State, ps *cutil.PageState) %}{% stripspace %}
    58    <a class="profile" title="{%s ps.AuthString() %}" href="{%s ps.ProfilePath %}">
    59      {%- if i := ps.Accounts.Image(); i != "" -%}
    60        <img style="width: 24px; height: 24px;" src="{%s i %}" />
    61      {%- else -%}
    62        {%= components.SVGRef(`profile`, 24, 24, ``, ps) %}
    63      {%- endif -%}
    64    </a>
    65  {% endstripspace %}{% endfunc %}