-
Notifications
You must be signed in to change notification settings - Fork 1
/
page_generics.go
76 lines (69 loc) · 2.48 KB
/
page_generics.go
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
76
// ThingsConstruction, a code generator for WoT-based models
// Copyright (C) 2017,2018 @aschmidt75
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// This program is dual-licensed. For commercial licensing options, please
// contact the author(s).
//
//
package main
import "context"
// Generic Page Data, valid for all pages
// template data embeds this struct
type PageData struct {
Title string
MetaDescription string
Feature map[string]bool
CopyrightLine string
Notices string
LinkedInUrl string
TwitterUrl string
GitHubUrl string
FlattrId string
FlattrUser string
InBlog bool
InApp bool
InContact bool
Robots bool
}
func (pd *PageData) SetFeaturesFromConfig() {
pd.Feature = map[string]bool{
"Blog": ServerConfig.Features.Blog,
"App": ServerConfig.Features.App,
"Contact": ServerConfig.Features.Contact,
"Twitter": ServerConfig.Features.Twitter,
"LinkedIn": ServerConfig.Features.LinkedIn,
"GitHub": ServerConfig.Features.GitHub,
"Analytics": ServerConfig.Features.Analytics,
"Shariff": ServerConfig.Features.Shariff,
"VoteForGenerators": ServerConfig.Features.VoteForGenerators,
"Flattr": ServerConfig.Features.Flattr,
}
pd.CopyrightLine = ServerConfig.StaticTexts.CopyrightLine
pd.Notices = ServerConfig.StaticTexts.Notices
pd.LinkedInUrl = ServerConfig.StaticTexts.LinkedInUrl
pd.TwitterUrl = ServerConfig.StaticTexts.TwitterUrl
pd.GitHubUrl = ServerConfig.StaticTexts.GitHubUrl
pd.FlattrId = ServerConfig.StaticTexts.FlattrId
pd.FlattrUser = ServerConfig.StaticTexts.FlattrUser
pd.InApp = false
}
func (pd *PageData) UpdateFeaturesFromContext(ctx context.Context) {
if nocookies := ctx.Value("tc-nocookies"); nocookies != nil {
if nocookies == true {
pd.Feature["Analytics"] = false
}
}
}