diff --git a/kontor-fiber/cmd/kontor/main.go b/kontor-fiber/cmd/kontor/main.go index eb95eaf..ba744c1 100644 --- a/kontor-fiber/cmd/kontor/main.go +++ b/kontor-fiber/cmd/kontor/main.go @@ -5,10 +5,12 @@ import ( "kontor-api-fiber/pkg/schema" "kontor-api-fiber/pkg/web" "log" + "time" jwtware "github.com/gofiber/contrib/v3/jwt" "github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3/middleware/logger" + "github.com/gofiber/fiber/v3/middleware/static" "github.com/gofiber/template/html/v3" ) @@ -22,7 +24,8 @@ func main() { engine := html.New("./views", ".html") app := fiber.New(fiber.Config{ - Views: engine, + Views: engine, + ViewsLayout: "layouts/main", }) //app.Use(logger.New()) @@ -38,8 +41,20 @@ func main() { api.Use(logger.New()) handler.SetupComicRoutes(api) handler.SetupMediaRoutes(api) + + app.Get("/*", static.New("./static", static.Config{ + Browse: false, + MaxAge: 3600, + CacheDuration: 10 * time.Second, + NotFoundHandler: func(c fiber.Ctx) error { + return c.Status(fiber.StatusNotFound).JSON(fiber.Map{ + "error": "asset not found", + "path": c.Path(), + }) + }, + })) // Listen on port 8900 - app.Listen(":8500") + app.Listen(":8510") log.Println("Kontor finished") } diff --git a/kontor-fiber/pkg/schema/media.go b/kontor-fiber/pkg/schema/media.go index f2b5a4f..9987f8a 100644 --- a/kontor-fiber/pkg/schema/media.go +++ b/kontor-fiber/pkg/schema/media.go @@ -24,6 +24,20 @@ type MediaFile struct { MediaActorFiles []MediaActorFile `bun:"rel:has-many,join:id=media_file_id"` } +type MediaLoFi struct { + bun.BaseModel `bun:"table:media_lofi"` + + ID string `bun:"id,pk"` + CreatedAt time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"` + UpdatedAt time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"` + Version int `bun:"version,default:0"` + WebLink string `bun:"url,unique:url"` + Review bool `bun:"review"` + ShouldDownload bool `bun:"should_download"` + Title string `bun:"title"` + FileName string `bun:"file_name"` +} + type MediaActor struct { bun.BaseModel `bun:"table:media_actor"` diff --git a/kontor-fiber/static/style/main.css b/kontor-fiber/static/style/main.css new file mode 100644 index 0000000..8b5c0c3 --- /dev/null +++ b/kontor-fiber/static/style/main.css @@ -0,0 +1,172 @@ +* { + box-sizing: border-box; +} + +body { + font-family: Arial; + padding: 10px; + background: lightgrey; +} + +/* Header/Blog Title */ +.header { + padding: 30px; + text-align: center; + background-color: lightblue; +} + +.header h1 { + font-size: 50px; +} + +/* Style the top navigation bar */ +.topnav { + overflow: hidden; + background-color: darkgrey; +} + +/* Style the topnav links */ +.topnav a { + float: left; + display: block; + color: #f2f2f2; + text-align: center; + padding: 14px 16px; + text-decoration: none; +} + +/* Change color on hover */ +.topnav a:hover { + background-color: #ddd; + color: black; +} + +.subnav { + overflow: hidden; + background-color: grey; +} + +.subnav a { + float: left; + display: block; + color: #f2f2f2; + text-align: center; + padding: 14px 16px; + text-decoration: none; +} + +.form-inline { + display: flex; + flex-flow: row wrap; + align-items: center; + padding-top: 10px; + padding-left: 20px; +} + +.form-inline label { + margin: 5px 10px 5px 0; +} + +.form-inline input { + padding-right: 50px; + margin-right: 10px; +} + +.form-inline button { + padding: 10px 20px; + background-color: dodgerblue; + border: 1px solid #ddd; + color: white; + border-radius: 10px; +} + +.form-inline button:hover { + background-color: royalblue; +} + +.pill-nav a { + display: inline-block; + color: white; + background-color: dodgerblue; + text-align: center; + padding: 10px; + text-decoration: none; + border-radius: 10px; + margin-left: 20px; +} + +/* Change the color of links on mouse-over */ +.pill-nav a:hover { + background-color: royalblue; + color: white; +} + +/* Add a color to the active/current link */ +.pill-nav a.active { + background-color: royalblue; + color: white; +} + +.maincolumn { + float:left; + width: 100%; +} +/* Create two unequal columns that floats next to each other */ +/* Left column */ +.leftcolumn { + float: left; + width: 75%; +} + +/* Right column */ +.rightcolumn { + float: left; + width: 25%; + background-color: #f1f1f1; + padding-left: 20px; +} + +/* Fake image */ +.fakeimg { + background-color: #aaa; + width: 100%; + padding: 20px; +} + +/* Add a card effect for articles */ +.card { + background-color: white; + padding: 20px; + margin-top: 20px; +} + +/* Clear floats after the columns */ +.row::after { + content: ""; + display: table; + clear: both; +} + +/* Footer */ +.footer { + padding: 20px; + text-align: center; + background: #ddd; + margin-top: 20px; +} + +/* Responsive layout - when the screen is less than 800px wide, make the two columns stack on top of each other instead of next to each other */ +@media screen and (max-width: 800px) { + .leftcolumn, .rightcolumn { + width: 100%; + padding: 0; + } +} + +/* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */ +@media screen and (max-width: 400px) { + .topnav a { + float: none; + width: 100%; + } +} diff --git a/kontor-fiber/views/index.html b/kontor-fiber/views/index.html index 6c8f1e5..d66dc08 100644 --- a/kontor-fiber/views/index.html +++ b/kontor-fiber/views/index.html @@ -1,5 +1 @@ -{{template "partials/header" .}} -