~netlandish/links

bb9bd2ac32e8c51d8d10762828e7060c2da65dbc — Peter Sanchez 9 months ago aa7aaa3
Hiding navigation when browsing user domain
3 files changed, 13 insertions(+), 6 deletions(-)

M core/templates.go
M templates/base.html
M templates/link_list.html
M core/templates.go => core/templates.go +8 -1
@@ 2,6 2,7 @@ package core

import (
	"links"
	"links/domain"
	"links/internal/localizer"
	"links/models"
	"log"


@@ 48,10 49,16 @@ func AddGlobalTmpl(c echo.Context) gobwebs.Map {
	gmap["serverVersion"] = serverVersion[len(serverVersion)-1]

	// Show left setting menu for oauth links
	if strings.Contains(c.Path(), "oauth2/") {
	if strings.Contains(c.Path(), "/oauth2/") {
		gmap["settingSection"] = true
	}

	dom := domain.ForContext(c.Request().Context())
	if dom.Level == models.DomainLevelUser && dom.OrgID.Valid {
		gmap["isUserDomain"] = true
		gmap["hideNav"] = true
	}

	if gctx.User != nil && gctx.User.IsAuthenticated() {
		gmap["isAuthorized"] = true
		user := gctx.User.(*models.User)

M templates/base.html => templates/base.html +1 -1
@@ 217,7 217,7 @@
  {{if .useTagAutocomplete}}
    <script src="{{staticURL "js/autocomplete.js"}}?{{.serverVersion}}"></script>
  {{end}}
  {{if .advancedSearch}}
  {{if and (not .hideNav) (.advancedSearch)}}
    <script src="{{staticURL "js/advancedsearch.js"}}?{{.serverVersion}}"></script>
  {{end}}
</html>

M templates/link_list.html => templates/link_list.html +4 -4
@@ 1,6 1,6 @@
{{template "base" .}}
<form method="GET"
    action="{{if .isPopular}}{{reverse "core:popular_link_list"}}{{else if .isOrgLink}}{{reverse "core:home_link_list"}}{{else}}{{reverse "core:recent_link_list"}}{{end}}"
    action="{{ if .isUserDomain }}/{{ else }}{{if .isPopular}}{{reverse "core:popular_link_list"}}{{else if .isOrgLink}}{{reverse "core:home_link_list"}}{{else}}{{reverse "core:recent_link_list"}}{{end}}{{ end }}"
    id="advanced-search-form">
    <section class="app-header app-header-advanced-search">
        <h1 class="app-header__title">{{ if .isOrgLink }}{{ .org.Name }} {{.pd.Title}}{{else if not .isPopular}}{{.pd.Data.recent}}{{else}}{{.pd.Data.popular}}{{end}}</h1>


@@ 13,10 13,10 @@
                    </svg>
                </button>
            </div>
            <p class="text-right"><a href="#" id="advanced-search-btn">{{.pd.Data.advanced_search}}</a></p>
            {{ if not .hideNav }}<p class="text-right"><a href="#" id="advanced-search-btn">{{.pd.Data.advanced_search}}</a></p>{{ end }}
        </div>
    </section>
    {{if .advancedSearch}}
    {{if and (not .hideNav) (.advancedSearch)}}
    <section id="advanced-search-div" {{if and (not .tagFilter) (not .excludeTagFilter)}}class="d-none"{{end}}>
        <div class="row">
            <div class="col-5"><label>{{.pd.Data.include_tags}}</label></div>


@@ 41,7 41,7 @@
    {{end}}
</form>
<section class="card shadow-card">
  {{if .isOrgLink}}
  {{if and (not .hideNav) .isOrgLink}}
    <p>
        <a class="filter-btn{{if .hasAllFilter}} active{{end}}" href="{{.currURL}}">{{.pd.Data.all}}</a>
        <a class="filter-btn{{if .hasUnreadFilter}} active{{end}}" href="?filter=unread">{{.pd.Data.unread}}</a>