Init commit
This commit is contained in:
parent
4836fea876
commit
96b317d3ff
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
gogs
|
||||
*.exe
|
||||
*.exe~
|
||||
.DS_Store
|
|
@ -1 +1,5 @@
|
|||
APP_NAME = Go Git Service
|
||||
|
||||
[server]
|
||||
HTTP_ADDR =
|
||||
HTTP_PORT = 3000
|
30
gogs.go
30
gogs.go
|
@ -5,15 +5,37 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/codegangsta/martini"
|
||||
"github.com/martini-contrib/render"
|
||||
|
||||
"github.com/gogits/gogs/routers"
|
||||
"github.com/gogits/gogs/utils"
|
||||
"github.com/gogits/gogs/utils/log"
|
||||
)
|
||||
|
||||
const APP_VER = "0.0.0.0212"
|
||||
|
||||
func main() {
|
||||
m := martini.Classic()
|
||||
m.Get("/", routers.HomeGet)
|
||||
m.Run()
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Info("App Name: %s", utils.Cfg.MustValue("", "APP_NAME"))
|
||||
|
||||
m := martini.Classic()
|
||||
|
||||
// Middleware.
|
||||
m.Use(render.Renderer())
|
||||
|
||||
// Routers.
|
||||
m.Get("/", routers.Home)
|
||||
|
||||
listenAddr := fmt.Sprintf("%s:%s",
|
||||
utils.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||
utils.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||
log.Info("Listen: %s", listenAddr)
|
||||
http.ListenAndServe(listenAddr, m)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
package routers
|
||||
|
||||
func HomeGet() string {
|
||||
return "Hello world!"
|
||||
import (
|
||||
"github.com/martini-contrib/render"
|
||||
)
|
||||
|
||||
func Home(r render.Render) {
|
||||
r.HTML(200, "home", map[string]interface{}{})
|
||||
}
|
||||
|
|
2
templates/base/base.tmpl
Normal file
2
templates/base/base.tmpl
Normal file
|
@ -0,0 +1,2 @@
|
|||
this is base.html
|
||||
Hello world!
|
1
templates/home.tmpl
Normal file
1
templates/home.tmpl
Normal file
|
@ -0,0 +1 @@
|
|||
{{template "base/base"}}
|
24
utils/conf.go
Normal file
24
utils/conf.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/Unknwon/goconfig"
|
||||
)
|
||||
|
||||
var Cfg *goconfig.ConfigFile
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
Cfg, err = goconfig.LoadConfigFile("conf/app.ini")
|
||||
if err != nil {
|
||||
fmt.Println("Cannot load config file 'app.ini'")
|
||||
os.Exit(2)
|
||||
}
|
||||
Cfg.BlockMode = false
|
||||
}
|
21
utils/log/log.go
Normal file
21
utils/log/log.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package log is a wrapper of logs for short calling name.
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/gogits/logs"
|
||||
)
|
||||
|
||||
var logger *logs.BeeLogger
|
||||
|
||||
func init() {
|
||||
logger = logs.NewLogger(10000)
|
||||
logger.SetLogger("console", "")
|
||||
}
|
||||
|
||||
func Info(format string, v ...interface{}) {
|
||||
logger.Info(format, v...)
|
||||
}
|
Loading…
Reference in a new issue