1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| {% import ( "fmt" "net/http"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/lib/menu" "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/components" ) %}
{% func Nav(as *app.State, ps *cutil.PageState) %}{%- if !ps.HideHeader -%}
<nav id="navbar"> <a class="logo" href="{%s ps.RootPath %}" title="{%s util.AppName %} {%s as.BuildInfo.String() %}">{%= components.SVGSimple(ps.RootIcon, 32, ps) %}</a> <div class="breadcrumbs"> {%- code extra := util.Choose(len(ps.Breadcrumbs) == 0, " simple", "") -%} <a href="{%s ps.RootPath %}" class="nav-root-icon{%s extra %}" title="{%s util.AppName %}">{%= components.SVGBreadcrumb(ps.RootIcon, ps) %}</a> <a class="link nav-root-item{%s extra %}" href="{%s ps.RootPath %}">{%s ps.RootTitle %}</a>{%= NavItems(ps) %} </div>{{{ if .HasModule "search" }}} {%- if ps.SearchPath != "-" -%} <form action="{%s ps.SearchPath %}" class="search" title="search"> <input id="search-input" type="search" name="q" placeholder=" " /> <div class="search-image" style="display: none;"><svg><use xlink:href="#svg-searchbox" /></svg></div> </form> {%- endif -%}{{{ end }}}{{{ if .HasModule "help" }}} {%= Help(as, ps) %}{{{ end }}} {%= ProfileLink(as, ps) %} {%- if !ps.HideMenu -%} <input type="checkbox" id="menu-toggle-input" style="display: none;" /> <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> {%= Menu(ps) %} {%- endif -%} </nav>{%- endif -%}{% endfunc %}
{% func NavItem(link string, title string, icon string, description string, last bool, ps *cutil.PageState) %}{% stripspace %} {% code shouldLink := link != "" || (last && ps.Method == http.MethodGet) %} {% if shouldLink %} {%- code extra := util.Choose(description == "", "", fmt.Sprintf(" title=%q", description)) -%} <a class="link{% if last %}{% space %}last{% endif %}" href="{%s link %}"{%s= extra %}> {% endif %}
<span>{%= components.SVGBreadcrumb(icon, ps) %}</span> <span class="nav-item-title">{%s title %}</span>
{% if shouldLink %} </a> {% endif %} {% endstripspace %}{% endfunc %}
{% func NavItems(ps *cutil.PageState) %}{% stripspace %} {% for idx, bc := range ps.Breadcrumbs %} {% code i := ps.Menu.GetByPath(ps.Breadcrumbs[:idx + 1]) if i == nil { i = menu.ItemFromString(bc, ps.DefaultNavIcon) } %} {%= components.Indent(true, 2) %} <span class="separator">/</span> {%= components.Indent(true, 2) %} {%= NavItem(i.Route, i.Title, i.Icon, i.Description, idx == len(ps.Breadcrumbs) - 1, ps) %} {% endfor %} {% endstripspace %}{% endfunc %}
{% func ProfileLink(as *app.State, ps *cutil.PageState) %}{% stripspace %} <a class="profile" title="{{{ if .HasAccount }}}{%s ps.AuthString() %}{{{ else }}}Settings{{{ end }}}" href="{%s ps.ProfilePath %}">{{{ if .HasAccount }}} {%- if i := ps.Accounts.Image(); i != "" -%} <img style="width: 24px; height: 24px;" src="{%s i %}" /> {%- else -%} {%= components.SVGSimple(`profile`, 24, ps) %} {%- endif -%}{{{ else }}} {%= components.SVGSimple(`profile`, 24, ps) %}{{{ end }}} </a> {% endstripspace %}{% endfunc %}
|