forked from OrgGo/Tasks
support for github flavoured markdown
This commit is contained in:
parent
0a3231d369
commit
df6d239ad3
|
@ -5,6 +5,7 @@ Tasks is a simplistic golang webapp to manage tasks, I built this tool to manage
|
|||
Features:
|
||||
1. Add, update, delete note
|
||||
2. Search notes, the query is highlighted in the search results page
|
||||
3. We use github flavoured markdown, which enables us for using a task list, advanced syntax highlighting and much more
|
||||
|
||||
How you install?
|
||||
==================
|
||||
|
@ -12,7 +13,7 @@ How you install?
|
|||
1. `go get github.com/thewhitetulip/Tasks`
|
||||
1. change dir to the respective folder and create the db file: `cat schema.sql | sqlite3 tasks.db`
|
||||
1. run `go build`
|
||||
1. ./Task
|
||||
1. `./Task`
|
||||
1. open [localhost:8080](http://localhost:8080)
|
||||
|
||||
Either this or download the latest from the release tab above and enjoy!
|
||||
|
|
5
db/db.go
5
db/db.go
|
@ -4,6 +4,7 @@ import (
|
|||
"database/sql"
|
||||
_ "github.com/mattn/go-sqlite3" //we want to use sqlite natively
|
||||
"github.com/thewhitetulip/Tasks/types"
|
||||
md "github.com/shurcooL/github_flavored_markdown"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -52,7 +53,8 @@ func GetTasks(status string) types.Context {
|
|||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
err := rows.Scan(&TaskID, &TaskTitle, &TaskContent, &TaskCreated, &TaskPriority)
|
||||
TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
|
||||
TaskContent = string(md.Markdown([]byte(TaskContent)))
|
||||
// TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
@ -267,6 +269,7 @@ func SearchTask(query string) types.Context {
|
|||
}
|
||||
TaskTitle = strings.Replace(TaskTitle, query, "<span class='highlight'>"+query+"</span>", -1)
|
||||
TaskContent = strings.Replace(TaskContent, query, "<span class='highlight'>"+query+"</span>", -1)
|
||||
TaskContent = string(md.Markdown([]byte(TaskContent)))
|
||||
a := types.Task{Id: TaskID, Title: TaskTitle, Content: TaskContent, Created: TaskCreated.Format(time.UnixDate)[0:20]}
|
||||
task = append(task, a)
|
||||
}
|
||||
|
|
|
@ -114,31 +114,28 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
|||
file, handler, err := r.FormFile("uploadfile")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
taskPriority, priorityErr := strconv.Atoi(r.FormValue("priority"))
|
||||
if priorityErr != nil {
|
||||
log.Print("Someone trying to hack")
|
||||
log.Print(priorityErr)
|
||||
}
|
||||
priorityList := []int{1, 2, 3}
|
||||
found := false
|
||||
for _, priority := range priorityList {
|
||||
if taskPriority != priority {
|
||||
log.Println("someone trying to hack")
|
||||
if taskPriority == priority {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
//If someone gives us incorrect priority number, we give the priority
|
||||
//to that task as 1 i.e. Low
|
||||
if found {
|
||||
taskPriority = 1
|
||||
}
|
||||
title := template.HTMLEscapeString(r.Form.Get("title"))
|
||||
content := template.HTMLEscapeString(r.Form.Get("content"))
|
||||
formToken := template.HTMLEscapeString(r.Form.Get("CSRFToken"))
|
||||
|
||||
=======
|
||||
return
|
||||
}
|
||||
title := template.HTMLEscapeString(r.Form.Get("title"))
|
||||
content := template.HTMLEscapeString(r.Form.Get("content"))
|
||||
formToken := template.HTMLEscapeString(r.Form.Get("CSRFToken"))
|
||||
|
||||
>>>>>>> 474ffbc0ea29e8ccacc707893a07534a4afed961
|
||||
cookie, _ := r.Cookie("csrftoken")
|
||||
if formToken == cookie.Value {
|
||||
if handler != nil {
|
||||
|
@ -151,19 +148,13 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer f.Close()
|
||||
io.Copy(f, file)
|
||||
<<<<<<< HEAD
|
||||
|
||||
filelink := "<br> <a href=/files/" + handler.Filename + ">" + handler.Filename + "</a>"
|
||||
content = content + filelink
|
||||
}
|
||||
|
||||
truth := db.AddTask(title, content, taskPriority)
|
||||
=======
|
||||
filelink := "<br> <a href=./files/"+handler.Filename+">"+ handler.Filename+"</a>"
|
||||
content = content + filelink
|
||||
}
|
||||
|
||||
truth := db.AddTask(title, content)
|
||||
>>>>>>> 474ffbc0ea29e8ccacc707893a07534a4afed961
|
||||
|
||||
if truth != nil {
|
||||
message = "Error adding task"
|
||||
log.Println("error adding task to db")
|
||||
|
|
Loading…
Reference in New Issue