-
Notifications
You must be signed in to change notification settings - Fork 0
/
posts.sim
86 lines (73 loc) · 2.89 KB
/
posts.sim
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
#!simple
display "Content-Type: text/html "+nl+nl
call web.functions.Methods
callModule("libsimple_sqlite")
pageTitle = "Blog"
postId = GET["post_id"] #get the post id for a article
call "header.sim" #call the header file for html assets e.g css, js
db = __init_sqlite3()
__sqlite3_open("simple_lang_io.db", db)
if postId == "" {
display `
<div class="blog posts" style="margin:3%;">
<span style="font-weight: bold;font-size:40px;">Articles</span><br /><br />`
blogs = __sqlite3_exec(db,"select * from BLOG order by Date desc Limit 50")
for blog in blogs {
if blog[:External] == "true" {
display `
<div class="articles" style="margin-top:20px;width:70%;">
<a target="_blank" href="` + blog[:Slug] + `" class="title">` + blog[:Title] + `</a>
<br /><span style="font-size:12px;">` + blog[:Date] + `<span>
<!-- <p> ` + blog[:Excerpt] + `</p>-->
</div>
`
else
display `
<div class="articles" style="margin-top:20px;width:70%;">
<a href="` + baseUrl + `blog/` + blog[:Id] + `" class="title">` + blog[:Title] + `</a>
<br /><span style="font-size:12px;">` + blog[:Date] + `<span>
<p>` + blog[:Excerpt] + `</p>
</div>
`
}
}
display `
</div>
`
elif strContains(postId, '-')
#fetch by slug
article = __sqlite3_exec(db,"select * from BLOG where Slug='" + postId + "'")
if lengthOf(article) > 0 {
display `<div class="article" >
<span style="font-weight: bold;font-size:30px;">` + article[0][:Title] + `</span><br /><br />
<span style="font-weight: bold;font-size:17px;">` /*+ article[0][:Author] + ` - `*/ + article[0][:Date] + `</span><br /><br />
<p id="markdown-paragraph"></p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
<script>
var converter = new showdown.Converter(),
text = '` + escapeString(article[0][:Content]) + `';
document.getElementById('markdown-paragraph').innerHTML = converter.makeHtml(text);
</script>
`
}
else
#fetch by number
article = __sqlite3_exec(db,"select * from BLOG where Id=" + postId + "")
if lengthOf(article) > 0 {
display `<div class="article" >
<span style="font-weight: bold;font-size:30px;">` + article[0][:Title] + `</span><br /><br />
<span style="font-weight: bold;font-size:17px;">` /*+ article[0][:Author] + ` - `*/ + article[0][:Date] + `</span><br /><br />
<p id="markdown-paragraph"> </p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
<script>
var converter = new showdown.Converter(),
text = "` + escapeString(article[0][:Content]) + `";
document.getElementById('markdown-paragraph').innerHTML = converter.makeHtml(text);
</script>
`
}
}
__sqlite3_close(db)
call "footer.sim" #call the footer to close the tags and other after body script