-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
executable file
·98 lines (89 loc) · 3.46 KB
/
main.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
package main
import (
"log"
"net/http"
"time"
"github.com/go-macaron/binding"
"github.com/go-macaron/csrf"
"github.com/go-macaron/session"
"github.com/robfig/cron"
"gopkg.in/macaron.v1"
)
type byDate []post
type link struct {
Name string
Description string
FileName string
ShortURL string
URL string
}
type reportForm struct {
Category string `form:"category" binding:"Required"`
Email string `form:"email"`
Description string `form:"description" binding:"Required"`
}
type contactForm struct {
Name string `form:"name"`
Description string `form:"description" binding:"Required"`
}
type post struct {
ColourDark string
ColourLight string
Date time.Time
DateFormatted string
Description string
FileName string
HTML string
Markdown string
Name string
Tags string
}
var projectsArr []post
var blogsArr []post
var linksArr = []link{
{Name: "Akilan", Description: "Not boring developer", FileName: "akilan.jpg", URL: "https://akilan.io", ShortURL: "akilan.io"},
{Name: "Amaan", Description: "", FileName: "amaan.jpg", URL: "https://amaanakram.tech", ShortURL: "amaanakram.tech"},
{Name: "Abdel", Description: "", FileName: "abdel.jpeg", URL: "https://elkabbany.xyz", ShortURL: "elkabbany.xyz"},
{Name: "Euan", Description: "", FileName: "euan.jpg", URL: "https://euangordon.me", ShortURL: "euangordon.me"},
{Name: "Humaid", Description: "", FileName: "humaid.jpg", URL: "https://huma.id", ShortURL: "huma.id"},
{Name: "Hutchie", Description: "", FileName: "hutchie.jpg", URL: "https://hutchie.scot", ShortURL: "hutchie.scot"},
{Name: "James", Description: "", FileName: "james.jpg", URL: "https://jamesl.dev/", ShortURL: "jamesl.dev"},
{Name: "ReamSystems", Description: "", FileName: "reamsystems.png", URL: "https://ream.systems", ShortURL: "ream.systems"},
{Name: "Rikesh", Description: "Aspiring developer and designer", FileName: "rikesh.jpeg", URL: "http://rikeshmm.com", ShortURL: "rikeshmm.com"},
{Name: "Rory", Description: "A collection of my projects and experiences", FileName: "rory.jpg", URL: "http://rorydobson.com/", ShortURL: "rorydobson.com"},
{Name: "Ruaridh", Description: "", FileName: "ruaridh.jpg", URL: "https://ruaridhmollica.com/", ShortURL: "ruaridhmollica.com"},
{Name: "Shiva", Description: "", URL: "https://shiva-m.com/", FileName: "shiva.jpg", ShortURL: "shiva-m.com"},
}
func main() {
m := macaron.Classic()
m.Use(macaron.Renderer())
m.Use(session.Sessioner())
m.Use(csrf.Csrfer())
c := cron.New()
c.AddFunc("@daily", func() { go updateDescriptions() })
c.Start()
go updateDescriptions()
go getPosts("public/projects/")
go getPosts("public/blog/")
m.Get("/", homeHandler)
m.Post("/", csrf.Validate, binding.Bind(contactForm{}), homeHandlerPOST)
m.Get("/projects", projectsHandler)
m.Get("/projects/:name", projectsFileHandler)
m.Get("/blog", blogHandler)
m.Get("/blog/:name", blogFileHandler)
m.Get("/pics", picsHandler)
m.Get("/report", reportHandler)
m.Post("/report", csrf.Validate, binding.Bind(reportForm{}), reportHandlerPOST)
m.Get("/thankyou", thankyouHandler)
m.Get("/emailerror", emailerrorHandler)
m.Get("/credits", creditsHandler)
m.Get("/links", linksHandler)
m.Get("/traffic", trafficHandler)
m.Get("/alakbot", alakbotHandler)
m.NotFound(func(ctx *macaron.Context) {
ctx.Data["Title"] = "Not Found"
ctx.HTML(http.StatusNotFound, "404")
})
log.Println("Server is running...")
log.Println(http.ListenAndServe("0.0.0.0:4000", m))
}