-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
91 lines (90 loc) · 2.91 KB
/
app.js
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
const srf = new SRF();
let srf_api = {}
srf.send.get("/api.json").then(result => {
srf_api = JSON.parse(result.responseText)
}).catch(e => {
alert("Can't reach api." + e)
})
srf.load.style("https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css")
srf.route("/", () => {
srf.page.set.title("SRF Framework")
srf.page.style.body("p-2 m-2")
srf.page.set.loadStatus()
let nav = new Nav({
class: "navbar navbar-expand-lg bg-dark navbar-dark rounded-4 fixed-top m-4",
brand: `<div class="d-flex"><img src="/assets/images/logo.png" style="width: 32px"><span class="ms-2">SRF Framework</span></div>`,
list: {
type: "ul",
class: "ms-auto my-2 my-lg-0"
},
items: [
{ label: "Home", url: "", active: true },
{ label: "Docs", url: "docs" },
],
})
nav.present()
srf.page.append.body(srf.load.template("views/home"))
})
srf.route("/docs", () => {
srf.page.set.title("SRF Docs")
srf.page.style.body("p-2 m-2 mt-5")
srf.page.set.loadStatus()
let nav = new Nav({
class: "navbar navbar-expand-lg bg-dark navbar-dark rounded-4 fixed-top m-4",
brand: `<div class="d-flex"><img src="/assets/images/logo.png" style="width: 32px"><span class="ms-2">SRF Framework</span></div>`,
list: {
type: "ul",
class: "ms-auto my-2 my-lg-0"
},
items: [
{ label: "Home", url: "" },
{ label: "Docs", url: "docs", active: true },
],
})
nav.present()
srf.page.append.body(srf.load.template("views/docs_home"))
})
srf.route("/docs/{all}", async (doc) => {
if (srf_api.docs === undefined) {
await srf.send.get("/api.json").then(result => {
srf_api = JSON.parse(result.responseText)
}).catch(e => {
alert("Can't reach api." + e)
})
}
srf.page.set.title("SRF Docs")
srf.page.style.body("p-2 m-2")
srf.page.set.loadStatus()
let nav = new Nav({
class: "navbar navbar-expand-lg bg-dark navbar-dark rounded-4",
brand: `<div class="d-flex"><img src="/assets/images/logo.png" style="width: 32px"><span class="ms-2">SRF Framework</span></div>`,
list: {
type: "ul",
class: "ms-auto my-2 my-lg-0"
},
items: [
{ label: "Home", url: "" },
{ label: "Docs", url: "docs", active: true },
],
})
nav.present()
doc = srf_api.docs.filter(d => d.document === doc[0])
let body = ""
if (doc[0] !== undefined) {
srf.page.set.title("SRF Docs - " + doc[0].name)
body = srf.load.template("views/docs", {
"title": doc[0].name,
"contents": doc[0].contents,
"version": doc[0].version_code,
"author.name": doc[0].writer.name,
"author.image": doc[0].writer.image,
"author.description": doc[0].writer.description
})
} else {
alert("Documentation is not complete, please check up later.")
srf.page.redirect("docs")
}
srf.page.append.body(body)
})
srf.route("/404", () => { srf.page.set.title("404 Not Found"); srf.page.set.body("Not Found") })
srf.run()