-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
60 lines (54 loc) · 1.09 KB
/
utils.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
package main
import (
"github.com/russross/blackfriday"
"net/http"
"strconv"
"time"
"strings"
)
func ConvertMarkdownToHtml(markdawn string) string {
return string(blackfriday.MarkdownBasic([]byte(markdawn)))
}
func CheckCookies(r *http.Request) bool {
a := false
for _, cookie := range r.Cookies() {
if cookie.Name == config.CookieName {
if cookie.Value == config.Pass {
a = true
} else {
a = false
}
}
}
return a
}
func timeX(t string) string{
i, _ := strconv.ParseInt(t, 10, 64)
tm := time.Unix(i, 0)
Time := tm.Format("_2-01-2006")
return Time
}
func tagsX(t string, u string) string{
t_ := strings.Split(t, ", ")
var tags string
var ta string
for _,element := range t_ {
if element == "" {
continue
}
if u != "true" {
ta += element+", "
tagsz := len(ta)
tags = ta[:tagsz-2]
} else {
tags += "<a class='tag' href='/tag/"+element+"'>"+element+"</a>"
}
}
return tags
}
func timeRFC(t string) string{
i, _ := strconv.ParseInt(t, 10, 64)
tm := time.Unix(i, 0)
Time := tm.Format(time.RFC1123Z)
return Time
}