Skip to content

Commit

Permalink
Merge pull request #2 from tychoish/yaml-rst-support
Browse files Browse the repository at this point in the history
Switching to YAML and adding support for optional restructured text parsing
  • Loading branch information
spf13 committed Jul 8, 2013
2 parents 4d2fbfc + d0ff312 commit 94e5777
Show file tree
Hide file tree
Showing 22 changed files with 201 additions and 170 deletions.
4 changes: 0 additions & 4 deletions docs/config.json

This file was deleted.

4 changes: 4 additions & 0 deletions docs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Indexes:
tag: 'tags'
BaseUrl: 'http://localhost'
...
28 changes: 15 additions & 13 deletions docs/content/doc/configuration.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"title": "Configuring Hugo",
"Pubdate": "2013-07-01"
}
---
title: "Configuring Hugo"
pubdate: "2013-07-01"
...

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
since the defaults used follow commonly used patterns.

The following is an example of a config file with the default values
The following is an example of a config file with the default values:

SourceDir: "content"
LayoutDir: "layouts"
PublishDir: "public"
BuildDrafts: false
Tags:
category: "categories"
tag: "tags"
BaseUrl: "http://yourSite.com/"
...

{
"SourceDir" : "content",
"LayoutDir" : "layouts",
"PublishDir" : "public",
"BuildDrafts" : false,
"Tags" : { "category" : "categories", "tag" : "tags" },
"BaseUrl" : "http://yourSite.com/"
}
8 changes: 4 additions & 4 deletions docs/content/doc/contributing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Contributing to Hugo",
"Pubdate": "2013-07-01"
}
---
title: "Contributing to Hugo"
Pubdate: "2013-07-01"
...

1. Fork it from https://github.com/spf13/hugo
2. Create your feature branch (`git checkout -b my-new-feature`)
Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/contributors.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Contributors",
"Pubdate": "2013-07-01"
}
---
title: "Contributors"
Pubdate: "2013-07-01"
...

Hugo was built with love and golang by:

Expand Down
28 changes: 14 additions & 14 deletions docs/content/doc/example.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"title": "Example Content File",
"Pubdate": "2013-07-01"
}
---
title: "Example Content File"
Pubdate: "2013-07-01"
...

Somethings are better shown than explained. The following is a very basic example of a content file:

**mysite/project/nitro.md <- http://mysite.com/project/nitro.html**

{
"Title": "Nitro : A quick and simple profiler for golang",
"Description": "",
"Keywords": [ "Development", "golang", "profiling" ],
"Tags": [ "Development", "golang", "profiling" ],
"Pubdate": "2013-06-19",
"Topics": [ "Development", "GoLang" ],
"Slug": "nitro",
"project_url": "http://github.com/spf13/nitro"
}
---
Title: "Nitro : A quick and simple profiler for golang"
Description": ""
Keywords": [ "Development", "golang", "profiling" ]
Tags": [ "Development", "golang", "profiling" ]
Pubdate": "2013-06-19"
Topics": [ "Development", "GoLang" ]
Slug": "nitro"
project_url": "http://github.com/spf13/nitro"
...

# Nitro

Expand Down
33 changes: 19 additions & 14 deletions docs/content/doc/front-matter.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
{
"title": "Front Matter",
"Pubdate": "2013-07-01"
}
---
title: "Front Matter"
Pubdate: "2013-07-01"
...

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
different formats. The main format supported is JSON. Here is an example:

{
"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" ],
"Pubdate": "2012-04-06",
"Categories": [ "Development", "VIM" ],
"Slug": "spf13-vim-3-0-release-and-new-website"
}
different formats. The main format supported is YAML. Here is an example:

---
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" ]
Pubdate: "2012-04-06"
Categories:
- "Development"
- "VIM"
Slug: "spf13-vim-3-0-release-and-new-website"
...

### Variables

There are a few predefined variables that Hugo is aware of and utilizes. The user can also create
any variable they want to. These will be placed into the `.Params` variable available to the templates.

Expand All @@ -31,6 +34,8 @@ any variable they want to. These will be placed into the `.Params` variable avai

**Draft** If true the content will not be rendered unless `hugo` is called with -d<br>
**Type** The type of the content (will be derived from the directory automatically if unset).<br>
**Markup** (Experimental) Specify "rst" for reStructuredText (requires
`rst2html`,) or "md" (default) for the Markdown.<br>
**Slug** The token to appear in the tail of the url.<br>
*or*<br>
**Url** The full path to the content from the web root.<br>
Expand Down
9 changes: 5 additions & 4 deletions docs/content/doc/installing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"title": "Installing Hugo",
"Pubdate": "2013-07-01"
}
---
title: "Installing Hugo"
Pubdate: "2013-07-01"
...

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).
Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/license.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "License",
"Pubdate": "2013-07-01"
}
---
title: "License"
Pubdate: "2013-07-01"
...

Hugo is released under the Simple Public License.

Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/organization.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Organization",
"Pubdate": "2013-07-01"
}
---
title: "Organization"
Pubdate: "2013-07-01"
...

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
Expand Down
9 changes: 4 additions & 5 deletions docs/content/doc/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"title": "Release Notes",
"Pubdate": "2013-07-01"

}
---
title: "Release Notes"
Pubdate: "2013-07-01"
...

* **0.7.0** July 4, 2013
* Hugo now includes a simple server
Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/roadmap.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Roadmap",
"Pubdate": "2013-07-01"
}
---
title: "Roadmap"
Pubdate: "2013-07-01"
...

In no particular order, here is what I'm working on:

Expand Down
14 changes: 14 additions & 0 deletions docs/content/doc/rst.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
Markup: 'rst'
...


==============
This is a Test
==============


Really
------

text *here* and **HERE**.
8 changes: 4 additions & 4 deletions docs/content/doc/shortcodes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Shortcodes",
"Pubdate": "2013-07-01"
}
---
title: "Shortcodes"
Pubdate: "2013-07-01"
...

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.
Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/source-directory.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Source Directory Organization",
"Pubdate": "2013-07-01"
}
---
title: "Source Directory Organization"
Pubdate: "2013-07-01"
...

Hugo takes a single directory and uses it as the input for creating a complete website.

Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/templates.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Templates",
"Pubdate": "2013-07-01"
}
---
title: "Templates"
Pubdate: "2013-07-01"
...

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
Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/usage.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Using Hugo",
"Pubdate": "2013-07-01"
}
---
title: "Using Hugo"
Pubdate: "2013-07-01"
...

Make sure either hugo is in your path or provide a path to it.

Expand Down
8 changes: 4 additions & 4 deletions docs/content/doc/variables.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Variables",
"Pubdate": "2013-07-01"
}
---
title: "Variables"
Pubdate: "2013-07-01"
...

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.
Expand Down
4 changes: 2 additions & 2 deletions hugolib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package hugolib

import (
"encoding/json"
"launchpad.net/goyaml"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -55,7 +55,7 @@ func SetupConfig(cfgfile *string, path *string) *Config {

file, err := ioutil.ReadFile(configPath)
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)
os.Exit(1)
}
Expand Down
4 changes: 2 additions & 2 deletions hugolib/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func interfaceToBool(i interface{}) bool {
case bool:
return b
default:
Error("Only Boolean values are supported for this JSON key")
Error("Only Boolean values are supported for this YAML key")
}

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

return ""
Expand Down
Loading

0 comments on commit 94e5777

Please sign in to comment.