diff options
author | FChannel <> | 2021-06-19 18:26:14 -0700 |
---|---|---|
committer | FChannel <> | 2021-06-19 18:26:14 -0700 |
commit | 6b265b0a8c2e45422f4a4601e041d44e5cef1c1b (patch) | |
tree | 7480eb20d741caa0c0e0b9ae03dee8bfaa739c16 | |
parent | a257a631ad6c9d6bcb3ae91057ca74a5e1d9515c (diff) |
added sensitive content checkbox for upload
-rw-r--r-- | activityPubStruct.go | 3 | ||||
-rw-r--r-- | cacheDatabase.go | 8 | ||||
-rw-r--r-- | database.go | 51 | ||||
-rw-r--r-- | databaseschema.psql | 3 | ||||
-rw-r--r-- | main.go | 1 | ||||
-rw-r--r-- | outboxPost.go | 1 | ||||
-rw-r--r-- | static/bottom.html | 3 | ||||
-rw-r--r-- | static/js/footerscript.js | 4 | ||||
-rw-r--r-- | static/posts.html | 41 | ||||
-rw-r--r-- | static/sensitive.png (renamed from static/sensative.png) | bin | 3737 -> 3737 bytes | |||
-rw-r--r-- | static/top.html | 1 |
11 files changed, 74 insertions, 42 deletions
diff --git a/activityPubStruct.go b/activityPubStruct.go index d74ae82..b19536a 100644 --- a/activityPubStruct.go +++ b/activityPubStruct.go @@ -137,7 +137,8 @@ type ObjectBase struct { Bcc string `json:"Bcc,omitempty"` MediaType string `json:"mediatype,omitempty"` Duration string `json:"duration,omitempty"` - Size int64 `json:"size,omitempty"` + Size int64 `json:"size,omitempty"` + Sensitive bool `json:"sensitive"` } type CryptoCur struct { diff --git a/cacheDatabase.go b/cacheDatabase.go index 390e98e..c234520 100644 --- a/cacheDatabase.go +++ b/cacheDatabase.go @@ -77,9 +77,9 @@ func WriteActivitytoCache(db *sql.DB, obj ObjectBase) { return } - query = `insert into cacheactivitystream (id, type, name, content, published, updated, attributedto, actor, tripcode) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)` + query = `insert into cacheactivitystream (id, type, name, content, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Published, obj.AttributedTo, obj.Actor.Id, obj.TripCode) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Published, obj.AttributedTo, obj.Actor.Id, obj.TripCode, obj.Sensitive) if e != nil{ fmt.Println("error inserting new activity cache") @@ -108,9 +108,9 @@ func WriteActivitytoCacheWithAttachment(db *sql.DB, obj ObjectBase, attachment O return } - query = `insert into cacheactivitystream (id, type, name, content, attachment, preview, published, updated, attributedto, actor, tripcode) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)` + query = `insert into cacheactivitystream (id, type, name, content, attachment, preview, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, preview.Id, obj.Published, obj.Published, obj.AttributedTo, obj.Actor.Id, obj.TripCode) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, preview.Id, obj.Published, obj.Published, obj.AttributedTo, obj.Actor.Id, obj.TripCode, obj.Sensitive) if e != nil{ fmt.Println("error inserting new activity with attachment cache") diff --git a/database.go b/database.go index 948bb38..7fdbb5e 100644 --- a/database.go +++ b/database.go @@ -6,7 +6,6 @@ import _ "github.com/lib/pq" import "time" import "os" import "strings" -// import "regexp" import "sort" func GetActorFromDB(db *sql.DB, id string) Actor { @@ -365,9 +364,9 @@ func WriteActivitytoDB(db *sql.DB, obj ObjectBase) { obj.Content = EscapeString(obj.Content) obj.AttributedTo = EscapeString(obj.AttributedTo) - query := `insert into activitystream (id, type, name, content, published, updated, attributedto, actor, tripcode) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)` + query := `insert into activitystream (id, type, name, content, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id, obj.TripCode) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id, obj.TripCode, obj.Sensitive) if e != nil{ fmt.Println("error inserting new activity") @@ -381,9 +380,9 @@ func WriteActivitytoDBWithAttachment(db *sql.DB, obj ObjectBase, attachment Obje obj.Content = EscapeString(obj.Content) obj.AttributedTo = EscapeString(obj.AttributedTo) - query := `insert into activitystream (id, type, name, content, attachment, preview, published, updated, attributedto, actor, tripcode) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)` + query := `insert into activitystream (id, type, name, content, attachment, preview, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, preview.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id, obj.TripCode) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, preview.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id, obj.TripCode, obj.Sensitive) if e != nil{ fmt.Println("error inserting new activity with attachment") @@ -420,7 +419,7 @@ func GetActivityFromDB(db *sql.DB, id string) Collection { nColl.Actor = &nActor - query := `select actor, id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where id=$1 order by updated asc` + query := `select actor, id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where id=$1 order by updated asc` rows, err := db.Query(query, id) @@ -433,7 +432,7 @@ func GetActivityFromDB(db *sql.DB, id string) Collection { var attachID string var previewID string - err = rows.Scan(&nColl.Actor.Id, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&nColl.Actor.Id, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error scan object into post struct") @@ -462,7 +461,7 @@ func GetObjectFromDBPage(db *sql.DB, id string, page int) Collection { var nColl Collection var result []ObjectBase - query := `select count (x.id) over(), x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from cacheactivitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note') as x order by x.updated desc limit 8 offset $2` + query := `select count (x.id) over(), x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note') as x order by x.updated desc limit 8 offset $2` rows, err := db.Query(query, id, page * 8) @@ -476,7 +475,7 @@ func GetObjectFromDBPage(db *sql.DB, id string, page int) Collection { var attachID string var previewID string - err = rows.Scan(&count, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&count, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error scan object into post struct") @@ -506,7 +505,7 @@ func GetObjectFromDB(db *sql.DB, id string) Collection { var nColl Collection var result []ObjectBase - query := `select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' order by updated desc` + query := `select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' order by updated desc` rows, err := db.Query(query, id) @@ -519,7 +518,7 @@ func GetObjectFromDB(db *sql.DB, id string) Collection { var attachID string var previewID string - err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error scan object into post struct") @@ -548,7 +547,7 @@ func GetObjectFromDBCatalog(db *sql.DB, id string) Collection { var nColl Collection var result []ObjectBase - query := `select x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from cacheactivitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note') as x order by x.updated desc` + query := `select x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note') as x order by x.updated desc` rows, err := db.Query(query, id) @@ -561,7 +560,7 @@ func GetObjectFromDBCatalog(db *sql.DB, id string) Collection { var attachID string var previewID string - err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error scan object into post struct") @@ -589,7 +588,7 @@ func GetObjectByIDFromDB(db *sql.DB, postID string) Collection { var nColl Collection var result []ObjectBase - query := `select x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from activitystream where id=$1 and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode from cacheactivitystream where id=$1 and type='Note') as x` + query := `select x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where id=$1 and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where id=$1 and type='Note') as x` rows, err := db.Query(query, postID) @@ -602,7 +601,7 @@ func GetObjectByIDFromDB(db *sql.DB, postID string) Collection { var attachID string var previewID string - err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.Updated, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error scan object into post struct") @@ -657,7 +656,7 @@ func GetObjectRepliesDBLimit(db *sql.DB, parent ObjectBase, limit int) (*Collect var nColl CollectionBase var result []ObjectBase - query := `select count(x.id) over(), sum(case when RTRIM(x.attachment) = '' then 0 else 1 end) over(), x.id, x.name, x.content, x.type, x.published, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode from (select * from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and type='Note') as x order by x.published desc limit $2` + query := `select count(x.id) over(), sum(case when RTRIM(x.attachment) = '' then 0 else 1 end) over(), x.id, x.name, x.content, x.type, x.published, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select * from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and type='Note') as x order by x.published desc limit $2` rows, err := db.Query(query, parent.Id, limit) @@ -675,7 +674,7 @@ func GetObjectRepliesDBLimit(db *sql.DB, parent ObjectBase, limit int) (*Collect post.InReplyTo = append(post.InReplyTo, parent) - err = rows.Scan(&postCount, &attachCount, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&postCount, &attachCount, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error with replies db scan") @@ -707,7 +706,7 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, in var nColl CollectionBase var result []ObjectBase - query := `select count(x.id) over(), sum(case when RTRIM(x.attachment) = '' then 0 else 1 end) over(), x.id, x.name, x.content, x.type, x.published, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode from (select * from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and type='Note') as x order by x.published asc` + query := `select count(x.id) over(), sum(case when RTRIM(x.attachment) = '' then 0 else 1 end) over(), x.id, x.name, x.content, x.type, x.published, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select * from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and type='Note') as x order by x.published asc` rows, err := db.Query(query, parent.Id) @@ -725,7 +724,7 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, in post.InReplyTo = append(post.InReplyTo, parent) - err = rows.Scan(&postCount, &attachCount, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&postCount, &attachCount, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error with replies db scan") @@ -755,7 +754,7 @@ func GetObjectRepliesReplies(db *sql.DB, parent ObjectBase) (*CollectionBase, in var nColl CollectionBase var result []ObjectBase - query := `select id, name, content, type, published, attributedto, attachment, preview, actor, tripcode from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' order by updated asc` + query := `select id, name, content, type, published, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' order by updated asc` rows, err := db.Query(query, parent.Id) @@ -770,7 +769,7 @@ func GetObjectRepliesReplies(db *sql.DB, parent ObjectBase) (*CollectionBase, in post.InReplyTo = append(post.InReplyTo, parent) - err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error with replies replies db scan") @@ -793,7 +792,7 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, var nColl CollectionBase var result []ObjectBase - query := `select count(x.id) over(), sum(case when RTRIM(x.attachment) = '' then 0 else 1 end) over(), x.id, x.name, x.content, x.type, x.published, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode from (select * from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and type='Note') as x order by x.published asc` + query := `select count(x.id) over(), sum(case when RTRIM(x.attachment) = '' then 0 else 1 end) over(), x.id, x.name, x.content, x.type, x.published, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select * from activitystream where id in (select id from replies where inreplyto=$1) and type='Note' union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and type='Note') as x order by x.published asc` rows, err := db.Query(query, parent.Id) @@ -810,7 +809,7 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, post.InReplyTo = append(post.InReplyTo, parent) - err = rows.Scan(&postCount, &attachCount, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode) + err = rows.Scan(&postCount, &attachCount, &post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id, &post.TripCode, &post.Sensitive) CheckError(err, "error with replies replies db scan") @@ -1417,11 +1416,7 @@ func DeleteCaptchaCodeDB(db *sql.DB, verify string) { } func EscapeString(text string) string { - // re := regexp.MustCompile("(?i)(n)+(\\s+)?(i)+(\\s+)?(g)+(\\s+)?(e)+?(\\s+)?(r)+(\\s+)?") - // text = re.ReplaceAllString(text, "I love black people") - // re = regexp.MustCompile("(?i)(n)+(\\s+)?(i)+(\\s+)?(g)(\\s+)?(g)+(\\s+)?") - // text = re.ReplaceAllString(text, "I love black people") - // text = strings.Replace(text, "<", "<", -1) + text = strings.Replace(text, "<", "<", -1) return text } diff --git a/databaseschema.psql b/databaseschema.psql index a9ede23..e12813e 100644 --- a/databaseschema.psql +++ b/databaseschema.psql @@ -217,3 +217,6 @@ file varchar(100) ); ALTER TABLE actor ADD COLUMN IF NOT EXISTS publicKeyPem varchar(100) default ''; + +ALTER TABLE activitystream ADD COLUMN IF NOT EXISTS sensitive boolean default false; +ALTER TABLE cacheactivitystream ADD COLUMN IF NOT EXISTS sensitive boolean default false;
\ No newline at end of file @@ -364,7 +364,6 @@ func main() { CheckError(err, "error with post form req") req.Header.Set("Content-Type", we.FormDataContentType()) - req.Header.Set("Authorization", "Basic " + *Key) resp, err := http.DefaultClient.Do(req) diff --git a/outboxPost.go b/outboxPost.go index e86703d..c5e582a 100644 --- a/outboxPost.go +++ b/outboxPost.go @@ -351,6 +351,7 @@ func ObjectFromForm(r *http.Request, db *sql.DB, obj ObjectBase) ObjectBase { obj.TripCode = EscapeString(r.FormValue("tripcode")) obj.Name = EscapeString(r.FormValue("subject")) obj.Content = EscapeString(r.FormValue("comment")) + obj.Sensitive = (r.FormValue("sensitive") != "") obj = ParseOptions(r, obj) diff --git a/static/bottom.html b/static/bottom.html index 8774419..19c82c6 100644 --- a/static/bottom.html +++ b/static/bottom.html @@ -6,11 +6,12 @@ <input id="reply-options" name="options" size="43" type="text" placeholder="Options" maxlength="100"> <textarea id="reply-comment" name="comment" rows="12" cols="54" style="width: 396px;" maxlength="2000"></textarea> <input id="reply-file" name="file" type="file"> - <input id="reply-submit" type="submit" value="Reply" style="float: right;"> + <input id="reply-submit" type="submit" value="Reply" style="float: right;"><br><br> <input type="hidden" id="inReplyTo-box" name="inReplyTo" value="{{ .Board.InReplyTo }}"> <input type="hidden" id="sendTo" name="sendTo" value="{{ .Board.To }}"> <input type="hidden" id="boardName" name="boardName" value="{{ .Board.Name }}"> <input type="hidden" id="captchaCode" name="captchaCode" value="{{ .Board.CaptchaCode }}"> + <input type="checkbox" name="sensitive"><span>Mark attachment as sensitive</span><br><br> <div style="width: 202px; margin: 0 auto; padding-top: 12px;"> <label for="captcha">Captcha:</label><br> <input style="display: inline-block;" type="text" id="captcha" name="captcha" autocomplete="off"><br> diff --git a/static/js/footerscript.js b/static/js/footerscript.js index b68c3b4..a63f422 100644 --- a/static/js/footerscript.js +++ b/static/js/footerscript.js @@ -3,6 +3,10 @@ var imgArray = [].slice.call(imgs); imgArray.forEach(function(img, i){ img.addEventListener("click", function(e){ + var id = img.getAttribute("id") + var media = document.getElementById("media-" + id) + var sensitive = document.getElementById("sensitive-" + id) + if(img.getAttribute("enlarge") == "0") { var attachment = img.getAttribute("attachment") diff --git a/static/posts.html b/static/posts.html index bfcc84b..a6cac44 100644 --- a/static/posts.html +++ b/static/posts.html @@ -14,14 +14,27 @@ {{ if .Attachment }} {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} <a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Attachment]</a> + <a href="/marksensitive?id={{ .Id }}&board={{ $board.Actor.Name }}">[Mark Sensitive]</a> {{ end }} <span style="display: block;">File: <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name }}</a><span id="{{ .Id }}-size">({{ (index .Attachment 0).Size }})</span></span> + <div id="hide-{{ .Id }}" style="display: none;">[Hide]</div> + <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div> <div id="media-{{ .Id }}"></div> <script> media = document.getElementById("media-{{ .Id }}") + + if({{ .Sensitive }} && {{ $board.Actor.Restricted }}){ + sensitive = document.getElementById("sensitive-{{ .Id }}") + hide = document.getElementById("hide-{{ .Id }}") + sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"} + hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"} + sensitive.style = "display: block" + media.style = "display: none;" + } + if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){ var img = document.createElement("img"); - img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px; cursor: pointer;" + img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" img.setAttribute("id", "img") img.setAttribute("main", "1") img.setAttribute("enlarge", "0") @@ -80,21 +93,35 @@ {{ if .Attachment }} {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} <a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Attachment]</a> + <a href="/marksensitive?id={{ .Id }}&board={{ $board.Actor.Name }}">[Mark Sensitive]</a> {{ end }} <span style="display: block;">File <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name }}</a> <span id="{{ .Id }}-size">({{ (index .Attachment 0).Size }})</span></span> - <div id="media-{{ .Id }}"></div> + <div id="hide-{{ .Id }}" style="display: none;">[Hide]</div> + <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div> + <div id="media-{{ .Id }}" sensitive="0"></div> <script> media = document.getElementById("media-{{ .Id }}") + + if({{ .Sensitive }} && {{ $board.Actor.Restricted }}){ + sensitive = document.getElementById("sensitive-{{ .Id }}") + hide = document.getElementById("hide-{{ .Id }}") + sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"} + hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"} + sensitive.style = "display: block" + media.style = "display: none;" + } + if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){ var img = document.createElement("img"); - img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px; cursor: pointer;" + img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" img.setAttribute("id", "img") img.setAttribute("main", "1") img.setAttribute("enlarge", "0") img.setAttribute("attachment", "{{ (index .Attachment 0).Href }}") - {{ if .Preview.Href }} + img.setAttribute("post", "{{ .Id }}") + {{ if and .Preview.Href . }} img.setAttribute("src", "{{ .Preview.Href }}") - img.setAttribute("preview", "{{ .Preview.Href }}") + img.setAttribute("preview", "{{ .Preview.Href }}") {{ else }} img.setAttribute("src", "{{ (index .Attachment 0).Href }}") img.setAttribute("preview", "{{ (index .Attachment 0).Href }}") @@ -107,7 +134,7 @@ audio.controls = 'controls' audio.preload = 'metadata' audio.src = '{{ (index .Attachment 0).Href }}' - audio.type = '{{ (index .Attachment 0).MediaType }}' + audio.type = '{{ (index .Attachment 0).MediaType }}' audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" audio.innerText = 'Audio is not supported.' media.appendChild(audio) @@ -119,7 +146,7 @@ video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' - video.type = '{{ (index .Attachment 0).MediaType }}' + video.type = '{{ (index .Attachment 0).MediaType }}' video.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" video.innerText = 'Video is not supported.' media.appendChild(video) diff --git a/static/sensative.png b/static/sensitive.png Binary files differindex ea706c8..ea706c8 100644 --- a/static/sensative.png +++ b/static/sensitive.png diff --git a/static/top.html b/static/top.html index b891e14..e2612e8 100644 --- a/static/top.html +++ b/static/top.html @@ -25,6 +25,7 @@ <input type="hidden" id="boardName" name="boardName" value="{{ .Board.Name }}"> <input type="hidden" id="captchaCode" name="captchaCode" value="{{ .Board.CaptchaCode }}"> <input type="file" id="file" name="file" {{ if gt $len 1 }} required {{ else }} {{ if eq $len 0 }} required {{ end }} {{ end }} ><br><br> + <input type="checkbox" name="sensitive"><span>Mark attachment as sensitive</span><br><br> <label stye="display: inline-block;" for="captcha">Captcha:</label> <br> <input style="display: inline-block;" type="text" id="captcha" name="captcha" autocomplete="off"><br> |