Move alias logic to target module

I want to move all logic to writing aliases to target so I can pave the
way for writing aliases specific to other runtimes (like .htaccess for
apache or a script for updating AWS or symlinking on a filesystem).
This commit is contained in:
Noah Campbell
2013-09-12 21:18:13 -07:00
parent 2f10da1570
commit 2ebfb33fe0
7 changed files with 76 additions and 47 deletions

View File

@@ -1,12 +0,0 @@
package bundle
import (
"testing"
)
func TestNothing(t *testing.T) {
b := NewTemplate()
if b.Lookup("alias") == nil {
t.Fatalf("Expecting alias to be initialized with new bundle")
}
}

View File

@@ -116,7 +116,6 @@ func NewTemplate() Template {
}
templates.Funcs(funcMap)
templates.primeTemplates()
return templates
}
@@ -145,14 +144,6 @@ func (t *GoHtmlTemplate) generateTemplateNameFrom(base, path string) string {
return filepath.ToSlash(path[len(base)+1:])
}
func (t *GoHtmlTemplate) primeTemplates() {
alias := "<!DOCTYPE html>\n <html>\n <head>\n <link rel=\"canonical\" href=\"{{ .Permalink }}\"/>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"refresh\" content=\"0;url={{ .Permalink }}\" />\n </head>\n </html>"
alias_xhtml := "<!DOCTYPE html>\n <html xmlns=\"http://www.w3.org/1999/xhtml\">\n <head>\n <link rel=\"canonical\" href=\"{{ .Permalink }}\"/>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"refresh\" content=\"0;url={{ .Permalink }}\" />\n </head>\n </html>"
t.AddTemplate("alias", alias)
t.AddTemplate("alias-xhtml", alias_xhtml)
}
func ignoreDotFile(path string) bool {
return filepath.Base(path)[0] == '.'
}