mark2web/path.go

39 lines
1015 B
Go
Raw Normal View History

2019-03-18 15:14:41 +01:00
package mark2web
2019-03-18 13:34:52 +01:00
import (
"path"
"strings"
"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, "/") {
2019-03-18 15:14:41 +01:00
target = Config.Directories.Output + "/" + target
2019-03-18 13:34:52 +01:00
} else {
2019-03-18 15:14:41 +01:00
target = CurrentTreeNode.OutputPath + "/" + target
2019-03-18 13:34:52 +01:00
}
return path.Clean(target)
}
// ResolveInputPath fixes input directory relative to current navigation path
func ResolveInputPath(target string) string {
if strings.HasPrefix(target, "/") {
2019-03-18 15:14:41 +01:00
target = Config.Directories.Input + "/" + target
2019-03-18 13:34:52 +01:00
} else {
2019-03-18 15:14:41 +01:00
target = CurrentTreeNode.InputPath + "/" + target
2019-03-18 13:34:52 +01:00
}
return path.Clean(target)
}