This commit is contained in:
konrad 2017-06-15 11:30:32 +02:00 committed by konrad
parent 798c0d4602
commit c40bab1a50
24 changed files with 9707 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Created by .ignore support plugin (hsz.mobi)
.idea/*

View File

@ -0,0 +1,16 @@
package main
import (
"github.com/labstack/echo"
"html/template"
"io"
)
type Template struct {
templates *template.Template
}
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.templates.ExecuteTemplate(w, name, data)
}

View File

@ -0,0 +1,11 @@
package main
import (
"github.com/labstack/echo"
"net/http"
)
func adminHandler (c echo.Context) error {
//Template
return c.Render(http.StatusOK, "admin", Message{"schinken"})
}

View File

@ -0,0 +1,23 @@
body{
background:#fff;
font-family:sans-serif;
}
th,td{
border: 1px solid #ccc;
border-bottom: none;
border-right: none;
padding: 2px 5px;
}
tr.top th{
border: none;
text-align: left;
padding-left: 10px;
}
table{
border:1px solid #ccc;
border-left: none;
border-top: none;
}

9472
src/KonfiCastleKasino/assets/js/jquery-1.8.3.js vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
setInterval(function() {
$.getJSON('/list', function (data) {
//console.log(data);
$( "#konfis" ).html('');
$.each( data.Kofis, function( i, item ) {
$( "#konfis" ).append('<tr> <td>' + item.Name + '</td> <td>' + item.Gemeinde + '</td> <td>' + item.KCoins + '</td></tr>');
});
});
}, 1000);

View File

@ -0,0 +1,23 @@
package main
import (
"github.com/go-ini/ini"
"log"
)
//Configuration Struct
type Configuration struct {
AdminPassword string
Interface string
}
var SiteConf Configuration = Configuration{}
func initConfig() *Configuration {
SiteConf := new(Configuration)
err := ini.MapTo(SiteConf, "config.ini")
if err != nil {
log.Fatal(err)
}
return SiteConf
}

View File

@ -0,0 +1,2 @@
AdminPassword = geheim
Interface = :8080

View File

@ -0,0 +1,25 @@
package main
import (
"github.com/labstack/echo"
"net/http"
"encoding/json"
"fmt"
"io/ioutil"
)
func getList(c echo.Context) error {
file, err := ioutil.ReadFile("konfis.json")
if(err != nil){
fmt.Println("whoops:", err)
}
var s = new(Kofis)
err = json.Unmarshal(file, &s)
if(err != nil){
fmt.Println("whoops:", err)
}
//Template
return c.JSON(http.StatusOK, s)
}

View File

@ -0,0 +1,14 @@
{
"Kofis": [
{
"Name": "Lorem",
"Gemeinde": "Cappel",
"kCoins": 3000
},
{
"Name": "Lorem 2",
"Gemeinde": "Cappel",
"kCoins": 30400
}
]
}

View File

@ -0,0 +1,39 @@
package main
import (
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"html/template"
"github.com/labstack/gommon/log"
)
func main(){
//Config
SiteConf := initConfig()
//Echo init
e := echo.New()
//Logger
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: "${time_rfc3339}: ${remote_ip} ${method} ${status} ${uri} - ${user_agent}\n",
}))
//Static ontent
e.Static("/assets", "assets")
//Routes
e.GET("/", showList)
e.GET("/list", getList)
e.GET("/admin", adminHandler)
//Template
t := &Template{
templates: template.Must(template.ParseGlob("tpl/*.html")),
}
e.Renderer = t
//Start the server
e.Logger.SetLevel(log.ERROR)
e.Logger.Debug(e.Start(SiteConf.Interface))
}

View File

@ -0,0 +1,11 @@
package main
import (
"github.com/labstack/echo"
"net/http"
)
func showList (c echo.Context) error {
//Template
return c.Render(http.StatusOK, "index", Message{"schinken"})
}

View File

@ -0,0 +1,12 @@
{{define "admin"}}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Kasino Admin</title>
</head>
<body>
</body>
</html>
{{end}}

View File

@ -0,0 +1,24 @@
{{define "index"}}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Kasino</title>
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr class="top">
<th scope="col">Name</th>
<th scope="col">Gemeinde</th>
<th scope="col">Eingezahle KonfiCoins</th>
</tr>
<tbody id="konfis">
</tbody>
</table>
<script src="/assets/js/jquery-1.8.3.js"></script>
<script src="/assets/js/load.js"></script>
</body>
</html>
{{end}}

View File

@ -0,0 +1,15 @@
package main
type Message struct {
Message string
}
type Kofi struct {
Name string
Gemeinde string
KCoins int
}
type Kofis struct {
Kofis []Kofi
}

@ -0,0 +1 @@
Subproject commit a539ee1a749a2b895533f979515ac7e6e0f5b650

@ -0,0 +1 @@
Subproject commit d3de07a94d22b4a0972deb4b96d790c2c0ce8333

@ -0,0 +1 @@
Subproject commit e827c85dc5054a2086c0d8b1459b310f4de0fad2

@ -0,0 +1 @@
Subproject commit 1121fd3e243c202482226a7afe4dcd07ffc4139a

@ -0,0 +1 @@
Subproject commit 941b50ebc6efddf4c41c8e4537a5f68a4e686b24

@ -0,0 +1 @@
Subproject commit fc9e8d8ef48496124e79ae0df75490096eccf6fe

@ -0,0 +1 @@
Subproject commit dcecefd839c4193db0d35b88ec65b4c12d360ab0

@ -0,0 +1 @@
Subproject commit 850760c427c516be930bc91280636328f1a62286

1
src/golang.org/x/net Submodule

@ -0,0 +1 @@
Subproject commit ddf80d0970594e2e4cccf5a98861cad3d9eaa4cd