First release

This commit is contained in:
Hugo Mårdbrink 2025-02-12 00:09:21 +01:00
parent 7cbcab0d48
commit 0df3d16dda
15 changed files with 71 additions and 98 deletions

View file

@ -5,7 +5,7 @@ tmp_dir = "tmp"
[build] [build]
args_bin = [] args_bin = []
bin = "./tmp/main" bin = "./tmp/main"
cmd = "go build -o ./tmp/main cmd/main.go" cmd = "go build -o ./tmp/main main.go"
delay = 0 delay = 0
exclude_dir = ["node_modules", "assets", "tmp", "vendor", "testdata"] exclude_dir = ["node_modules", "assets", "tmp", "vendor", "testdata"]
exclude_file = [] exclude_file = []
@ -13,7 +13,7 @@ tmp_dir = "tmp"
exclude_unchanged = false exclude_unchanged = false
follow_symlink = false follow_symlink = false
full_bin = "" full_bin = ""
include_dir = ["cmd", "internal", "views", "pkg"] include_dir = ["internal", "views", "pkg"]
include_ext = ["go", "html"] include_ext = ["go", "html"]
include_file = [] include_file = []
kill_delay = "0s" kill_delay = "0s"

5
.dockerignore Normal file
View file

@ -0,0 +1,5 @@
# flyctl launch added from .gitignore
tmp
views/**/*.go
fly.toml

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
/tmp/ /tmp/
/views/**/*.go /views/**/*.go
fly.toml

22
Dockerfile Normal file
View file

@ -0,0 +1,22 @@
FROM golang:1.22.3-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main .
# Runtime image
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/main .
COPY views views/
COPY css css/
COPY resources resources/
CMD ["./main"]

4
README.md Normal file
View file

@ -0,0 +1,4 @@
## Run locally
```
air
```

View file

