styles and organization
This commit is contained in:
parent
303d9703f1
commit
ef48719cf5
6 changed files with 73 additions and 55 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
www/*.html
|
||||
www/styles/style.css
|
||||
docker-compose.yml
|
||||
docker-compose.yml
|
||||
www/style.css
|
||||
|
|
|
|||
90
main.go
90
main.go
|
|
@ -3,31 +3,14 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"piekarnikgosi/resources"
|
||||
"piekarnikgosi/templates"
|
||||
"piekarnikgosi/types"
|
||||
)
|
||||
|
||||
var Cakes = []types.Product{
|
||||
{"Malinowa chmurka", "001", "150", "kruchy spód, warstwa malin w galaretce, krem śmietankowy, beza"},
|
||||
{"Sernik ulubiony", "002", "150", "kruchy spód, aksamitna masa serowa, beza z kruszonką"},
|
||||
{"Jabłecznik z kruszonką", "003", "130", "ciasto ucierane, jabłka, kruszonka"},
|
||||
{"Sernik klasyczny", "004", "150", "wykończony czekoladowym ganache lub oprószony cukrem pudrem"},
|
||||
{"Sernik królewski", "005", "150", "kakaowy spód i kruszonka, wilgotna masa serowa"},
|
||||
{"Pleśniak", "006", "120", "kruche ciasto waniliowe, powidła owocowe, kruche ciasto kakaowe, beza i kruszonka"},
|
||||
{"Leśny mech z musem truskawkowym", "007", "110", "biszkoptowe ciasto z dodatkiem szpinaku, mus truskawkowy"},
|
||||
{"Snickers", "008", "150", "dwie warstwy kakaowego biszkoptu a pomiędzy bezowy blat orzechowy , krem budyniowy , toffi i,orzeszki ziemne"},
|
||||
{"Mleczna kanapka", "009", "120", "dwa blaty czekoladowego ciasta, a pomiędzy krem waniliowy z dodatkiem cienkiej warstwy,czekoladowej"},
|
||||
{"3Bit", "010", "120", "herbatniki, krem budyniowy, toffi i śmietana"},
|
||||
{"Biszkoptowe z kremem i owocami w galaretce", "011", "120", "biszkopt, krem budyniowy, owoce"},
|
||||
{"Kora orzechowa", "012", "150", "dwa blaty bezy orzechowej a pomiędzy krem budyniowy na bazie soku z brzoskwiń, delicje,pomarańczowe, owoce brzoskwiń i galaretka"},
|
||||
{"Nutelowiec z wiśniami", "013", "120", "nutelowy spód , krem śmietankowy z dodatkiem twarożku, wiśnie i galaretka"},
|
||||
{"Karpatka", "014", "120", ""},
|
||||
}
|
||||
|
||||
type ComponentRenderer interface {
|
||||
Render(ctx context.Context, w io.Writer) error
|
||||
}
|
||||
|
|
@ -35,47 +18,72 @@ type ComponentRenderer interface {
|
|||
func saveFile(name string, comp ComponentRenderer) {
|
||||
file, err := os.Create("www/" + name + ".html")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
err = comp.Render(context.Background(), file)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func generateHTML() {
|
||||
log.Println("generating html")
|
||||
saveFile(`index`, templates.Index())
|
||||
saveFile(`kawiarnia`, templates.Kawiarnia())
|
||||
saveFile(`portfolio`, templates.Portfolio())
|
||||
saveFile(`wyroby`, templates.WyrobyCiasta(Cakes))
|
||||
saveFile(`wyroby`, templates.WyrobyCiasta(resources.Cakes))
|
||||
saveFile(`wyroby_torty`, templates.WyrobyTorty())
|
||||
saveFile(`wyroby_slodkie_stoly`, templates.WyrobySlodkieStoly())
|
||||
saveFile(`wyroby_lody`, templates.WyrobyLody())
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("generating html")
|
||||
err := os.MkdirAll("www/styles", 0777)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
func mergeStyles() {
|
||||
log.Println("generating css")
|
||||
cssFiles := []string{
|
||||
"normalize.css",
|
||||
"base.css",
|
||||
"components.css",
|
||||
"home.css",
|
||||
"layout.css",
|
||||
"wyroby.css",
|
||||
"wyroby_torty.css",
|
||||
"wyroby_slodkie_stoly.css",
|
||||
"wyroby_lody.css",
|
||||
"portfolio.css",
|
||||
"kawiarnia.css",
|
||||
}
|
||||
generateHTML()
|
||||
fmt.Println("generating css")
|
||||
t, err := template.ParseGlob(`templates/styles/*`)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
var bundledCSS []byte
|
||||
|
||||
for _, fileName := range cssFiles {
|
||||
filePath := fmt.Sprint("templates/styles/", fileName)
|
||||
content, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
bundledCSS = append(bundledCSS, content...)
|
||||
bundledCSS = append(bundledCSS, '\n')
|
||||
}
|
||||
file, err := os.Create("www/styles/style.css")
|
||||
|
||||
err := os.WriteFile("www/style.css", bundledCSS, 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
err = t.ExecuteTemplate(file, "style.gohtml", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("listening on :8000")
|
||||
panic(http.ListenAndServe(":8000", http.FileServer(http.Dir("www"))))
|
||||
}
|
||||
|
||||
func ensureDir() {
|
||||
log.Println("creating directories")
|
||||
err := os.MkdirAll("www/styles", 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
ensureDir()
|
||||
generateHTML()
|
||||
mergeStyles()
|
||||
log.Println("listening on :8000")
|
||||
log.Fatal(http.ListenAndServe(":8000", http.FileServer(http.Dir("www"))))
|
||||
}
|
||||
|
|
|
|||
20
resources/cakes.go
Normal file
20
resources/cakes.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package resources
|
||||
|
||||
import "piekarnikgosi/types"
|
||||
|
||||
var Cakes = []types.Product{
|
||||
{Name: "Malinowa chmurka", Image: "001", Price: "150", Description: "kruchy spód, warstwa malin w galaretce, krem śmietankowy, beza"},
|
||||
{Name: "Sernik ulubiony", Image: "002", Price: "150", Description: "kruchy spód, aksamitna masa serowa, beza z kruszonką"},
|
||||
{Name: "Jabłecznik z kruszonką", Image: "003", Price: "130", Description: "ciasto ucierane, jabłka, kruszonka"},
|
||||
{Name: "Sernik klasyczny", Image: "004", Price: "150", Description: "wykończony czekoladowym ganache lub oprószony cukrem pudrem"},
|
||||
{Name: "Sernik królewski", Image: "005", Price: "150", Description: "kakaowy spód i kruszonka, wilgotna masa serowa"},
|
||||
{Name: "Pleśniak", Image: "006", Price: "120", Description: "kruche ciasto waniliowe, powidła owocowe, kruche ciasto kakaowe, beza i kruszonka"},
|
||||
{Name: "Leśny mech z musem truskawkowym", Image: "007", Price: "110", Description: "biszkoptowe ciasto z dodatkiem szpinaku, mus truskawkowy"},
|
||||
{Name: "Snickers", Image: "008", Price: "150", Description: "dwie warstwy kakaowego biszkoptu a pomiędzy bezowy blat orzechowy , krem budyniowy , toffi i,orzeszki ziemne"},
|
||||
{Name: "Mleczna kanapka", Image: "009", Price: "120", Description: "dwa blaty czekoladowego ciasta, a pomiędzy krem waniliowy z dodatkiem cienkiej warstwy,czekoladowej"},
|
||||
{Name: "3Bit", Image: "010", Price: "120", Description: "herbatniki, krem budyniowy, toffi i śmietana"},
|
||||
{Name: "Biszkoptowe z kremem i owocami w galaretce", Image: "011", Price: "120", Description: "biszkopt, krem budyniowy, owoce"},
|
||||
{Name: "Kora orzechowa", Image: "012", Price: "150", Description: "dwa blaty bezy orzechowej a pomiędzy krem budyniowy na bazie soku z brzoskwiń, delicje,pomarańczowe, owoce brzoskwiń i galaretka"},
|
||||
{Name: "Nutelowiec z wiśniami", Image: "013", Price: "120", Description: "nutelowy spód , krem śmietankowy z dodatkiem twarożku, wiśnie i galaretka"},
|
||||
{Name: "Karpatka", Image: "014", Price: "120", Description: ""},
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ templ layout(activePage string) {
|
|||
<title>Piekarnik Gosi</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||||
<meta name="description" content=""/>
|
||||
<link href="styles/style.css" rel="stylesheet"/>
|
||||
<link href="style.css" rel="stylesheet"/>
|
||||
<link rel="icon" href="images/favicon.png"/>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func layout(activePage string) templ.Component {
|
|||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"pl\"><head><meta charset=\"UTF-8\"><title>Piekarnik Gosi</title><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta name=\"description\" content=\"\"><link href=\"styles/style.css\" rel=\"stylesheet\"><link rel=\"icon\" href=\"images/favicon.png\"></head><body><nav><div><a href=\"index.html\"><img alt=\"logo\" src=\"images/logo.png\"></a><div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"pl\"><head><meta charset=\"UTF-8\"><title>Piekarnik Gosi</title><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta name=\"description\" content=\"\"><link href=\"style.css\" rel=\"stylesheet\"><link rel=\"icon\" href=\"images/favicon.png\"></head><body><nav><div><a href=\"index.html\"><img alt=\"logo\" src=\"images/logo.png\"></a><div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
{{template "normalize.css"}}
|
||||
{{template "base.css"}}
|
||||
{{template "components.css"}}
|
||||
{{template "home.css"}}
|
||||
{{template "layout.css"}}
|
||||
{{template "wyroby.css"}}
|
||||
{{template "wyroby_torty.css"}}
|
||||
{{template "wyroby_slodkie_stoly.css"}}
|
||||
{{template "wyroby_lody.css"}}
|
||||
{{template "portfolio.css"}}
|
||||
{{template "kawiarnia.css"}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue