-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
206 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
language: go | ||
language: go | ||
go: | ||
- tip | ||
before_install: | ||
- go get github.com/axw/gocov/gocov | ||
- go get github.com/mattn/goveralls | ||
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi | ||
script: | ||
- $HOME/gopath/bin/goveralls -service=travis-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# web | ||
# Web framework for golang | ||
|
||
Golang MVC web framework. | ||
|
||
[![Build Status](https://travis-ci.org/zhgo/web.svg)](https://travis-ci.org/zhgo/web) | ||
[![Coverage](http://gocover.io/_badge/github.com/zhgo/web)](http://gocover.io/github.com/zhgo/web) | ||
[![Coverage Status](https://coveralls.io/repos/zhgo/web/badge.svg)](https://coveralls.io/r/zhgo/web) | ||
[![GoDoc](https://godoc.org/github.com/zhgo/web?status.png)](http://godoc.org/github.com/zhgo/web) | ||
[![License](https://img.shields.io/badge/license-BSD-ff69b4.svg?style=flat)](https://github.com/zhgo/web/blob/master/LICENSE) | ||
[![License](https://img.shields.io/badge/license-BSD-blue.svg?style=flat)](https://github.com/zhgo/web/blob/master/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2014 The zhgo Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package web | ||
|
||
import ( | ||
"html/template" | ||
"log" | ||
"reflect" | ||
"strconv" | ||
"strings" | ||
"unicode" | ||
) | ||
|
||
//funcMap | ||
var funcMap = template.FuncMap{ | ||
"FnURL": func(m string, c string, a string, args ...interface{}) string { | ||
return URL(m, c, a, args...) | ||
}, | ||
"FnPub": func(p string) string { | ||
return Pub(p) | ||
}, | ||
} | ||
|
||
// for example: transfer browse_by_set to BrowseBySet | ||
func pathToMethod(path string) string { | ||
var method string | ||
sli := strings.Split(path, "_") | ||
for _, v := range sli { | ||
method += strings.Title(v) | ||
} | ||
return method | ||
} | ||
|
||
// for example: transfer BrowseBySet to browse_by_set | ||
func methodToPath(method string) string { | ||
var words []string | ||
|
||
l := 0 | ||
for s := method; s != ""; s = s[l:] { | ||
l = strings.IndexFunc(s[1:], unicode.IsUpper) + 1 | ||
if l < 1 { | ||
l = len(s) | ||
} | ||
words = append(words, strings.ToLower(s[:l])) | ||
} | ||
|
||
return strings.Join(words, "_") | ||
} | ||
|
||
// Parameter Conversion | ||
func parameterConversion(str string, kind reflect.Kind) (reflect.Value, error) { | ||
var v reflect.Value | ||
var err error | ||
|
||
switch kind { | ||
case reflect.String: | ||
v = reflect.ValueOf(str) | ||
case reflect.Int64: | ||
var i64 int64 | ||
i64, err = strconv.ParseInt(str, 10, 64) | ||
v = reflect.ValueOf(i64) | ||
default: | ||
log.Printf("String convert to int failure: %s\n", str) | ||
} | ||
|
||
return v, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.