mark2web/context/path.go
Sebastian Frank b2e0d78a2c
Some checks failed
continuous-integration/drone/push Build is failing
reorganized code
2019-03-18 13:34:52 +01:00

40 lines
1.1 KiB
Go

package context
import (
"path"
"strings"
"gitbase.de/apairon/mark2web/config"
"gitbase.de/apairon/mark2web/helper"
)
// ResolveNavPath fixes nav target relative to current navigation path
func ResolveNavPath(target string) string {
curNavPath := (*CurrentContext)["CurrentPath"].(string)
if strings.HasPrefix(target, "/") {
target = helper.BackToRoot(curNavPath) + target
}
target = path.Clean(target)
return target
}
// ResolveOutputPath fixes output directory relative to current navigation path
func ResolveOutputPath(target string) string {
if strings.HasPrefix(target, "/") {
target = config.Config.Directories.Output + "/" + target
} else {
target = CurrentTreeNodeConfig.OutputPath + "/" + target
}
return path.Clean(target)
}
// ResolveInputPath fixes input directory relative to current navigation path
func ResolveInputPath(target string) string {
if strings.HasPrefix(target, "/") {
target = config.Config.Directories.Input + "/" + target
} else {
target = CurrentTreeNodeConfig.InputPath + "/" + target
}
return path.Clean(target)
}