1
0
mirror of https://github.com/JustKato/FreePad.git synced 2026-02-23 15:50:46 +02:00

+ Reading from files

+ Working Page access
This commit is contained in:
2022-05-20 00:46:14 +03:00
parent a3de00aabd
commit a76b9d02ba
10 changed files with 177 additions and 39 deletions

View File

@@ -1,8 +1,13 @@
package routes
import (
"fmt"
"net/url"
"github.com/JustKato/FreePad/lib/helper"
"github.com/JustKato/FreePad/lib/objects"
"github.com/gin-gonic/gin"
"github.com/mrz1836/go-sanitize"
)
func HomeRoutes(router *gin.Engine) {
@@ -18,9 +23,22 @@ func HomeRoutes(router *gin.Engine) {
// Get the post we are looking for.
postName := c.Param("post")
fmt.Println("Sanitizing ", postName)
// Sanitize the postName
newPostName, err := url.QueryUnescape(postName)
if err == nil {
postName = newPostName
}
postName = sanitize.AlphaNumeric(postName, true)
fmt.Println("Fetching ", postName)
post := objects.GetPost(postName)
c.HTML(200, "page.html", gin.H{
"title": postName,
"post_content": "",
"post_content": post.Content,
"domain_base": helper.GetDomainBase(),
})
})