mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-30 05:48:57 +01:00
Move *_helpers.go -> ./helpers/*.go
This commit is contained in:
parent
01f423ef02
commit
2102f544dc
2
build.go
2
build.go
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
)
|
||||
|
||||
// Clean the destination. Remove files that aren't in keep_files, and resulting empty diretories.
|
||||
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"io"
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
@ -23,7 +23,8 @@ func LeftPad(s string, n int) string {
|
||||
return string(ws) + s
|
||||
}
|
||||
|
||||
func stringArrayToMap(strings []string) map[string]bool {
|
||||
// StringArrayToMap creates a map for use as a set.
|
||||
func StringArrayToMap(strings []string) map[string]bool {
|
||||
stringMap := map[string]bool{}
|
||||
for _, s := range strings {
|
||||
stringMap[s] = true
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"testing"
|
2
main.go
2
main.go
@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
_ "gopkg.in/urfave/cli.v1"
|
||||
|
@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
)
|
||||
|
||||
// IsMarkdown returns a boolean indicating whether the file is a Markdown file, according to the current project.
|
||||
@ -14,5 +16,5 @@ func (s *Site) IsMarkdown(path string) bool {
|
||||
// MarkdownExtensions returns a set of markdown extension, without the final dots.
|
||||
func (s *Site) MarkdownExtensions() map[string]bool {
|
||||
extns := strings.SplitN(s.config.MarkdownExt, `,`, -1)
|
||||
return stringArrayToMap(extns)
|
||||
return StringArrayToMap(extns)
|
||||
}
|
||||
|
8
page.go
8
page.go
@ -10,6 +10,8 @@ import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/acstech/liquid"
|
||||
@ -62,11 +64,7 @@ func ReadPage(site *Site, rel string, defaults VariableMap) (p Page, err error)
|
||||
return
|
||||
}
|
||||
|
||||
fields := pageFields{
|
||||
site: site,
|
||||
path: rel,
|
||||
frontMatter: defaults,
|
||||
}
|
||||
fields := pageFields{site: site, path: rel, frontMatter: defaults}
|
||||
if string(magic) == "---\n" {
|
||||
p, err = NewDynamicPage(fields)
|
||||
if err != nil {
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
)
|
||||
|
||||
// PermalinkStyles defines built-in styles from https://jekyllrb.com/docs/permalinks/#builtinpermalinkstyles
|
||||
|
2
sass.go
2
sass.go
@ -9,6 +9,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
|
||||
libsass "github.com/wellington/go-libsass"
|
||||
)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
go run `find . -name \*.go ! -name \*_test.go` $@
|
||||
# go run `ls *.go | grep -v _test.go` $@
|
||||
go run `find . -maxdepth 1 -name \*.go ! -name \*_test.go` $@
|
||||
|
||||
# go build && ./gojekyll $@
|
||||
|
6
site.go
6
site.go
@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/osteele/gojekyll/helpers"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@ -131,8 +133,8 @@ func (s *Site) GetFileURL(path string) (string, bool) {
|
||||
// Exclude returns a boolean indicating that the site excludes a file.
|
||||
func (s *Site) Exclude(path string) bool {
|
||||
// TODO exclude based on glob, not exact match
|
||||
inclusionMap := stringArrayToMap(s.config.Include)
|
||||
exclusionMap := stringArrayToMap(s.config.Exclude)
|
||||
inclusionMap := StringArrayToMap(s.config.Include)
|
||||
exclusionMap := StringArrayToMap(s.config.Exclude)
|
||||
base := filepath.Base(path)
|
||||
switch {
|
||||
case inclusionMap[path]:
|
||||
|
Loading…
Reference in New Issue
Block a user