From fa895350a8bdf2eb93495dbf569fa3fe0680d2af Mon Sep 17 00:00:00 2001
From: FChannel <>
Date: Thu, 22 Jul 2021 15:14:14 -0700
Subject: removed media javascript parsing it on server
---
client.go | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 85 insertions(+), 1 deletion(-)
(limited to 'client.go')
diff --git a/client.go b/client.go
index 12e6147..5d824bf 100644
--- a/client.go
+++ b/client.go
@@ -190,7 +190,10 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co
},
"short": func(actorName string, url string) string {
return shortURL(actorName, url)
- },
+ },
+ "parseAttachment": func(obj ObjectBase, catalog bool) template.HTML {
+ return ParseAttachment(obj, catalog)
+ },
"sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/nposts.html", "./static/top.html", "./static/bottom.html", "./static/posts.html"))
@@ -254,6 +257,9 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C
},
"short": func(actorName string, url string) string {
return shortURL(actorName, url)
+ },
+ "parseAttachment": func(obj ObjectBase, catalog bool) template.HTML {
+ return ParseAttachment(obj, catalog)
},
"sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/ncatalog.html", "./static/top.html"))
actor := collection.Actor
@@ -294,6 +300,9 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){
},
"short": func(actorName string, url string) string {
return shortURL(actorName, url)
+ },
+ "parseAttachment": func(obj ObjectBase, catalog bool) template.HTML {
+ return ParseAttachment(obj, catalog)
},
"sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/npost.html", "./static/top.html", "./static/bottom.html", "./static/posts.html"))
@@ -702,3 +711,78 @@ func ParseContent(db *sql.DB, board Actor, op string, content string, thread Obj
return template.HTML(nContent)
}
+
+func ParseAttachment(obj ObjectBase, catalog bool) template.HTML {
+
+ if len(obj.Attachment) < 1 {
+ return ""
+ }
+
+ var media string
+ if(regexp.MustCompile(`image\/`).MatchString(obj.Attachment[0].MediaType)){
+ media = ""
+
+ return template.HTML(media)
+ }
+
+ if(regexp.MustCompile(`audio\/`).MatchString(obj.Attachment[0].MediaType)){
+ media = ""
+
+ return template.HTML(media)
+ }
+
+ if(regexp.MustCompile(`video\/`).MatchString(obj.Attachment[0].MediaType)){
+ media = ""
+
+ return template.HTML(media)
+ }
+
+ return template.HTML(media)
+}
--
cgit v1.2.3