1package html
2
3import (
4 "fmt"
5 "generate/config"
6 "generate/piece"
7 "time"
8)
9
10func Wrapper(CSS string, innerHTML string) string {
11 return fmt.Sprintf(`
12 <!DOCTYPE html>
13<html lang="en">
14<!-- Autogenerated on %s-->
15 <head>
16 <!-- Stylesheet-->
17 <style>
18 @import url('https://fonts.googleapis.com/css2?family=Yeseva+One&display=swap');
19 @font-face {
20 font-family: 'Begika';
21 src: url('assets/fonts/begika.ttf') format('truetype');
22 }
23 body{
24 margin:0;
25 overflow-y: hidden;
26 }
27 #background{
28 position:fixed;
29 height:100vh;
30 width:100vw;
31 background: rgb(210,210,210);
32 background: linear-gradient(0deg, rgba(210,210,210,1) 0%%, rgba(247,247,247,1) 19%%, rgba(247,247,247,1) 100%%);
33 }
34
35 #shadows{
36 position:absolute;
37 height:100vh;
38 pointer-events: none;
39 background-image: url(assets/images/gallery-wall.png);
40 background-size: cover;
41 mix-blend-mode: multiply;
42 }
43
44 .piece-container {
45 padding:%dpx;
46 }
47
48 .piece-container,.info-card{
49 position:absolute;
50 background:white;
51 box-shadow: #d6dbe1 -%dpx %dpx 4px;
52 }
53
54 .info-card{
55 width:%dpx;
56 height:%dpx;
57 padding:%dpx;
58 font-family: "Begika", serif;
59 }
60
61 .info-card-title{
62 font-size:24px;
63 }
64
65 .info-card-date{
66 font-size:12px;
67 }
68
69 #gallery-container{
70 margin: 0;
71 position: absolute;
72 top: 50%%;
73 -ms-transform: translateY(-50%%);
74 transform: translateY(-50%%);
75 height:%dpx;
76 }
77
78 #gallery-title{
79 position:absolute;
80 top:420px;
81 left:200px;
82 font-family: "Begika", serif;
83 font-size:128px;
84 }
85 %s
86 </style>
87 <!-- Title Element-->
88 <title>gallery.visit | ontake.dev</title>
89 <!-- Icon-->
90 <link rel="icon" type="image/webp" href="/assets/images/icon.png" />
91 <!-- Metadata-->
92 <meta property="og:type" content="website" />
93 <meta property="og:url" content="https://ontake.dev/gallery/visit" />
94 <meta property="og:title" content="gallery.visit | ontake.dev" />
95 <meta name="viewport" content="width=device-width, initial-scale=0.1" />
96 </head>
97
98 <body>
99 <div id="background"></div>
100 <div id="gallery-title">OnTake's<br>Gallery</div>
101 <div id="content">
102 %s
103 </div>
104 </body>
105</html>
106`, time.Now().Format("02-Jan-2006"), config.PiecePadding, config.ShadowOffset, config.ShadowOffset, config.InfoCardWidth-config.InfoCardPadding*2, config.InfoCardHeight-config.InfoCardPadding*2, config.InfoCardPadding, config.GalleryHeight, CSS, innerHTML)
107}
108
109func GeneratePiecesHTML(pieces []piece.Piece) string {
110 maxX := 0.0
111 innerHTML := ""
112 for _, currpiece := range pieces {
113 pieceHTML, curMaxX := piece.GeneratePieceHTML(currpiece, pieces)
114 maxX = max(maxX, curMaxX)
115 innerHTML += pieceHTML
116 }
117 return fmt.Sprintf(`<div id="gallery-container" style="width:%fpx">%s</div><div id="shadows" style="width:%fpx"></div>`, maxX+config.GalleryPadding, innerHTML, maxX+config.GalleryPadding)
118}
119
120func GeneratePage() string {
121 return Wrapper("", GeneratePiecesHTML(piece.GalleryPieces))
122}