feat: add grid for threads

This commit is contained in:
Yanislav Igonin 2021-08-30 23:29:51 +03:00
parent 5c7551b6ad
commit c3e4bf7204
4 changed files with 30 additions and 19 deletions

View File

@ -24,6 +24,7 @@ func main() {
router := gin.Default() router := gin.Default()
router.LoadHTMLGlob("templates/*.html") router.LoadHTMLGlob("templates/*.html")
router.Static("/uploads", "./uploads") router.Static("/uploads", "./uploads")
router.Static("/static", "./static")
router.GET("/", Controllers.GetThreads) router.GET("/", Controllers.GetThreads)
router.POST("/", Controllers.CreateThread) router.POST("/", Controllers.CreateThread)
router.GET("/:threadId", Controllers.GetThread) router.GET("/:threadId", Controllers.GetThread)

View File

@ -43,7 +43,7 @@ func getThread(id int) Thread {
var ThreadsDb = []Thread{} var ThreadsDb = []Thread{}
func SeedMocks() { func SeedMocks() {
for i := 1; i < 101; i++ { for i := 1; i < 10; i++ {
ThreadsDb = append(ThreadsDb, getThread(i)) ThreadsDb = append(ThreadsDb, getThread(i))
} }
} }

0
static/index.css Normal file
View File

View File

@ -14,11 +14,16 @@
integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj"
crossorigin="anonymous"> crossorigin="anonymous">
</script> </script>
<link
href="/static/index.css"
rel="stylesheet"
>
<!-- Primary Meta Tags --> <!-- Primary Meta Tags -->
<title>Micrach</title> <title>Micrach</title>
<meta name="title" content="Micrach"> <meta name="title" content="Micrach">
<meta name="description" content="Single board imageboard."> <meta name="description" content="Single board imageboard.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Open Graph / Facebook --> <!-- Open Graph / Facebook -->
<meta property="og:type" content="website"> <meta property="og:type" content="website">
@ -39,10 +44,13 @@
<h1 class="display-1 text-center">Welcome to Micrach</h1> <h1 class="display-1 text-center">Welcome to Micrach</h1>
<div class="container"> <div class="container">
<div class="row row-cols-auto gy-4">
{{range $Thread := .}} {{range $Thread := .}}
<div class="col col-sm-6 col-md-4 col-lg-3">
{{$FirstPost := index $Thread.Posts 0}} {{$FirstPost := index $Thread.Posts 0}}
<div class="card" style="width: 18rem;"> <div class="card">
{{$FirstFile := index $FirstPost.Files 0}} {{$FirstFile := index $FirstPost.Files 0}}
<img <img
@ -56,9 +64,11 @@
<a href="/{{$Thread.ID}}" class="btn btn-primary">Open</a> <a href="/{{$Thread.ID}}" class="btn btn-primary">Open</a>
</div> </div>
</div> </div>
</div>
{{end}} {{end}}
</div> </div>
</div>
</body> </body>
</html> </html>