Skip to content

Commit 75d66c3

Browse files
Merge pull request revel#1150 from revel/develop
v0.14.0
2 parents 76317ca + eacd8f4 commit 75d66c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1158
-1273
lines changed

.travis.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ go:
44
- 1.4
55
- 1.5
66
- 1.6
7+
- 1.7
8+
- 1.8
79
- tip
810

911
os:
@@ -12,34 +14,42 @@ os:
1214

1315
sudo: false
1416

17+
branches:
18+
only:
19+
- master
20+
- develop
21+
1522
services:
1623
# github.com/revel/revel/cache
1724
- memcache
1825
- redis-server
1926

2027
before_install:
2128
# TRAVIS_OS_NAME - linux and osx
22-
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew install memcached redis; fi'
23-
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nohup /usr/local/opt/memcached/bin/memcached & fi'
24-
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nohup redis-server /usr/local/etc/redis.conf & fi'
29+
- echo $TRAVIS_OS_NAME
30+
- |
31+
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
32+
brew update && brew install memcached redis && brew services start redis && brew services start memcached
33+
fi
34+
- redis-server --daemonize yes
35+
- redis-cli info
2536

2637
install:
2738
# Setting environments variables
2839
- export PATH=$PATH:$HOME/gopath/bin
2940
- export REVEL_BRANCH="develop"
3041
- 'if [[ "$TRAVIS_BRANCH" == "master" ]]; then export REVEL_BRANCH="master"; fi'
3142
- 'echo "Travis branch: $TRAVIS_BRANCH, Revel dependency branch: $REVEL_BRANCH"'
32-
- go get -v github.com/revel/revel/...
33-
- rm -rf ../config
3443
- git clone -b $REVEL_BRANCH git://github.com/revel/modules ../modules/
3544
- git clone -b $REVEL_BRANCH git://github.com/revel/cmd ../cmd/
3645
- git clone -b $REVEL_BRANCH git://github.com/revel/config ../config/
3746
- git clone -b $REVEL_BRANCH git://github.com/revel/cron ../cron/
38-
- git clone git://github.com/revel/samples ../samples/
47+
- git clone -b $REVEL_BRANCH git://github.com/revel/examples ../examples/
48+
- go get -v github.com/revel/revel/...
3949
- go get -v github.com/revel/cmd/revel
4050

4151
script:
42-
- go test -v github.com/revel/revel...
52+
- go test -v github.com/revel/revel/...
4353

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

54-
# Build & run the sample apps
55-
- revel test github.com/revel/samples/booking
56-
- revel test github.com/revel/samples/chat
57-
- revel test github.com/revel/samples/facebook-oauth2
58-
- revel test github.com/revel/samples/twitter-oauth
59-
- revel test github.com/revel/samples/validation
60-
- revel test github.com/revel/samples/upload
61-
6264
# Commented out persona test sample, since persona.org gonna be shutdown.
6365
# Also http://personatestuser.org becomes non-responsive most of the time.
6466
# https://wiki.mozilla.org/Identity/Persona_Shutdown_Guidelines_for_Reliers
65-
# - revel test github.com/revel/samples/persona
67+
# - revel test github.com/revel/examples/persona
6668

6769
matrix:
6870
allow_failures:

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ you have a validated your ideas with other community members)!
7777
In order to have your pull requests accepted, we recommend you make your changes to Revel on a
7878
new git branch. For example,
7979
```
80-
$ git checkout -b feature/useful-new-thing develop # Create a new branch based on develop and switch to it
81-
$ ... # Make your changes and commit them
82-
$ git push fork develop # After new commits, push to your fork
80+
$ git checkout -b feature/useful-new-thing origin/develop # Create a new branch based on develop and switch to it
81+
$ ... # Make your changes and commit them
82+
$ git push fork feature/useful-new-thing # After new commits, push to your fork
8383
```
8484

8585
### Format Your Code

README.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

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

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

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

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

