This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added some new generators, jquery, bootstrap, bootswatch, and railsjs * added a basic resource generator * fixed code climate issues. * version bump * added brian's "testimonial".
- Loading branch information
Showing
13 changed files
with
517 additions
and
42 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
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,40 @@ | ||
// Copyright © 2016 Mark Bates <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package cmd | ||
|
||
import ( | ||
"github.com/markbates/buffalo/buffalo/cmd/generate" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var generateCmd = &cobra.Command{ | ||
Use: "generate", | ||
Aliases: []string{"g"}, | ||
} | ||
|
||
func init() { | ||
generateCmd.AddCommand(generate.JQueryCmd) | ||
generateCmd.AddCommand(generate.RailsJSCmd) | ||
generateCmd.AddCommand(generate.BootstrapCmd) | ||
generateCmd.AddCommand(generate.BootswatchCmd) | ||
generateCmd.AddCommand(generate.ResourceCmd) | ||
RootCmd.AddCommand(generateCmd) | ||
} |
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,75 @@ | ||
// Copyright © 2016 Mark Bates <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package generate | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/markbates/gentronics" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// BootstrapCmd will generate new Bootstrap files. Regardless of whatever | ||
// other settings you might, this will generate jQuery files as that is a | ||
// pre-requisite of Bootstrap. | ||
var BootstrapCmd = &cobra.Command{ | ||
Use: "bootstrap", | ||
Short: "Generates Bootstrap 3 files", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return NewBootstrapGenerator().Run(".", gentronics.Data{ | ||
"withBootstrap": true, | ||
}) | ||
}, | ||
} | ||
|
||
// NewBootstrapGenerator will generate new Bootstrap files. Regardless of whatever | ||
// other settings you might, this will generate jQuery files as that is a | ||
// pre-requisite of Bootstrap. | ||
func NewBootstrapGenerator() *gentronics.Generator { | ||
should := func(data gentronics.Data) bool { | ||
if p, ok := data["withBootstrap"]; ok { | ||
return p.(bool) | ||
} | ||
return false | ||
} | ||
g := gentronics.New() | ||
jf := &gentronics.RemoteFile{ | ||
File: gentronics.NewFile(filepath.Join("assets", "bootstrap.css"), ""), | ||
} | ||
jf.Should = should | ||
jf.RemotePath = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
g.Add(jf) | ||
|
||
jf = &gentronics.RemoteFile{ | ||
File: gentronics.NewFile(filepath.Join("assets", "bootstrap.js"), ""), | ||
} | ||
jf.Should = should | ||
jf.RemotePath = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" | ||
g.Add(jf) | ||
g.Add(&gentronics.Func{ | ||
Should: should, | ||
Runner: func(rootPath string, data gentronics.Data) error { | ||
data["withJQuery"] = true | ||
return NewJQueryGenerator().Run(rootPath, data) | ||
}, | ||
}) | ||
return g | ||
} |
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,88 @@ | ||
// Copyright © 2016 Mark Bates <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package generate | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/markbates/gentronics" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// BootswatchCmd will generate new Bootswatch themes. Regardless of whatever | ||
// other settings you have, this will generate jQuery and Bootstrap files as | ||
// they are pre-requisites for Bootswatch | ||
var BootswatchCmd = &cobra.Command{ | ||
Use: "bootswatch [theme]", | ||
Short: "Generates Bootswatch 3 files", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
return fmt.Errorf("You must choose a theme! [%s]", strings.Join(bootswatchThemes, ", ")) | ||
} | ||
g, err := NewBootswatchGenerator(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
return g.Run(".", gentronics.Data{ | ||
"withBootswatch": true, | ||
}) | ||
}, | ||
} | ||
|
||
// NewBootswatchGenerator will generate new Bootswatch themes. Regardless of whatever | ||
// other settings you have, this will generate jQuery and Bootstrap files as | ||
// they are pre-requisites for Bootswatch | ||
func NewBootswatchGenerator(theme string) (*gentronics.Generator, error) { | ||
themeFound := false | ||
for _, t := range bootswatchThemes { | ||
if t == theme { | ||
themeFound = true | ||
break | ||
} | ||
} | ||
if !themeFound { | ||
return nil, fmt.Errorf("Could not find a Bootswatch theme for %s!", theme) | ||
} | ||
g := gentronics.New() | ||
g.Add(&gentronics.Func{ | ||
Should: func(data gentronics.Data) bool { return true }, | ||
Runner: func(rootPath string, data gentronics.Data) error { | ||
data["withJQuery"] = true | ||
data["withBootstrap"] = true | ||
err := NewJQueryGenerator().Run(rootPath, data) | ||
if err != nil { | ||
return err | ||
} | ||
return NewBootstrapGenerator().Run(rootPath, data) | ||
}, | ||
}) | ||
jf := &gentronics.RemoteFile{ | ||
File: gentronics.NewFile(filepath.Join("assets", "bootstrap.css"), ""), | ||
} | ||
jf.RemotePath = fmt.Sprintf("https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/%s/bootstrap.min.css", theme) | ||
g.Add(jf) | ||
|
||
return g, nil | ||
} | ||
|
||
var bootswatchThemes = []string{"cerulean", "cosmo", "cyborg", "darkly", "flatly", "journal", "lumen", "paper", "readable", "sandstone", "simplex", "slate", "spacelab", "superhero", "united", "yeti"} |
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,20 @@ | ||
package generate | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/markbates/gentronics" | ||
) | ||
|
||
// Fmt is command that will use `goimports` if available, | ||
// or fail back to `gofmt` otherwise. | ||
var Fmt *gentronics.Command | ||
|
||
func init() { | ||
c := "gofmt" | ||
_, err := exec.LookPath("goimports") | ||
if err == nil { | ||
c = "goimports" | ||
} | ||
Fmt = gentronics.NewCommand(exec.Command(c, "-w", ".")) | ||
} |
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,66 @@ | ||
// Copyright © 2016 Mark Bates <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package generate | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/markbates/gentronics" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// JQueryCmd will generate jQuery files. | ||
var JQueryCmd = &cobra.Command{ | ||
Use: "jquery", | ||
Short: "Generates an assets/jquery.js file", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
data := gentronics.Data{ | ||
"withJQuery": true, | ||
} | ||
return NewJQueryGenerator().Run(".", data) | ||
}, | ||
} | ||
|
||
// NewJQueryGenerator will generate jQuery files. | ||
func NewJQueryGenerator() *gentronics.Generator { | ||
should := func(data gentronics.Data) bool { | ||
if p, ok := data["withJQuery"]; ok { | ||
return p.(bool) | ||
} | ||
return false | ||
} | ||
|
||
g := gentronics.New() | ||
jf := &gentronics.RemoteFile{ | ||
File: gentronics.NewFile(filepath.Join("assets", "jquery.js"), ""), | ||
} | ||
jf.Should = should | ||
jf.RemotePath = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" | ||
g.Add(jf) | ||
|
||
jm := &gentronics.RemoteFile{ | ||
File: gentronics.NewFile(filepath.Join("assets", "jquery.map"), ""), | ||
} | ||
jm.Should = should | ||
jm.RemotePath = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.map" | ||
g.Add(jm) | ||
return g | ||
} |
Oops, something went wrong.