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)
|
|
|
|
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
|
|
|
}
|