sanity: move from json to yaml

This commit is contained in:
tycho garen 2013-07-06 19:36:30 -04:00
parent f875577197
commit a7f5f97bc2
21 changed files with 82 additions and 82 deletions

View file

@ -1,4 +0,0 @@
{
"Indexes" : {"tag": "tags"},
"BaseUrl" : "http://localhost"
}

4
docs/config.yaml Normal file
View file

@ -0,0 +1,4 @@
Indexes:
tag: 'tags'
BaseUrl: 'http://localhost'
...

View file

@ -1,7 +1,7 @@
{ ---
"title": "Configuring Hugo", title: "Configuring Hugo"
"Pubdate": "2013-07-01" pubdate: "2013-07-01"
} ...
The directory structure and templates provide the majority of the The directory structure and templates provide the majority of the
configuration for a site. In fact a config file isn't even needed for many websites configuration for a site. In fact a config file isn't even needed for many websites

View file

@ -1,7 +1,7 @@
{ ---
"title": "Contributing to Hugo", title: "Contributing to Hugo"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
1. Fork it from https://github.com/spf13/hugo 1. Fork it from https://github.com/spf13/hugo
2. Create your feature branch (`git checkout -b my-new-feature`) 2. Create your feature branch (`git checkout -b my-new-feature`)

View file

@ -1,7 +1,7 @@
{ ---
"title": "Contributors", title: "Contributors"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo was built with love and golang by: Hugo was built with love and golang by:

View file

@ -1,7 +1,7 @@
{ ---
"title": "Example Content File", title: "Example Content File"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Somethings are better shown than explained. The following is a very basic example of a content file: Somethings are better shown than explained. The following is a very basic example of a content file:

View file

@ -1,7 +1,7 @@
{ ---
"title": "Front Matter", title: "Front Matter"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
The front matter is one of the features that gives Hugo it's strength. It enables The front matter is one of the features that gives Hugo it's strength. It enables
you to include the meta data of the content right with it. Hugo supports a few you to include the meta data of the content right with it. Hugo supports a few

View file

@ -1,7 +1,8 @@
{ ---
"title": "Installing Hugo", title: "Installing Hugo"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo is written in GoLang with support for Windows, Linux, FreeBSD and OSX. Hugo is written in GoLang with support for Windows, Linux, FreeBSD and OSX.
The latest release can be found at [hugo releases](https://github.com/spf13/hugo/releases). The latest release can be found at [hugo releases](https://github.com/spf13/hugo/releases).

View file

@ -1,7 +1,7 @@
{ ---
"title": "License", title: "License"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo is released under the Simple Public License. Hugo is released under the Simple Public License.

View file

@ -1,7 +1,7 @@
{ ---
"title": "Organization", title: "Organization"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo uses markdown files with headers commonly called the front matter. Hugo respects the organization Hugo uses markdown files with headers commonly called the front matter. Hugo respects the organization
that you provide for your content to minimize any extra configuration, though this can be overridden that you provide for your content to minimize any extra configuration, though this can be overridden

View file

@ -1,8 +1,7 @@
{ ---
"title": "Release Notes", title: "Release Notes"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
...
}
* **0.7.0** July 4, 2013 * **0.7.0** July 4, 2013
* Hugo now includes a simple server * Hugo now includes a simple server

View file

@ -1,7 +1,7 @@
{ ---
"title": "Roadmap", title: "Roadmap"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
In no particular order, here is what I'm working on: In no particular order, here is what I'm working on:

View file

@ -1,7 +1,7 @@
{ ---
"title": "Shortcodes", title: "Shortcodes"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Because Hugo uses markdown for it's content format, it was clear that there's a lot of things that Because Hugo uses markdown for it's content format, it was clear that there's a lot of things that
markdown doesn't support well. This is good, the simple nature of markdown is exactly why we chose it. markdown doesn't support well. This is good, the simple nature of markdown is exactly why we chose it.

View file

@ -1,7 +1,7 @@
{ ---
"title": "Source Directory Organization", title: "Source Directory Organization"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo takes a single directory and uses it as the input for creating a complete website. Hugo takes a single directory and uses it as the input for creating a complete website.

View file

@ -1,7 +1,7 @@
{ ---
"title": "Templates", title: "Templates"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo uses the excellent golang html/template library for it's template engine. It is an extremely Hugo uses the excellent golang html/template library for it's template engine. It is an extremely
lightweight engine that provides a very small amount of logic. In our lightweight engine that provides a very small amount of logic. In our

View file

@ -1,7 +1,7 @@
{ ---
"title": "Using Hugo", title: "Using Hugo"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Make sure either hugo is in your path or provide a path to it. Make sure either hugo is in your path or provide a path to it.

View file

@ -1,7 +1,7 @@
{ ---
"title": "Variables", title: "Variables"
"Pubdate": "2013-07-01" Pubdate: "2013-07-01"
} ...
Hugo makes a set of values available to the templates. Go templates are context based. The following Hugo makes a set of values available to the templates. Go templates are context based. The following
are available in the context for the templates. are available in the context for the templates.

View file

@ -14,7 +14,7 @@
package hugolib package hugolib
import ( import (
"encoding/json" "launchpad.net/goyaml"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -55,7 +55,7 @@ func SetupConfig(cfgfile *string, path *string) *Config {
file, err := ioutil.ReadFile(configPath) file, err := ioutil.ReadFile(configPath)
if err == nil { if err == nil {
if err := json.Unmarshal(file, &c); err != nil { if err := goyaml.Unmarshal(file, &c); err != nil {
fmt.Printf("Error parsing config: %s", err) fmt.Printf("Error parsing config: %s", err)
os.Exit(1) os.Exit(1)
} }

View file

@ -81,7 +81,7 @@ func interfaceToBool(i interface{}) bool {
case bool: case bool:
return b return b
default: default:
Error("Only Boolean values are supported for this JSON key") Error("Only Boolean values are supported for this YAML key")
} }
return false return false
@ -106,7 +106,7 @@ func interfaceToString(i interface{}) string {
case string: case string:
return s return s
default: default:
Error("Only Strings are supported for this JSON key") Error("Only Strings are supported for this YAML key")
} }
return "" return ""

View file

@ -15,7 +15,7 @@ package hugolib
import ( import (
"bytes" "bytes"
"encoding/json" "launchpad.net/goyaml"
"fmt" "fmt"
"github.com/theplant/blackfriday" "github.com/theplant/blackfriday"
"html/template" "html/template"
@ -141,23 +141,23 @@ func (p *Page) analyzePage() {
} }
// TODO //rewrite to use byte methods instead // TODO //rewrite to use byte methods instead
func (page *Page) parseJsonMetaData(data []byte) ([]string, error) { func (page *Page) parseYamlMetaData(data []byte) ([]string, error) {
var err error var err error
lines := strings.Split(string(data), "\n") lines := strings.Split(string(data), "\n")
datum := lines[0:] datum := lines[0:]
// go through content parse between "{" and "}" // go through content parse between "---" and "..."
// must be on their own lines (for now) // must be on their own lines (for now)
var found = 0 var found = 0
for i, line := range lines { for i, line := range lines {
line = strings.TrimSpace(line) line = strings.TrimSpace(line)
if line == "{" { if line == "---" {
found += 1 found += 1
} }
if line == "}" { if line == "..." {
found -= 1 found -= 1
} }
@ -168,7 +168,7 @@ func (page *Page) parseJsonMetaData(data []byte) ([]string, error) {
} }
} }
err = page.handleJsonMetaData([]byte(strings.Join(datum, "\n"))) err = page.handleYamlMetaData([]byte(strings.Join(datum, "\n")))
return lines, err return lines, err
} }
@ -185,10 +185,10 @@ func (p *Page) Permalink() template.HTML {
} }
} }
func (page *Page) handleJsonMetaData(datum []byte) error { func (page *Page) handleYamlMetaData(datum []byte) error {
var f interface{} var f interface{}
if err := json.Unmarshal(datum, &f); err != nil { if err := goyaml.Unmarshal(datum, &f); err != nil {
return fmt.Errorf("Invalide JSON in $v \nError parsing page meta data: %s", page.FileName, err) return fmt.Errorf("Invalide YAML in $v \nError parsing page meta data: %s", page.FileName, err)
} }
m := f.(map[string]interface{}) m := f.(map[string]interface{})
@ -309,7 +309,7 @@ func (page *Page) parseFileHeading(data []byte) ([]string, error) {
if data[0] == '-' { if data[0] == '-' {
return page.parseFileMetaData(data) return page.parseFileMetaData(data)
} }
return page.parseJsonMetaData(data) return page.parseYamlMetaData(data)
} }
return nil, nil return nil, nil
} }

View file

@ -17,7 +17,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"github.com/howeyc/fsnotify" "github.com/howeyc/fsnotify"
"github.com/spf13/hugo/hugolib" "./hugolib"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -26,12 +26,12 @@ import (
) )
const ( const (
cfgFiledefault = "config.json" cfgFiledefault = "config.yaml"
) )
var ( var (
baseUrl = flag.String("b", "", "hostname (and path) to the root eg. http://spf13.com/") baseUrl = flag.String("b", "", "hostname (and path) to the root eg. http://spf13.com/")
cfgfile = flag.String("c", cfgFiledefault, "config file (default is path/config.json)") cfgfile = flag.String("c", cfgFiledefault, "config file (default is path/config.yaml)")
checkMode = flag.Bool("k", false, "analyze content and provide feedback") checkMode = flag.Bool("k", false, "analyze content and provide feedback")
draft = flag.Bool("d", false, "include content marked as draft") draft = flag.Bool("d", false, "include content marked as draft")
help = flag.Bool("h", false, "show this help") help = flag.Bool("h", false, "show this help")