-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpages.osl
More file actions
48 lines (41 loc) · 1.22 KB
/
pages.osl
File metadata and controls
48 lines (41 loc) · 1.22 KB
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
def homePage(*gin.Context c) (
string token = getCookie(c, "auth_token")
string username = getCookie(c, "username")
array notesData = []
if token != "" (
array notes = listNotesWithMetadata(token)
// Sort by edited time (most recent first)
notes = notes.sortBy("edited")
for i notes.len (
string title = notes[i].title.assert(string)
string content = readNote(token, title)
array tags = readTags(token, title)
string preview = content
if len(preview) > 400 (
preview = preview.trim(1, 400) ++ "..."
)
notesData.append({
title: title,
content: content,
preview: preview,
tags: tags
})
)
)
c.HTML(200, "index.html", {
ActivePage: "notes",
Notes: notesData,
Authenticated: token != "",
Username: username
})
)
def authPage(*gin.Context c) (
c.HTML(200, "auth.html", {})
)
def storagePage(*gin.Context c) (
string token = getCookie(c, "auth_token")
c.HTML(200, "storage.html", {
ActivePage: "storage",
Authenticated: token != ""
})
)