Beispiel #1
0
func newContentPathSection(path string) (string, string) {
	// Forward slashes is used in all examples. Convert if needed.
	// Issue #1133
	createpath := strings.Replace(path, "/", helpers.FilePathSeparator, -1)
	var section string
	// assume the first directory is the section (kind)
	if strings.Contains(createpath[1:], helpers.FilePathSeparator) {
		section = helpers.GuessSection(createpath)
	}

	return createpath, section
}
Beispiel #2
0
func NewFile(relpath string) *File {
	f := &File{
		relpath: relpath,
	}

	f.dir, _ = filepath.Split(f.relpath)
	_, f.logicalName = filepath.Split(f.relpath)
	f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".")
	f.section = helpers.GuessSection(f.Dir())
	f.uniqueID = helpers.Md5String(f.LogicalName())

	return f
}