remove splitCapitalize

pull/144/head
Henrique Dias 2016-07-18 16:12:02 +01:00
parent 9a65508048
commit 5c7296322a
5 changed files with 5 additions and 79 deletions

View File

@ -197,7 +197,7 @@ func templatesEditorTmpl() (*asset, error) {
return a, nil
}
var _templatesFrontmatterTmpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x55\x4d\x6f\xdb\x30\x0c\xbd\xf7\x57\x08\x42\x0f\x1b\x30\x3b\x6e\xf7\x71\x28\x9c\x00\x43\x81\x62\x87\x6d\x1d\xb0\xfc\x01\xc5\xa6\x5b\xad\x8a\xed\xc9\x4c\xb1\xac\xe8\x7f\x1f\xf5\x65\xcb\x89\xb3\x65\x45\x6e\x32\x43\x91\x4f\x8f\xef\x31\x4f\x4f\xac\x84\x4a\xd6\xc0\xf8\x4a\x35\xc5\x43\xc7\xd9\xf3\xf3\x19\xa3\xb0\xac\x58\x7a\x23\x41\x95\x9d\x8d\xb0\xbc\x94\x8f\xac\x50\xa2\xeb\xe6\xfc\x4e\x37\x9b\x96\x2f\x28\x4a\x89\x50\x97\x2e\x83\xce\x5a\xd4\x77\xc0\xce\x1f\x60\xfb\x86\x9d\x3f\x0a\xb5\x01\x76\x35\x1f\xd7\xf1\xb5\xe1\xa7\x4f\x48\xbf\x09\x0d\x35\xa6\xcb\x6d\x4b\x20\x84\xd6\x62\xcb\x7d\xa6\xeb\x29\xcb\x39\xa7\x3b\x3e\xfb\xab\x58\x03\xfd\x9c\x98\x08\xb5\xa1\x23\x67\xa5\x40\x91\x20\xdd\x9f\xbb\xfb\x89\x44\x58\x5b\x78\xae\x1d\x7d\xb5\x4a\x20\x95\xb7\x35\x78\x80\xe6\xbb\x8c\x9e\x26\x0a\x94\x4d\x4d\xa4\x28\x40\xf0\xa5\xdd\xc7\x3f\x50\xf8\x76\x2c\x97\xa1\xd4\x9a\x5a\x6a\x29\x54\x22\x8b\xa6\xee\xf8\xa2\x50\x4d\x07\xf9\x4c\xfa\xcc\x7c\x46\x6d\xdd\x39\x3a\x1a\x42\x55\x07\x23\x06\x7c\x3d\x3b\x20\x6e\xf9\xb0\xc7\x64\x0f\x8f\xc7\x4b\xed\x90\x28\x9d\x00\x1c\x50\xe6\x4a\xac\x40\xb1\xaa\xd1\x93\x49\x14\xfa\xde\x2a\x89\xd7\xa2\x95\x28\x94\xfc\x0d\x21\x65\x29\x51\x99\x9c\x7c\x66\x2b\x9c\x9e\xe3\x43\x2f\x3b\x0d\xbd\x3b\x72\x8d\xcf\x7b\x7a\xf7\x97\x86\xb4\xb3\xbf\x28\xfc\xa3\xd1\x5d\xd7\x17\x1b\xd8\xa8\xa4\x19\x27\x8e\xf8\x38\xae\xe4\xed\xea\x07\x14\xf8\x82\x9a\xe3\x63\xb0\xb7\x1f\xcb\xe0\x6e\x72\x60\xfa\x69\xf9\xe5\xb3\x33\x1e\xc2\x2f\x24\x23\x0a\xef\xbd\x3c\x7c\x07\xb6\xbb\x42\x37\x4a\x71\x56\xd3\x3c\xac\x66\x06\xcd\x39\x83\xee\x68\xb0\xb5\xae\xf6\xae\x34\xe9\xb1\xcd\xbd\xc6\xd2\x6b\x27\xd4\xf4\x16\xef\x41\x5b\x55\x85\xb6\x61\xb7\x18\x2b\xec\x61\xa5\x06\x80\x72\x0d\x01\xab\xac\xdb\x0d\x1e\x46\x16\x05\x2c\x09\x2e\x36\xea\x9d\xde\x34\x9a\xf4\xc4\xf8\x65\x96\x7d\x48\xb2\x8b\x24\xbb\x5c\x5e\xbc\xbf\xca\xde\x71\x7b\xcd\xbd\x22\xb4\x4d\x48\xa2\x42\x1d\xfb\x4e\x52\xa4\x81\x17\x3f\xe8\x54\xa8\x23\x6c\xe6\xb7\x9e\xa0\xe3\x87\x30\x80\x1b\x44\x33\x2d\x9f\x5e\x73\x06\x7c\x5e\x59\xa3\x00\xee\x63\x8d\x76\xb1\x89\xf7\x9d\x7a\x93\xd5\x0d\xb2\x57\x66\x9e\x6e\x95\x70\xfe\xda\xef\x88\xfc\xfe\xed\xd4\xe2\x89\x56\x0e\x25\xec\xf8\x76\x62\xab\x88\xb2\x74\xcb\xe2\xf0\xa6\xa0\x14\xbf\x27\xfa\xcd\xf0\x1f\x7f\x01\xe3\x95\x74\xdc\x3e\xea\xfb\x8c\x7c\x1c\xfe\x71\xc3\x54\x1d\xb7\xb3\x40\xee\x22\x1a\xc5\x9f\x00\x00\x00\xff\xff\x81\xbc\x28\x25\xa8\x07\x00\x00")
var _templatesFrontmatterTmpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x55\xc9\x6e\xdb\x30\x10\xbd\xe7\x2b\x08\x22\x87\x16\xa8\x64\x25\x5d\x0e\x81\x6c\xa0\x28\x10\xf4\xd0\x36\x3d\xf8\x07\x68\x69\x94\xb0\xa1\x45\x95\x1c\x07\x35\x82\xfc\x7b\x87\x9b\x16\x2f\xad\x5b\xf8\x46\x8d\x87\x33\x8f\x6f\xde\x1b\x3f\x3f\xb3\x1a\x1a\xd9\x02\xe3\x2b\xa5\xab\x47\xcb\xd9\xcb\xcb\x05\xa3\xb0\x6c\x58\x7e\x2b\x41\xd5\xd6\x47\x58\x59\xcb\x27\x56\x29\x61\xed\x9c\xdf\x1b\xbd\xe9\xf8\x82\xa2\x94\x08\x6d\x1d\x32\xe8\x6c\x44\x7b\x0f\xec\xf2\x11\xb6\x6f\xd8\xe5\x93\x50\x1b\x60\x37\xf3\x69\x9d\x58\x1b\x7e\xc6\x84\xfc\xbb\x30\xd0\x62\xbe\xdc\x76\x04\x42\x18\x23\xb6\x3c\x66\x86\x9e\xb2\x9e\x73\xba\x13\xb3\xbf\x89\x35\xd0\xcf\x99\x8b\x50\x1b\x3a\x72\x56\x0b\x14\x19\xd2\xfd\x79\xb8\x9f\x49\x84\xb5\x87\x17\xda\xd1\x57\xa7\x04\x52\x79\x5f\x83\x27\x68\xb1\xcb\xe4\x69\xa2\x42\xa9\x5b\x22\x45\x01\x42\x2c\x1d\x3e\xfe\x82\x22\xb6\x63\xa5\x4c\xa5\xd6\xd4\xd2\x48\xa1\x32\x59\xe9\xd6\xf2\x45\xa5\xb4\x85\x72\x26\x63\x66\x39\xa3\xb6\xe1\x3c\x3a\x3a\x42\x95\x85\x09\x03\xb1\x9e\x1f\x10\xf7\x7c\xf8\x63\xb6\x87\x27\xe2\xa5\x76\x48\x94\x1e\x00\x9c\x50\x96\x4a\xac\x40\xb1\x46\x9b\x83\x49\x43\x68\x29\x51\xb9\x58\x39\xf3\x37\xce\xcf\xe9\xb1\x97\x9c\x87\xce\x1d\x79\x8e\xcf\x7b\xfa\x8e\x97\x86\xb4\x8b\x3f\x28\xfa\xa3\xd3\x99\xed\x8b\x0d\x6c\x34\xd2\x8d\x0f\x27\x7c\x9c\x56\xf2\x6e\xf5\x03\x2a\xfc\x8f\x9a\xd3\x63\xb2\x73\x1c\xcb\xe0\x66\x72\x5c\xfe\x79\xf9\xf5\x4b\x30\x1a\xc2\x2f\x24\xe3\x89\xe8\xb5\x32\x7d\x27\xb6\x6d\x65\xb4\x52\x9c\xb5\x34\x0f\xaf\x91\x41\x63\xc1\x90\x3b\x9a\xeb\xbc\x8b\xa3\x0b\x5d\xfa\xd8\xd6\x51\x53\xf9\xa7\x20\xcc\xfc\x0e\x1f\xc0\x78\x55\xa5\xb6\x69\x97\x38\xe9\xef\x61\xa5\x06\x80\x72\x0d\x09\xab\x6c\xbb\x0d\x1e\x47\x36\x0a\x78\x12\x42\x6c\xd2\x3b\xbf\xd5\x86\xf4\xc4\xf8\x75\x51\x7c\xc8\x8a\xab\xac\xb8\x5e\x5e\xbd\xbf\x29\xde\x71\x7f\x2d\xbc\x22\xb5\xcd\x48\xa2\x42\x9d\xfa\x4e\x52\xa4\x83\x37\x7e\xd0\xb9\x50\x8f\xb0\xb9\xdf\x7a\x82\x4e\x1f\xc2\x00\x6e\x10\xcd\x61\xf9\xf4\x9a\x73\xe0\xcb\xc6\x1b\x05\x70\x1f\xeb\x68\xf7\xba\x78\xdf\xa9\x37\x59\xab\x91\xbd\x72\xf3\x0c\xab\x84\xf3\xd7\x71\x47\x94\x0f\x6f\xbd\x28\x86\x15\x43\x81\x1d\x9f\x1e\xd8\x22\xa2\xae\xc3\x72\x38\xbe\x19\x28\x25\xee\x85\x7e\x13\xfc\xc3\x8a\x9f\xae\xa0\xd3\xf6\x4f\xdf\x67\xe2\xdb\xf4\x8f\x9a\xa6\x18\xb8\x9c\x25\x32\x17\x23\xea\x7f\x07\x00\x00\xff\xff\x2d\xb7\x5d\x4e\x88\x07\x00\x00")
func templatesFrontmatterTmplBytes() ([]byte, error) {
return bindataRead(
@ -212,7 +212,7 @@ func templatesFrontmatterTmpl() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "templates/frontmatter.tmpl", size: 1960, mode: os.FileMode(438), modTime: time.Unix(1467126307, 0)}
info := bindataFileInfo{name: "templates/frontmatter.tmpl", size: 1928, mode: os.FileMode(438), modTime: time.Unix(1468854685, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}

View File

@ -12,7 +12,7 @@
</div>
{{ else }}
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
<label for="{{ $value.Name }}">{{ $value.Title }}</label>
{{ template "value" $value }}
<div class="action delete" data-delete="block-{{ $value.Name }}">
<i class="material-icons">close</i>
@ -47,7 +47,7 @@
{{ define "fielset" }}
<fieldset id="{{ .Name }}" data-type="{{ .Type }}">
{{ if not (eq .Title "") }}
<h3>{{ SplitCapitalize .Title }}</h3>
<h3>{{ .Title }}</h3>
{{ end }}
<div class="action add">
<i class="material-icons">add</i>

View File

@ -75,8 +75,7 @@ func (p Page) PrintAsHTML(w http.ResponseWriter, templates ...string) (int, erro
// Create the functions map, then the template, check for erros and
// execute the template if there aren't errors
functions := template.FuncMap{
"SplitCapitalize": variables.SplitCapitalize,
"Defined": variables.Defined,
"Defined": variables.Defined,
}
if p.Minimal {

View File

@ -1,42 +0,0 @@
package variables
import (
"strings"
"unicode"
)
var splitCapitalizeExceptions = map[string]string{
"youtube": "YouTube",
"github": "GitHub",
"googleplus": "Google Plus",
"linkedin": "LinkedIn",
}
// SplitCapitalize splits a string by its uppercase letters and capitalize the
// first letter of the string
func SplitCapitalize(name string) string {
if val, ok := splitCapitalizeExceptions[strings.ToLower(name)]; ok {
return val
}
var words []string
l := 0
for s := name; s != ""; s = s[l:] {
l = strings.IndexFunc(s[1:], unicode.IsUpper) + 1
if l <= 0 {
l = len(s)
}
words = append(words, s[:l])
}
name = ""
for _, element := range words {
name += element + " "
}
name = strings.ToLower(name[:len(name)-1])
name = strings.ToUpper(string(name[0])) + name[1:]
return name
}

View File

@ -1,31 +0,0 @@
package variables
import "testing"
type testSplitCapitalize struct {
name string
result string
}
var testSplitCapitalizeCases = []testSplitCapitalize{
{"loremIpsum", "Lorem ipsum"},
{"LoremIpsum", "Lorem ipsum"},
{"loremipsum", "Loremipsum"},
{"YouTube", "YouTube"},
{"GitHub", "GitHub"},
{"GooglePlus", "Google Plus"},
{"Facebook", "Facebook"},
}
func TestSplitCapitalize(t *testing.T) {
for _, pair := range testSplitCapitalizeCases {
v := SplitCapitalize(pair.name)
if v != pair.result {
t.Error(
"For", pair.name,
"expected", pair.result,
"got", v,
)
}
}
}