9
"xelbot.com/reprogl/container"
10
"xelbot.com/reprogl/models/repositories"
11
"xelbot.com/reprogl/views"
14
func InfoAction(app *container.Application) http.HandlerFunc {
15
return func(w http.ResponseWriter, r *http.Request) {
16
templateData := views.NewInfoPageData()
17
templateData.SetCanonical(container.GenerateAbsoluteURL("info-page"))
18
err := views.WriteTemplateWithContext(r.Context(), w, "about.gohtml", templateData)
20
app.ServerError(w, err)
27
func StatisticsAction(app *container.Application) http.HandlerFunc {
28
return func(w http.ResponseWriter, r *http.Request) {
29
repo := repositories.CommentRepository{DB: app.DB}
30
commentators, err := repo.GetMostActiveCommentators()
32
app.ServerError(w, err)
37
articleRepo := repositories.ArticleRepository{DB: app.DB}
38
monthArticles, err := articleRepo.GetMostVisitedArticlesOfMonth()
40
app.ServerError(w, err)
45
allTimeArticles, err := articleRepo.GetMostVisitedArticles()
47
app.ServerError(w, err)
52
templateData := views.NewStatisticsPageData()
53
templateData.Commentators = commentators
54
templateData.MonthArticles = monthArticles
55
templateData.AllTimeArticles = allTimeArticles
56
templateData.SetCanonical(container.GenerateAbsoluteURL("statistics"))
58
cacheControl(w, container.StatisticsTTL)
59
err = views.WriteTemplate(w, "statistics.gohtml", templateData)
61
app.ServerError(w, err)
68
func RobotsTXTAction(w http.ResponseWriter, r *http.Request) {
71
if container.IsCDN(r) {
72
body = "User-agent: *\n\nDisallow: /\n"
74
cfg := container.GetConfig()
76
"User-agent: *\n\nSitemap: https://%s/sitemap.xml\n",
80
cacheControl(w, container.RobotsTxtTTL)
81
w.Header().Set("Content-Type", "text/plain")
85
func HumansTXTAction(w http.ResponseWriter, r *http.Request) {
86
var lastUpdateStr string
87
lastUpdate, err := time.Parse(time.RFC3339, container.BuildTime)
89
lastUpdateStr = container.BuildTime
91
lastUpdateStr = lastUpdate.Format("2006/01/02")
94
cfg := container.GetConfig()
104
Inspirer: Alex Edwards
105
Site: https://www.alexedwards.net/
108
pxThemes: Anima Multipurpose Ghost Theme
109
Site: https://themeforest.net/user/pxthemes
112
Colorlib: Free 404 Error Page Templates
113
Site: https://colorlib.com/wp/free-404-error-page-templates/
116
8biticon: Pixel Character Maker
117
Site: https://8biticon.com/
123
IDE: GoLand, VS Code, nano
124
Server: NGINX + Varnish + Golang custom application
128
cfg.AuthorLocationEn,
130
container.GoVersionNumbers,
133
cacheControl(w, container.StatisticsTTL)
134
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
135
w.Write([]byte(body + "\n"))
138
func FavIconAction(w http.ResponseWriter, _ *http.Request) {
139
body, err := os.ReadFile("./public/favicon.ico")
141
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
144
cacheControl(w, container.RobotsTxtTTL)
145
w.Header().Set("Content-Type", "image/x-icon")