123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- package controller
- import (
- "fmt"
- "net/http"
- "git.aetherial.dev/aeth/keiji/pkg/helpers"
- "github.com/gin-gonic/gin"
- )
- func (c *Controller) ServePost(ctx *gin.Context) {
- rds := helpers.NewRedisClient(c.RedisConfig)
- post, exist := ctx.Params.Get("post-name")
- if !exist {
- ctx.JSON(404, map[string]string{
- "Error": "the requested file could not be found",
- })
- return
- }
- doc, err := rds.GetItem(post)
- if err != nil {
- ctx.JSON(500, map[string]string{
- "Error": err.Error(),
- })
- return
- }
- if doc.Category == helpers.CONFIGURATION {
- ctx.Status(404)
- return
- }
- ctx.HTML(http.StatusOK, "blogpost", gin.H{
- "navigation": gin.H{
- "menu": c.Menu(),
- "headers": c.Headers().Elements,
- },
- "title": doc.Ident,
- "Ident": doc.Ident,
- "Created": doc.Created,
- "Body": doc.Body,
- })
- }
- func (c *Controller) ServeBlogHome(ctx *gin.Context) {
- docs, err := helpers.GetAllDocuments(helpers.BLOG, c.RedisConfig)
- if err != nil {
- ctx.JSON(500, map[string]string{
- "Error getting docs": err.Error(),
- })
- return
- }
- ctx.HTML(http.StatusOK, "home", gin.H{
- "navigation": gin.H{
- "menu": c.Menu(),
- "headers": c.Headers().Elements,
- },
- "listings": docs,
- })
- }
- func (c *Controller) ServeHome(ctx *gin.Context) {
- docs, err := helpers.GetAllDocuments(helpers.BLOG, c.RedisConfig)
- if err != nil {
- ctx.JSON(500, map[string]string{
- "Error getting docs": err.Error(),
- })
- return
- }
- ctx.HTML(http.StatusOK, "home", gin.H{
- "navigation": gin.H{
- "menu": c.Menu(),
- "headers": c.Headers().Elements,
- },
- "listings": docs,
- })
- }
- func (c *Controller) ServeCreativeWriting(ctx *gin.Context) {
- docs, err := helpers.GetAllDocuments(helpers.CREATIVE, c.RedisConfig)
- if err != nil {
- ctx.JSON(500, map[string]string{
- "Error getting docs": err.Error(),
- })
- return
- }
- ctx.HTML(http.StatusOK, "home", gin.H{
- "navigation": gin.H{
- "menu": c.Menu(),
- "headers": c.Headers().Elements,
- },
- "listings": docs,
- })
- }
- func (c *Controller) ServeTechnicalWriteups(ctx *gin.Context) {
- docs, err := helpers.GetAllDocuments(helpers.TECHNICAL, c.RedisConfig)
- if err != nil {
- ctx.JSON(500, map[string]string{
- "Error getting docs": err.Error(),
- })
- return
- }
- ctx.HTML(http.StatusOK, "home", gin.H{
- "navigation": gin.H{
- "menu": c.Menu(),
- "headers": c.Headers().Elements,
- },
- "listings": docs,
- })
- }
- func (c *Controller) ServeDigitalArt(ctx *gin.Context) {
- ctx.HTML(http.StatusOK, "digital_art", gin.H{
- "navigation": gin.H{
- "menu": c.Menu(),
- "headers": c.Headers().Elements,
- },
- "images": []string{
- fmt.Sprintf("/api/v1/images/%s", "keepoff_small.jpg"),
- fmt.Sprintf("/api/v1/images/%s", "someoneatthedoor_small.jpg"),
- fmt.Sprintf("/api/v1/images/%s", "whyhere.gif"),
- },
- })
- }
|