aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/main.go b/main.go
index 2874396..69e8902 100644
--- a/main.go
+++ b/main.go
@@ -290,6 +290,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){
@@ -602,6 +617,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") {