Compare commits
2 commits
c5925e16e0
...
836d6a337a
Author | SHA1 | Date | |
---|---|---|---|
|
836d6a337a | ||
|
38ebb21a34 |
|
@ -1,7 +1,15 @@
|
|||
html {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
|
||||
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
|
||||
"Helvetica Neue", sans-serif;
|
||||
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
|
||||
"Helvetica Neue", sans-serif;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic styling
|
||||
*/
|
||||
input, select, textarea {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
body.role-site {
|
||||
|
@ -44,15 +52,67 @@ div.post {
|
|||
border-bottom: solid thin grey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Post form
|
||||
*/
|
||||
|
||||
form.post-form {
|
||||
display: flex;
|
||||
display: grid;
|
||||
grid-template-columns: auto 23vw;
|
||||
grid-template-rows: auto 2.5em;
|
||||
gap: 6px;
|
||||
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
form.post-form input[type='text'] {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
form.post-form div.main-area {
|
||||
grid-column-start: 1;
|
||||
grid-column-end: 3;
|
||||
grid-row-start: 1;
|
||||
grid-row-end: 2;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
div.right-area div.section {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
div.right-area div.section input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.right-area div.section div.section-heading {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
form.post-form textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form.post-form textarea[name="body"] {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
dialog {
|
||||
width: 400px;
|
||||
top: 30%;
|
||||
}
|
||||
|
||||
dialog h3 {
|
||||
margin-block: 0;
|
||||
margin-block-end: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
dialog textarea {
|
||||
min-height: 10vh !important;
|
||||
width: 100%;
|
||||
}
|
23
go.mod
23
go.mod
|
@ -3,18 +3,25 @@ module lmika.dev/lmika/hugo-cms
|
|||
go 1.23.3
|
||||
|
||||
require (
|
||||
github.com/Netflix/go-env v0.1.2
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.4
|
||||
github.com/golang-migrate/migrate/v4 v4.18.1
|
||||
github.com/jackc/pgx/v5 v5.7.2
|
||||
golang.org/x/crypto v0.33.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
lmika.dev/pkg/modash v0.0.0-20250216001243-c73e50a0913d
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Netflix/go-env v0.1.2 // indirect
|
||||
github.com/PuerkitoBio/goquery v1.10.2 // indirect
|
||||
github.com/Southclaws/fault v0.8.1 // indirect
|
||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.3 // indirect
|
||||
github.com/coreos/go-oidc/v3 v3.12.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
|
||||
github.com/gofiber/fiber/v2 v2.52.6 // indirect
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.4 // indirect
|
||||
github.com/gofiber/schema v1.2.0 // indirect
|
||||
github.com/gofiber/template v1.8.3 // indirect
|
||||
github.com/gofiber/template/html/v2 v2.1.3 // indirect
|
||||
|
@ -41,12 +48,10 @@ require (
|
|||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/yuin/goldmark v1.7.8 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
golang.org/x/crypto v0.32.0 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/oauth2 v0.21.0 // indirect
|
||||
golang.org/x/sync v0.10.0 // indirect
|
||||
golang.org/x/sys v0.29.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
lmika.dev/pkg/modash v0.0.0-20250216001243-c73e50a0913d // indirect
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
resty.dev/v3 v3.0.0-beta.2 // indirect
|
||||
)
|
||||
|
|
81
go.sum
81
go.sum
|
@ -1,10 +1,17 @@
|
|||
github.com/Netflix/go-env v0.1.2 h1:0DRoLR9lECQ9Zqvkswuebm3jJ/2enaDX6Ei8/Z+EnK0=
|
||||
github.com/Netflix/go-env v0.1.2/go.mod h1:WlIhYi++8FlKNJtrop1mjXYAJMzv1f43K4MqCoh0yGE=
|
||||
github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8=
|
||||
github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU=
|
||||
github.com/Southclaws/fault v0.8.1 h1:mgqqdC6kUBQ6ExMALZ0nNaDfNJD5h2+wq3se5mAyX+8=
|
||||
github.com/Southclaws/fault v0.8.1/go.mod h1:VUVkAWutC59SL16s6FTqf3I6I2z77RmnaW5XRz4bLOE=
|
||||
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
|
||||
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
|
||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
||||
github.com/coreos/go-oidc/v3 v3.12.0 h1:sJk+8G2qq94rDI6ehZ71Bol3oUHy63qNYmkiSjrc/Jo=
|
||||
github.com/coreos/go-oidc/v3 v3.12.0/go.mod h1:gE3LgjOgFoHi9a4ce4/tJczr0Ai2/BoDhf0r5lltWI0=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||
|
@ -28,6 +35,7 @@ github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQg
|
|||
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang-migrate/migrate/v4 v4.18.1 h1:JML/k+t4tpHCpQTCAD62Nu43NUFzHY4CV3uAuvHGC+Y=
|
||||
github.com/golang-migrate/migrate/v4 v4.18.1/go.mod h1:HAX6m3sQgcdO81tdjn5exv20+3Kb13cmGli1hrD6hks=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
|
@ -72,25 +80,96 @@ github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7Fw
|
|||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
|
||||
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
@ -101,3 +180,5 @@ lmika.dev/pkg/modash v0.0.0-20250201221851-97d4b9b4a1ac h1:i/C+DYDCVQTQHtv7w1O8m
|
|||
lmika.dev/pkg/modash v0.0.0-20250201221851-97d4b9b4a1ac/go.mod h1:8NDl/yR1eCCEhip9FJlVuMNXIeaztQ0Ks/tizExFcTI=
|
||||
lmika.dev/pkg/modash v0.0.0-20250216001243-c73e50a0913d h1:x5aMBOkCr4cjJyFmq+qJVUsByfffD9k56HYDx1yZSR4=
|
||||
lmika.dev/pkg/modash v0.0.0-20250216001243-c73e50a0913d/go.mod h1:8NDl/yR1eCCEhip9FJlVuMNXIeaztQ0Ks/tizExFcTI=
|
||||
resty.dev/v3 v3.0.0-beta.2 h1:xu4mGAdbCLuc3kbk7eddWfWm4JfhwDtdapwss5nCjnQ=
|
||||
resty.dev/v3 v3.0.0-beta.2/go.mod h1:OgkqiPvTDtOuV4MGZuUDhwOpkY8enjOsjjMzeOHefy4=
|
||||
|
|
|
@ -3,10 +3,12 @@ package handlers
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"lmika.dev/lmika/hugo-cms/models"
|
||||
"lmika.dev/lmika/hugo-cms/services/posts"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Post struct {
|
||||
|
@ -35,18 +37,12 @@ func (h *Post) New(c fiber.Ctx) error {
|
|||
func (h *Post) Create(c fiber.Ctx) error {
|
||||
site := GetSite(c)
|
||||
|
||||
var req struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Body string `json:"body" form:"body"`
|
||||
}
|
||||
if err := c.Bind().Body(&req); err != nil {
|
||||
req, err := h.parseReqToNewPost(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := h.Post.Create(c.Context(), site, posts.NewPost{
|
||||
Title: req.Title,
|
||||
Body: req.Body,
|
||||
})
|
||||
_, err = h.Post.Create(c.Context(), site, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -54,6 +50,28 @@ func (h *Post) Create(c fiber.Ctx) error {
|
|||
return c.Redirect().To(fmt.Sprintf("/sites/%v/posts", site.ID))
|
||||
}
|
||||
|
||||
func (h *Post) NewLinkPost(c fiber.Ctx) error {
|
||||
return c.Render("posts/new-link", fiber.Map{}, "layouts/site")
|
||||
}
|
||||
|
||||
func (h *Post) CreateLinkPost(c fiber.Ctx) error {
|
||||
site := GetSite(c)
|
||||
|
||||
var req posts.NewLinkPost
|
||||
if err := c.Bind().Body(&req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
post, err := h.Post.CreateLinkPost(c.Context(), site, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.Render("posts/new", fiber.Map{
|
||||
"post": post,
|
||||
}, "layouts/site")
|
||||
}
|
||||
|
||||
func (h *Post) Edit(c fiber.Ctx) error {
|
||||
site := GetSite(c)
|
||||
|
||||
|
@ -82,14 +100,13 @@ func (h *Post) Update(c fiber.Ctx) error {
|
|||
return errors.New("postId is required")
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Body string `json:"body" form:"body"`
|
||||
}
|
||||
if err := c.Bind().Body(&req); err != nil {
|
||||
req, err := h.parseReqToNewPost(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
spew.Dump(req)
|
||||
|
||||
post, err := h.Post.GetPost(c.Context(), postID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -128,3 +145,26 @@ func (h *Post) Delete(c fiber.Ctx) error {
|
|||
}),
|
||||
)
|
||||
}
|
||||
|
||||
func (h *Post) parseReqToNewPost(c fiber.Ctx) (req posts.NewPost, err error) {
|
||||
reqMap := make(map[string]string)
|
||||
if err := c.Bind().Body(&reqMap); err != nil {
|
||||
return req, err
|
||||
}
|
||||
|
||||
for k, v := range reqMap {
|
||||
switch {
|
||||
case k == "title":
|
||||
req.Title = v
|
||||
case k == "body":
|
||||
req.Body = v
|
||||
case strings.HasPrefix(k, "params."):
|
||||
kk := strings.TrimPrefix(k, "params.")
|
||||
if req.Params == nil {
|
||||
req.Params = make(map[string]string)
|
||||
}
|
||||
req.Params[kk] = v
|
||||
}
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -139,7 +139,9 @@ func main() {
|
|||
|
||||
sr.Get("/posts", postHandlers.Posts)
|
||||
sr.Get("/posts/new", postHandlers.New)
|
||||
sr.Get("/posts/new-link", postHandlers.NewLinkPost)
|
||||
sr.Post("/posts", postHandlers.Create)
|
||||
sr.Post("/posts/new-link", postHandlers.CreateLinkPost)
|
||||
sr.Get("/posts/:postId", postHandlers.Edit)
|
||||
sr.Post("/posts/:postId", postHandlers.Update)
|
||||
sr.Delete("/posts/:postId", postHandlers.Delete)
|
||||
|
|
|
@ -15,6 +15,7 @@ type Post struct {
|
|||
OwnerID int64
|
||||
Title string
|
||||
Body string
|
||||
Params map[string]string
|
||||
State PostState
|
||||
PublishDate time.Time
|
||||
CreatedAt time.Time
|
||||
|
|
|
@ -2,6 +2,7 @@ package db
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"lmika.dev/lmika/hugo-cms/gen/sqlc/dbq"
|
||||
"lmika.dev/lmika/hugo-cms/models"
|
||||
|
@ -15,7 +16,7 @@ func (db *DB) ListPostsOfSite(ctx context.Context, siteID int64) ([]models.Post,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return moslice.Map(res, dbPostToPost), nil
|
||||
return moslice.MapWithError(res, dbPostToPost)
|
||||
}
|
||||
|
||||
func (db *DB) GetPost(ctx context.Context, postID int64) (models.Post, error) {
|
||||
|
@ -24,7 +25,7 @@ func (db *DB) GetPost(ctx context.Context, postID int64) (models.Post, error) {
|
|||
return models.Post{}, err
|
||||
}
|
||||
|
||||
return dbPostToPost(res), nil
|
||||
return dbPostToPost(res)
|
||||
}
|
||||
|
||||
func (db *DB) DeletePost(ctx context.Context, postID int64) error {
|
||||
|
@ -41,16 +42,21 @@ func (db *DB) ListPublishablePosts(ctx context.Context, fromID, siteID int64, no
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return moslice.Map(res, dbPostToPost), nil
|
||||
return moslice.MapWithError(res, dbPostToPost)
|
||||
}
|
||||
|
||||
func (db *DB) InsertPost(ctx context.Context, p *models.Post) error {
|
||||
props, err := marshalPostProps(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, err := db.q.InsertPost(ctx, dbq.InsertPostParams{
|
||||
SiteID: p.SiteID,
|
||||
Title: pgtype.Text{String: p.Title, Valid: p.Title != ""},
|
||||
Body: p.Body,
|
||||
State: dbq.PostState(p.State),
|
||||
Props: []byte(`{}`),
|
||||
Props: props,
|
||||
PublishDate: pgtype.Timestamptz{Time: p.PublishDate, Valid: !p.PublishDate.IsZero()},
|
||||
CreatedAt: pgtype.Timestamp{Time: p.CreatedAt, Valid: !p.CreatedAt.IsZero()},
|
||||
UpdatedAt: pgtype.Timestamp{Time: p.UpdatedAt, Valid: !p.UpdatedAt.IsZero()},
|
||||
|
@ -64,19 +70,44 @@ func (db *DB) InsertPost(ctx context.Context, p *models.Post) error {
|
|||
}
|
||||
|
||||
func (db *DB) UpdatePost(ctx context.Context, p *models.Post) error {
|
||||
props, err := marshalPostProps(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return db.q.UpdatePost(ctx, dbq.UpdatePostParams{
|
||||
ID: p.ID,
|
||||
SiteID: p.SiteID,
|
||||
Title: pgtype.Text{String: p.Title, Valid: p.Title != ""},
|
||||
Body: p.Body,
|
||||
State: dbq.PostState(p.State),
|
||||
Props: []byte(`{}`),
|
||||
Props: props,
|
||||
PublishDate: pgtype.Timestamptz{Time: p.PublishDate, Valid: !p.PublishDate.IsZero()},
|
||||
UpdatedAt: pgtype.Timestamp{Time: p.UpdatedAt, Valid: !p.UpdatedAt.IsZero()},
|
||||
})
|
||||
}
|
||||
|
||||
func dbPostToPost(p dbq.Post) models.Post {
|
||||
func marshalPostProps(p *models.Post) ([]byte, error) {
|
||||
var props []byte
|
||||
if len(p.Params) == 0 {
|
||||
props = []byte(`{}`)
|
||||
} else {
|
||||
var err error
|
||||
props, err = json.Marshal(p.Params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return props, nil
|
||||
}
|
||||
func dbPostToPost(p dbq.Post) (models.Post, error) {
|
||||
postProps := map[string]string{}
|
||||
if len(p.Props) != 0 {
|
||||
if err := json.Unmarshal(p.Props, &postProps); err != nil {
|
||||
return models.Post{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return models.Post{
|
||||
ID: p.ID,
|
||||
SiteID: p.SiteID,
|
||||
|
@ -85,5 +116,5 @@ func dbPostToPost(p dbq.Post) models.Post {
|
|||
State: models.PostState(p.State),
|
||||
PublishDate: p.PublishDate.Time,
|
||||
CreatedAt: p.CreatedAt.Time,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package posts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/Southclaws/fault"
|
||||
"html/template"
|
||||
"lmika.dev/lmika/hugo-cms/models"
|
||||
"lmika.dev/lmika/hugo-cms/providers/db"
|
||||
"lmika.dev/lmika/hugo-cms/services/jobs"
|
||||
"lmika.dev/lmika/hugo-cms/services/sitebuilder"
|
||||
"resty.dev/v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -69,6 +74,26 @@ func (s *Service) Create(ctx context.Context, site models.Site, req NewPost) (mo
|
|||
return post, nil
|
||||
}
|
||||
|
||||
func (s *Service) CreateLinkPost(ctx context.Context, site models.Site, req NewLinkPost) (models.Post, error) {
|
||||
fl, err := s.fetchLinkedPage(ctx, req)
|
||||
if err != nil {
|
||||
return models.Post{}, err
|
||||
}
|
||||
|
||||
var bodyTemplate bytes.Buffer
|
||||
if err := linkedPostTemplate.Execute(&bodyTemplate, fl); err != nil {
|
||||
return models.Post{}, err
|
||||
}
|
||||
|
||||
post := models.Post{
|
||||
SiteID: site.ID,
|
||||
Title: fl.LinkTitle,
|
||||
Body: bodyTemplate.String(),
|
||||
}
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (s *Service) Save(ctx context.Context, site models.Site, post *models.Post) error {
|
||||
post.SiteID = site.ID
|
||||
|
||||
|
@ -88,7 +113,66 @@ func (s *Service) Save(ctx context.Context, site models.Site, post *models.Post)
|
|||
return s.jobs.Queue(ctx, s.sb.WritePost(site, *post))
|
||||
}
|
||||
|
||||
type NewPost struct {
|
||||
Title string
|
||||
Body string
|
||||
func (s *Service) fetchLinkedPage(ctx context.Context, req NewLinkPost) (fl fetchedLink, err error) {
|
||||
client := resty.New()
|
||||
defer client.Close()
|
||||
|
||||
// Fetch the linked site
|
||||
res, err := client.R().WithContext(ctx).Get(req.LinkURL)
|
||||
if err != nil {
|
||||
return fetchedLink{}, err
|
||||
} else if res.StatusCode() != 200 {
|
||||
return fetchedLink{}, fault.Newf("page returns non-200 status code %d", res.StatusCode())
|
||||
}
|
||||
|
||||
if len(res.RedirectHistory()) > 0 {
|
||||
fl.LinkURL = res.RedirectHistory()[len(res.RedirectHistory())-1].URL
|
||||
} else {
|
||||
fl.LinkURL = req.LinkURL
|
||||
}
|
||||
|
||||
resDom, err := goquery.NewDocumentFromReader(bytes.NewReader(res.Bytes()))
|
||||
if err != nil {
|
||||
return fetchedLink{}, err
|
||||
}
|
||||
|
||||
fl.LinkTitle = resDom.Find("title").Text()
|
||||
|
||||
// Fetch the via site
|
||||
if req.ViaURL != "" {
|
||||
if res, err := client.R().WithContext(ctx).Get(req.ViaURL); err == nil && res.StatusCode() == 200 {
|
||||
if len(res.RedirectHistory()) > 0 {
|
||||
fl.ViaURL = res.RedirectHistory()[len(res.RedirectHistory())-1].URL
|
||||
} else {
|
||||
fl.ViaURL = req.LinkURL
|
||||
}
|
||||
|
||||
if viaDom, err := goquery.NewDocumentFromReader(bytes.NewReader(res.Bytes())); err == nil {
|
||||
fl.ViaTitle = viaDom.Find("title").Text()
|
||||
}
|
||||
}
|
||||
}
|
||||
return fl, nil
|
||||
}
|
||||
|
||||
type NewPost struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Body string `json:"body" form:"body"`
|
||||
Params map[string]string `json:"params" form:"params"`
|
||||
}
|
||||
|
||||
type NewLinkPost struct {
|
||||
LinkURL string `json:"title" form:"link_url"`
|
||||
ViaURL string `json:"body" form:"via_url"`
|
||||
}
|
||||
|
||||
type fetchedLink struct {
|
||||
LinkURL string
|
||||
LinkTitle string
|
||||
ViaURL string
|
||||
ViaTitle string
|
||||
}
|
||||
|
||||
var linkedPostTemplate = template.Must(template.New("").Parse(`🔗 [{{.LinkTitle}}]({{.LinkURL}})
|
||||
|
||||
{{if .ViaURL}}Via: [{{.ViaTitle}}]({{.ViaURL}}){{end}}`))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<div>
|
||||
<a href="/sites/{{.site.ID}}/posts/new">New Post</a>
|
||||
<a href="/sites/{{.site.ID}}/posts/new">New Post</a> |
|
||||
<a href="/sites/{{.site.ID}}/posts/new-link">New Link Post</a>
|
||||
</div>
|
||||
|
||||
{{range .posts}}
|
||||
|
|
13
templates/posts/new-link.html
Normal file
13
templates/posts/new-link.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<form method="post" action="/sites/{{.site.ID}}/posts/new-link">
|
||||
<p>
|
||||
<label>Link URL</label>
|
||||
<input type="text" name="link_url" value="" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Via URL</label>
|
||||
<input type="text" name="via_url" value="" />
|
||||
</p>
|
||||
<div class="bottom-area">
|
||||
<input type="submit" value="Create Post">
|
||||
</div>
|
||||
</form>
|
|
@ -3,11 +3,11 @@
|
|||
{{- $postTarget = printf "/sites/%v/posts/%v" .site.ID .post.ID -}}
|
||||
{{- end -}}
|
||||
<form method="post" action="{{$postTarget}}" class="post-form">
|
||||
<input name="title" placeholder="Title" value="{{.post.Title}}">
|
||||
|
||||
<textarea name="body">{{.post.Body}}</textarea>
|
||||
|
||||
<div class="bottom-bar">
|
||||
<div class="main-area">
|
||||
<input name="title" type="text" placeholder="Title" value="{{.post.Title}}">
|
||||
<textarea name="body">{{.post.Body}}</textarea>
|
||||
</div>
|
||||
<div class="bottom-area">
|
||||
<input type="submit" value="Post">
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
Loading…
Reference in a new issue