Browse Source

Added opg folder

Toby Chui 3 năm trước cách đây
mục cha
commit
c59ad0b40d
2 tập tin đã thay đổi với 24 bổ sung2 xóa
  1. 6 1
      mod/share/share.go
  2. 18 1
      system/share/downloadPageFolder.html

+ 6 - 1
mod/share/share.go

@@ -113,6 +113,10 @@ func (s *Manager) HandleOPGServing(w http.ResponseWriter, r *http.Request, share
 
 	fs := filesystem.GetFileSize(shareEntry.FileRealPath)
 	shareMeta := filepath.Ext(shareEntry.FileRealPath) + " / " + filesystem.GetFileDisplaySize(fs, 2)
+	if isDir(shareEntry.FileRealPath) {
+		fs, fc := filesystem.GetDirctorySize(shareEntry.FileRealPath, false)
+		shareMeta = strconv.Itoa(fc) + " items / " + filesystem.GetFileDisplaySize(fs, 2)
+	}
 
 	if len([]rune(filename)) > 20 {
 		//Split into lines
@@ -176,7 +180,7 @@ func (s *Manager) HandleOPGServing(w http.ResponseWriter, r *http.Request, share
 		}
 
 		resizedThumb := resize.Resize(250, 0, thumb, resize.Lanczos3)
-		draw.Draw(resultopg, resultopg.Bounds(), resizedThumb, image.Point{-(resultopg.Bounds().Dx() - resizedThumb.Bounds().Dx() - 90), -60}, draw.Src)
+		draw.Draw(resultopg, resultopg.Bounds(), resizedThumb, image.Point{-(resultopg.Bounds().Dx() - resizedThumb.Bounds().Dx() - 90), -60}, draw.Over)
 	}
 
 	w.Header().Set("Content-Type", "image/jpeg") // <-- set the content-type header
@@ -548,6 +552,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 				t := fasttemplate.New(string(content), "{{", "}}")
 				s := t.ExecuteString(map[string]interface{}{
 					"hostname":     s.options.HostName,
+					"host":         r.Host,
 					"reqid":        id,
 					"mime":         "application/x-directory",
 					"size":         filesystem.GetFileDisplaySize(fsize, 2),

+ 18 - 1
system/share/downloadPageFolder.html

@@ -3,7 +3,24 @@
     <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
-    <title>{{hostname}} File Share</title>
+    <title>{{filename}} - {{hostname}} File Share</title>
+    <meta name="description" content="Folder shared from  {{hostname}}">
+
+      <!-- Facebook Meta Tags -->
+      <meta property="og:url" content="{{requri}}">
+      <meta property="og:type" content="website">
+      <meta property="og:title" content="{{filename}}">
+      <meta property="og:description" content="File shared from {{hostname}}">
+      <meta property="og:image" content="{{opg_image}}">
+    
+      <!-- Twitter Meta Tags -->
+      <meta name="twitter:card" content="summary_large_image">
+      <meta property="twitter:domain" content="{{host}}">
+      <meta property="twitter:url" content="{{requri}}">
+      <meta name="twitter:title" content="{{filename}}">
+      <meta name="twitter:description" content="File shared from {{hostname}}">
+      <meta name="twitter:image" content="{{opg_image}}">
+      
     <link rel="stylesheet" href="../../script/skeleton/offline.css">
     <link rel="stylesheet" href="../../script/skeleton/normalize.css">
     <link rel="stylesheet" href="../../script/skeleton/skeleton.css">