ref: 18f2b82658b6f0ea82c867c2c4d40cf0772841d2
parent: 48e1068e3e7082615df462c1df186e6045f3ca45
author: spf13 <[email protected]>
date: Tue Oct 1 18:45:24 EDT 2013
Switching to the rjson library which is more friendly to human generated json.
--- a/commands/server.go
+++ b/commands/server.go
@@ -61,7 +61,7 @@
fmt.Println("Serving pages from " + Config.GetAbsPath(Config.PublishDir))
}
- fmt.Println("Web Server is available at http://localhost:", port)
+ fmt.Printf("Web Server is available at http://localhost:%v\n", port)
fmt.Println("Press ctrl+c to stop")
panic(http.ListenAndServe(":"+strconv.Itoa(port), http.FileServer(http.Dir(Config.GetAbsPath(Config.PublishDir)))))
}
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -15,7 +15,6 @@
import (
"bytes"
- "encoding/json"
"errors"
"fmt"
"github.com/BurntSushi/toml"
@@ -26,11 +25,12 @@
"html/template"
"io"
"launchpad.net/goyaml"
+ json "launchpad.net/rjson"
+ "net/url"
"path"
"sort"
"strings"
"time"
- "net/url"
)
type Page struct {
@@ -467,4 +467,3 @@
return path.Join(p.Dir, strings.TrimSpace(outfile))
}
-
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -51,6 +51,21 @@
Content of the file goes Here
`
+ SIMPLE_PAGE_JSON_LOOSE = `
+{
+"title": "spf13-vim 3.0 release and new website"
+"description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
+"tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ]
+"date": "2012-04-06"
+"categories": [
+ "Development"
+ "VIM"
+],
+"slug": "spf13-vim-3-0-release-and-new-website"
+}
+
+Content of the file goes Here
+`
SIMPLE_PAGE_RFC3339_DATE = "---\ntitle: RFC3339 Date\ndate: \"2013-05-17T16:59:30Z\"\n---\nrfc3339 content"
SIMPLE_PAGE_JSON_MULTIPLE = `
{
@@ -223,6 +238,7 @@
r string
}{
{SIMPLE_PAGE_JSON},
+ {SIMPLE_PAGE_JSON_LOOSE},
{SIMPLE_PAGE_JSON_MULTIPLE},
//{strings.NewReader(SIMPLE_PAGE_JSON_COMPACT)},
}
--- a/parser/parse_frontmatter_test.go
+++ b/parser/parse_frontmatter_test.go
@@ -29,6 +29,7 @@
CONTENT_SLUG_BUG = "---\ntitle: slug doc 2\nslug: slug-doc-2\n---\nslug doc 2 content"
CONTENT_FM_NO_DOC = "---\ntitle: no doc\n---"
CONTENT_WITH_JS_FM = "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories"
+ CONTENT_WITH_JS_LOOSE_FM = "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories"
)
var lineEndings = []string{"\n", "\r\n"}
@@ -113,6 +114,7 @@
{CONTENT_LWS_HTML, false, true, "", "<html><body></body></html>"},
{CONTENT_LWS_LF_HTML, false, true, "", "<html><body></body></html>"},
{CONTENT_WITH_JS_FM, true, false, "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}", "JSON Front Matter with tags and categories"},
+ {CONTENT_WITH_JS_LOOSE_FM, true, false, "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}", "JSON Front Matter with tags and categories"},
{CONTENT_SLUG_WORKING, true, false, "---\ntitle: slug doc 2\nslug: slug-doc-2\n\n---\n", "slug doc 2 content"},
{CONTENT_SLUG_WORKING_VARIATION, true, false, "---\ntitle: slug doc 3\nslug: slug-doc 3\n---\n", "slug doc 3 content"},
{CONTENT_SLUG_BUG, true, false, "---\ntitle: slug doc 2\nslug: slug-doc-2\n---\n", "slug doc 2 content"},
@@ -281,6 +283,7 @@
{"{ { } { } }", "{ { } { } }", noErrExpected},
{"{\n{\n}\n}\n", "{\n{\n}\n}", noErrExpected},
{"{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories", "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}", noErrExpected},
+ {"{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories", "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}", noErrExpected},
}
for _, test := range tests {