Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Development (#2072)
Browse files Browse the repository at this point in the history
* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

* moving to latest 2 go versions (#2038)

* Task binding cleanup (#2039)

* moving to latest 2 go versions

* cleaning up the decoder on the binding package

* Task update formam (#2041)

* v0.16.14 (#2030)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updates formam version #2040

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating flect versionm (#2042)

* updating version

* updating some libraries to pass the github security warnings (#2044)

* Removing Grifts folder (#2050)

* removing the grifts folder

* removing grifts folder from codeclimate exceptions

* fixes the non-existing .git folder case (#2053)

* calling persist explicitly (#2054)

* adding version number

* Pointing README to new go docs link

* running packr2

* Warns if response is attempted to be written twice (#2059)

* v0.16.16 (#2055)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

* moving to latest 2 go versions (#2038)

* Task binding cleanup (#2039)

* moving to latest 2 go versions

* cleaning up the decoder on the binding package

* Task update formam (#2041)

* v0.16.14 (#2030)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updates formam version #2040

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating flect versionm (#2042)

* updating version

* updating some libraries to pass the github security warnings (#2044)

* Removing Grifts folder (#2050)

* removing the grifts folder

* removing grifts folder from codeclimate exceptions

* fixes the non-existing .git folder case (#2053)

* calling persist explicitly (#2054)

* adding version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* only writing the header if it has not been written

* bumping version

* adding packr2 files

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* allows to specify custom partialfeeders

* cleaning up a bit for codeclimate

* changing the version

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>
  • Loading branch information
3 people authored Dec 24, 2020
1 parent 0fc3b9f commit 4c0bda0
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN npm install -g --no-progress yarn \
# Install golangci
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
# Installing buffalo binary
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].16 | sh
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].18 | sh
RUN go get github.com/gobuffalo/buffalo-pop/v2
RUN buffalo version

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.slim.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN npm i -g --no-progress yarn \
&& yarn config set yarn-offline-mirror-pruning true

# Pulling docker binary from releases
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].16 | sh
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].18 | sh
RUN go get github.com/gobuffalo/buffalo-pop/v2
RUN buffalo version

Expand Down
33 changes: 33 additions & 0 deletions render/partials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@ func Test_Template_Partial(t *testing.T) {
r.Equal("Foo > Mark", strings.TrimSpace(bb.String()))
}

func Test_Template_PartialCustomFeeder(t *testing.T) {
r := require.New(t)

box := packd.NewMemoryBox()
r.NoError(box.AddString("base.plush.html", `<%= partial("foo.plush.html") %>`))
r.NoError(box.AddString("_foo.plush.html", "other"))

e := NewEngine()
e.TemplatesBox = box

t.Run("Custom Feeder", func(t *testing.T) {
e.Helpers["partialFeeder"] = func(path string) (string, error) {
return "custom", nil
}

bb := &bytes.Buffer{}

re := e.HTML("base.plush.html")
r.NoError(re.Render(bb, Data{}))
r.Equal("custom", strings.TrimSpace(bb.String()))
})

t.Run("Default Feeder", func(t *testing.T) {
e.Helpers["partialFeeder"] = nil

bb := &bytes.Buffer{}

re := e.HTML("base.plush.html")
r.NoError(re.Render(bb, Data{}))
r.Equal("other", strings.TrimSpace(bb.String()))
})
}

func Test_Template_Partial_WithoutExtension(t *testing.T) {
r := require.New(t)

Expand Down
61 changes: 37 additions & 24 deletions render/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,7 @@ func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
name = fixExtension(name, ct)

// Try to use localized version
templateName := name
if languages, ok := data["languages"].([]string); ok {
ll := len(languages)
if ll > 0 {
// Default language is the last in the list
defaultLanguage := languages[ll-1]
ext := filepath.Ext(name)
rawName := strings.TrimSuffix(name, ext)

for _, l := range languages {
var candidateName string
if l == defaultLanguage {
break
}
candidateName = rawName + "." + strings.ToLower(l) + ext
if _, err := s.resolve(candidateName); err == nil {
// Replace name with the existing suffixed version
templateName = candidateName
break
}
}
}
}
templateName := s.localizedName(name, data)

// Set current_template to context
if _, ok := data["current_template"]; !ok {
Expand All @@ -158,7 +136,11 @@ func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
for k, v := range s.Helpers {
helpers[k] = v
}
helpers["partialFeeder"] = s.partialFeeder

// Allows to specify custom partialFeeder
if helpers["partialFeeder"] == nil {
helpers["partialFeeder"] = s.partialFeeder
}

helpers = s.addAssetsHelpers(helpers)

Expand All @@ -178,6 +160,37 @@ func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
return template.HTML(body), nil
}

func (s templateRenderer) localizedName(name string, data Data) string {
templateName := name

languages, ok := data["languages"].([]string)
if !ok || len(languages) == 0 {
return templateName
}

ll := len(languages)
// Default language is the last in the list
defaultLanguage := languages[ll-1]
ext := filepath.Ext(name)
rawName := strings.TrimSuffix(name, ext)

for _, l := range languages {
var candidateName string
if l == defaultLanguage {
break
}

candidateName = rawName + "." + strings.ToLower(l) + ext
if _, err := s.resolve(candidateName); err == nil {
// Replace name with the existing suffixed version
templateName = candidateName
break
}
}

return templateName
}

func (s templateRenderer) exts(name string) []string {
exts := []string{}
for {
Expand Down
15 changes: 12 additions & 3 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ type Response struct {
}

// WriteHeader sets the status code for a response
func (w *Response) WriteHeader(i int) {
w.Status = i
w.ResponseWriter.WriteHeader(i)
func (w *Response) WriteHeader(code int) {
if code == w.Status {
return
}

if w.Status > 0 {
fmt.Printf("[WARNING] Headers were already written. Wanted to override status code %d with %d", w.Status, code)
return
}

w.Status = code
w.ResponseWriter.WriteHeader(code)
}

// Write the body of the response
Expand Down
22 changes: 22 additions & 0 deletions response_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package buffalo

import (
"net/http"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/require"
)

func Test_Response_MultipleWrite(t *testing.T) {
r := require.New(t)
resWr := httptest.NewRecorder()
res := Response{
ResponseWriter: resWr,
}

res.WriteHeader(http.StatusOK)
res.WriteHeader(http.StatusInternalServerError)

r.Equal(res.Status, http.StatusOK)
}
2 changes: 1 addition & 1 deletion runtime/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package runtime

// Version is the current version of the buffalo binary
var Version = "v0.16.16"
var Version = "v0.16.18"

0 comments on commit 4c0bda0

Please sign in to comment.