40 lines
1.1 KiB
Go
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)
|
|
}
|