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:
@@ -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(),
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user