2015-11-13 17:04:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the main file for the Task application
|
|
|
|
* License: MIT
|
|
|
|
**/
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
2016-02-01 21:45:04 +08:00
|
|
|
|
|
|
|
"github.com/thewhitetulip/Tasks/config"
|
|
|
|
"github.com/thewhitetulip/Tasks/views"
|
2015-11-13 17:04:42 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-01-23 18:33:10 +08:00
|
|
|
values := config.ReadConfig("config.json")
|
2015-11-21 15:58:23 +08:00
|
|
|
views.PopulateTemplates()
|
|
|
|
http.HandleFunc("/", views.ShowAllTasksFunc)
|
2016-05-09 10:11:05 +08:00
|
|
|
http.HandleFunc("/login/", views.LoginFunc)
|
|
|
|
http.HandleFunc("/logout/", views.LogoutFunc)
|
2016-02-03 01:40:44 +08:00
|
|
|
http.HandleFunc("/add-category/", views.AddCategoryFunc)
|
2016-02-15 01:46:22 +08:00
|
|
|
http.HandleFunc("/add-comment/", views.AddCommentFunc)
|
2016-02-17 00:53:15 +08:00
|
|
|
http.HandleFunc("/del-comment/", views.DeleteCommentFunc)
|
2016-02-06 14:58:00 +08:00
|
|
|
http.HandleFunc("/del-category/", views.DeleteCategoryFunc)
|
|
|
|
http.HandleFunc("/upd-category/", views.UpdateCategoryFunc)
|
2016-02-03 01:40:44 +08:00
|
|
|
http.HandleFunc("/category/", views.ShowCategoryFunc)
|
2015-11-21 15:58:23 +08:00
|
|
|
http.HandleFunc("/complete/", views.CompleteTaskFunc)
|
2016-02-01 22:26:06 +08:00
|
|
|
//delete permanently deletes from db
|
2015-11-21 15:58:23 +08:00
|
|
|
http.HandleFunc("/delete/", views.DeleteTaskFunc)
|
2016-01-30 01:06:49 +08:00
|
|
|
http.HandleFunc("/files/", views.UploadedFileHandler)
|
2015-11-21 15:58:23 +08:00
|
|
|
http.HandleFunc("/deleted/", views.ShowTrashTaskFunc)
|
2016-02-01 22:26:06 +08:00
|
|
|
//trash moves to recycle bin
|
2015-11-21 15:58:23 +08:00
|
|
|
http.HandleFunc("/trash/", views.TrashTaskFunc)
|
|
|
|
http.HandleFunc("/edit/", views.EditTaskFunc)
|
|
|
|
http.HandleFunc("/completed/", views.ShowCompleteTasksFunc)
|
|
|
|
http.HandleFunc("/restore/", views.RestoreTaskFunc)
|
2016-01-09 13:03:35 +08:00
|
|
|
http.HandleFunc("/incomplete/", views.RestoreFromCompleteFunc)
|
2015-11-21 15:58:23 +08:00
|
|
|
http.HandleFunc("/add/", views.AddTaskFunc)
|
|
|
|
http.HandleFunc("/update/", views.UpdateTaskFunc)
|
|
|
|
http.HandleFunc("/search/", views.SearchTaskFunc)
|
2015-11-21 14:39:06 +08:00
|
|
|
//http.HandleFunc("/static/", ServeStaticFunc)
|
|
|
|
http.Handle("/static/", http.FileServer(http.Dir("public")))
|
2016-01-23 18:33:10 +08:00
|
|
|
log.Println("running server on ", values.ServerPort)
|
|
|
|
log.Fatal(http.ListenAndServe(values.ServerPort, nil))
|
2015-11-13 17:04:42 +08:00
|
|
|
}
|