1
0
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:
Oliver Steele 2017-06-16 19:17:22 -04:00
parent 01f423ef02
commit 2102f544dc
11 changed files with 27 additions and 13 deletions

View File

@ -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.

View File

@ -1,4 +1,4 @@
package main
package helpers
import (
"io"

View File

@ -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

View File

@ -1,4 +1,4 @@
package main
package helpers
import (
"testing"

View File

@ -9,6 +9,8 @@ import (
"strings"
"time"
. "github.com/osteele/gojekyll/helpers"
"github.com/urfave/cli"
_ "gopkg.in/urfave/cli.v1"

View File

@ -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)
}

View File

@ -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 {

View File

@ -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

View File

@ -9,6 +9,8 @@ import (
"path/filepath"
"strings"
. "github.com/osteele/gojekyll/helpers"
libsass "github.com/wellington/go-libsass"
)

View File

@ -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 $@

View File

@ -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]: