Kaynağa Gözat

brought htmx dependencies to the internal cdn i have

AETH-erial 7 ay önce
ebeveyn
işleme
f5db3c0d3b

+ 1 - 1
Makefile

@@ -23,6 +23,6 @@ build-seed-cmd:
 	go build -o ./build/linux/$(SEED_CMD)/$(SEED_CMD) ./cmd/$(SEED_CMD)/$(SEED_CMD).go
 
 dev-run:
-	go build -ldflags "-X main.WEB_ROOT=/home/aeth/keiji/html" \
+	go build -ldflags "-X main.WEB_ROOT=$(WEB_ROOT)" \
 	-o ./build/linux/$(WEBSERVER)/$(WEBSERVER) ./cmd/$(WEBSERVER)/$(WEBSERVER).go && \
 	./build/linux/$(WEBSERVER)/$(WEBSERVER) .env

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
html/htmx/htmx.min.js


+ 1 - 0
html/htmx/json-enc.js

@@ -0,0 +1 @@
+Found. Redirecting to /htmx.org@1.9.10/dist/ext/json-enc.js

+ 2 - 3
html/templates/admin.html

@@ -16,7 +16,6 @@
     <div class="container-fluid row">
         {{ range .Tables }}
             <div class="col">
-            
                 <div class="col container h-2 p-2" style="background-color: rgb(22, 22, 22); color: white; height: fit-content; font-size: larger; font-family: monospace;">
                     {{ .TableName }}
                 </div>
@@ -36,8 +35,8 @@
             {{ end }}
     </div>
     <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-    <script src="https://unpkg.com/htmx.org@1.9.4"></script> 
-    <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+    <script src="/api/v1/htmx/htmx.min.js"></script>
+    <script src="/api/v1/htmx/json-enc.js"></script>
 </body>
 </html>
 {{ end }}

+ 2 - 2
html/templates/blogpost.html

@@ -25,8 +25,8 @@
             <div class="col"></div>
         </div>
         <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-        <script src="https://unpkg.com/htmx.org@1.9.4"></script>
-        <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+        <script src="/api/v1/htmx/htmx.min.js"></script>
+        <script src="/api/v1/htmx/json-enc.js"></script>
     </body>
 
 </html>

+ 2 - 2
html/templates/blogpost_editor.html

@@ -57,8 +57,8 @@
         </div>
     </div>
     <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-    <script src="https://unpkg.com/htmx.org@1.9.4"></script>
-    <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+    <script src="/api/v1/htmx/htmx.min.js"></script>
+    <script src="/api/v1/htmx/json-enc.js"></script>
 </body>
 </html>
 {{ end }}

+ 2 - 3
html/templates/digital_art.html

@@ -17,15 +17,14 @@
                         <div class="row position-relative shadow-lg p-3 m-3 rounded justify-content-center"
                             style="width: 80vh; max-width: 95%; background-color: rgb(22, 22, 22);">
                                 {{ template "centered_image.html" . }}
-
                         </div>
                     </div>
                 </div>
             {{ end }}
             </div>
         <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-        <script src="https://unpkg.com/htmx.org@1.9.4"></script>
-        <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+        <script src="/api/v1/htmx/htmx.min.js"></script>
+        <script src="/api/v1/htmx/json-enc.js"></script>
     </body>
 </html>
 {{ end }}

+ 2 - 2
html/templates/home.html

@@ -19,8 +19,8 @@
         {{ end }}
         </div>
         <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-        <script src="https://unpkg.com/htmx.org@1.9.4"></script> 
-        <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+        <script src="/api/v1/htmx/htmx.min.js"></script>
+        <script src="/api/v1/htmx/json-enc.js"></script>
     </body>
 </html>
 {{ end }}

+ 2 - 2
html/templates/login.html

@@ -39,7 +39,7 @@
             </div>
         </div>
     </body>
-    <script src="https://unpkg.com/htmx.org@1.9.4"></script>
-    <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+    <script src="/api/v1/htmx/htmx.min.js"></script>
+    <script src="/api/v1/htmx/json-enc.js"></script>
 </html>
 {{ end }}

+ 2 - 2
html/templates/new_blogpost.html

@@ -57,8 +57,8 @@
         </div>
     </div>
     <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-    <script src="https://unpkg.com/htmx.org@1.9.4"></script>
-    <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+    <script src="/api/v1/htmx/htmx.min.js"></script>
+    <script src="/api/v1/htmx/json-enc.js"></script>
 </body>
 </html>
 {{ end }}

+ 2 - 2
html/templates/upload.html

@@ -33,8 +33,8 @@
         </div>
         <div class="col"></div>
     </div>
-    <script src="https://unpkg.com/htmx.org@1.9.4"></script>
-    <script src="https://unpkg.com/htmx.org/dist/ext/json-enc.js"></script>
+    <script src="/api/v1/htmx/htmx.min.js"></script>
+    <script src="/api/v1/htmx/json-enc.js"></script>
     <script type="text/javascript" src="/api/v1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
     </body>
 </html>

+ 26 - 0
pkg/controller/cdn_handlers.go

@@ -80,6 +80,32 @@ func (c *Controller) ServeMdbCss(ctx *gin.Context) {
 
 }
 
+
+// @Name ServeHtmx
+// @Summary serves some htmx assets
+// @Tags cdn
+// @Param file path string true "The JS file to serve to the client"
+// @Router /api/v1/htmx/{file} [get]
+func (c *Controller) ServeHtmx(ctx *gin.Context) {
+	f, exist := ctx.Params.Get("file")
+	if !exist {
+		ctx.JSON(404, map[string]string{
+			"Error": "the requested file could not be found",
+		})
+	}
+	css := fmt.Sprintf("%s/htmx/%s", c.WebRoot, f)
+	b, err := os.ReadFile(css)
+	if err != nil {
+		ctx.JSON(500, map[string]string{
+			"Error": "Could not serve the requested file",
+			"msg":   err.Error(),
+		})
+	}
+	ctx.Data(200, "text/javascript", b)
+
+}
+
+
 // @Name ServeAsset
 // @Summary serves assets to put in a webpage
 // @Tags cdn

+ 1 - 0
pkg/routes/register.go

@@ -25,6 +25,7 @@ func Register(e *gin.Engine, root string, domain string, redisPort string, redis
 	cdn.GET("/style/mdb/:file", c.ServeMdbCss)
 	cdn.GET("/assets/:file", c.ServeAsset)
 	cdn.GET("/images/:file", c.ServeImage)
+	cdn.GET("/htmx/:file", c.ServeHtmx)
 
 
 

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor