Skip to content

Commit

Permalink
Merge pull request #1150 from revel/develop
Browse files Browse the repository at this point in the history
v0.14.0
  • Loading branch information
brendensoares committed Mar 24, 2017
2 parents 76317ca + eacd8f4 commit 75d66c3
Show file tree
Hide file tree
Showing 82 changed files with 1,158 additions and 1,273 deletions.
34 changes: 18 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go:
- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
- tip

os:
Expand All @@ -12,34 +14,42 @@ os:

sudo: false

branches:
only:
- master
- develop

services:
# github.com/revel/revel/cache
- memcache
- redis-server

before_install:
# TRAVIS_OS_NAME - linux and osx
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew install memcached redis; fi'
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nohup /usr/local/opt/memcached/bin/memcached & fi'
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nohup redis-server /usr/local/etc/redis.conf & fi'
- echo $TRAVIS_OS_NAME
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update && brew install memcached redis && brew services start redis && brew services start memcached
fi
- redis-server --daemonize yes
- redis-cli info

install:
# Setting environments variables
- export PATH=$PATH:$HOME/gopath/bin
- export REVEL_BRANCH="develop"
- 'if [[ "$TRAVIS_BRANCH" == "master" ]]; then export REVEL_BRANCH="master"; fi'
- 'echo "Travis branch: $TRAVIS_BRANCH, Revel dependency branch: $REVEL_BRANCH"'
- go get -v github.com/revel/revel/...
- rm -rf ../config
- git clone -b $REVEL_BRANCH git://github.com/revel/modules ../modules/
- git clone -b $REVEL_BRANCH git://github.com/revel/cmd ../cmd/
- git clone -b $REVEL_BRANCH git://github.com/revel/config ../config/
- git clone -b $REVEL_BRANCH git://github.com/revel/cron ../cron/
- git clone git://github.com/revel/samples ../samples/
- git clone -b $REVEL_BRANCH git://github.com/revel/examples ../examples/
- go get -v github.com/revel/revel/...
- go get -v github.com/revel/cmd/revel

script:
- go test -v github.com/revel/revel...
- go test -v github.com/revel/revel/...

# Ensure the new-app flow works (plus the other commands).
- revel version
Expand All @@ -51,18 +61,10 @@ script:
- revel package my/testapp
- revel package my/testapp prod

# Build & run the sample apps
- revel test github.com/revel/samples/booking
- revel test github.com/revel/samples/chat
- revel test github.com/revel/samples/facebook-oauth2
- revel test github.com/revel/samples/twitter-oauth
- revel test github.com/revel/samples/validation
- revel test github.com/revel/samples/upload

# Commented out persona test sample, since persona.org gonna be shutdown.
# Also http://personatestuser.org becomes non-responsive most of the time.
# https://wiki.mozilla.org/Identity/Persona_Shutdown_Guidelines_for_Reliers
# - revel test github.com/revel/samples/persona
# - revel test github.com/revel/examples/persona

matrix:
allow_failures:
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ you have a validated your ideas with other community members)!
In order to have your pull requests accepted, we recommend you make your changes to Revel on a
new git branch. For example,
```
$ git checkout -b feature/useful-new-thing develop # Create a new branch based on develop and switch to it
$ ... # Make your changes and commit them
$ git push fork develop # After new commits, push to your fork
$ git checkout -b feature/useful-new-thing origin/develop # Create a new branch based on develop and switch to it
$ ... # Make your changes and commit them
$ git push fork feature/useful-new-thing # After new commits, push to your fork
```

