jsonresume/themes/kendall/kendall.go

71 lines
2.2 KiB
Go
Raw Normal View History

2018-05-07 00:58:03 +02:00
/*
* Copyright (c) 2018 Arnaud Ysmal. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package kendall
import (
2018-05-10 17:23:38 +02:00
"jsonresume/model"
2018-05-07 00:58:03 +02:00
"jsonresume/themes"
2018-05-07 22:24:43 +02:00
"path"
2018-05-07 00:58:03 +02:00
"text/template"
)
2018-05-07 22:24:43 +02:00
const (
packageDirectory = "themes/kendall"
fileCSS = "style.css"
fileCSSPrint = "print.css"
fileTemplate = "resume.template"
)
2018-05-07 00:58:03 +02:00
var Theme = themes.Theme{
2018-05-07 22:24:43 +02:00
Name: "kendall",
Directory: packageDirectory,
2018-05-07 00:58:03 +02:00
Functions: template.FuncMap{
2018-05-09 23:30:40 +02:00
"css": getCSS,
"printcss": getPrintCSS,
2018-05-10 17:23:38 +02:00
"md2html": md2html,
2018-05-07 00:58:03 +02:00
},
}
func init() {
2018-05-09 23:30:40 +02:00
t, _ := Asset(path.Join(packageDirectory, fileTemplate))
Theme.Template = string(t)
2018-05-07 00:58:03 +02:00
(&Theme).Register()
}
2018-05-09 23:30:40 +02:00
2018-05-07 22:24:43 +02:00
func getCSS() string {
2018-05-09 23:30:40 +02:00
r, _ := Asset(path.Join(packageDirectory, fileCSS))
2018-05-07 22:24:43 +02:00
return string(r)
}
func getPrintCSS() string {
2018-05-09 23:30:40 +02:00
r, _ := Asset(path.Join(packageDirectory, fileCSSPrint))
2018-05-07 22:24:43 +02:00
return string(r)
}
2018-05-10 17:23:38 +02:00
func md2html(s string) string {
return model.MarkdownURLRegexp.ReplaceAllString(s, `<a href="$2" target="_blank">$1</a>`)
}