This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
/
archpages.go
201 lines (169 loc) · 8.64 KB
/
archpages.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package main
import (
"strconv"
"time"
"github.com/hoisie/web"
. "github.com/xyproto/genericsite"
. "github.com/xyproto/onthefly"
"github.com/xyproto/permissions2"
"github.com/xyproto/pinterface"
. "github.com/xyproto/siteengines"
)
const (
author = "Alexander F Rødseth"
)
// The default settings for Arch Linux content pages
func ArchBaseCP(state pinterface.IUserState) *ContentPage {
cp := DefaultCP(state)
cp.Title = "Arch Linux"
cp.Subtitle = "no"
y := time.Now().Year()
// TODO: Use templates for the footer, for more accurate measurment of the time made to generate the page
cp.FooterText = author + ", " + strconv.Itoa(y)
cp.Url = "/" // Is replaced when the contentpage is published
cp.ColorScheme = NewArchColorScheme()
// Behind the text
//cp.BgImageURL = "/img/nasty_fabric.png"
//cp.BgImageURL = "/img/cloth_alike.png"
//cp.BgImageURL = "/img/strange_bullseyes.png"
cp.BgImageURL = "/img/rough_diagonal.png"
cp.StretchBackground = false
// Behind the menu
//cp.BackgroundTextureURL = "/img/bg2.png"
//cp.BackgroundTextureURL = "/img/simple_dashed.png"
//cp.BackgroundTextureURL = "/img/grey.png"
//cp.BackgroundTextureURL = "/img/pw_maze_black.png"
//cp.BackgroundTextureURL = "/img/black_twill.png"
cp.BackgroundTextureURL = "/img/dark_wood.png"
//cp.BackgroundTextureURL = "/img/hixs_pattern_evolution.png"
//ps_neutral.png"
return cp
}
// Returns a ArchBaseCP with the contentTitle set
func ArchBaseTitleCP(contentTitle string, userState pinterface.IUserState) *ContentPage {
cp := ArchBaseCP(userState)
cp.ContentTitle = contentTitle
return cp
}
func OverviewCP(userState pinterface.IUserState, url string) *ContentPage {
cp := ArchBaseCP(userState)
cp.ContentTitle = "Arch Linux Norway"
//cp.ContentHTML = `This site is currently under construction.<br />Visit the <a href="https://bbs.archlinux.org/viewtopic.php?id=4998">Arch Linux Forum</a> in the meantime.<br /><br /><i>- Alexander Rødseth <rodseth / gmail></i>`
cp.ContentHTML = `<img src="/img/arch-linux-logo.png">`
cp.Url = url
return cp
}
func MirrorsCP(userState pinterface.IUserState, url string) *ContentPage {
cp := ArchBaseCP(userState)
cp.ContentTitle = "Mirrors"
cp.ContentHTML = "List over Norwegian Arch Linux mirrors:"
cp.Url = url
return cp
}
func CountCP(userState pinterface.IUserState, url string) *ContentPage {
apc := ArchBaseCP(userState)
apc.ContentTitle = "Counting"
apc.ContentHTML = "1 2 3"
apc.Url = url
return apc
}
func BobCP(userState pinterface.IUserState, url string) *ContentPage {
apc := ArchBaseCP(userState)
apc.ContentTitle = "Bob"
if userState.HasUser("bob") {
apc.ContentHTML = "has bob, l "
} else {
apc.ContentHTML = "no bob, l "
}
if userState.IsLoggedIn("bob") {
apc.ContentHTML += "yes"
} else {
apc.ContentHTML += "no"
}
apc.Url = url
return apc
}
func JQueryCP(userState pinterface.IUserState, url string) *ContentPage {
apc := ArchBaseCP(userState)
apc.ContentTitle = "JQuery"
apc.ContentHTML = "<button id=clickme>bob</button><br />"
apc.ContentHTML += "<div id=status>status</div>"
//apc.contentJS = OnClick("#clickme", GetTest())
//apc.contentJS += OnClick("#clickme", SetText("#clickme", "ost"))
//apc.contentJS += OnClick("#clickme", SetTextFromURL("#clickme", "http://archlinux.no/status/bob"))
//apc.contentJS += OnClick("#clickme", GetTest())
apc.ContentJS += Load("#status", "/status/elg")
apc.ContentJS += OnClick("#clickme", Load("#status", "/status/bob"))
apc.ContentJS += SetText("#menuJQuery", "Heppa")
apc.Url = url
return apc
}
func TextCP(userState pinterface.IUserState, url string) *ContentPage {
apc := ArchBaseCP(userState)
apc.ContentTitle = "YOLO narwhal"
apc.ContentHTML = `<p>Locavore Austin fanny pack pickled. Marfa hoodie pitchfork american apparel, flexitarian YOLO pickled keytar twee cred craft beer seitan authentic raw denim kogi. Selvage mixtape blog, pickled cosby sweater williamsburg skateboard brooklyn lo-fi twee. Blue bottle echo park kale chips, selvage fap skateboard swag chambray tousled. Street art etsy four loko fap, iphone carles cliche banh mi fashion axe PBR authentic leggings. Narwhal mumblecore street art tumblr. Messenger bag vice art party, next level aesthetic church-key tumblr direct trade typewriter street art.</p><p>Messenger bag blue bottle VHS before they sold out. Artisan pickled swag, VHS meggings jean shorts blog tonx salvia cosby sweater mumblecore aesthetic literally narwhal. Brunch tofu gluten-free disrupt blog occupy. Austin bicycle rights sartorial narwhal, butcher trust fund cred. Neutra kale chips letterpress literally, williamsburg kogi brunch bicycle rights. Williamsburg craft beer brunch quinoa, forage YOLO swag put a bird on it four loko mixtape banksy. Tumblr semiotics yr fixie.</p><p>Iphone banksy wolf squid wayfarers, VHS photo booth banh mi fap. Tonx flexitarian vinyl scenester terry richardson squid synth deep v. VHS tousled godard, cardigan american apparel lo-fi flannel. Vice church-key cliche, hashtag banh mi direct trade skateboard. Sriracha meh pitchfork, wayfarers helvetica leggings try-hard viral YOLO lo-fi fingerstache synth ennui next level ugh. Wayfarers organic american apparel fingerstache craft beer bicycle rights, beard keffiyeh banksy four loko butcher hashtag mumblecore banjo wes anderson. Williamsburg next level deep v pickled typewriter kogi.</p><p>Meggings gastropub flexitarian, before they sold out DIY wes anderson cred authentic artisan dreamcatcher aesthetic ennui food truck. Fanny pack selvage synth vegan pug. YOLO shoreditch pitchfork, letterpress whatever put a bird on it truffaut mumblecore flannel terry richardson irony cray master cleanse ethnic gluten-free. Fap banksy blog pickled meh ethnic food truck +1, vice leggings retro quinoa. Small batch vice pop-up mustache. +1 ethnic echo park semiotics letterpress raw denim. Keytar photo booth wes anderson, freegan before they sold out skateboard seitan brooklyn.</p><p>Wes anderson high life banksy messenger bag art party plaid disrupt tattooed, next level swag viral raw denim. Cliche meggings terry richardson cray. Next level 3 wolf moon retro marfa. Pork belly authentic banjo, iphone lomo williamsburg letterpress cosby sweater Austin typewriter quinoa skateboard hoodie. Plaid kale chips godard farm-to-table. Fashion axe mixtape freegan, pop-up chambray ugh etsy YOLO jean shorts dreamcatcher meggings. Banh mi letterpress tousled, skateboard stumptown high life vegan fap typewriter shoreditch 8-bit lo-fi master cleanse selfies bespoke.</p>`
apc.Url = url
return apc
}
func HelloCP(userState pinterface.IUserState, url string) *ContentPage {
apc := ArchBaseCP(userState)
apc.ContentTitle = "This is it"
apc.Url = url
return apc
}
// This is where the possibilities for the menu are listed
// TODO: Find a way to support many languages
// TODO: Refactor this ugly function
func Cps2MenuEntries(cps []ContentPage) MenuEntries {
links := []string{
"Overview:/",
"Login:/login",
"Register:/register",
"Logout:/logout",
"Admin:/admin",
"Chat:/chat",
"Wiki:/wiki",
//"Text:/text",
}
//for _, cp := range cps {
// text_and_url := cp.ContentTitle + ":" + cp.Url
// links = append(links, text_and_url)
//}
return Links2menuEntries(links)
}
// Routing for the archlinux.no webpage
// Admin, search and user management is already provided
func ServeArchlinuxNo(userState *permissions.UserState, jquerypath string) MenuEntries {
cps := []ContentPage{
*OverviewCP(userState, "/"),
//*TextCP(userState, "/text"),
*JQueryCP(userState, "/jquery"),
*BobCP(userState, "/bob"),
*CountCP(userState, "/counting"),
*MirrorsCP(userState, "/mirrors"),
*HelloCP(userState, "/feedback"),
*LoginCP(ArchBaseCP, userState, "/login"),
*RegisterCP(ArchBaseCP, userState, "/register"),
}
menuEntries := Cps2MenuEntries(cps)
// template content generator
tvgf := DynamicMenuFactoryGenerator(menuEntries)
// TODO: Simplify ServeSearchPages to take fewer parameters
ServeSearchPages(ArchBaseCP, userState, cps, ArchBaseCP(userState).ColorScheme, tvgf(userState))
ServeSite(ArchBaseCP, userState, cps, tvgf, jquerypath)
// "dynamic" pages
// Makes helloSF handle the content for /hello/(.*) urls, but wrapped in a BaseCP with the title "Hello"
web.Get("/hello/(.*)", ArchBaseTitleCP("Hello", userState).WrapWebHandle(helloHandle, tvgf(userState)))
return menuEntries
}
func NewArchColorScheme() *ColorScheme {
var cs ColorScheme
cs.Darkgray = "#202020"
cs.Nicecolor = "#5080D0" // nice blue
cs.Menu_link = "#c0c0c0" // light gray
cs.Menu_hover = "#efefe0" // light gray, somewhat yellow
cs.Menu_active = "#ffffff" // white
cs.Default_background = "#000030"
cs.TitleText = "#e0e0e0" // The first word of the title text
return &cs
}