From 218d04ca12051c4330156fc1f3290f27bb24c155 Mon Sep 17 00:00:00 2001
From: Horus_Arch
Date: Thu, 12 Feb 2015 18:48:08 +0100
Subject: Initial commit. With basic database schema.
---
app/controllers/app.go | 11 ++++++++
app/controllers/db.go | 37 +++++++++++++++++++++++++++
app/init.go | 38 ++++++++++++++++++++++++++++
app/views/App/Index.html | 23 +++++++++++++++++
app/views/debug.html | 64 +++++++++++++++++++++++++++++++++++++++++++++++
app/views/errors/404.html | 20 +++++++++++++++
app/views/errors/500.html | 16 ++++++++++++
app/views/flash.html | 18 +++++++++++++
app/views/footer.html | 5 ++++
app/views/header.html | 17 +++++++++++++
10 files changed, 249 insertions(+)
create mode 100644 app/controllers/app.go
create mode 100644 app/controllers/db.go
create mode 100644 app/init.go
create mode 100644 app/views/App/Index.html
create mode 100644 app/views/debug.html
create mode 100644 app/views/errors/404.html
create mode 100644 app/views/errors/500.html
create mode 100644 app/views/flash.html
create mode 100644 app/views/footer.html
create mode 100644 app/views/header.html
(limited to 'app')
diff --git a/app/controllers/app.go b/app/controllers/app.go
new file mode 100644
index 0000000..e76d76b
--- /dev/null
+++ b/app/controllers/app.go
@@ -0,0 +1,11 @@
+package controllers
+
+import "github.com/revel/revel"
+
+type App struct {
+ *revel.Controller
+}
+
+func (c App) Index() revel.Result {
+ return c.Render()
+}
diff --git a/app/controllers/db.go b/app/controllers/db.go
new file mode 100644
index 0000000..f1ff18a
--- /dev/null
+++ b/app/controllers/db.go
@@ -0,0 +1,37 @@
+package controllers
+
+import (
+ "github.com/jinzhu/gorm"
+ _ "github.com/mattn/go-sqlite3"
+ "github.com/revel/revel"
+)
+
+/* Maybe worth saving uptime history? */
+
+type Hosts struct {
+ Id int64
+ UserId int64
+ Url string
+ Protocoll string // e.g. http
+ Private bool
+ Response int64
+ Date time.Time
+ Success bool
+ Include string // Website must include this string
+ Except string // Website must not include this string
+ Reason string // Include, Exclude, Connection failure
+ Alert bool // True to send alert on failure
+ CreatedAt time.Time
+ DeletedAt time.Time
+ UpdatedAt time.Time
+}
+
+type User struct {
+ Id int64
+ Name string
+ Email string
+ Password string
+ CreatedAt time.Time
+ DeletedAt time.Time
+ UpdatedAt time.Time
+}
diff --git a/app/init.go b/app/init.go
new file mode 100644
index 0000000..2305d73
--- /dev/null
+++ b/app/init.go
@@ -0,0 +1,38 @@
+package app
+
+import "github.com/revel/revel"
+
+func init() {
+ // Filters is the default set of global filters.
+ revel.Filters = []revel.Filter{
+ revel.PanicFilter, // Recover from panics and display an error page instead.
+ revel.RouterFilter, // Use the routing table to select the right Action
+ revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
+ revel.ParamsFilter, // Parse parameters into Controller.Params.
+ revel.SessionFilter, // Restore and write the session cookie.
+ revel.FlashFilter, // Restore and write the flash cookie.
+ revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie.
+ revel.I18nFilter, // Resolve the requested language
+ HeaderFilter, // Add some security based headers
+ revel.InterceptorFilter, // Run interceptors around the action.
+ revel.CompressFilter, // Compress the result.
+ revel.ActionInvoker, // Invoke the action.
+ }
+
+ // register startup functions with OnAppStart
+ // ( order dependent )
+ // revel.OnAppStart(InitDB)
+ // revel.OnAppStart(FillCache)
+}
+
+// TODO turn this into revel.HeaderFilter
+// should probably also have a filter for CSRF
+// not sure if it can go in the same filter or not
+var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
+ // Add some common security headers
+ c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
+ c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
+ c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")
+
+ fc[0](c, fc[1:]) // Execute the next filter stage.
+}
diff --git a/app/views/App/Index.html b/app/views/App/Index.html
new file mode 100644
index 0000000..deb2304
--- /dev/null
+++ b/app/views/App/Index.html
@@ -0,0 +1,23 @@
+{{set . "title" "Home"}}
+{{template "header.html" .}}
+
+It works!
+
+
+ {{.Description}} +
+ {{end}} +{{end}} + + diff --git a/app/views/errors/500.html b/app/views/errors/500.html new file mode 100644 index 0000000..0cef4de --- /dev/null +++ b/app/views/errors/500.html @@ -0,0 +1,16 @@ + + + ++ This exception has been logged. +
+ {{end}} + + diff --git a/app/views/flash.html b/app/views/flash.html new file mode 100644 index 0000000..9c9ade9 --- /dev/null +++ b/app/views/flash.html @@ -0,0 +1,18 @@ +{{if .flash.success}} +