summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHorus32015-02-19 02:38:34 +0100
committerHorus32015-02-19 02:38:34 +0100
commitf53fa2f2f9eb445527e0a1b29b9e37c224499233 (patch)
tree229cc07cb4713a01393d4775f98ec733baa2afe7
parent58e63343703e0c3f3c12934e62fc0f4575761869 (diff)
downloadstatuspage-f53fa2f2f9eb445527e0a1b29b9e37c224499233.tar.gz
Reorder files and parses templates.
-rw-r--r--.gitignore4
-rw-r--r--Makefile17
-rw-r--r--app/Makefile21
-rw-r--r--app/db.go (renamed from db.go)0
-rw-r--r--app/fetch.go (renamed from fetch.go)0
-rw-r--r--app/handler.go (renamed from handler.go)20
-rw-r--r--app/main.go (renamed from main.go)5
-rw-r--r--app/struct.go (renamed from struct.go)0
-rw-r--r--app/utilities.go (renamed from utilities.go)5
-rw-r--r--templates/admin.html (renamed from templates/admin/admin.html)0
-rw-r--r--templates/index.html (renamed from templates/index/index.html)0
-rw-r--r--templates/login.html (renamed from templates/login/login.html)0
-rw-r--r--templates/register.html (renamed from templates/register/register.html)0
13 files changed, 36 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore
index 37ab148..e055c24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
*.swp
-*.db
+db/
+statuspage
+
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 64c916d..0000000
--- a/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-export STATUS_DB_DRIVER:=sqlite3
-export STATUS_DB_CREDENTIALS:=status.db
-
-all: kill build run
-
-clean:
- rm status.db
- rm statuspage
-
-build:
- go build
-
-run:
- ./statuspage &
-
-kill:
- pkill statuspage || true
diff --git a/app/Makefile b/app/Makefile
new file mode 100644
index 0000000..f246e69
--- /dev/null
+++ b/app/Makefile
@@ -0,0 +1,21 @@
+export STATUS_DB_DRIVER:=sqlite3
+export STATUS_DB_CREDENTIALS:=../db/status.db
+
+all: kill build run
+
+clean:
+ @echo "Removing sqlite3 database..."
+ @rm $$STATUS_DB_CREDENTIALS
+ @echo "Removing binary..."
+ @rm statuspage
+ @echo "Done"
+
+build:
+ go build -o statuspage
+
+run:
+ ./statuspage &
+
+kill:
+ @echo "Killing running instances..."
+ @pkill statuspage || true
diff --git a/db.go b/app/db.go
index dc9a15d..dc9a15d 100644
--- a/db.go
+++ b/app/db.go
diff --git a/fetch.go b/app/fetch.go
index 27aa628..27aa628 100644
--- a/fetch.go
+++ b/app/fetch.go
diff --git a/handler.go b/app/handler.go
index 16640ae..f87e92a 100644
--- a/handler.go
+++ b/app/handler.go
@@ -2,7 +2,7 @@ package main
import (
"fmt"
- "html/template"
+ // "html/template"
"log"
"net/http"
)
@@ -25,19 +25,11 @@ func PrintRegisterHandler(w http.ResponseWriter, r *http.Request) {
}
func PrintNewJobHandler(w http.ResponseWriter, r *http.Request) {
- log.Printf("Printing job")
- //t := template.Must(template.ParseFiles("templates/header.html", "templates/navbar.html", "templates/jobs.html", "templates/footer.html"))
- t := template.Must(template.ParseFiles("templates/jobs.html", "templates/header.html", "templates/navbar.html", "templates/footer.html"))
- //t := template.New("job")
- //t := templ
- //fmt.Printf("%s", t)
- //t, err := template.ParseFiles("templates/jobs.html", "templates/header.html")
- //t, err := template.ParseFiles("templates/jobs.html")
- //t, err := t.ParseFiles("templates/jobs.html")
- //if err != nil {
- // log.Panic(err)
- //}
- err := t.Execute(w, nil)
+ log.Println("Printing job")
+
+ job := mainTempl.Lookup("jobs.html")
+
+ err := job.ExecuteTemplate(w, "jobs.html", nil)
if err != nil {
log.Panic(err)
}
diff --git a/main.go b/app/main.go
index fcbeaf5..0a8b7dd 100644
--- a/main.go
+++ b/app/main.go
@@ -3,13 +3,14 @@ package main
import (
"github.com/gorilla/mux"
"github.com/gorilla/schema"
- //"html/template"
+ "html/template"
"net/http"
)
var decoder = schema.NewDecoder()
-//var templ = template.Must(template.ParseFiles("templates/header.html", "templates/navbar.html", "templates/footer.html"))
+//var mainTempl = template.Must(template.New("global").ParseFiles("templates/header.html", "templates/navbar.html", "templates/footer.html"))
+var mainTempl = template.Must(template.New("global").ParseGlob("../templates/*.html"))
func main() {
InitDB()
diff --git a/struct.go b/app/struct.go
index 26c462b..26c462b 100644
--- a/struct.go
+++ b/app/struct.go
diff --git a/utilities.go b/app/utilities.go
index 75f153f..bc6c0ca 100644
--- a/utilities.go
+++ b/app/utilities.go
@@ -7,6 +7,7 @@ import (
"golang.org/x/crypto/bcrypt"
"io"
"io/ioutil"
+ "log"
"math/rand"
"net/http"
// "time"
@@ -29,7 +30,7 @@ func HttpGet(url string) (http.Header, string, error) {
}
// Hashs and returns a string (md5)
-func Hash(content string) string {
+func Md5Hash(content string) string {
h := md5.New()
io.WriteString(h, content)
hash := fmt.Sprintf("%x", h.Sum(nil))
@@ -89,7 +90,7 @@ func HashPassword(password string) (string, error) {
func VerifyPassword(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
if err != nil {
- revel.ERROR.Printf("%s \n", err)
+ log.Printf("%s \n", err)
return false
}
return true
diff --git a/templates/admin/admin.html b/templates/admin.html
index e69de29..e69de29 100644
--- a/templates/admin/admin.html
+++ b/templates/admin.html
diff --git a/templates/index/index.html b/templates/index.html
index e69de29..e69de29 100644
--- a/templates/index/index.html
+++ b/templates/index.html
diff --git a/templates/login/login.html b/templates/login.html
index e69de29..e69de29 100644
--- a/templates/login/login.html
+++ b/templates/login.html
diff --git a/templates/register/register.html b/templates/register.html
index e69de29..e69de29 100644
--- a/templates/register/register.html
+++ b/templates/register.html