fix tags not being in lowercase, #491 - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 4e9b04086afcb51103f339c4ad97136a7a10d6a6
 (DIR) parent 012a473e27aee4a8bd6e7e7923d697a6c6b4b82c
 (HTM) Author: Joel Scoble <joel.scoble@outlook.com>
       Date:   Tue,  9 Sep 2014 15:58:02 -0500
       
       fix tags not being in lowercase, #491
       
       Diffstat:
         M hugolib/page.go                     |      18 ++++++++++++++++--
         M hugolib/page_taxonomy_test.go       |      10 +++++-----
         M hugolib/page_test.go                |      24 ++++++++++++++++++++++--
       
       3 files changed, 43 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/hugolib/page.go b/hugolib/page.go
       @@ -431,7 +431,7 @@ func (page *Page) GetParam(key string) interface{} {
                case bool:
                        return cast.ToBool(v)
                case string:
       -                return cast.ToString(v)
       +                return strings.ToLower(cast.ToString(v))
                case int64, int32, int16, int8, int:
                        return cast.ToInt(v)
                case float64, float32:
       @@ -439,7 +439,7 @@ func (page *Page) GetParam(key string) interface{} {
                case time.Time:
                        return cast.ToTime(v)
                case []string:
       -                return v
       +                return sliceToLower(v.([]string))
                }
                return nil
        }
       @@ -795,3 +795,17 @@ func (p *Page) TargetPath() (outfile string) {
        
                return path.Join(p.Dir, strings.TrimSpace(outfile))
        }
       +
       +// sliceToLower goes through the source slice and lowers all values.
       +func sliceToLower(s []string) []string {
       +        if s == nil {
       +                return nil
       +        }
       +
       +        l  := make([]string, len(s))
       +        for i, v := range s {
       +                l[i] = strings.ToLower(v)
       +        }
       +
       +        return l
       +}
 (DIR) diff --git a/hugolib/page_taxonomy_test.go b/hugolib/page_taxonomy_test.go
       @@ -6,7 +6,7 @@ import (
        )
        
        var PAGE_YAML_WITH_TAXONOMIES_A = `---
       -tags: ['a', 'b', 'c']
       +tags: ['a', 'B', 'c']
        categories: 'd'
        ---
        YAML frontmatter with tags and categories taxonomy.`
       @@ -14,20 +14,20 @@ YAML frontmatter with tags and categories taxonomy.`
        var PAGE_YAML_WITH_TAXONOMIES_B = `---
        tags:
         - "a"
       - - "b"
       + - "B"
         - "c"
        categories: 'd'
        ---
        YAML frontmatter with tags and categories taxonomy.`
        
        var PAGE_YAML_WITH_TAXONOMIES_C = `---
       -tags: 'e'
       +tags: 'E'
        categories: 'd'
        ---
        YAML frontmatter with tags and categories taxonomy.`
        
        var PAGE_JSON_WITH_TAXONOMIES = `{
       -  "categories": "d",
       +  "categories": "D",
          "tags": [
            "a",
            "b",
       @@ -37,7 +37,7 @@ var PAGE_JSON_WITH_TAXONOMIES = `{
        JSON Front Matter with tags and categories`
        
        var PAGE_TOML_WITH_TAXONOMIES = `+++
       -tags = [ "a", "b", "c" ]
       +tags = [ "a", "B", "c" ]
        categories = "d"
        +++
        TOML Front Matter with tags and categories`
 (DIR) diff --git a/hugolib/page_test.go b/hugolib/page_test.go
       @@ -40,7 +40,7 @@ Leading
        {
        "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" ],
       +"tags": [ ".vimrc", "plugins", "spf13-vim", "VIm" ],
        "date": "2012-04-06",
        "categories": [
            "Development",
       @@ -55,7 +55,7 @@ Content of the file goes Here
        {
        "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" ]
       +"tags": [ ".vimrc", "plugins", "spf13-vim", "VIm" ]
        "date": "2012-04-06"
        "categories": [
            "Development"
       @@ -565,6 +565,26 @@ func TestLayoutOverride(t *testing.T) {
                }
        }
        
       +func TestSliceToLower(t *testing.T) {
       +        tests := []struct{
       +                value []string
       +                expected []string
       +        }{
       +                {[]string{"a","b","c"}, []string{"a", "b", "c"}},
       +                {[]string{"a","B","c"}, []string{"a", "b", "c"}},
       +                {[]string{"A","B","C"}, []string{"a", "b", "c"}},
       +        }
       +
       +        for _, test := range tests {
       +                res := sliceToLower(test.value)
       +                for i, val := range res {
       +                        if val != test.expected[i] {
       +                                t.Errorf("Case mismatch. Expected %s, got %s", test.expected[i], res[i])
       +                        }
       +                }
       +        }
       +}
       +
        func listEqual(left, right []string) bool {
                if len(left) != len(right) {
                        return false