24+
25+
## Community
26+
27+
* [Gitter](https://gitter.im/revel/community)
28+
* [StackOverflow](http://stackoverflow.com/questions/tagged/revel)
29+
* [Google Groups](https://groups.google.com/forum/#!forum/revel-framework)
30+
2431
## Learn More
2532

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

35-
## Community
36-
37-
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)
38-
39-
* Report bugs [here](https://github.com/revel/revel/issues)
40-
* 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))
41-
* 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))
42-
* Propose your own ideas via [Google Groups](https://groups.google.com/forum/#!forum/revel-framework)
43-
4442

4543
## Gratitude
4644

4745
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!
4846

49-
Also, thank you to those who have increased their level of involvement with Revel and revitalized the momentum of Revel:
50-
* [Jeeva](https://github.com/jeevatkm)
51-
* [Pedro](https://github.com/pedromorgan)
52-
* Many others who provided valuable Pull Requests, testing, and feedback.
53-
5447
Finally, we'd like to thank the professional organizations that have supported the development of Revel:
5548
* [Looking Glass](https://www.lookingglasscyber.com/)
56-
* [Surge](http://surgeforward.com/)
5749

5850

5951
## Announcements
6052

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

6456
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!

binder.go

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
2+
// Revel Framework source code and usage is governed by a MIT style
3+
// license that can be found in the LICENSE file.
4+
15
package revel
26

37
import (
@@ -39,7 +43,7 @@ type Binder struct {
3943
Unbind func(output map[string]string, name string, val interface{})
4044
}
4145

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

57+
// Revel's default date and time constants
5358
const (
54-
DEFAULT_DATE_FORMAT = "2006-01-02"
55-
DEFAULT_DATETIME_FORMAT = "2006-01-02 15:04"
59+
DefaultDateFormat = "2006-01-02"
60+
DefaultDateTimeFormat = "2006-01-02 15:04"
5661
)
5762

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

137-
// Booleans support a couple different value formats:
138-
// "true" and "false"
139-
// "on" and "" (a checkbox)
140-
// "1" and "0" (why not)
143+
// Booleans support a various value formats,
144+
// refer `revel.Atob` method.
141145
BoolBinder = Binder{
142146
Bind: ValueBinder(func(val string, typ reflect.Type) reflect.Value {
143-
v := strings.TrimSpace(strings.ToLower(val))
144-
switch v {
145-
case "true", "on", "1":
146-
return reflect.ValueOf(true)
147-
}
148-
// Return false by default.
149-
return reflect.ValueOf(false)
147+
return reflect.ValueOf(Atob(val))
150148
}),
151149
Unbind: func(output map[string]string, name string, val interface{}) {
152150
output[name] = fmt.Sprintf("%t", val)
@@ -155,7 +153,12 @@ var (
155153

156154
PointerBinder = Binder{
157155
Bind: func(params *Params, name string, typ reflect.Type) reflect.Value {
158-
return Bind(params, name, typ.Elem()).Addr()
156+
v := Bind(params, name, typ.Elem())
157+
if v.CanAddr() {
158+
return v.Addr()
159+
}
160+
161+
return v
159162
},
160163
Unbind: func(output map[string]string, name string, val interface{}) {
161164
Unbind(output, name, reflect.ValueOf(val).Elem().Interface())
@@ -190,46 +193,6 @@ var (
190193
}
191194
)
192195

193-
// Sadly, the binder lookups can not be declared initialized -- that results in
194-
// an "initialization loop" compile error.
195-
func init() {
196-
KindBinders[reflect.Int] = IntBinder
197-
KindBinders[reflect.Int8] = IntBinder
198-
KindBinders[reflect.Int16] = IntBinder
199-
KindBinders[reflect.Int32] = IntBinder
200-
KindBinders[reflect.Int64] = IntBinder
201-
202-
KindBinders[reflect.Uint] = UintBinder
203-
KindBinders[reflect.Uint8] = UintBinder
204-
KindBinders[reflect.Uint16] = UintBinder
205-
KindBinders[reflect.Uint32] = UintBinder
206-
KindBinders[reflect.Uint64] = UintBinder
207-
208-
KindBinders[reflect.Float32] = FloatBinder
209-
KindBinders[reflect.Float64] = FloatBinder
210-
211-
KindBinders[reflect.String] = StringBinder
212-
KindBinders[reflect.Bool] = BoolBinder
213-
KindBinders[reflect.Slice] = Binder{bindSlice, unbindSlice}
214-
KindBinders[reflect.Struct] = Binder{bindStruct, unbindStruct}
215-
KindBinders[reflect.Ptr] = PointerBinder
216-
KindBinders[reflect.Map] = MapBinder
217-
218-
TypeBinders[reflect.TypeOf(time.Time{})] = TimeBinder
219-
220-
// Uploads
221-
TypeBinders[reflect.TypeOf(&os.File{})] = Binder{bindFile, nil}
222-
TypeBinders[reflect.TypeOf([]byte{})] = Binder{bindByteArray, nil}
223-
TypeBinders[reflect.TypeOf((*io.Reader)(nil)).Elem()] = Binder{bindReadSeeker, nil}
224-
TypeBinders[reflect.TypeOf((*io.ReadSeeker)(nil)).Elem()] = Binder{bindReadSeeker, nil}
225-
226-
OnAppStart(func() {
227-
DateTimeFormat = Config.StringDefault("format.datetime", DEFAULT_DATETIME_FORMAT)
228-
DateFormat = Config.StringDefault("format.date", DEFAULT_DATE_FORMAT)
229-
TimeFormats = append(TimeFormats, DateTimeFormat, DateFormat)
230-
})
231-
}
232-
233196
// Used to keep track of the index for individual keyvalues.
234197
type sliceValue struct {
235198
index int // Index extracted from brackets. If -1, no index was provided.
@@ -329,7 +292,7 @@ func unbindSlice(output map[string]string, name string, val interface{}) {
329292
func bindStruct(params *Params, name string, typ reflect.Type) reflect.Value {
330293
result := reflect.New(typ).Elem()
331294
fieldValues := make(map[string]reflect.Value)
332-
for key, _ := range params.Values {
295+
for key := range params.Values {
333296
if !strings.HasPrefix(key, name+".") {
334297
continue
335298
}
@@ -506,3 +469,43 @@ func binderForType(typ reflect.Type) (Binder, bool) {
506469
}
507470
return binder, true
508471
}
472+
473+
// Sadly, the binder lookups can not be declared initialized -- that results in
474+
// an "initialization loop" compile error.
475+
func init() {
476+
KindBinders[reflect.Int] = IntBinder
477+
KindBinders[reflect.Int8] = IntBinder
478+
KindBinders[reflect.Int16] = IntBinder
479+
KindBinders[reflect.Int32] = IntBinder
480+
KindBinders[reflect.Int64] = IntBinder
481+
482+
KindBinders[reflect.Uint] = UintBinder
483+
KindBinders[reflect.Uint8] = UintBinder
484+
KindBinders[reflect.Uint16] = UintBinder
485+
KindBinders[reflect.Uint32] = UintBinder
486+
KindBinders[reflect.Uint64] = UintBinder
487+
488+
KindBinders[reflect.Float32] = FloatBinder
489+
KindBinders[reflect.Float64] = FloatBinder
490+
491+
KindBinders[reflect.String] = StringBinder
492+
KindBinders[reflect.Bool] = BoolBinder
493+
KindBinders[reflect.Slice] = Binder{bindSlice, unbindSlice}
494+
KindBinders[reflect.Struct] = Binder{bindStruct, unbindStruct}
495+
KindBinders[reflect.Ptr] = PointerBinder
496+
KindBinders[reflect.Map] = MapBinder
497+
498+
TypeBinders[reflect.TypeOf(time.Time{})] = TimeBinder
499+
500+
// Uploads
501+
TypeBinders[reflect.TypeOf(&os.File{})] = Binder{bindFile, nil}
502+
TypeBinders[reflect.TypeOf([]byte{})] = Binder{bindByteArray, nil}
503+
TypeBinders[reflect.TypeOf((*io.Reader)(nil)).Elem()] = Binder{bindReadSeeker, nil}
504+
TypeBinders[reflect.TypeOf((*io.ReadSeeker)(nil)).Elem()] = Binder{bindReadSeeker, nil}
505+
506+
OnAppStart(func() {
507+
DateTimeFormat = Config.StringDefault("format.datetime", DefaultDateTimeFormat)
508+
DateFormat = Config.StringDefault("format.date", DefaultDateFormat)
509+
TimeFormats = append(TimeFormats, DateTimeFormat, DateFormat)
510+
})
511+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy