Changing Themes + Few New Routes
tailored this to suite my personal site theme with additional options to run this on exozyme
This commit is contained in:
parent
9e8b98891b
commit
3202b6b008
7 changed files with 221 additions and 246 deletions
1
assets/htmx.min.js
vendored
1
assets/htmx.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,78 +0,0 @@
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
|
||||||
background-color: lightgray;
|
|
||||||
/* font-size: 15px; */
|
|
||||||
display: flex;
|
|
||||||
justify-content:center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload {
|
|
||||||
display: flex;
|
|
||||||
justify-content:center;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
#uploadlink {
|
|
||||||
text-decoration: none;
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.imgcontainer {
|
|
||||||
width: 100%;
|
|
||||||
padding-top: 100%;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container {
|
|
||||||
max-width: 600px;
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items:center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#posts {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
img{
|
|
||||||
object-fit: cover;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
flex:1;
|
|
||||||
}
|
|
||||||
.date {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary{
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: start;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.post {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding-top: 40px;
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 5px;
|
|
||||||
word-wrap:break-word;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
27
go.mod
27
go.mod
|
@ -1,35 +1,32 @@
|
||||||
module tinygram
|
module tinygram
|
||||||
|
|
||||||
go 1.21.6
|
go 1.22.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/a-h/templ v0.2.513
|
github.com/a-h/templ v0.2.648
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/sessions v1.2.2
|
github.com/gorilla/sessions v1.2.2
|
||||||
github.com/labstack/echo-contrib v0.15.0
|
github.com/labstack/echo-contrib v0.16.0
|
||||||
github.com/labstack/echo/v4 v4.11.4
|
github.com/labstack/echo/v4 v4.11.4
|
||||||
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55
|
gorm.io/driver/sqlite v1.5.5
|
||||||
|
gorm.io/gorm v1.25.8
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||||
github.com/gorilla/context v1.1.1 // indirect
|
github.com/gorilla/context v1.1.2 // indirect
|
||||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
|
||||||
golang.org/x/time v0.5.0 // indirect
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/google/uuid v1.6.0
|
|
||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
golang.org/x/crypto v0.17.0 // indirect
|
golang.org/x/crypto v0.21.0 // indirect
|
||||||
golang.org/x/net v0.19.0 // indirect
|
golang.org/x/net v0.22.0 // indirect
|
||||||
golang.org/x/sys v0.15.0 // indirect
|
golang.org/x/sys v0.18.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
gorm.io/driver/sqlite v1.5.4
|
golang.org/x/time v0.5.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
36
go.sum
36
go.sum
|
@ -1,5 +1,5 @@
|
||||||
github.com/a-h/templ v0.2.513 h1:ZmwGAOx4NYllnHy+FTpusc4+c5msoMpPIYX0Oy3dNqw=
|
github.com/a-h/templ v0.2.648 h1:A1ggHGIE7AONOHrFaDTM8SrqgqHL6fWgWCijQ21Zy9I=
|
||||||
github.com/a-h/templ v0.2.513/go.mod h1:9gZxTLtRzM3gQxO8jr09Na0v8/jfliS97S9W5SScanM=
|
github.com/a-h/templ v0.2.648/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
|
@ -10,8 +10,8 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
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/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
|
||||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
|
||||||
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||||
github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY=
|
github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY=
|
||||||
|
@ -20,8 +20,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/labstack/echo-contrib v0.15.0 h1:9K+oRU265y4Mu9zpRDv3X+DGTqUALY6oRHCSZZKCRVU=
|
github.com/labstack/echo-contrib v0.16.0 h1:vk5Kd+egpTOJxD3l+3IvZzQWPbrXiYxhkkgkJL99j/w=
|
||||||
github.com/labstack/echo-contrib v0.15.0/go.mod h1:lei+qt5CLB4oa7VHTE0yEfQSEB9XTJI1LUqko9UWvo4=
|
github.com/labstack/echo-contrib v0.16.0/go.mod h1:mjX5VB3OqJcroIEycptBOY9Hr7rK+unq79W8QFKGNV0=
|
||||||
github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8=
|
github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8=
|
||||||
github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8=
|
github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8=
|
||||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
|
@ -35,27 +35,27 @@ github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6
|
||||||
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||||
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
|
gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
|
||||||
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
|
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
|
||||||
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 h1:sC1Xj4TYrLqg1n3AN10w871An7wJM0gzgcm8jkIkECQ=
|
gorm.io/gorm v1.25.8 h1:WAGEZ/aEcznN4D03laj8DKnehe1e9gYQAjW8xyPRdeo=
|
||||||
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
gorm.io/gorm v1.25.8/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
|
180
index.templ
180
index.templ
|
@ -5,106 +5,132 @@ import "time"
|
||||||
import "net/url"
|
import "net/url"
|
||||||
|
|
||||||
templ index(ps []Post) {
|
templ index(ps []Post) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
<title>x's tinygram</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<link href="/css/gram.css" rel="stylesheet"/>
|
||||||
<link rel="preload" href="/static/style.css" as="style"/>
|
</head>
|
||||||
<link rel="stylesheet" href="/static/style.css"/>
|
<body>
|
||||||
</head>
|
<canvas id="background"></canvas>
|
||||||
<body>
|
<div class="container">
|
||||||
<div id="container">
|
<div class="heading">
|
||||||
<div id="header">
|
<h1>X's TinyGram</h1>
|
||||||
<a id="uploadlink" href="/upload"><h2>Tinygram</h2></a>
|
<p class="subheadings">Here remains all the shitty photos I took and will take. This is my less bloated instagram like thing.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="posts">
|
<div class="posts">
|
||||||
@posts(ps)
|
@posts(ps)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="footer">
|
||||||
</body>
|
<p class="foottext">CC BY-SA 4.0</p>
|
||||||
</html>
|
<p class="foottext">We Might Be Dead by Tomorrow</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script src="/htmx.min.js"></script>
|
||||||
|
<script src="/sort.js"></script>
|
||||||
|
<script src="/matrix.js"></script>
|
||||||
|
</html>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
templ loginPage(csrfToken string) {
|
templ loginPage(csrfToken string) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
<title>x's tinygram</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<link href="/css/gram.css" rel="stylesheet"/>
|
||||||
<link rel="preload" href="/static/style.css" as="style"/>
|
</head>
|
||||||
<link rel="stylesheet" href="/static/style.css"/>
|
<body>
|
||||||
</head>
|
<canvas id="background"></canvas>
|
||||||
<body>
|
<div class="container">
|
||||||
<form
|
<div class="heading">
|
||||||
class="login"
|
<h1>X's TinyGram</h1>
|
||||||
hx-encoding="multipart/form-data"
|
<p class="subheadings">Enter your shitty password to log into this shit.</p>
|
||||||
hx-post="/login"
|
</div>
|
||||||
>
|
<div class="posts">
|
||||||
<input type="password" name="password"/>
|
<form
|
||||||
<input type="hidden" name="_csrf" value={ csrfToken }/>
|
class="login"
|
||||||
<button>
|
hx-encoding="multipart/form-data"
|
||||||
Login
|
hx-post="/g/login">
|
||||||
</button>
|
<input type="password" name="password"/>
|
||||||
</form>
|
<input type="hidden" name="_csrf" value={ csrfToken }/>
|
||||||
|
<button>login</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p class="foottext">CC BY-SA 4.0</p>
|
||||||
|
<p class="foottext">We Might Be Dead by Tomorrow</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="/htmx.min.js"></script>
|
||||||
|
<script src="/sort.js"></script>
|
||||||
|
<script src="/matrix.js"></script>
|
||||||
</html>
|
</html>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
templ uploadPage(csrfToken string) {
|
templ uploadPage(csrfToken string) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
<title>x's tinygram</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<link href="/css/gram.css" rel="stylesheet"/>
|
||||||
<link rel="preload" href="/static/style.css" as="style"/>
|
</head>
|
||||||
<link rel="stylesheet" href="/static/style.css"/>
|
<body>
|
||||||
</head>
|
<canvas id="background"></canvas>
|
||||||
<body>
|
<div class="container">
|
||||||
<form
|
<div class="heading">
|
||||||
class="upload"
|
<h1>X's TinyGram</h1>
|
||||||
hx-encoding="multipart/form-data"
|
<p class="subheadings">upload your shitty photos from here</p>
|
||||||
hx-post="/upload"
|
</div>
|
||||||
_="on htmx:xhr:progress(loaded, total) set #progress.value to (loaded/total)*100"
|
<div class="posts">
|
||||||
>
|
<form
|
||||||
<input type="file" name="file"/>
|
class="upload"
|
||||||
<input type="hidden" name="_csrf" value={ csrfToken }/>
|
hx-encoding="multipart/form-data"
|
||||||
<div>
|
hx-post="/g/upload"
|
||||||
<span>Description:</span>
|
_="on htmx:xhr:progress(loaded, total) set #progress.value to (loaded/total)*100"
|
||||||
<input type="text" name="description"/>
|
>
|
||||||
</div>
|
<input type="file" name="file"/>
|
||||||
<button>
|
<input type="hidden" name="_csrf" value={ csrfToken }/>
|
||||||
Upload
|
<div>
|
||||||
</button>
|
<span>description:</span>
|
||||||
<progress id="progress" value="0" max="100"></progress>
|
<input type="text" name="description"/>
|
||||||
</form>
|
</div>
|
||||||
|
<button>upload</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p class="foottext">CC BY-SA 4.0</p>
|
||||||
|
<p class="foottext">We Might Be Dead by Tomorrow</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="/htmx.min.js"></script>
|
||||||
|
<script src="/sort.js"></script>
|
||||||
|
<script src="/matrix.js"></script>
|
||||||
</html>
|
</html>
|
||||||
}
|
}
|
||||||
|
|
||||||
templ posts(posts []Post) {
|
templ posts(posts []Post) {
|
||||||
for _, post := range posts {
|
for _, post := range posts {
|
||||||
<div class="post">
|
<section class="post">
|
||||||
<div class="imgcontainer">
|
<p class="date">{ post.CreatedAt.Format("2006-01-02 - 15:04") }</p>
|
||||||
<img src={ post.ImageID } alt={ post.ImageID }/>
|
<img loading="lazy" src={ post.ImageID } alt={ post.ImageID }/>
|
||||||
</div>
|
<p>{ post.Description }</p>
|
||||||
<div class="summary">
|
</section>
|
||||||
<p class="description">{ post.Description }</p>
|
|
||||||
<p class="date">{ post.CreatedAt.Format("2006-01-02 - 15:04") }</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
if len(posts) > 0 {
|
if len(posts) > 0 {
|
||||||
<div
|
<div
|
||||||
style="min-height:1px"
|
style="min-height:1px"
|
||||||
hx-get={ fmt.Sprintf("/posts?after=%v", url.QueryEscape(posts[len(posts)-1].CreatedAt.Format(time.RFC3339))) }
|
hx-get={ fmt.Sprintf("/g/pics?after=%v", url.QueryEscape(posts[len(posts)-1].CreatedAt.Format(time.RFC3339))) }
|
||||||
hx-target="#posts"
|
hx-target=".posts"
|
||||||
hx-trigger="revealed"
|
hx-trigger="revealed"
|
||||||
hx-swap="beforeend"
|
hx-swap="beforeend"
|
||||||
></div>
|
></div>
|
||||||
|
|
103
index_templ.go
103
index_templ.go
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.543
|
// templ: version: v0.2.648
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -27,7 +27,7 @@ func index(ps []Post) templ.Component {
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"><script src=\"/static/htmx.min.js\"></script><link rel=\"preload\" href=\"/static/style.css\" as=\"style\"><link rel=\"stylesheet\" href=\"/static/style.css\"></head><body><div id=\"container\"><div id=\"header\"><a id=\"uploadlink\" href=\"/upload\"><h2>Tinygram</h2></a></div><div id=\"posts\">")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>x's tinygram</title><link href=\"/css/gram.css\" rel=\"stylesheet\"></head><body><canvas id=\"background\"></canvas><div class=\"container\"><div class=\"heading\"><h1>X's TinyGram</h1><p class=\"subheadings\">Here remains all the shitty photos I took and will take. This is my less bloated instagram like thing.</p></div><div class=\"posts\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func index(ps []Post) templ.Component {
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></body></html>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"footer\"><p class=\"foottext\">CC BY-SA 4.0</p><p class=\"foottext\">We Might Be Dead by Tomorrow</p></div></div></body><script src=\"/htmx.min.js\"></script><script src=\"/sort.js\"></script><script src=\"/matrix.js\"></script></html>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
@ -59,15 +59,20 @@ func loginPage(csrfToken string) templ.Component {
|
||||||
templ_7745c5c3_Var2 = templ.NopComponent
|
templ_7745c5c3_Var2 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"><script src=\"/static/htmx.min.js\"></script><link rel=\"preload\" href=\"/static/style.css\" as=\"style\"><link rel=\"stylesheet\" href=\"/static/style.css\"></head><body><form class=\"login\" hx-encoding=\"multipart/form-data\" hx-post=\"/login\"><input type=\"password\" name=\"password\"> <input type=\"hidden\" name=\"_csrf\" value=\"")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>x's tinygram</title><link href=\"/css/gram.css\" rel=\"stylesheet\"></head><body><canvas id=\"background\"></canvas><div class=\"container\"><div class=\"heading\"><h1>X's TinyGram</h1><p class=\"subheadings\">Enter your shitty password to log into this shit.</p></div><div class=\"posts\"><form class=\"login\" hx-encoding=\"multipart/form-data\" hx-post=\"/g/login\"><input type=\"password\" name=\"password\"> <input type=\"hidden\" name=\"_csrf\" value=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(csrfToken))
|
var templ_7745c5c3_Var3 string
|
||||||
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(csrfToken)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 61, Col: 63}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <button>Login</button></form></body></html>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <button>login</button></form></div><div class=\"footer\"><p class=\"foottext\">CC BY-SA 4.0</p><p class=\"foottext\">We Might Be Dead by Tomorrow</p></div></div></body><script src=\"/htmx.min.js\"></script><script src=\"/sort.js\"></script><script src=\"/matrix.js\"></script></html>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
@ -86,20 +91,25 @@ func uploadPage(csrfToken string) templ.Component {
|
||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var3 == nil {
|
if templ_7745c5c3_Var4 == nil {
|
||||||
templ_7745c5c3_Var3 = templ.NopComponent
|
templ_7745c5c3_Var4 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"><script src=\"/static/htmx.min.js\"></script><link rel=\"preload\" href=\"/static/style.css\" as=\"style\"><link rel=\"stylesheet\" href=\"/static/style.css\"></head><body><form class=\"upload\" hx-encoding=\"multipart/form-data\" hx-post=\"/upload\" _=\"on htmx:xhr:progress(loaded, total) set #progress.value to (loaded/total)*100\"><input type=\"file\" name=\"file\"> <input type=\"hidden\" name=\"_csrf\" value=\"")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>x's tinygram</title><link href=\"/css/gram.css\" rel=\"stylesheet\"></head><body><canvas id=\"background\"></canvas><div class=\"container\"><div class=\"heading\"><h1>X's TinyGram</h1><p class=\"subheadings\">upload your shitty photos from here</p></div><div class=\"posts\"><form class=\"upload\" hx-encoding=\"multipart/form-data\" hx-post=\"/g/upload\" _=\"on htmx:xhr:progress(loaded, total) set #progress.value to (loaded/total)*100\"><input type=\"file\" name=\"file\"> <input type=\"hidden\" name=\"_csrf\" value=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(csrfToken))
|
var templ_7745c5c3_Var5 string
|
||||||
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(csrfToken)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 102, Col: 63}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div><span>Description:</span> <input type=\"text\" name=\"description\"></div><button>Upload</button> <progress id=\"progress\" value=\"0\" max=\"100\"></progress></form></body></html>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div><span>description:</span> <input type=\"text\" name=\"description\"></div><button>upload</button></form></div><div class=\"footer\"><p class=\"foottext\">CC BY-SA 4.0</p><p class=\"foottext\">We Might Be Dead by Tomorrow</p></div></div></body><script src=\"/htmx.min.js\"></script><script src=\"/sort.js\"></script><script src=\"/matrix.js\"></script></html>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
@ -118,17 +128,35 @@ func posts(posts []Post) templ.Component {
|
||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var4 == nil {
|
if templ_7745c5c3_Var6 == nil {
|
||||||
templ_7745c5c3_Var4 = templ.NopComponent
|
templ_7745c5c3_Var6 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
for _, post := range posts {
|
for _, post := range posts {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"post\"><div class=\"imgcontainer\"><img src=\"")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<section class=\"post\"><p class=\"date\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(post.ImageID))
|
var templ_7745c5c3_Var7 string
|
||||||
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(post.CreatedAt.Format("2006-01-02 - 15:04"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 124, Col: 69}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><img loading=\"lazy\" src=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var8 string
|
||||||
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(post.ImageID)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 125, Col: 42}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
@ -136,37 +164,29 @@ func posts(posts []Post) templ.Component {
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(post.ImageID))
|
var templ_7745c5c3_Var9 string
|
||||||
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(post.ImageID)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 125, Col: 63}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></div><div class=\"summary\"><p class=\"description\">")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var5 string
|
var templ_7745c5c3_Var10 string
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(post.Description)
|
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(post.Description)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 97, Col: 45}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 126, Col: 25}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p class=\"date\">")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></section>")
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var6 string
|
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(post.CreatedAt.Format("2006-01-02 - 15:04"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 98, Col: 65}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
@ -176,11 +196,16 @@ func posts(posts []Post) templ.Component {
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("/posts?after=%v", url.QueryEscape(posts[len(posts)-1].CreatedAt.Format(time.RFC3339)))))
|
var templ_7745c5c3_Var11 string
|
||||||
|
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("/g/pics?after=%v", url.QueryEscape(posts[len(posts)-1].CreatedAt.Format(time.RFC3339))))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 132, Col: 112}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"#posts\" hx-trigger=\"revealed\" hx-swap=\"beforeend\"></div>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\".posts\" hx-trigger=\"revealed\" hx-swap=\"beforeend\"></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|
42
main.go
42
main.go
|
@ -25,26 +25,30 @@ type Post struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
homePath := os.Getenv("HOME")
|
||||||
|
configPath := homePath + "/.config/tinygram/"
|
||||||
|
tinygramVolumedir := homePath + "/Public/Volumes/tinygram/"
|
||||||
|
staticWebPath := homePath + "/Public/Websites/x/"
|
||||||
|
|
||||||
dbPath := os.Getenv("DB_PATH")
|
dbPath := os.Getenv("DB_PATH")
|
||||||
if dbPath == "" {
|
if dbPath == "" {
|
||||||
dbPath = "tinygram.db"
|
dbPath = tinygramVolumedir + "tinygram.db"
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionSecret := os.Getenv("SESSION_SECRET")
|
sessionSecret := os.Getenv("TINYGRAM_SESSION_SECRET")
|
||||||
if sessionSecret == "" {
|
if sessionSecret == "" {
|
||||||
fmt.Println("NEED TO PROVIDE A SECRET")
|
fmt.Println("you need to set a session secret to run this.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
passwordFilePath := os.Getenv("PASSWORD_FILE_PATH")
|
passwordFilePath := os.Getenv("PASSWORD_FILE_PATH")
|
||||||
if passwordFilePath == "" {
|
if passwordFilePath == "" {
|
||||||
passwordFilePath = "password.txt"
|
passwordFilePath = configPath + "password.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
assetsPath := os.Getenv("ASSETS_PATH")
|
assetsPath := os.Getenv("ASSETS_PATH")
|
||||||
if assetsPath == "" {
|
if assetsPath == "" {
|
||||||
assetsPath = "assets"
|
assetsPath = tinygramVolumedir + "assets"
|
||||||
}
|
}
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
|
@ -68,7 +72,9 @@ func main() {
|
||||||
|
|
||||||
e.Static("/static", assetsPath)
|
e.Static("/static", assetsPath)
|
||||||
|
|
||||||
e.GET("/", func(c echo.Context) error {
|
e.Static("/", staticWebPath)
|
||||||
|
|
||||||
|
e.GET("/photos", func(c echo.Context) error {
|
||||||
var posts []Post
|
var posts []Post
|
||||||
db.Order("created_at DESC").Limit(5).Find(&posts)
|
db.Order("created_at DESC").Limit(5).Find(&posts)
|
||||||
component := index(posts)
|
component := index(posts)
|
||||||
|
@ -79,7 +85,7 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
e.GET("/login", func(c echo.Context) error {
|
e.GET("/g/login", func(c echo.Context) error {
|
||||||
component := loginPage(c.Get(middleware.DefaultCSRFConfig.ContextKey).(string))
|
component := loginPage(c.Get(middleware.DefaultCSRFConfig.ContextKey).(string))
|
||||||
err := component.Render(c.Request().Context(), c.Response().Writer)
|
err := component.Render(c.Request().Context(), c.Response().Writer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -88,11 +94,11 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
e.POST("/login", func(c echo.Context) error {
|
e.POST("/g/login", func(c echo.Context) error {
|
||||||
// read password file, check content, add session if correct
|
// read password file, check content, add session if correct
|
||||||
file, err := os.Open(passwordFilePath)
|
file, err := os.Open(passwordFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Response().Header().Set("HX-Redirect", "/")
|
c.Response().Header().Set("HX-Redirect", "/g/upload")
|
||||||
return c.NoContent(http.StatusUnauthorized)
|
return c.NoContent(http.StatusUnauthorized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,14 +122,14 @@ func main() {
|
||||||
sess.Values["user"] = "admin"
|
sess.Values["user"] = "admin"
|
||||||
sess.Save(c.Request(), c.Response())
|
sess.Save(c.Request(), c.Response())
|
||||||
|
|
||||||
c.Response().Header().Set("HX-Redirect", "/upload")
|
c.Response().Header().Set("HX-Redirect", "/g/upload")
|
||||||
return c.NoContent(http.StatusOK)
|
return c.NoContent(http.StatusOK)
|
||||||
})
|
})
|
||||||
|
|
||||||
e.GET("/upload", func(c echo.Context) error {
|
e.GET("/g/upload", func(c echo.Context) error {
|
||||||
sess, _ := session.Get("session", c)
|
sess, _ := session.Get("session", c)
|
||||||
if sess.Values["user"] != "admin" {
|
if sess.Values["user"] != "admin" {
|
||||||
return c.Redirect(http.StatusSeeOther, "/login")
|
return c.Redirect(http.StatusSeeOther, "/g/login")
|
||||||
}
|
}
|
||||||
component := uploadPage(c.Get(middleware.DefaultCSRFConfig.ContextKey).(string))
|
component := uploadPage(c.Get(middleware.DefaultCSRFConfig.ContextKey).(string))
|
||||||
err := component.Render(c.Request().Context(), c.Response().Writer)
|
err := component.Render(c.Request().Context(), c.Response().Writer)
|
||||||
|
@ -133,7 +139,7 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
e.POST("/upload", func(c echo.Context) error {
|
e.POST("/g/upload", func(c echo.Context) error {
|
||||||
file, err := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -168,11 +174,11 @@ func main() {
|
||||||
}
|
}
|
||||||
db.Create(&post)
|
db.Create(&post)
|
||||||
|
|
||||||
c.Response().Header().Set("HX-Redirect", "/")
|
c.Response().Header().Set("HX-Redirect", "/photos")
|
||||||
return c.NoContent(http.StatusOK)
|
return c.NoContent(http.StatusOK)
|
||||||
})
|
})
|
||||||
|
|
||||||
e.GET("/posts", func(c echo.Context) error {
|
e.GET("/g/pics", func(c echo.Context) error {
|
||||||
after, err := time.Parse(time.RFC3339, c.QueryParam("after"))
|
after, err := time.Parse(time.RFC3339, c.QueryParam("after"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -189,5 +195,5 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
e.Logger.Fatal(e.Start(":8080"))
|
e.Logger.Fatal(e.Start(":6844"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue