summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHorus_Arch2015-02-14 23:11:57 +0100
committerHorus_Arch2015-02-14 23:11:57 +0100
commit2f9fe2cfad83416647beed9c3c9085d686c43b09 (patch)
treefce1e043672f94cf42f8197079ce6fb3017dade0 /app
downloadfreemail-2f9fe2cfad83416647beed9c3c9085d686c43b09.tar.gz
Initial commit.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/app.go20
-rw-r--r--app/controllers/db.go92
-rw-r--r--app/controllers/email.dbbin0 -> 6144 bytes
-rw-r--r--app/controllers/init.go12
-rw-r--r--app/init.go38
-rw-r--r--app/views/App/Index.html13
-rw-r--r--app/views/App/Index.html.bak23
-rw-r--r--app/views/App/Register.html50
-rw-r--r--app/views/debug.html64
-rw-r--r--app/views/errors/404.html20
-rw-r--r--app/views/errors/500.html16
-rw-r--r--app/views/flash.html18
-rw-r--r--app/views/footer.html19
-rw-r--r--app/views/header.html19
-rw-r--r--app/views/navbar.html23
15 files changed, 427 insertions, 0 deletions
diff --git a/app/controllers/app.go b/app/controllers/app.go
new file mode 100644
index 0000000..754deee
--- /dev/null
+++ b/app/controllers/app.go
@@ -0,0 +1,20 @@
+package controllers
+
+import "github.com/revel/revel"
+
+type App struct {
+ //*revel.Controller
+ GormController
+}
+
+func (c App) Index() revel.Result {
+ return c.Render()
+}
+
+func (c App) Register() revel.Result {
+ return c.Render()
+}
+
+func (c App) DoRegister() revel.Result {
+ return c.Render()
+}
diff --git a/app/controllers/db.go b/app/controllers/db.go
new file mode 100644
index 0000000..0f50968
--- /dev/null
+++ b/app/controllers/db.go
@@ -0,0 +1,92 @@
+package controllers
+
+import (
+ "github.com/jinzhu/gorm"
+ _ "github.com/mattn/go-sqlite3"
+ "github.com/revel/revel"
+ "time"
+)
+
+type User struct {
+ Id int64
+ Name string
+ Email string
+ Password string
+ Domains []Domain
+ CreatedAt time.Time
+ UpdatedAt time.Time
+ DeletedAt time.Time
+}
+
+type Domain struct {
+ Id int64
+ UserId int64
+ Domain string
+ CreatedAt time.Time
+ UpdatedAt time.Time
+ DeletedAt time.Time
+}
+
+type GormController struct {
+ *revel.Controller
+ Db *gorm.DB
+}
+
+var Gdb gorm.DB
+
+func InitDB() {
+ Gdb, err := gorm.Open(revel.Config.StringDefault("db.driver", "sqlite3"), revel.Config.StringDefault("db.spec", "email.db"))
+ if err != nil {
+ revel.ERROR.Printf("%s", err)
+ }
+ Gdb.LogMode(true)
+ Gdb.SetLogger(gorm.Logger{revel.TRACE})
+ user := User{}
+ Gdb.AutoMigrate(&user)
+ Gdb.Model(&user).AddUniqueIndex("idx_user_password", "password")
+ Gdb.Model(&user).AddUniqueIndex("idx_user_email", "email")
+
+ domain := Domain{}
+ Gdb.AutoMigrate(&domain)
+ Gdb.Model(&domain).AddUniqueIndex("idx_domain_name", "domain")
+}
+
+/*
+// transactions
+
+// This method fills the c.Txn before each transaction
+func (c *GormController) Begin() revel.Result {
+ txn := Gdb.Begin()
+ if txn.Error != nil {
+ panic(txn.Error)
+ }
+ c.Txn = txn
+ return nil
+}
+
+// This method clears the c.Txn after each transaction
+func (c *GormController) Commit() revel.Result {
+ if c.Txn == nil {
+ return nil
+ }
+ c.Txn.Commit()
+ if err := c.Txn.Error; err != nil && err != sql.ErrTxDone {
+ panic(err)
+ }
+ c.Txn = nil
+ return nil
+}
+
+// This method clears the c.Txn after each transaction, too
+func (c *GormController) Rollback() revel.Result {
+ if c.Txn == nil {
+ return nil
+ }
+ c.Txn.Rollback()
+ if err := c.Txn.Error; err != nil && err != sql.ErrTxDone {
+ panic(err)
+ }
+ c.Txn = nil
+ return nil
+}
+*/
diff --git a/app/controllers/email.db b/app/controllers/email.db
new file mode 100644
index 0000000..2199268
--- /dev/null
+++ b/app/controllers/email.db
Binary files differ
diff --git a/app/controllers/init.go b/app/controllers/init.go
new file mode 100644
index 0000000..affa2e0
--- /dev/null
+++ b/app/controllers/init.go
@@ -0,0 +1,12 @@
+package controllers
+
+import "github.com/revel/revel"
+
+func init() {
+ revel.OnAppStart(InitDB) // invoke InitDB function before
+ /*
+ revel.InterceptMethod((*GormController).Begin, revel.BEFORE)
+ revel.InterceptMethod((*GormController).Commit, revel.AFTER)
+ revel.InterceptMethod((*GormController).Rollback, revel.FINALLY)
+ */
+}
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..cf36a51
--- /dev/null
+++ b/app/views/App/Index.html
@@ -0,0 +1,13 @@
+{{set . "title" "Home"}}
+{{template "header.html" .}}
+{{template "navbar.html" .}}
+
+<div class="container">
+ <div class="text-center">
+ <div class="row">
+ </div>
+ </div>
+</div>
+
+
+{{template "footer.html" .}}
diff --git a/app/views/App/Index.html.bak b/app/views/App/Index.html.bak
new file mode 100644
index 0000000..deb2304
--- /dev/null
+++ b/app/views/App/Index.html.bak
@@ -0,0 +1,23 @@
+{{set . "title" "Home"}}
+{{template "header.html" .}}
+
+<header class="hero-unit" style="background-color:#A9F16C">
+ <div class="container">
+ <div class="row">
+ <div class="hero-text">
+ <h1>It works!</h1>
+ <p></p>
+ </div>
+ </div>
+ </div>
+</header>
+
+<div class="container">
+ <div class="row">
+ <div class="span6">
+ {{template "flash.html" .}}
+ </div>
+ </div>
+</div>
+
+{{template "footer.html" .}}
diff --git a/app/views/App/Register.html b/app/views/App/Register.html
new file mode 100644
index 0000000..9c8683c
--- /dev/null
+++ b/app/views/App/Register.html
@@ -0,0 +1,50 @@
+{{set . "title" "Register"}}
+{{template "header.html" .}}
+{{template "navbar.html" .}}
+
+ <div>
+ <div class="noscript">
+ <div class="container">
+ <div class="row text-center noscript">
+ <noscript>
+ <!--h5>Please enable JavaScript. This page will not work otherwise.</h5-->
+ </noscript>
+ <h5>Please note: We haven't started yet! This is just a demo page.</h4>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+ <div class="container">
+ <div class="text-center">
+ <div class="row">
+ <form class="form-horizontal" method='POST' action='./'>
+ <fieldset>
+ <legend>
+ <h1>Mail Exchange</h1>
+ <p>Free E-Mail hosting for your own domain. <br>Reqister yourself below and point your MX entry to "mx.iamfabulous.de"</p>
+ </legend>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label" for="domain">Domain*</label>
+ <div class="col-md-4">
+ <input id="domain" name="domain" placeholder="Your domain here." class="form-control input-md" required="" type="text">
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label" for="submit"></label>
+ <div class="col-md-4">
+ <button id="submit" name="submit" class="btn btn-primary"><span class="glyphicon glyphicon-log-in"></span> Register</button>
+ </div>
+ </div>
+
+
+ </fieldset>
+ </form>
+ </div>
+ </div>
+ </div>
+
+{{template "footer.html" .}}
diff --git a/app/views/debug.html b/app/views/debug.html
new file mode 100644
index 0000000..f3975b7
--- /dev/null
+++ b/app/views/debug.html
@@ -0,0 +1,64 @@
+<style type="text/css">
+ #sidebar {
+ position: absolute;
+ right: 0px;
+ top:69px;
+ max-width: 75%;
+ z-index: 1000;
+ background-color: #fee;
+ border: thin solid grey;
+ padding: 10px;
+ }
+ #toggleSidebar {
+ position: absolute;
+ right: 0px;
+ top: 50px;
+ background-color: #fee;
+ }
+
+</style>
+<div id="sidebar" style="display:none;">
+ <h4>Available pipelines</h4>
+ <dl>
+ {{ range $index, $value := .}}
+ <dt>{{$index}}</dt>
+ <dd>{{$value}}</dd>
+ {{end}}
+ </dl>
+ <h4>Flash</h4>
+ <dl>
+ {{ range $index, $value := .flash}}
+ <dt>{{$index}}</dt>
+ <dd>{{$value}}</dd>
+ {{end}}
+ </dl>
+
+ <h4>Errors</h4>
+ <dl>
+ {{ range $index, $value := .errors}}
+ <dt>{{$index}}</dt>
+ <dd>{{$value}}</dd>
+ {{end}}
+ </dl>
+</div>
+<a id="toggleSidebar" href="#" class="toggles"><i class="icon-chevron-left"></i></a>
+
+<script>
+ $sidebar = 0;
+ $('#toggleSidebar').click(function() {
+ if ($sidebar === 1) {
+ $('#sidebar').hide();
+ $('#toggleSidebar i').addClass('icon-chevron-left');
+ $('#toggleSidebar i').removeClass('icon-chevron-right');
+ $sidebar = 0;
+ }
+ else {
+ $('#sidebar').show();
+ $('#toggleSidebar i').addClass('icon-chevron-right');
+ $('#toggleSidebar i').removeClass('icon-chevron-left');
+ $sidebar = 1;
+ }
+
+ return false;
+ });
+</script>
diff --git a/app/views/errors/404.html b/app/views/errors/404.html
new file mode 100644
index 0000000..ebdfe10
--- /dev/null
+++ b/app/views/errors/404.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>Not found</title>
+ </head>
+ <body>
+{{if eq .RunMode "dev"}}
+{{template "errors/404-dev.html" .}}
+{{else}}
+ {{with .Error}}
+ <h1>
+ {{.Title}}
+ </h1>
+ <p>
+ {{.Description}}
+ </p>
+ {{end}}
+{{end}}
+ </body>
+</html>
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 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Application error</title>
+ </head>
+ <body>
+ {{if eq .RunMode "dev"}}
+ {{template "errors/500-dev.html" .}}
+ {{else}}
+ <h1>Oops, an error occured</h1>
+ <p>
+ This exception has been logged.
+ </p>
+ {{end}}
+ </body>
+</html>
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}}
+<div class="alert alert-success">
+ {{.flash.success}}
+</div>
+{{end}}
+
+{{if or .errors .flash.error}}
+<div class="alert alert-error">
+ {{if .flash.error}}
+ {{.flash.error}}
+ {{end}}
+ <ul style="margin-top:10px;">
+ {{range .errors}}
+ <li>{{.}}</li>
+ {{end}}
+ </ul>
+</div>
+{{end}}
diff --git a/app/views/footer.html b/app/views/footer.html
new file mode 100644
index 0000000..1b06355
--- /dev/null
+++ b/app/views/footer.html
@@ -0,0 +1,19 @@
+ {{if eq .RunMode "dev"}}
+ {{template "debug.html" .}}
+ {{end}}
+ {{range .moreScripts}}
+ <script src="/public/{{.}}" type="text/javascript" charset="utf-8"></script>
+ {{end}}
+<div class="footer">
+ <div class="container">
+ <div class="row">
+ <footer>
+ <p id="copyright-text" align='right'> Copyright 2015 <a class="footer-a" href="//www.iamfabulous.de" title="Maximilian Möhring">Maximilian M&ouml;hring</a></p>
+ </footer>
+ </div>
+ </div>
+</div>
+<script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
+<script src="/static/js/bootstrap.js"></script>
+ </body>
+</html>
diff --git a/app/views/header.html b/app/views/header.html
new file mode 100644
index 0000000..2875487
--- /dev/null
+++ b/app/views/header.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>{{.title}}</title>
+ <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
+ <!--link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css"-->
+ <link rel="stylesheet" type="text/css" href="/static/css/style.css">
+ <link rel="shortcut icon" type="image/png" href="/static/img/favicon.ico">
+ {{range .moreStyles}}
+ <link rel="stylesheet" type="text/css" href="/public/{{.}}">
+ {{end}}
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <noscript>
+ <style>.navbar{margin-bottom:0;}</style>
+ </noscript>
+ </head>
+ <body>
diff --git a/app/views/navbar.html b/app/views/navbar.html
new file mode 100644
index 0000000..2e45d0a
--- /dev/null
+++ b/app/views/navbar.html
@@ -0,0 +1,23 @@
+<nav class="navbar navbar-default navbar-custom" role="navigation">
+ <div class="container">
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="/"><span class="glyphicon glyphicon-home"></span> Home</a>
+ </div>
+ <div class="collapse navbar-collapse" id="navbarCollapse">
+ <ul class="nav navbar-nav navbar-bar-left">
+ <li>
+ <a href="#" >About</a>
+ </li>
+ <li>
+ <a href="#" >About</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+</nav>