@ -55,6 +55,14 @@ html, body {
z-index: 100000; z-index: 100000;
} }
.page {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 100%;
}
.main-container { .main-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -62,25 +70,18 @@ html, body {
align-items: center; align-items: center;
height: 100%; height: 100%;
gap: 2rem; gap: 2rem;
} margin-top: -2rem;
.home-padding {
margin-top: 5rem;
@media screen and (max-width: 1000px) {
margin-top: 2rem;
}
} }
.title-container { .title-container {
margin-top: 2rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
gap: 1rem;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
margin-bottom: -3rem; gap: 0.5rem;
} }
} }
@ -94,8 +95,15 @@ html, body {
} }
} }
.title-offset {
margin-top: 2rem;
@media screen and (max-width: 1000px) {
margin-top: 1rem;
}
}
.menu-container { .menu-container {
margin-top: 3rem;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
@ -104,7 +112,7 @@ html, body {
width: 100%; width: 100%;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
margin-top: 7.5rem; margin-top: 1.5rem;
gap: 1.5rem; gap: 1.5rem;
flex-direction: column; flex-direction: column;
} }
@ -142,11 +150,10 @@ html, body {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100%; gap: 5rem;
gap: 2.5rem;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
gap: 0.75rem; gap: 3rem;
} }
} }
@ -175,7 +182,6 @@ html, body {
width: 22.5rem; width: 22.5rem;
border: 0.4rem solid var(--dark-text); border: 0.4rem solid var(--dark-text);
box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text); box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text);
margin-top: 5rem;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
display: none; display: none;
@ -245,7 +251,6 @@ html, body {
width: 28rem; width: 28rem;
border: 0.4rem solid var(--dark-text); border: 0.4rem solid var(--dark-text);
box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text); box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text);
margin-top: 5rem;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
width: 18rem; width: 18rem;
@ -320,8 +325,6 @@ html, body {
content: ""; content: "";
} }
} }
} }
.project-info-link-right:hover, .project-info-link-left:hover { .project-info-link-right:hover, .project-info-link-left:hover {
@ -340,7 +343,6 @@ html, body {
width: 22.5rem; width: 22.5rem;
border: 0.4rem solid var(--dark-text); border: 0.4rem solid var(--dark-text);
box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text); box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text);
margin-top: 5rem;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
display: none; display: none;
@ -452,7 +454,6 @@ html, body {
width: 22.5rem; width: 22.5rem;
border: 0.4rem solid var(--dark-text); border: 0.4rem solid var(--dark-text);
box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text); box-shadow: 0.5rem 0.5rem 0 0.1rem var(--dark-text);
margin-top: 5rem;
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
display: none; display: none;

Binary file not shown.

View file

@ -1,44 +0,0 @@
package database
import (
"database/sql"
"log"
"os"
_ "github.com/mattn/go-sqlite3"
"hugo.mardbrink.se/internal/config"
)
func InitDB() *sql.DB {
db, err := sql.Open("sqlite3", config.DatabaseFile)
if err != nil {
log.Fatal(err)
}
if err := initSchema(db); err != nil {
log.Fatal(err)
}
return db
}
func initSchema(db *sql.DB) error {
content, err := os.ReadFile(config.SeedFile)
if err != nil {
return err
}
_, err = db.Exec(string(content))
if err != nil {
return err
}
return nil
}
func CloseDB(db *sql.DB) {
db.Close()
}

View file

@ -1,7 +0,0 @@
CREATE TABLE IF NOT EXISTS articles (
route TEXT PRIMARY KEY,
title TEXT,
description TEXT,
content TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View file

@ -1,7 +1,6 @@
package handlers package handlers
import ( import (
"database/sql"
"net/http" "net/http"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
@ -9,7 +8,7 @@ import (
"hugo.mardbrink.se/internal/models" "hugo.mardbrink.se/internal/models"
) )
func RegisterRoutes(e *echo.Echo, db *sql.DB) { func RegisterRoutes(e *echo.Echo,) {
e.GET("/", homePageHandler()) e.GET("/", homePageHandler())
e.GET("/projects", projectsPageHandler()) e.GET("/projects", projectsPageHandler())
e.GET("/articles", articlesPageHandler()) e.GET("/articles", articlesPageHandler())

View file

@ -7,7 +7,6 @@ import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4/middleware"
"hugo.mardbrink.se/database"
"hugo.mardbrink.se/internal/handlers" "hugo.mardbrink.se/internal/handlers"
) )
@ -34,10 +33,7 @@ func main() {
e.Static("/resources", "resources") e.Static("/resources", "resources")
e.Static("/css", "css") e.Static("/css", "css")
db := database.InitDB() handlers.RegisterRoutes(e)
defer database.CloseDB(db)
handlers.RegisterRoutes(e, db) e.Logger.Fatal(e.Start("0.0.0.0:8080"))
e.Logger.Fatal(e.Start(":8080"))
} }

View file

@ -0,0 +1,3 @@
<svg width="33" height="16" viewBox="0 0 33 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.892897 7.84207C0.343789 7.90122 -0.0533992 8.39432 0.00575206 8.94342C0.0649033 9.49253 0.557995 9.88972 1.1071 9.83057L0.892897 7.84207ZM32.6238 9.78155C33.0555 9.437 33.1261 8.80779 32.7815 8.37615L27.1669 1.34224C26.8224 0.910607 26.1932 0.840003 25.7615 1.18455C25.3299 1.52909 25.2593 2.1583 25.6038 2.58994L30.5946 8.8423L24.3422 13.8331C23.9106 14.1776 23.84 14.8068 24.1845 15.2385C24.5291 15.6701 25.1583 15.7407 25.5899 15.3962L32.6238 9.78155ZM1.1071 9.83057C4.12992 9.50494 11.6177 8.88806 17.3893 9.01759L17.4342 7.01809C11.5353 6.88571 3.94851 7.51292 0.892897 7.84207L1.1071 9.83057ZM17.3893 9.01759C23.1858 9.14768 29.4761 9.72307 31.8885 9.99376L32.1115 8.00624C29.6612 7.73129 23.3083 7.14992 17.4342 7.01809L17.3893 9.01759Z" fill="#3F3715"/>
</svg>

After

Width:  |  Height:  |  Size: 877 B

View file

@ -12,10 +12,8 @@
{{ block "articles.content" . }} {{ block "articles.content" . }}
<div class="main-container">
<div class="title-container"> <div class="title-container">
<span class="title">ARTICLES</span> <span class="title title-offset">ARTICLES</span>
</div>
</div> </div>
{{ end }} {{ end }}

View file

@ -27,7 +27,7 @@
<body> <body>
<img src="resources/grain.png" class="grain-bg" alt="Grainy background"/> <img src="resources/grain.png" class="grain-bg" alt="Grainy background"/>
{{ template "breadcrumb" . }} {{ template "breadcrumb" . }}
<div id="page"> <div id="page" class="page">
{{ end }} {{ end }}
{{ block "base.end" . }} {{ block "base.end" . }}

View file

@ -12,17 +12,13 @@
{{ block "projects.content" . }} {{ block "projects.content" . }}
<div class="main-container">
<div class="project-page"> <div class="project-page">
<div class="title-container"> <span class="title title-offset">PROJECTS</span>
<span class="title">PROJECTS</span>
</div>
{{ template "projects.skal" . }} {{ template "projects.skal" . }}
{{ template "projects.dct" . }} {{ template "projects.dct" . }}
{{ template "projects.modmark" . }} {{ template "projects.modmark" . }}
<span class="title"> <br> </span> <span class="title"> <br> </span>
</div> </div>
</div>
{{ end }} {{ end }}
{{ block "projects.modmark" . }} {{ block "projects.modmark" . }}