mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 23:20:54 +00:00
Merge branch 'master' of https://github.com/astaxie/beego into form
This commit is contained in:
commit
d31ac49ead
2
log.go
2
log.go
@ -32,7 +32,7 @@ type FileLogWriter struct {
|
|||||||
|
|
||||||
rotate bool
|
rotate bool
|
||||||
|
|
||||||
startLock sync.Mutex //only one log can writer to the file
|
startLock sync.Mutex // Only one log can write to the file
|
||||||
}
|
}
|
||||||
|
|
||||||
type MuxWriter struct {
|
type MuxWriter struct {
|
||||||
|
@ -94,7 +94,8 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t := reflect.Indirect(reflect.ValueOf(c)).Type()
|
reflectVal := reflect.ValueOf(c)
|
||||||
|
t := reflect.Indirect(reflectVal).Type()
|
||||||
methods := make(map[string]string)
|
methods := make(map[string]string)
|
||||||
if len(mappingMethods) > 0 {
|
if len(mappingMethods) > 0 {
|
||||||
semi := strings.Split(mappingMethods[0], ";")
|
semi := strings.Split(mappingMethods[0], ";")
|
||||||
@ -106,7 +107,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
|
|||||||
comma := strings.Split(colon[0], ",")
|
comma := strings.Split(colon[0], ",")
|
||||||
for _, m := range comma {
|
for _, m := range comma {
|
||||||
if m == "*" || inSlice(strings.ToLower(m), HTTPMETHOD) {
|
if m == "*" || inSlice(strings.ToLower(m), HTTPMETHOD) {
|
||||||
if _, ok := t.MethodByName(colon[1]); ok {
|
if val := reflectVal.MethodByName(colon[1]); val.IsValid() {
|
||||||
methods[strings.ToLower(m)] = colon[1]
|
methods[strings.ToLower(m)] = colon[1]
|
||||||
} else {
|
} else {
|
||||||
panic(colon[1] + " method don't exist in the controller " + t.Name())
|
panic(colon[1] + " method don't exist in the controller " + t.Name())
|
||||||
|
@ -23,7 +23,6 @@ func init() {
|
|||||||
beegoTplFuncMap = make(template.FuncMap)
|
beegoTplFuncMap = make(template.FuncMap)
|
||||||
BeeTemplateExt = make([]string, 0)
|
BeeTemplateExt = make([]string, 0)
|
||||||
BeeTemplateExt = append(BeeTemplateExt, "tpl", "html")
|
BeeTemplateExt = append(BeeTemplateExt, "tpl", "html")
|
||||||
beegoTplFuncMap["markdown"] = MarkDown
|
|
||||||
beegoTplFuncMap["dateformat"] = DateFormat
|
beegoTplFuncMap["dateformat"] = DateFormat
|
||||||
beegoTplFuncMap["date"] = Date
|
beegoTplFuncMap["date"] = Date
|
||||||
beegoTplFuncMap["compare"] = Compare
|
beegoTplFuncMap["compare"] = Compare
|
||||||
|
9
utils.go
9
utils.go
@ -2,7 +2,6 @@ package beego
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/russross/blackfriday"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -20,14 +19,6 @@ func webTime(t time.Time) string {
|
|||||||
return ftime
|
return ftime
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkDown parses a string in MarkDown format and returns HTML. Used by the template parser as "markdown"
|
|
||||||
func MarkDown(raw string) (output template.HTML) {
|
|
||||||
input := []byte(raw)
|
|
||||||
bOutput := blackfriday.MarkdownBasic(input)
|
|
||||||
output = template.HTML(string(bOutput))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func Substr(s string, start, length int) string {
|
func Substr(s string, start, length int) string {
|
||||||
bt := []rune(s)
|
bt := []rune(s)
|
||||||
if start < 0 {
|
if start < 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user