func NewFile(relpath string) *File { f := &File{ relpath: relpath, } f.dir, 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 }
// NewFile creates a new File pointer with the given relative path. func NewFile(relpath string) *File { f := &File{ relpath: relpath, } f.dir, f.logicalName = filepath.Split(f.relpath) f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".") f.baseName = helpers.Filename(f.LogicalName()) f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".") if f.lang == "" { f.lang = viper.GetString("defaultContentLanguage") } f.translationBaseName = helpers.Filename(f.baseName) f.section = helpers.GuessSection(f.Dir()) f.uniqueID = helpers.Md5String(f.LogicalName()) return f }
func (f *File) UniqueId() string { if f.uniqueId == "" { f.uniqueId = helpers.Md5String(f.LogicalName()) } return f.uniqueId }