6fbdbaae by miraclesu

Refactor template

1 parent 5ccdaeb0
Showing 1 changed file with 12 additions and 11 deletions
...@@ -51,19 +51,13 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error { ...@@ -51,19 +51,13 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
51 if f == nil { 51 if f == nil {
52 return err 52 return err
53 } 53 }
54 if f.IsDir() { 54 if f.IsDir() || (f.Mode()&os.ModeSymlink) > 0 {
55 return nil 55 return nil
56 } else if (f.Mode() & os.ModeSymlink) > 0 {
57 return nil
58 } else {
59 hasExt := false
60 for _, v := range BeeTemplateExt {
61 if strings.HasSuffix(paths, v) {
62 hasExt = true
63 break
64 } 56 }
57 if !HasTemplateEXt(paths) {
58 return nil
65 } 59 }
66 if hasExt { 60
67 replace := strings.NewReplacer("\\", "/") 61 replace := strings.NewReplacer("\\", "/")
68 a := []byte(paths) 62 a := []byte(paths)
69 a = a[len([]byte(self.root)):] 63 a = a[len([]byte(self.root)):]
...@@ -76,9 +70,16 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error { ...@@ -76,9 +70,16 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
76 self.files[subdir] = m 70 self.files[subdir] = m
77 } 71 }
78 72
73 return nil
74 }
75
76 func HasTemplateEXt(paths string) bool {
77 for _, v := range BeeTemplateExt {
78 if strings.HasSuffix(paths, "."+v) {
79 return true
79 } 80 }
80 } 81 }
81 return nil 82 return false
82 } 83 }
83 84
84 func AddTemplateExt(ext string) { 85 func AddTemplateExt(ext string) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!