From 4e3848cadbb3fd89b94a7ef24838173939d198db Mon Sep 17 00:00:00 2001 From: knotteye Date: Thu, 1 Jul 2021 17:56:04 -0500 Subject: Add a list of local boards and server news --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 972e69e..037f240 100644 --- a/main.go +++ b/main.go @@ -598,6 +598,17 @@ func main() { MakeActivityRequestOutbox(db, newActorActivity) http.Redirect(w, r, "/" + *Key, http.StatusSeeOther) }) + + http.HandleFunc("/" + *Key + "/postnews", func(w http.ResponseWriter, r *http.Request) { + var newsitem NewsItem + + newsitem.Title = r.FormValue("title") + newsitem.Content = r.FormValue("summary") + + WriteNewsToDB(db, newsitem) + + http.Redirect(w, r, "/", http.StatusSeeOther) + }) http.HandleFunc("/verify", func(w http.ResponseWriter, r *http.Request){ if(r.Method == "POST") { -- cgit v1.2.3 From 168225daa21fe494bcd74ab6c90d6498ecf9f1e3 Mon Sep 17 00:00:00 2001 From: knotteye Date: Thu, 1 Jul 2021 20:26:49 -0500 Subject: Make news list links to full page news articles --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 037f240..4f7f3e8 100644 --- a/main.go +++ b/main.go @@ -286,6 +286,21 @@ func main() { w.WriteHeader(http.StatusForbidden) w.Write([]byte("404 no path")) }) + + http.HandleFunc("/news/", func(w http.ResponseWriter, r *http.Request){ + timestamp := r.URL.Path[6:] + if timestamp[len(timestamp)-1:] == "/" { + timestamp = timestamp[:len(timestamp)-1] + } + + ts, err := strconv.Atoi(timestamp) + if err != nil { + w.WriteHeader(http.StatusForbidden) + w.Write([]byte("404 no path")) + } else { + NewsGet(w, r, db, ts) + } + }) http.HandleFunc("/post", func(w http.ResponseWriter, r *http.Request){ -- cgit v1.2.3 From faae38726dd804e3246514d88f93794c23a0cdb2 Mon Sep 17 00:00:00 2001 From: knotteye Date: Fri, 2 Jul 2021 14:20:16 -0500 Subject: show only the last 3 news items on index, link to a page with all news items --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 69e8902..3eb47c0 100644 --- a/main.go +++ b/main.go @@ -293,6 +293,12 @@ func main() { http.HandleFunc("/news/", func(w http.ResponseWriter, r *http.Request){ timestamp := r.URL.Path[6:] + + if(len(timestamp) < 2) { + AllNewsGet(w, r, db) + return + } + if timestamp[len(timestamp)-1:] == "/" { timestamp = timestamp[:len(timestamp)-1] } -- cgit v1.2.3 From fab8de7187571a4f3f8a30966057d661a858b645 Mon Sep 17 00:00:00 2001 From: knotteye Date: Fri, 2 Jul 2021 15:10:49 -0500 Subject: add deletion of news items --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 3eb47c0..f98add9 100644 --- a/main.go +++ b/main.go @@ -634,6 +634,21 @@ func main() { http.Redirect(w, r, "/", http.StatusSeeOther) }) + + http.HandleFunc("/" + *Key + "/newsdelete/", func(w http.ResponseWriter, r *http.Request){ + timestamp := r.URL.Path[13+len(*Key):] + + tsint, err := strconv.Atoi(timestamp) + + if(err != nil){ + w.WriteHeader(http.StatusForbidden) + w.Write([]byte("404 no path")) + return + } else { + deleteNewsItemFromDB(db, tsint) + http.Redirect(w, r, "/news/", http.StatusSeeOther) + } + }) http.HandleFunc("/verify", func(w http.ResponseWriter, r *http.Request){ if(r.Method == "POST") { -- cgit v1.2.3