From ac288d40da3235b9382d685c9958ad167a758bcd Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sat, 31 Jul 2021 11:42:59 -0700 Subject: added archive page and viewing --- client.go | 93 ++++++++++++++++++++++++ database.go | 194 +++++++++++++++++++++++++++++++++++++++++++++++++-- main.go | 24 +++++++ outboxGet.go | 28 ++++---- outboxPost.go | 6 ++ static/archive.html | 81 +++++++++++++++++++++ static/main.html | 32 +++++---- static/ncatalog.html | 24 ++++--- static/npost.html | 18 +++-- static/nposts.html | 5 +- static/posts.html | 6 +- static/top.html | 55 +++++++++++++-- 12 files changed, 504 insertions(+), 62 deletions(-) create mode 100644 static/archive.html diff --git a/client.go b/client.go index f6b2f96..c157416 100644 --- a/client.go +++ b/client.go @@ -277,6 +277,7 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C 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 var returnData PageData @@ -308,6 +309,54 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C t.ExecuteTemplate(w, "layout", returnData) } +func ArchiveGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Collection){ + t := template.Must(template.New("").Funcs(template.FuncMap{ + "proxy": func(url string) string { + return MediaProxy(url) + }, + "short": func(actorName string, url string) string { + return shortURL(actorName, url) + }, + "shortExcerpt": func(post ObjectBase) template.HTML { + return template.HTML(ShortExcerpt(post)) + }, + "parseAttachment": func(obj ObjectBase, catalog bool) template.HTML { + return ParseAttachment(obj, catalog) + }, + "mod": func(i, j int) bool { return i % j == 0 }, + "sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/archive.html", "./static/bottom.html")) + + actor := collection.Actor + + var returnData PageData + returnData.Board.Name = actor.Name + returnData.Board.PrefName = actor.PreferredUsername + returnData.Board.InReplyTo = "" + returnData.Board.To = actor.Outbox + returnData.Board.Actor = *actor + returnData.Board.Summary = actor.Summary + returnData.Board.ModCred, _ = GetPasswordFromSession(r) + returnData.Board.Domain = Domain + returnData.Board.Restricted = actor.Restricted + returnData.Key = *Key + returnData.ReturnTo = "archive" + + returnData.Board.Post.Actor = actor.Id + + returnData.Instance = GetActorFromDB(db, Domain) + + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) + returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) + + returnData.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername + + returnData.Boards = Boards + + returnData.Posts = collection.OrderedItems + + t.ExecuteTemplate(w, "layout", returnData) +} + func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ t := template.Must(template.New("").Funcs(template.FuncMap{ "proxy": func(url string) string { @@ -455,6 +504,22 @@ func WantToServeCatalog(db *sql.DB, actorName string) (Collection, bool) { return collection, serve } +func WantToServeArchive(db *sql.DB, actorName string) (Collection, bool) { + + var collection Collection + serve := false + + actor := GetActorByNameFromDB(db, actorName) + + if actor.Id != "" { + collection = GetActorCollectionDBType(db, actor.Id, "Archive") + collection.Actor = &actor + return collection, true + } + + return collection, serve +} + func StripTransferProtocol(value string) string { re := regexp.MustCompile("(http://|https://)?(www.)?") @@ -924,3 +989,31 @@ func ConvertSize(size int64) string { return rValue; } + +func ShortExcerpt(post ObjectBase) string { + var returnString string + + if post.Name != "" { + returnString = post.Name + ": " + post.Content; + } else { + returnString = post.Content; + } + + re := regexp.MustCompile(`(^.{100})`) + + match := re.FindStringSubmatch(returnString) + + if len(match) > 0 { + returnString = match[0] + "..." + } + + re = regexp.MustCompile(`(^.+:)`) + + match = re.FindStringSubmatch(returnString) + + if len(match) > 0 { + returnString = strings.Replace(returnString, match[0], "" + match[0] + "", 1) + } + + return returnString +} diff --git a/database.go b/database.go index f0601ce..e3f4050 100644 --- a/database.go +++ b/database.go @@ -250,7 +250,17 @@ func WriteObjectReplyToLocalDB(db *sql.DB, id string, replyto string) { } func WriteObjectReplyToDB(db *sql.DB, obj ObjectBase) { - for _, e := range obj.InReplyTo { + for i, e := range obj.InReplyTo { + + if !CheckIfObjectOP(db, obj.Id) && i == 0 { + nType := GetObjectTypeDB(db, e.Id) + + if nType == "Archive" { + UpdateObjectTypeDB(db, obj.Id, "Archive") + } + } + + query := `select id from replies where id=$1 and inreplyto=$2` rows, err := db.Query(query, obj.Id, e.Id) @@ -268,7 +278,6 @@ func WriteObjectReplyToDB(db *sql.DB, obj ObjectBase) { _, err := db.Exec(query, obj.Id, e.Id) - CheckError(err, "error inserting replies db") } @@ -513,12 +522,54 @@ func GetObjectFromDBPage(db *sql.DB, id string, page int) Collection { return nColl } -func GetObjectFromDB(db *sql.DB, id string) Collection { +func GetActorObjectCollectionFromDB(db *sql.DB, actorId string) Collection { var nColl Collection var result []ObjectBase 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, actorId) + + CheckError(err, "error query object from db") + + defer rows.Close() + for rows.Next(){ + var post ObjectBase + var actor Actor + 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, &post.Sensitive) + + CheckError(err, "error scan object into post struct") + + post.Actor = actor.Id + + var postCnt int + var imgCnt int + post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post) + + post.Replies.TotalItems = postCnt + post.Replies.TotalImgs = imgCnt + + post.Attachment = GetObjectAttachment(db, attachID) + + post.Preview = GetObjectPreview(db, previewID) + + result = append(result, post) + } + + nColl.OrderedItems = result + + return nColl +} + +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, sensitive from activitystream where id=$1 order by updated desc` + rows, err := db.Query(query, id) CheckError(err, "error query object from db") @@ -651,7 +702,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, 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` + 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' or type='Archive') union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where id=$1 and (type='Note' or type='Archive')) as x` rows, err := db.Query(query, postID) @@ -770,7 +821,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, 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` + 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' or type='Archive') union select * from cacheactivitystream where id in (select id from replies where inreplyto=$1) and (type='Note' or type='Archive')) as x order by x.published asc` rows, err := db.Query(query, parent.Id) @@ -819,7 +870,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, sensitive 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' or type='Archive') order by updated asc` rows, err := db.Query(query, parent.Id) @@ -1781,3 +1832,134 @@ func IsInactiveTimestamp(db *sql.DB, timeStamp string) bool { return false } + +func ArchivePosts(db *sql.DB, actor Actor) { + if actor.Id != "" { + col := GetAllActorArchiveDB(db, actor.Id, 165) + for _, e := range col.OrderedItems { + for _, k := range e.Replies.OrderedItems { + UpdateObjectTypeDB(db, k.Id, "Archive") + } + UpdateObjectTypeDB(db, e.Id, "Archive") + } + } +} + +func GetAllActorArchiveDB(db *sql.DB, id string, offset int) Collection { + var nColl Collection + var result []ObjectBase + + query := `select x.id, x.updated from (select id, updated from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' union select id, updated 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, updated 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 offset $2` + + rows, err := db.Query(query, id, offset) + + CheckError(err, "error query object from db") + + defer rows.Close() + for rows.Next(){ + var post ObjectBase + + err = rows.Scan(&post.Id, &post.Updated) + + CheckError(err, "error scan object into post struct for archive") + + post.Replies, _, _ = GetObjectRepliesDB(db, post) + + result = append(result, post) + } + + nColl.OrderedItems = result + + return nColl +} + +func GetActorCollectionDBType(db *sql.DB, actorId string, nType 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, 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=$2 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=$2 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=$2) as x order by x.updated desc` + + rows, err := db.Query(query, actorId, nType) + + CheckError(err, "error query object from db archive") + + defer rows.Close() + for rows.Next(){ + var post ObjectBase + var actor Actor + 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, &post.Sensitive) + + CheckError(err, "error scan object into post struct archive") + + post.Actor = actor.Id + + var replies CollectionBase + + post.Replies = &replies + + post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesCount(db, post) + + post.Attachment = GetObjectAttachment(db, attachID) + + post.Preview = GetObjectPreview(db, previewID) + + result = append(result, post) + } + + nColl.OrderedItems = result + + return nColl +} + +func UpdateObjectTypeDB(db *sql.DB, id string, nType string) { + query := `update activitystream set type=$2 where id=$1 and type !='Tombstone'` + + _, err := db.Exec(query, id, nType) + + CheckError(err, "error updating activitystream reply type to archive") + + query = `update cacheactivitystream set type=$2 where id=$1 and type !='Tombstone'` + + _, err = db.Exec(query, id, nType) + + CheckError(err, "error updating cache reply type to archive") +} + +func UnArchiveLast(db *sql.DB) { + query := `select id, updated from activitystream where type='Archive' union select id, updated from cacheactivitystream where type='Archive' order by updated desc limit 1` + + rows, err := db.Query(query) + + CheckError(err, "error with unarchive last") + + var id, updated string + defer rows.Close() + rows.Next() + rows.Scan(&id, &updated) + + col := GetObjectFromDB(db, id) + + for _, e := range col.OrderedItems { + for _, k := range e.Replies.OrderedItems { + UpdateObjectTypeDB(db, k.Id, "Note") + } + UpdateObjectTypeDB(db, e.Id, "Note") + } +} + +func GetObjectTypeDB(db *sql.DB, id string) string { + query := `select type from activitystream where id=$1 union select type from cacheactivitystream where id=$1` + + rows, err := db.Query(query, id) + CheckError(err, "error with getting object type from db") + + var nType string + defer rows.Close() + rows.Next() + rows.Scan(&nType) + + return nType +} diff --git a/main.go b/main.go index 5da910a..d43fab0 100644 --- a/main.go +++ b/main.go @@ -69,6 +69,8 @@ func main() { FollowingBoards = GetActorFollowingDB(db, Domain) + StartupArchive(db) + Boards = GetBoardCollection(db) // root actor is used to follow remote feeds that are not local @@ -113,6 +115,7 @@ func main() { var actorReported bool var actorVerification bool var actorMainPage bool + var actorArchive bool var accept = r.Header.Get("Accept") @@ -135,6 +138,7 @@ func main() { actorFollowers = (path == "/" + actor.Name + "/followers") actorReported = (path == "/" + actor.Name + "/reported") actorVerification = (path == "/" + actor.Name + "/verification") + actorArchive = (path == "/" + actor.Name + "/archive") escapedActorName := strings.Replace(actor.Name, "*", "\\*", -1) escapedActorName = strings.Replace(escapedActorName, "^", "\\^", -1) @@ -253,6 +257,14 @@ func main() { return } + if actorArchive { + collection, valid := WantToServeArchive(db, actor.Name) + if valid { + ArchiveGet(w, r, db, collection) + } + return + } + if actorReported { GetActorReported(w, r, db, actor.Id) return @@ -843,6 +855,7 @@ func main() { go DeleteObjectRequest(db, id) } + UnArchiveLast(db) if !isOP { if (!IsIDLocal(db, id)){ @@ -890,6 +903,9 @@ func main() { TombstoneObjectAndReplies(db, id) } + UnArchiveLast(db) + + if(manage == "t"){ http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) return @@ -928,6 +944,8 @@ func main() { go DeleteObjectRequest(db, id) } + UnArchiveLast(db) + if(manage == "t"){ http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) return @@ -2898,3 +2916,9 @@ func GetReplyOP(db *sql.DB, link string) string { return id } + +func StartupArchive(db *sql.DB) { + for _, e := range FollowingBoards { + ArchivePosts(db, GetActorFromDB(db, e.Id)) + } +} diff --git a/outboxGet.go b/outboxGet.go index 4064f0b..f656b3e 100644 --- a/outboxGet.go +++ b/outboxGet.go @@ -9,7 +9,7 @@ func GetActorOutbox(w http.ResponseWriter, r *http.Request, db *sql.DB) { actor := GetActorFromPath(db, r.URL.Path, "/") var collection Collection - collection.OrderedItems = GetObjectFromDB(db, actor.Id).OrderedItems + collection.OrderedItems = GetActorObjectCollectionFromDB(db, actor.Id).OrderedItems collection.AtContext.Context = "https://www.w3.org/ns/activitystreams" collection.Actor = &actor @@ -32,17 +32,17 @@ func GetCollectionFromPath(db *sql.DB, path string) Collection { rows, err := db.Query(query, path) CheckError(err, "error query collection path from db") - + defer rows.Close() for rows.Next(){ var actor Actor var post ObjectBase var attachID string - var previewID string - + var previewID string + err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id) - + CheckError(err, "error scan object into post struct from path") post.Actor = actor.Id @@ -50,13 +50,13 @@ func GetCollectionFromPath(db *sql.DB, path string) Collection { post.InReplyTo = GetInReplyToDB(db, post) var postCnt int - var imgCnt int + var imgCnt int post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post) post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesCount(db, post) post.Replies.TotalItems = post.Replies.TotalItems + postCnt - post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt + post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt post.Attachment = GetObjectAttachment(db, attachID) @@ -65,11 +65,11 @@ func GetCollectionFromPath(db *sql.DB, path string) Collection { result = append(result, post) } - nColl.AtContext.Context = "https://www.w3.org/ns/activitystreams" + nColl.AtContext.Context = "https://www.w3.org/ns/activitystreams" nColl.OrderedItems = result - return nColl + return nColl } func GetObjectFromPath(db *sql.DB, path string) ObjectBase{ @@ -81,7 +81,7 @@ func GetObjectFromPath(db *sql.DB, path string) ObjectBase{ rows, err := db.Query(query, path) CheckError(err, "error query collection path from db") - + defer rows.Close() rows.Next() var attachID string @@ -89,9 +89,9 @@ func GetObjectFromPath(db *sql.DB, path string) ObjectBase{ var nActor Actor nObj.Actor = nActor.Id - + err = rows.Scan(&nObj.Id, &nObj.Name, &nObj.Content, &nObj.Type, &nObj.Published, &nObj.AttributedTo, &attachID, &previewID, &nObj.Actor) - + CheckError(err, "error scan object into post struct from path") var postCnt int @@ -102,11 +102,11 @@ func GetObjectFromPath(db *sql.DB, path string) ObjectBase{ nObj.Replies.TotalItems, nObj.Replies.TotalImgs = GetObjectRepliesCount(db, nObj) nObj.Replies.TotalItems = nObj.Replies.TotalItems + postCnt - nObj.Replies.TotalImgs = nObj.Replies.TotalImgs + imgCnt + nObj.Replies.TotalImgs = nObj.Replies.TotalImgs + imgCnt nObj.Attachment = GetObjectAttachment(db, attachID) nObj.Preview = GetObjectPreview(db, previewID) - return nObj + return nObj } diff --git a/outboxPost.go b/outboxPost.go index beb49fb..d54dd8e 100644 --- a/outboxPost.go +++ b/outboxPost.go @@ -55,6 +55,11 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { nObj.Actor = Domain + "/" + actor.Name nObj = WriteObjectToDB(db, nObj) + + if len(nObj.To) == 0 { + ArchivePosts(db, actor) + } + activity := CreateActivity("Create", nObj) activity = AddFollowersToActivity(db, activity) go MakeActivityRequest(db, activity) @@ -536,6 +541,7 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { if IsActorLocal(db, e) { if !IsActorLocal(db, activity.Actor.Id) { WriteObjectToCache(db, *activity.Object) + ArchivePosts(db, GetActorFromDB(db, e)) } } } diff --git a/static/archive.html b/static/archive.html new file mode 100644 index 0000000..2b7d69a --- /dev/null +++ b/static/archive.html @@ -0,0 +1,81 @@ +{{ define "header" }} +/{{ .Board.Name }}/ - Archive + + + + + + + + + + + +{{ if (index .Posts 0).Preview }} + + +{{ end }} + + +{{ end }} + +{{ define "top" }} +

/{{ .Board.Name }}/ - {{ .Board.PrefName }}

+

{{ .Board.Summary }}

+

Archived Posts

+{{ end }} + +{{ define "content" }} +{{ $board := .Board }} + +
+ +
+ + + + + + + + {{ range $i, $e := .Posts }} + {{ if mod $i 2 }} + + + + + + {{ else }} + + + + + + {{ end }} + {{ end }} +
No.Excerpt
{{ short $board.Actor.Outbox $e.Id }}{{ shortExcerpt $e }}[View]
{{ short $board.Actor.Outbox $e.Id }}{{ shortExcerpt $e }}[View]
+ +
+
+ +
+
+ +{{ end }} + +{{ define "script" }} + + +{{ end }} diff --git a/static/main.html b/static/main.html index 9209ed9..362b7b3 100644 --- a/static/main.html +++ b/static/main.html @@ -2,9 +2,9 @@ - + - + @@ -30,7 +30,7 @@ color: #820404 {{ end }} } - + .popup-box { {{ if .Board.Restricted }} border: 4px solid #d3caf0; @@ -47,8 +47,16 @@ {{ else }} background-color: #f9f9e0; {{ end }} - } - + } + + .box-alt { + {{ if .Board.Restricted }} + background-color: #d3caf0; + {{ else }} + background-color: #f0e2d9; + {{ end }} + } + .quote { color: #789922; } @@ -60,7 +68,7 @@ background-color: #f0e0d6; {{ end }} } - + :target > div > .post { {{ if .Board.Restricted }} background-color: #d6bad0; @@ -72,21 +80,21 @@ color: #117743; } - {{ template "header" . }} + {{ template "header" . }} @@ -96,9 +104,9 @@ {{ end }} {{ end }} {{ template "top" . }} - + {{ template "content" . }} - + {{ template "bottom" . }}
[Home][Rules][FAQ] diff --git a/static/ncatalog.html b/static/ncatalog.html index c7f5b30..8ce418a 100644 --- a/static/ncatalog.html +++ b/static/ncatalog.html @@ -19,25 +19,26 @@
+
{{ range .Posts }}
- {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} + {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} [Delete Post] {{ end }} {{ if .Attachment }} - {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} + {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} [Delete Attachment] - [Mark Sensitive] - {{ end }} + [Mark Sensitive] + {{ end }} - - + +
{{ parseAttachment . true }}
+ media.style = "display: none;" + } + {{ end }}
@@ -84,10 +85,11 @@
-
+
{{ end }} {{ define "bottom" }} {{ end }} diff --git a/static/npost.html b/static/npost.html index 419a1a9..2f0778f 100644 --- a/static/npost.html +++ b/static/npost.html @@ -15,8 +15,6 @@ {{ end }} - - {{ end }} {{ define "content" }} @@ -25,7 +23,6 @@
@@ -36,23 +33,24 @@
-{{ $replies := (index .Posts 0).Replies }} +{{ $replies := (index .Posts 0).Replies }} {{ $replies.TotalItems }} / {{ $replies.TotalImgs }} -
- [Post a Reply] + +
+{{ if eq (index .Posts 0).Type "Note" }} +[Post a Reply] +{{ end }}
+
{{ end }} {{ define "script" }} + - {{ end }} diff --git a/static/nposts.html b/static/nposts.html index 2b05b66..e70b982 100644 --- a/static/nposts.html +++ b/static/nposts.html @@ -10,15 +10,14 @@ - {{ end }} - {{ define "content" }} {{ $board := .Board }}
@@ -28,6 +27,7 @@
@@ -54,5 +54,6 @@ {{ end }} {{ define "script" }} + {{ end }} diff --git a/static/posts.html b/static/posts.html index 8ee3844..0349ebb 100644 --- a/static/posts.html +++ b/static/posts.html @@ -45,7 +45,7 @@ } {{ end }} - {{ .Name }}{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }} {{ .TripCode }} {{ .Published }} No. {{ short $board.Actor.Outbox .Id }} {{ if ne .Type "Tombstone" }}[Report]{{ end }} + {{ .Name }}{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }} {{ .TripCode }} {{ .Published }} No. {{ short $board.Actor.Outbox .Id }} {{ if ne .Type "Tombstone" }}[Report]{{ end }}

{{ parseContent $board.Actor $opId .Content $thread }}

{{ if .Replies }} {{ $replies := .Replies }} @@ -68,7 +68,7 @@ [Delete Attachment] [Mark Sensitive] {{ end }} - File {{ shortImg (index .Attachment 0).Name }} ({{ convertSize (index .Attachment 0).Size }}) + File {{ shortImg (index .Attachment 0).Name }} ({{ convertSize (index .Attachment 0).Size }})
@@ -97,7 +97,7 @@ } {{ end }} - {{ .Name }}{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }} {{ .TripCode }} {{ .Published }} No. {{ short $board.Actor.Outbox .Id }} {{ if ne .Type "Tombstone" }}[Report]{{ end }} + {{ .Name }}{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }} {{ .TripCode }} {{ .Published }} No. {{ short $board.Actor.Outbox .Id }} {{ if ne .Type "Tombstone" }}[Report]{{ end }} {{ $parentId := .Id }} {{ if .Replies.OrderedItems }} {{ range .Replies.OrderedItems }} diff --git a/static/top.html b/static/top.html index 952feb0..0081fc7 100644 --- a/static/top.html +++ b/static/top.html @@ -3,11 +3,12 @@

/{{ .Board.Name }}/ - {{ .Board.PrefName }}

{{ .Board.Summary }}

{{ $len := len .Posts }} + {{ if eq $len 0 }} {{ if .Board.InReplyTo }} - {{ else }} + {{ else }} - {{ end }} + {{ end }}

@@ -35,9 +36,55 @@
+ + {{ else }} + + {{ if eq (index .Posts 0).Type "Note" }} + {{ if .Board.InReplyTo }} + + {{ else }} + + {{ end }} + {{ $len := len .Posts }} +
+
+
+
+
+ {{ if .Board.InReplyTo }}{{ end }}
+ {{ if eq .Board.InReplyTo "" }} +
+
+ {{ end }} +
+
+ + + + + +

+ Mark attachment as sensitive

+ +
+
+
+ +
+
+
+ {{ else }} +

Archived Post

+ {{ end }} + {{ end }}
{{ end }} -- cgit v1.2.3