copy other files
This commit is contained in:
@@ -8,3 +8,6 @@ Assets:
|
|||||||
FixTemplate: # change path in html templates, no <base> used
|
FixTemplate: # change path in html templates, no <base> used
|
||||||
Find: "\\.\\./assets/"
|
Find: "\\.\\./assets/"
|
||||||
Replace: ""
|
Replace: ""
|
||||||
|
|
||||||
|
OtherFiles:
|
||||||
|
Action: "copy"
|
||||||
@@ -3,17 +3,7 @@ Meta:
|
|||||||
Title: Leistungen und Referenzen
|
Title: Leistungen und Referenzen
|
||||||
|
|
||||||
Data:
|
Data:
|
||||||
von: 2018-12-24
|
bild: bild.jpg
|
||||||
bis: 2019-01-01
|
|
||||||
bild: /media/bild.jpg
|
|
||||||
|
|
||||||
gallerie:
|
|
||||||
- media/bild1.jpg
|
|
||||||
- media/bild2.jpg
|
|
||||||
|
|
||||||
formular:
|
|
||||||
- feld: vorname
|
|
||||||
typ: text
|
|
||||||
|
|
||||||
Template: mitBild.html
|
Template: mitBild.html
|
||||||
|
|
||||||
|
|||||||
BIN
example/content/de/main/02_Leistungen_und_Referenzen/bild.jpg
Normal file
BIN
example/content/de/main/02_Leistungen_und_Referenzen/bild.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -4,11 +4,13 @@
|
|||||||
{{> header.html }}
|
{{> header.html }}
|
||||||
|
|
||||||
<div style="padding: 20px;">
|
<div style="padding: 20px;">
|
||||||
|
|
||||||
|
{{#if Data.bild }}
|
||||||
|
<img src="{{ Data.bild }}" style="float: right; margin-left: 20px; margin-bottom: 20px">
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{{ Body }}}
|
{{{ Body }}}
|
||||||
|
|
||||||
<pre>
|
|
||||||
Daten: {{ Data.von }} - {{ Data.bis }} / {{ Data.bild }}
|
|
||||||
</pre>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{> footer.html }}
|
{{> footer.html }}
|
||||||
|
|||||||
45
main.go
45
main.go
@@ -40,6 +40,10 @@ type GlobalConfig struct {
|
|||||||
Replace string `yaml:"Replace"`
|
Replace string `yaml:"Replace"`
|
||||||
} `yaml:"FixTemplate"`
|
} `yaml:"FixTemplate"`
|
||||||
} `yaml:"Assets"`
|
} `yaml:"Assets"`
|
||||||
|
|
||||||
|
OtherFiles struct {
|
||||||
|
Action string `yaml:"Action"`
|
||||||
|
} `yaml:"OtherFiles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var globalConfig = new(GlobalConfig)
|
var globalConfig = new(GlobalConfig)
|
||||||
@@ -84,6 +88,7 @@ type PathConfigTree struct {
|
|||||||
OutputPath string
|
OutputPath string
|
||||||
|
|
||||||
InputFiles []string
|
InputFiles []string
|
||||||
|
OtherFiles []string
|
||||||
|
|
||||||
Config *PathConfig
|
Config *PathConfig
|
||||||
Sub []*PathConfigTree
|
Sub []*PathConfigTree
|
||||||
@@ -144,7 +149,7 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig,
|
|||||||
inPath += "/" + dir
|
inPath += "/" + dir
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Noticef("reading input directory: %s", inPath)
|
log.Infof("reading input directory: %s", inPath)
|
||||||
|
|
||||||
files, err := ioutil.ReadDir(inPath)
|
files, err := ioutil.ReadDir(inPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -196,7 +201,7 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig,
|
|||||||
outPath := outBase + "/" + stripedDir
|
outPath := outBase + "/" + stripedDir
|
||||||
outPath = path.Clean(outPath)
|
outPath = path.Clean(outPath)
|
||||||
|
|
||||||
log.Noticef("calculated output directory: %s", outPath)
|
log.Infof("calculated output directory: %s", outPath)
|
||||||
tree.OutputPath = outPath
|
tree.OutputPath = outPath
|
||||||
|
|
||||||
if tree.Config.This.Navname == nil {
|
if tree.Config.This.Navname == nil {
|
||||||
@@ -207,12 +212,22 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig,
|
|||||||
// first only files
|
// first only files
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
p := inPath + "/" + f.Name()
|
p := inPath + "/" + f.Name()
|
||||||
if strings.HasSuffix(f.Name(), ".md") {
|
if !f.IsDir() {
|
||||||
|
switch path.Ext(f.Name()) {
|
||||||
|
case ".md":
|
||||||
log.Debugf(".MD %s", p)
|
log.Debugf(".MD %s", p)
|
||||||
if tree.InputFiles == nil {
|
if tree.InputFiles == nil {
|
||||||
tree.InputFiles = make([]string, 0)
|
tree.InputFiles = make([]string, 0)
|
||||||
}
|
}
|
||||||
tree.InputFiles = append(tree.InputFiles, f.Name())
|
tree.InputFiles = append(tree.InputFiles, f.Name())
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
log.Debugf("FIL %s", p)
|
||||||
|
if tree.OtherFiles == nil {
|
||||||
|
tree.OtherFiles = make([]string, 0)
|
||||||
|
}
|
||||||
|
tree.OtherFiles = append(tree.OtherFiles, f.Name())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +327,7 @@ func processContent(conf *PathConfigTree) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("could not read '%s':%s", inFile, err)
|
log.Panicf("could not read '%s':%s", inFile, err)
|
||||||
}
|
}
|
||||||
log.Noticef("processing input file '%s'", inFile)
|
log.Infof("processing input file '%s'", inFile)
|
||||||
|
|
||||||
newConfig := new(PathConfig)
|
newConfig := new(PathConfig)
|
||||||
|
|
||||||
@@ -346,7 +361,7 @@ func processContent(conf *PathConfigTree) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ignoreFile {
|
if ignoreFile {
|
||||||
log.Noticef("ignoring file '%s', because of filename.ignore", inFile)
|
log.Infof("ignoring file '%s', because of filename.ignore", inFile)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// build output filename
|
// build output filename
|
||||||
@@ -433,6 +448,20 @@ func processContent(conf *PathConfigTree) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process other files, copy...
|
||||||
|
for _, file := range conf.OtherFiles {
|
||||||
|
switch globalConfig.OtherFiles.Action {
|
||||||
|
case "copy":
|
||||||
|
from := conf.InputPath + "/" + file
|
||||||
|
to := conf.OutputPath + "/" + file
|
||||||
|
log.Noticef("copying file from '%s' to '%s'", from, to)
|
||||||
|
err := cpy.Copy(from, to)
|
||||||
|
if err != nil {
|
||||||
|
log.Panicf("could not copy file from '%s' to '%s': %s", from, to, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, el := range conf.Sub {
|
for _, el := range conf.Sub {
|
||||||
processContent(el)
|
processContent(el)
|
||||||
}
|
}
|
||||||
@@ -503,12 +532,12 @@ func main() {
|
|||||||
if inDir == nil || *inDir == "" {
|
if inDir == nil || *inDir == "" {
|
||||||
log.Panic("input directory not specified")
|
log.Panic("input directory not specified")
|
||||||
}
|
}
|
||||||
log.Noticef("input directory: %s", *inDir)
|
log.Infof("input directory: %s", *inDir)
|
||||||
|
|
||||||
if outDir == nil || *outDir == "" {
|
if outDir == nil || *outDir == "" {
|
||||||
log.Panic("output directory not specified")
|
log.Panic("output directory not specified")
|
||||||
}
|
}
|
||||||
log.Noticef("output directory: %s", *outDir)
|
log.Infof("output directory: %s", *outDir)
|
||||||
|
|
||||||
if createOutDir != nil && *createOutDir {
|
if createOutDir != nil && *createOutDir {
|
||||||
if _, err := os.Stat(*outDir); os.IsNotExist(err) {
|
if _, err := os.Stat(*outDir); os.IsNotExist(err) {
|
||||||
@@ -581,7 +610,7 @@ func main() {
|
|||||||
for _, f := range entries {
|
for _, f := range entries {
|
||||||
if !f.IsDir() {
|
if !f.IsDir() {
|
||||||
pFile := partialsPath + "/" + f.Name()
|
pFile := partialsPath + "/" + f.Name()
|
||||||
log.Noticef("registering partial: %s", pFile)
|
log.Infof("registering partial: %s", pFile)
|
||||||
pContent, err := ioutil.ReadFile(pFile)
|
pContent, err := ioutil.ReadFile(pFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("could not read partial '%s': %s", pFile, err)
|
log.Panicf("could not read partial '%s': %s", pFile, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user