mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-30 11:09:01 +01:00
Add --remote-liquid
This commit is contained in:
parent
af9261222b
commit
66495ca55f
30
README.md
30
README.md
@ -25,11 +25,13 @@ It's currently ~50x faster than Jekyll using an embedded Liquid engine (that isn
|
||||
- [ ] Data Files
|
||||
- [ ] Assets
|
||||
- [ ] Coffeescript
|
||||
- [x] Sass
|
||||
- [x] Sass/SCSS
|
||||
- [ ] Customization
|
||||
- [x] Templates
|
||||
- [ ] All Jekyll Liquid filters
|
||||
- [ ] All Jekyll Liquid tags
|
||||
- [x] link tag
|
||||
- [x] include tag
|
||||
- [ ] Remaining Jekyll Liquid tags
|
||||
- [ ] Jekyll Liquid filters
|
||||
- [x] Includes
|
||||
- [x] Permalinks
|
||||
- [ ] Pagination
|
||||
@ -61,22 +63,16 @@ git pull -f osteele
|
||||
## Run
|
||||
|
||||
```bash
|
||||
gojekyll --source test build
|
||||
gojekyll --source test serve
|
||||
gojekyll --source test render index.md # render a file to stdout
|
||||
gojekyll --source test render / # render a URL to stdout
|
||||
gojekyll --source test data / # print a path's template variables
|
||||
gojekyll build # builds into ./_site
|
||||
gojekyll serve # serves from memory, w/ live reload
|
||||
gojekyll render index.md # render a file to stdout
|
||||
gojekyll render / # render a URL to stdout
|
||||
gojekyll data / # print a file or URL's variables
|
||||
gojekyll --remote-liquid # use a local Liquid engine server
|
||||
gojekyll help
|
||||
```
|
||||
|
||||
`--source DIR` is optional.
|
||||
|
||||
`build` needn't be run before `server`. The latter serves from memory.
|
||||
|
||||
`server` only rebuilds individual changed pages, doesn't rebuild collections, and doesn't detect new pages.
|
||||
|
||||
`render` renders a single file, identified by permalink if it starts with `/`, and by pathname (relative to the source directory) if it doesn't.
|
||||
|
||||
For develpment, `./scripts/gojekyll` uses `go run` each time it's invoked.
|
||||
For development, `./scripts/gojekyll` uses `go run` each time it's invoked.
|
||||
|
||||
## Credits
|
||||
|
||||
|
@ -43,8 +43,6 @@ func benchmarkCommand(c *cli.Context, site *gojekyll.Site) error {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
// elapsed := time.Since(commandStartTime)
|
||||
// printSetting("", fmt.Sprintf("created %d files in %.2fs.", count, elapsed.Seconds()))
|
||||
}
|
||||
|
||||
func serveCommand(c *cli.Context, site *gojekyll.Site) error {
|
||||
@ -124,6 +122,7 @@ func loadSite(source, destination string) (*gojekyll.Site, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
site.UseRemoteLiquidEngine = useRemoteLiquidEngine
|
||||
if destination != "" {
|
||||
site.Destination = destination
|
||||
}
|
||||
@ -131,7 +130,6 @@ func loadSite(source, destination string) (*gojekyll.Site, error) {
|
||||
printPathSetting(configurationFileLabel, *site.ConfigFile)
|
||||
} else {
|
||||
printSetting(configurationFileLabel, "none")
|
||||
|
||||
}
|
||||
printPathSetting("Source:", site.Source)
|
||||
return site, site.ReadFiles()
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
|
||||
// Command-line options
|
||||
var buildOptions gojekyll.BuildOptions
|
||||
var useRemoteLiquidEngine bool
|
||||
|
||||
// This is the longest label. Pull it out here so we can both use it, and measure it for alignment.
|
||||
const configurationFileLabel = "Configuration file:"
|
||||
@ -50,6 +51,11 @@ func main() {
|
||||
Usage: "Destination directory",
|
||||
Destination: &destination,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "remote-liquid",
|
||||
Usage: "Use Liquid JSON-RPC server",
|
||||
Destination: &useRemoteLiquidEngine,
|
||||
},
|
||||
}
|
||||
|
||||
withSite := func(cmd func(*cli.Context, *gojekyll.Site) error) func(*cli.Context) error {
|
||||
@ -80,7 +86,7 @@ func main() {
|
||||
{
|
||||
Name: "benchmark",
|
||||
Aliases: []string{"b"},
|
||||
Usage: "Benchmark",
|
||||
Usage: "Build several times, and write a profile file",
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "dry-run, n",
|
||||
@ -91,11 +97,12 @@ func main() {
|
||||
Action: withSite(benchmarkCommand),
|
||||
}, {
|
||||
Name: "data",
|
||||
Aliases: []string{"b"},
|
||||
Usage: "Print a file or URL path's variables",
|
||||
Action: withSite(dataCommand),
|
||||
},
|
||||
{
|
||||
Name: "routes",
|
||||
Usage: "Display site permalinks and associated files",
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "dynamic",
|
||||
@ -106,6 +113,7 @@ func main() {
|
||||
},
|
||||
{
|
||||
Name: "render",
|
||||
Usage: "Render a file or URL path",
|
||||
Action: withSite(renderCommand),
|
||||
},
|
||||
}
|
||||
|
11
site.go
11
site.go
@ -14,9 +14,10 @@ import (
|
||||
|
||||
// Site is a Jekyll site.
|
||||
type Site struct {
|
||||
ConfigFile *string
|
||||
Source string
|
||||
Destination string
|
||||
ConfigFile *string
|
||||
Source string
|
||||
Destination string
|
||||
UseRemoteLiquidEngine bool
|
||||
|
||||
Collections []*Collection
|
||||
Variables VariableMap
|
||||
@ -216,12 +217,10 @@ func (s *Site) createRemoteEngine() liquid.Engine {
|
||||
return engine
|
||||
}
|
||||
|
||||
const useRemoteLiquidEngine = true
|
||||
|
||||
// LiquidEngine create a liquid engine with site-specific behavior.
|
||||
func (s *Site) LiquidEngine() liquid.Engine {
|
||||
if s.liquidEngine == nil {
|
||||
if useRemoteLiquidEngine {
|
||||
if s.UseRemoteLiquidEngine {
|
||||
s.liquidEngine = s.createRemoteEngine()
|
||||
} else {
|
||||
s.liquidEngine = s.createLocalEngine()
|
||||
|
Loading…
Reference in New Issue
Block a user