Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information...
Depado committed Feb 21, 2016
1 parent ee61eec commit a395fd51a3286300c44d6dc574b5498267058bba
Showing with 1,753 additions and 0 deletions.
  1. +19 −0 .drone.yml
  2. +1 −0 .gitignore
  3. +16 −0 assets/css/materialize.min.css
  4. +428 −0 assets/font/material-design-icons/LICENSE.txt
  5. BIN assets/font/material-design-icons/Material-Design-Icons.eot
  6. +769 −0 assets/font/material-design-icons/Material-Design-Icons.svg
  7. BIN assets/font/material-design-icons/Material-Design-Icons.ttf
  8. BIN assets/font/material-design-icons/Material-Design-Icons.woff
  9. BIN assets/font/material-design-icons/Material-Design-Icons.woff2
  10. BIN assets/font/roboto/Roboto-Bold.ttf
  11. BIN assets/font/roboto/Roboto-Bold.woff
  12. BIN assets/font/roboto/Roboto-Bold.woff2
  13. BIN assets/font/roboto/Roboto-Light.ttf
  14. BIN assets/font/roboto/Roboto-Light.woff
  15. BIN assets/font/roboto/Roboto-Light.woff2
  16. BIN assets/font/roboto/Roboto-Medium.ttf
  17. BIN assets/font/roboto/Roboto-Medium.woff
  18. BIN assets/font/roboto/Roboto-Medium.woff2
  19. BIN assets/font/roboto/Roboto-Regular.ttf
  20. BIN assets/font/roboto/Roboto-Regular.woff
  21. BIN assets/font/roboto/Roboto-Regular.woff2
  22. BIN assets/font/roboto/Roboto-Thin.ttf
  23. BIN assets/font/roboto/Roboto-Thin.woff
  24. BIN assets/font/roboto/Roboto-Thin.woff2
  25. BIN assets/img/01-Morning.png
  26. BIN assets/img/02-Late-Morning.png
  27. BIN assets/img/03-Afternoon.png
  28. BIN assets/img/04-Late-Afternoon.png
  29. BIN assets/img/05-Evening.png
  30. BIN assets/img/06-Late-Evening.png
  31. BIN assets/img/07-Night.png
  32. BIN assets/img/08-Late-Night.png
  33. BIN assets/img/background.png
  34. BIN assets/img/defab.png
  35. BIN assets/img/mobeye.png
  36. BIN assets/img/oop.png
  37. BIN assets/img/oop_white.png
  38. +9 −0 assets/js/materialize.min.js
  39. +26 −0 main.go
  40. +447 −0 templates/index.html
  41. +38 −0 utils/router.go
@@ -0,0 +1,19 @@
build:
image: armhfbuild/golang:$$GO_VERSION
commands:
- go get
- go build

matrix:
GO_VERSION:
- 1.6
- 1.5

notify:
irc:
prefix: Portfolio Build
nick: Depadrone
channel: n0sec-bot
server:
host: irc.freenode.net
port: 6667
@@ -22,3 +22,4 @@ _testmain.go
*.exe
*.test
*.prof
portfolio

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN +11.2 KB assets/img/defab.png
Binary file not shown.
BIN +219 KB assets/img/mobeye.png
Binary file not shown.
BIN +1.43 KB assets/img/oop.png
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

26 main.go
@@ -0,0 +1,26 @@
package main

import (
"log"
"net/http"

"github.com/Depado/articles/rice-gin/utils"
"github.com/GeertJohan/go.rice"
"github.com/gin-gonic/gin"
)

func main() {
var err error

tbox, _ := rice.FindBox("templates")
abox, _ := rice.FindBox("assets")

r := gin.Default()
if err = utils.InitAssetsTemplates(r, tbox, abox, "index.html"); err != nil {
log.Fatal(err)
}
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{})
})
r.Run(":8093")
}

Large diffs are not rendered by default.

@@ -0,0 +1,38 @@
package utils

import (
"html/template"

"github.com/GeertJohan/go.rice"
"github.com/gin-gonic/gin"
)

// InitAssetsTemplates initializes the router to use the rice boxes.
// r is our main router, tbox is our template rice box, abox is our assets box
// and names are the file names of the templates to load
func InitAssetsTemplates(r *gin.Engine, tbox, abox *rice.Box, names ...string) error {
var err error

if tbox != nil {
var tmpl string
var message *template.Template
for _, x := range names {
if tmpl, err = tbox.String(x); err != nil {
return err
}
if message, err = template.New(x).Parse(tmpl); err != nil {
return err
}
r.SetHTMLTemplate(message)
}
} else {
r.LoadHTMLGlob("templates/*")
}

if abox != nil {
r.StaticFS("/static", abox.HTTPBox())
} else {
r.Static("/static", "assets")
}
return nil
}

0 comments on commit a395fd5

Please sign in to comment.
You can’t perform that action at this time.