소스 검색

Added hidden file css style rendering in template

Toby Chui 2 년 전
부모
커밋
b15c0fd90a
1개의 변경된 파일13개의 추가작업 그리고 4개의 파일을 삭제
  1. 13 4
      mod/fileservers/servers/dirserv/template.go

+ 13 - 4
mod/fileservers/servers/dirserv/template.go

@@ -7,6 +7,7 @@ import (
 	"strings"
 
 	"imuslab.com/arozos/mod/filesystem/arozfs"
+	"imuslab.com/arozos/mod/filesystem/hidden"
 )
 
 func getPageHeader(pathname string) string {
@@ -62,13 +63,14 @@ func getPageHeader(pathname string) string {
 func getItemHTML(displayText string, link string, isDir bool, modTime string, size string) string {
 	icon := "📄"
 	downloadBtn := ""
-	hidden := ""
+	hiddenStyle := ""
 	if isDir {
 		icon = "📁"
-		if strings.HasPrefix(displayText, ".") {
+		isHidden, _ := hidden.IsHidden(link, true)
+		if isHidden {
 			//Hidden folder
 			icon = "📁"
-			hidden = "filter: alpha(opacity=50); opacity: 0.5;  zoom: 1;"
+			hiddenStyle = "filter: alpha(opacity=50); opacity: 0.5;  zoom: 1;"
 		}
 
 		size = "-"
@@ -85,9 +87,16 @@ func getItemHTML(displayText string, link string, isDir bool, modTime string, si
 		}
 		//fmt.Println(fileMime, filepath.Ext(displayText))
 
+		//Check if hidden file
+		isHidden, _ := hidden.IsHidden(link, true)
+		if isHidden {
+			//Hidden folder
+			hiddenStyle = "filter: alpha(opacity=50); opacity: 0.5;  zoom: 1;"
+		}
+
 		downloadBtn = `<a href="` + link + `" download>Download</a>`
 	}
-	return `<tr style="` + hidden + `">
+	return `<tr style="` + hiddenStyle + `">
 		<td class="fx">` + icon + `</td>
 		<td><a href="` + link + `">` + displayText + `</a></td>
 		<td>` + modTime + `</td>