### Format Your Code
Expand Down
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A high productivity, full-stack web framework for the [Go language](http://www.golang.org).

Current Version: 0.13.1 (2016-06-06)
Current Version: 0.14.0 (2017-03-24)

**As of Revel 0.13.0, Go 1.4+ is required.**

Expand All @@ -21,6 +21,13 @@ Create a new app and run it:

Open http://localhost:9000 in your browser and you should see "It works!"


## Community

* [Gitter](https://gitter.im/revel/community)
* [StackOverflow](http://stackoverflow.com/questions/tagged/revel)
* [Google Groups](https://groups.google.com/forum/#!forum/revel-framework)

## Learn More

* [Manual, Samples, Godocs, etc](http://revel.github.io)
Expand All @@ -32,33 +39,18 @@ Open http://localhost:9000 in your browser and you should see "It works!"
* [Contributing Code Guidelines](https://github.com/revel/revel/blob/master/CONTRIBUTING.md)
* [Revel Contributors](https://github.com/revel/revel/graphs/contributors)

## Community

Join on [StackOverflow](http://stackoverflow.com/questions/tagged/revel), [IRC #revel](http://webchat.freenode.net/?channels=%23revel&uio=d4) and [Google Groups](https://groups.google.com/forum/#!forum/revel-framework)

* Report bugs [here](https://github.com/revel/revel/issues)
* Answer questions of other community members (via [StackOverflow](http://stackoverflow.com/questions/tagged/revel), [Google Groups](https://groups.google.com/forum/#!forum/revel-framework) and [IRC](http://webchat.freenode.net/?channels=%23revel&uio=d4))
* Give feedback on new feature discussions (via [GitHub Issues](https://github.com/revel/revel/issues) and [Google Groups](https://groups.google.com/forum/#!forum/revel-framework))
* Propose your own ideas via [Google Groups](https://groups.google.com/forum/#!forum/revel-framework)


## Gratitude

First and foremost, we'd like to thank the growing community of developers who enjoy using and contributing to Revel. Your patience, feedback, and moral support are vital to the ongoing development of Revel!

Also, thank you to those who have increased their level of involvement with Revel and revitalized the momentum of Revel:
* [Jeeva](https://github.com/jeevatkm)
* [Pedro](https://github.com/pedromorgan)
* Many others who provided valuable Pull Requests, testing, and feedback.

Finally, we'd like to thank the professional organizations that have supported the development of Revel:
* [Looking Glass](https://www.lookingglasscyber.com/)
* [Surge](http://surgeforward.com/)


## Announcements

View the [v0.13.0 release notes](https://github.com/revel/revel/releases/tag/v0.13.0)
View the [v0.14.0 release notes](https://github.com/revel/revel/releases/tag/v0.14.0)
for all of the relevant changes.

We are working on increasing the speed and quality of our releases. Your feedback has never been so valuable, please share your thoughts with us and help shape Revel!
115 changes: 59 additions & 56 deletions binder.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package revel

import (
Expand Down Expand Up @@ -39,7 +43,7 @@ type Binder struct {
Unbind func(output map[string]string, name string, val interface{})
}

// An adapter for easily making one-key-value binders.
// ValueBinder is adapter for easily making one-key-value binders.
func ValueBinder(f func(value string, typ reflect.Type) reflect.Value) func(*Params, string, reflect.Type) reflect.Value {
return func(params *Params, name string, typ reflect.Type) reflect.Value {
vals, ok := params.Values[name]
Expand All @@ -50,11 +54,13 @@ func ValueBinder(f func(value string, typ reflect.Type) reflect.Value) func(*Par
}
}

// Revel's default date and time constants
const (
DEFAULT_DATE_FORMAT = "2006-01-02"
DEFAULT_DATETIME_FORMAT = "2006-01-02 15:04"
DefaultDateFormat = "2006-01-02"
DefaultDateTimeFormat = "2006-01-02 15:04"
)

// Binders type and kind definition
var (
// These are the lookups to find a Binder for any type of data.
// The most specific binder found will be used (Type before Kind)
Expand Down Expand Up @@ -134,19 +140,11 @@ var (
},
}

// Booleans support a couple different value formats:
// "true" and "false"
// "on" and "" (a checkbox)
// "1" and "0" (why not)
// Booleans support a various value formats,
// refer `revel.Atob` method.
BoolBinder = Binder{
Bind: ValueBinder(func(val string, typ reflect.Type) reflect.Value {
v := strings.TrimSpace(strings.ToLower(val))
switch v {
case "true", "on", "1":
return reflect.ValueOf(true)
}
// Return false by default.
return reflect.ValueOf(false)
return reflect.ValueOf(Atob(val))
}),
Unbind: func(output map[string]string, name string, val interface{}) {
output[name] = fmt.Sprintf("%t", val)
Expand All @@ -155,7 +153,12 @@ var (

PointerBinder = Binder{
Bind: func(params *Params, name string, typ reflect.Type) reflect.Value {
return Bind(params, name, typ.Elem()).Addr()
v := Bind(params, name, typ.Elem())
if v.CanAddr() {
return v.Addr()
}

return v
},
Unbind: func(output map[string]string, name string, val interface{}) {
Unbind(output, name, reflect.ValueOf(val).Elem().Interface())
Expand Down Expand Up @@ -190,46 +193,6 @@ var (
}
)

// Sadly, the binder lookups can not be declared initialized -- that results in
// an "initialization loop" compile error.
func init() {
KindBinders[reflect.Int] = IntBinder
KindBinders[reflect.Int8] = IntBinder
KindBinders[reflect.Int16] = IntBinder
KindBinders[reflect.Int32] = IntBinder
KindBinders[reflect.Int64] = IntBinder

KindBinders[reflect.Uint] = UintBinder
KindBinders[reflect.Uint8] = UintBinder
KindBinders[reflect.Uint16] = UintBinder
KindBinders[reflect.Uint32] = UintBinder
KindBinders[reflect.Uint64] = UintBinder

KindBinders[reflect.Float32] = FloatBinder
KindBinders[reflect.Float64] = FloatBinder

KindBinders[reflect.String] = StringBinder
KindBinders[reflect.Bool] = BoolBinder
KindBinders[reflect.Slice] = Binder{bindSlice, unbindSlice}
KindBinders[reflect.Struct] = Binder{bindStruct, unbindStruct}
KindBinders[reflect.Ptr] = PointerBinder
KindBinders[reflect.Map] = MapBinder

TypeBinders[reflect.TypeOf(time.Time{})] = TimeBinder

// Uploads
TypeBinders[reflect.TypeOf(&os.File{})] = Binder{bindFile, nil}
TypeBinders[reflect.TypeOf([]byte{})] = Binder{bindByteArray, nil}
TypeBinders[reflect.TypeOf((*io.Reader)(nil)).Elem()] = Binder{bindReadSeeker, nil}
TypeBinders[reflect.TypeOf((*io.ReadSeeker)(nil)).Elem()] = Binder{bindReadSeeker, nil}

OnAppStart(func() {
DateTimeFormat = Config.StringDefault("format.datetime", DEFAULT_DATETIME_FORMAT)
DateFormat = Config.StringDefault("format.date", DEFAULT_DATE_FORMAT)
TimeFormats = append(TimeFormats, DateTimeFormat, DateFormat)
})
}

// Used to keep track of the index for individual keyvalues.
type sliceValue struct {
index int // Index extracted from brackets. If -1, no index was provided.
Expand Down Expand Up @@ -329,7 +292,7 @@ func unbindSlice(output map[string]string, name string, val interface{}) {
func bindStruct(params *Params, name string, typ reflect.Type) reflect.Value {
result := reflect.New(typ).Elem()
fieldValues := make(map[string]reflect.Value)
for key, _ := range params.Values {
for key := range params.Values {
if !strings.HasPrefix(key, name+".") {
continue
}
Expand Down Expand Up @@ -506,3 +469,43 @@ func binderForType(typ reflect.Type) (Binder, bool) {
}
return binder, true
}

// Sadly, the binder lookups can not be declared initialized -- that results in
// an "initialization loop" compile error.
func init() {
KindBinders[reflect.Int] = IntBinder
KindBinders[reflect.Int8] = IntBinder
KindBinders[reflect.Int16] = IntBinder
KindBinders[reflect.Int32] = IntBinder
KindBinders[reflect.Int64] = IntBinder

KindBinders[reflect.Uint] = UintBinder
KindBinders[reflect.Uint8] = UintBinder
KindBinders[reflect.Uint16] = UintBinder
KindBinders[reflect.Uint32] = UintBinder
KindBinders[reflect.Uint64] = UintBinder

KindBinders[reflect.Float32] = FloatBinder
KindBinders[reflect.Float64] = FloatBinder

KindBinders[reflect.String] = StringBinder
KindBinders[reflect.Bool] = BoolBinder
KindBinders[reflect.Slice] = Binder{bindSlice, unbindSlice}
KindBinders[reflect.Struct] = Binder{bindStruct, unbindStruct}
KindBinders[reflect.Ptr] = PointerBinder
KindBinders[reflect.Map] = MapBinder

TypeBinders[reflect.TypeOf(time.Time{})] = TimeBinder

// Uploads
TypeBinders[reflect.TypeOf(&os.File{})] = Binder{bindFile, nil}
TypeBinders[reflect.TypeOf([]byte{})] = Binder{bindByteArray, nil}
TypeBinders[reflect.TypeOf((*io.Reader)(nil)).Elem()] = Binder{bindReadSeeker, nil}
TypeBinders[reflect.TypeOf((*io.ReadSeeker)(nil)).Elem()] = Binder{bindReadSeeker, nil}

OnAppStart(func() {
DateTimeFormat = Config.StringDefault("format.datetime", DefaultDateTimeFormat)
DateFormat = Config.StringDefault("format.date", DefaultDateFormat)
TimeFormats = append(TimeFormats, DateTimeFormat, DateFormat)
})
}

0 comments on commit 75d66c3

Please sign in to comment.