Skip to content

Commit

Permalink
Pass submission enabled flag to site templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jun 19, 2022
1 parent 8e0a60f commit bce2d6e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
14 changes: 8 additions & 6 deletions cmd/dictpress/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ type pageTpl struct {
// into public templates for accessing data.
type tplData struct {
// These are available in the template as .Page, .Data etc.
RootURL string
Langs data.LangMap
RootURL string
EnableSubmissions bool
Langs data.LangMap

Path string
Data interface{}
Expand Down Expand Up @@ -221,9 +222,10 @@ func (t *tplRenderer) Render(w io.Writer, name string, data interface{}, c echo.
app := c.Get("app").(*App)

return t.tpls.ExecuteTemplate(w, name, tplData{
Path: c.Path(),
RootURL: app.constants.RootURL,
Langs: app.data.Langs,
Data: data,
Path: c.Path(),
RootURL: app.constants.RootURL,
EnableSubmissions: app.constants.EnableSubmissions,
Langs: app.data.Langs,
Data: data,
})
}
4 changes: 3 additions & 1 deletion site/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
{{ define "footer" }}
<nav class="nav">
<a href="/glossary/english/italian/a">Glossary</a>
<a href="/submit">Submit new</a>
{{ if .EnableSubmissions }}
<a href="/submit">Submit new</a>
{{ end }}
<a href="/pages/about">About</a>
</nav>
</div>
Expand Down
9 changes: 7 additions & 2 deletions site/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{{ range $k, $r := .Data.Results.Entries }}
<li class="entry" data-guid="{{ $r.GUID }}">
<header class="head">
<a href="" data-from="{{ $r.GUID }}" class="edit" title="Suggest edit">✏️</a>
{{ if $.EnableSubmissions }}
<a href="" data-from="{{ $r.GUID }}" class="edit" title="Suggest edit">✏️</a>
{{ end }}
<h3 class="title">{{ $r.Content }}</h3>
<span class="pronun">♪ {{ JoinStrings $r.Phones "," }}</span>
</header>
Expand All @@ -20,7 +22,10 @@ <h3 class="title">{{ $r.Content }}</h3>
<li>
<div data-guid="{{ $d.GUID }}" class="def">
{{ $d.Content }}
<a href="" data-from="{{ $r.GUID }}" data-to="{{ $d.GUID }}" class="edit" title="Suggest edit">✏️</a>

{{ if $.EnableSubmissions }}
<a href="" data-from="{{ $r.GUID }}" data-to="{{ $d.GUID }}" class="edit" title="Suggest edit">✏️</a>
{{ end }}
</div>
</li>
{{ $prevTypes = $types }}
Expand Down

0 comments on commit bce2d6e

Please sign in to comment.