From 0006a5dad75513848ed6e86a477e95b4a7dc3d2b Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Thu, 6 Jun 2013 09:16:28 -0700 Subject: [PATCH 1/7] Ignore emacs autosave files. --- util.go | 1 + 1 file changed, 1 insertion(+) diff --git a/util.go b/util.go index af0acdd..cda017a 100644 --- a/util.go +++ b/util.go @@ -41,6 +41,7 @@ func isHiddenOrTemp(fn string) bool { base := filepath.Base(fn) return strings.HasPrefix(base, ".") || strings.HasPrefix(fn, ".") || + strings.HasPrefix(base, "#") || strings.HasSuffix(base, "~") || fn == "README.md" } From 5db132975c54cf59b472e161fe1210d738624664 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 20 Jan 2015 16:18:04 -0800 Subject: [PATCH 2/7] gofmt --- config.go | 2 +- post.go | 4 ++-- template.go | 52 +++++++++++++++++++++++-------------------- util_test.go | 62 ++++++++++++++++++++++++++-------------------------- 4 files changed, 62 insertions(+), 58 deletions(-) diff --git a/config.go b/config.go index 5d0bd43..907930d 100644 --- a/config.go +++ b/config.go @@ -42,7 +42,7 @@ func ParseConfig(path string) (Config, error) { } func parseConfig(data []byte) (Config, error) { - conf := map[string] interface{} { } + conf := map[string]interface{}{} err := goyaml.Unmarshal(data, &conf) if err != nil { return nil, err diff --git a/post.go b/post.go index d124bf9..d25edf1 100644 --- a/post.go +++ b/post.go @@ -21,7 +21,7 @@ func ParsePost(fn string) (Page, error) { } // parse the Date and Title from the post's file name - _,f := filepath.Split(fn) + _, f := filepath.Split(fn) t, d, err := parsePostName(f) if err != nil { return nil, err @@ -40,7 +40,7 @@ func ParsePost(fn string) (Page, error) { year := fmt.Sprintf("%02d", d.Year()) name := replaceExt(f, ".html") post["id"] = filepath.Join(year, mon, day, f) // TODO try to remember why I need this field - post["url"]= filepath.Join(year, mon, day, name[11:]) + post["url"] = filepath.Join(year, mon, day, name[11:]) return post, nil } diff --git a/template.go b/template.go index fb93ce8..52d1198 100644 --- a/template.go +++ b/template.go @@ -6,23 +6,23 @@ import ( ) // Additional functions available in Jekyll templates -var funcMap = map[string]interface{} { - - "capitalize" : capitalize, - "date_to_string" : dateToString, - "date_to_xmlschema" : dateToXmlSchema, - "downcase" : lower, - "eq" : eq, - "newline_to_br" : newlineToBreak, - "replace" : replace, - "replace_first" : replaceFirst, - "remove" : remove, - "remove_first" : removeFirst, - "split" : split, - "strip_newlines" : stripNewlines, - "truncate" : truncate, - "truncatewords" : truncateWords, - "upcase" : upper, +var funcMap = map[string]interface{}{ + + "capitalize": capitalize, + "date_to_string": dateToString, + "date_to_xmlschema": dateToXmlSchema, + "downcase": lower, + "eq": eq, + "newline_to_br": newlineToBreak, + "replace": replace, + "replace_first": replaceFirst, + "remove": remove, + "remove_first": removeFirst, + "split": split, + "strip_newlines": stripNewlines, + "truncate": truncate, + "truncatewords": truncateWords, + "upcase": upper, } // Capitalize words in the input sentence @@ -31,17 +31,17 @@ func capitalize(s string) string { } // Checks if two values are equal -func eq(v1 interface{}, v2 interface{}) bool { +func eq(v1 interface{}, v2 interface{}) bool { return v1 == v2 } // Converts a date to a string -func dateToString(date time.Time) string { +func dateToString(date time.Time) string { return date.Format("2006-01-02") } // Converts a date to a string -func dateToXmlSchema(date time.Time) string { +func dateToXmlSchema(date time.Time) string { return date.Format(time.RFC3339) } @@ -86,15 +86,19 @@ func stripNewlines(s string) string { } // Truncate a string down to x characters -func truncate(s string, x int) (string) { - if len(s) > x { return s[0:x] } +func truncate(s string, x int) string { + if len(s) > x { + return s[0:x] + } return s } // Truncate a string down to x words -func truncateWords(s string, x int) (string) { +func truncateWords(s string, x int) string { words := strings.Split(s, " ") - if len(words) <= x { return s } + if len(words) <= x { + return s + } return strings.Join(words[0:x], " ") } diff --git a/util_test.go b/util_test.go index 424f9d8..e222262 100644 --- a/util_test.go +++ b/util_test.go @@ -6,10 +6,10 @@ import ( func TestAppendExt(t *testing.T) { if ext := appendExt("/test.html", ".html"); ext != "/test.html" { - t.Errorf("Expected appended extension [/test.html] got [%s]", ext) + t.Errorf("Expected appended extension [/test.html] got [%s]", ext) } if ext := appendExt("/test", ".html"); ext != "/test.html" { - t.Errorf("Expected appended extension [/test.html] got [%s]", ext) + t.Errorf("Expected appended extension [/test.html] got [%s]", ext) } } @@ -18,11 +18,11 @@ func TestHasMatter(t *testing.T) { } func TestIsHiddenOrTemp(t *testing.T) { - tests := map[string]bool { - ".tmp" : true, - "tmp~" : true, - "tmp" : false, - ".git" : true } + tests := map[string]bool{ + ".tmp": true, + "tmp~": true, + "tmp": false, + ".git": true} for key, val := range tests { if result := isHiddenOrTemp(key); result != val { @@ -32,12 +32,12 @@ func TestIsHiddenOrTemp(t *testing.T) { } func TestIsTemplate(t *testing.T) { - tests := map[string]bool { - "_layouts/page.html" : true, - "_includes/page.html" : true, - "_includes/page.html~" : false, - "static/js/script.js" : false, - "index.html" : false } + tests := map[string]bool{ + "_layouts/page.html": true, + "_includes/page.html": true, + "_includes/page.html~": false, + "static/js/script.js": false, + "index.html": false} for key, val := range tests { if result := isTemplate(key); result != val { @@ -47,12 +47,12 @@ func TestIsTemplate(t *testing.T) { } func TestIsHtml(t *testing.T) { - tests := map[string]bool { - "page.html" : true, - "page.xml" : true, - "page.html~" : false, - "page.rss" : true, - "page.atom" : true } + tests := map[string]bool{ + "page.html": true, + "page.xml": true, + "page.html~": false, + "page.rss": true, + "page.atom": true} for key, val := range tests { if result := isHtml(key); result != val { @@ -62,10 +62,10 @@ func TestIsHtml(t *testing.T) { } func TestIsMarkdown(t *testing.T) { - tests := map[string]bool { - "page.md" : true, - "page.markdown" : true, - "page.md~" : false } + tests := map[string]bool{ + "page.md": true, + "page.markdown": true, + "page.md~": false} for key, val := range tests { if result := isMarkdown(key); result != val { @@ -83,10 +83,10 @@ func TestIsPost(t *testing.T) { } func TestIsStatic(t *testing.T) { - tests := map[string]bool { - "_site" : false, - "_site/index.html" : false, - "img/logo.png" : true } + tests := map[string]bool{ + "_site": false, + "_site/index.html": false, + "img/logo.png": true} for key, val := range tests { if result := isStatic(key); result != val { @@ -97,18 +97,18 @@ func TestIsStatic(t *testing.T) { func TestRemoveExt(t *testing.T) { if ext := removeExt("/test"); ext != "/test" { - t.Errorf("Expected removed extension [/test] got [%s]", ext) + t.Errorf("Expected removed extension [/test] got [%s]", ext) } if ext := removeExt("/test.html"); ext != "/test" { - t.Errorf("Expected removed extension [/test] got [%s]", ext) + t.Errorf("Expected removed extension [/test] got [%s]", ext) } } func TestReplaceExt(t *testing.T) { if ext := replaceExt("/test", ".html"); ext != "/test.html" { - t.Errorf("Expected replaced extension [/test.html] got [%s]", ext) + t.Errorf("Expected replaced extension [/test.html] got [%s]", ext) } if ext := replaceExt("/test.markdown", ".html"); ext != "/test.html" { - t.Errorf("Expected replaced extension [/test.html] got [%s]", ext) + t.Errorf("Expected replaced extension [/test.html] got [%s]", ext) } } From 29b2c967d6f5f4a65a222f8815c24518901ca8c9 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 20 Jan 2015 16:19:09 -0800 Subject: [PATCH 3/7] goimports --- config.go | 1 + page.go | 5 +++-- site.go | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index 907930d..e3ab4fa 100644 --- a/config.go +++ b/config.go @@ -2,6 +2,7 @@ package main import ( "io/ioutil" + "launchpad.net/goyaml" ) diff --git a/page.go b/page.go index c39a89c..815877a 100644 --- a/page.go +++ b/page.go @@ -2,12 +2,13 @@ package main import ( "bytes" - "github.com/russross/blackfriday" "io" "io/ioutil" - "launchpad.net/goyaml" "path/filepath" "strings" + + "github.com/russross/blackfriday" + "launchpad.net/goyaml" ) // A Page represents the key-value pairs in a page or posts front-end YAML as diff --git a/site.go b/site.go index cf3f700..12b851a 100644 --- a/site.go +++ b/site.go @@ -4,13 +4,14 @@ import ( "bytes" "fmt" "io/ioutil" - "launchpad.net/goamz/aws" - "launchpad.net/goamz/s3" "mime" "os" "path/filepath" "text/template" "time" + + "launchpad.net/goamz/aws" + "launchpad.net/goamz/s3" ) var ( From f8fcbbf015a29af0ee3e9c13fba3faf3c1d3596c Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 20 Jan 2015 16:22:28 -0800 Subject: [PATCH 4/7] goamz moved --- site.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site.go b/site.go index 12b851a..a57c100 100644 --- a/site.go +++ b/site.go @@ -10,8 +10,8 @@ import ( "text/template" "time" - "launchpad.net/goamz/aws" - "launchpad.net/goamz/s3" + "gopkg.in/amz.v1/aws" + "gopkg.in/amz.v1/s3" ) var ( From 605e0ce6691b5f80fad68f275cb8a5e9e5803aa9 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 7 Jul 2015 11:53:01 -0700 Subject: [PATCH 5/7] Upgrade yaml lib used --- config.go | 6 +++--- page.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index e3ab4fa..fd4577c 100644 --- a/config.go +++ b/config.go @@ -3,7 +3,7 @@ package main import ( "io/ioutil" - "launchpad.net/goyaml" + "gopkg.in/yaml.v1" ) // Config represents the key-value pairs in a _config.yml file. @@ -44,7 +44,7 @@ func ParseConfig(path string) (Config, error) { func parseConfig(data []byte) (Config, error) { conf := map[string]interface{}{} - err := goyaml.Unmarshal(data, &conf) + err := yaml.Unmarshal(data, &conf) if err != nil { return nil, err } @@ -72,7 +72,7 @@ func ParseDeployConfig(path string) (*DeployConfig, error) { func parseDeployConfig(data []byte) (*DeployConfig, error) { conf := DeployConfig{} - err := goyaml.Unmarshal(data, &conf) + err := yaml.Unmarshal(data, &conf) if err != nil { return nil, err } diff --git a/page.go b/page.go index 815877a..e5b65dd 100644 --- a/page.go +++ b/page.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/russross/blackfriday" - "launchpad.net/goyaml" + "gopkg.in/yaml.v1" ) // A Page represents the key-value pairs in a page or posts front-end YAML as @@ -73,7 +73,7 @@ func parsePage(fn string, c []byte) (Page, error) { // Helper function to parse the front-end yaml matter. func parseMatter(content []byte) (Page, error) { page := map[string]interface{}{} - err := goyaml.Unmarshal(content, &page) + err := yaml.Unmarshal(content, &page) return page, err } From 8e96409b775facc5c5d5592aa9ab4cc1acf0564c Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 7 Jul 2015 11:53:10 -0700 Subject: [PATCH 6/7] Upgrade aws lib used --- site.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site.go b/site.go index a57c100..275da7a 100644 --- a/site.go +++ b/site.go @@ -10,8 +10,8 @@ import ( "text/template" "time" - "gopkg.in/amz.v1/aws" - "gopkg.in/amz.v1/s3" + "github.com/crowdmob/goamz/aws" + "github.com/crowdmob/goamz/s3" ) var ( @@ -121,9 +121,9 @@ func (s *Site) Deploy(user, pass, url string) error { // try to upload the file ... sometimes this fails due to amazon // issues. If so, we'll re-try - if err := b.Put(rel, content, typ, s3.PublicRead); err != nil { + if err := b.Put(rel, content, typ, s3.PublicRead, s3.Options{}); err != nil { time.Sleep(100 * time.Millisecond) // sleep so that we don't immediately retry - return b.Put(rel, content, typ, s3.PublicRead) + return b.Put(rel, content, typ, s3.PublicRead, s3.Options{}) } // file upload was a success, return nil From 77b417efd4fd508497b78921eaa5261056834277 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Fri, 20 Dec 2019 21:09:47 -0700 Subject: [PATCH 7/7] Add go.mod with known-good versions --- go.mod | 12 ++++++++++++ go.sum | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..623b206 --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/bazil/jkl + +go 1.13 + +require ( + github.com/crowdmob/goamz v0.0.0-20150128194925-3a06871fe9fc + github.com/howeyc/fsnotify v0.9.0 + github.com/kr/pretty v0.1.0 // indirect + github.com/russross/blackfriday v1.5.2 + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f33e15b --- /dev/null +++ b/go.sum @@ -0,0 +1,15 @@ +github.com/crowdmob/goamz v0.0.0-20150128194925-3a06871fe9fc h1:Gn/roShKxUNtNYEEH+ZeGxMJ+RsCBZdIdb8pKOesTaA= +github.com/crowdmob/goamz v0.0.0-20150128194925-3a06871fe9fc/go.mod h1:4zrXGiIhmCfgVUO6nJpSa9QVXylPKBYkLa179m59HzE= +github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY= +github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU= +gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=