Browse Source

Fix styles

master
Alfred 1 year ago
parent
commit
2ff22f2379
4 changed files with 43 additions and 3 deletions
  1. 5
    0
      public/css/main.css
  2. 2
    0
      src/index.js
  3. 22
    1
      src/managers/s3manager.js
  4. 14
    2
      views/index.html

+ 5
- 0
public/css/main.css View File

@@ -1,3 +1,8 @@
1 1
 .folder {
2 2
     margin-left: 10px;
3
+}
4
+
5
+.svg-inline--fa.fa-w-12, .svg-inline--fa.fa-w-18 {
6
+    width: 100%;
7
+    height: 100%;
3 8
 }

+ 2
- 0
src/index.js View File

@@ -47,6 +47,8 @@ initializeDb(config, db => {
47 47
 		}
48 48
 		let baseUrl = (req.baseUrl <= 1) ? req.protocol + "://" + req.headers.host : req.baseUrl;
49 49
 		let _url = req.url.replace(new RegExp("%20", 'g'), " ");
50
+		_url = _url.replace(new RegExp("%7D", 'g'), "}");
51
+		_url = _url.replace(new RegExp("%7B", 'g'), "{");
50 52
 		let access_data = appmanager.s3.access_data(_url);
51 53
 		appmanager.s3.list(access_data).then(function(data) {
52 54
 			data.baseUrl = baseUrl;

+ 22
- 1
src/managers/s3manager.js View File

@@ -1,5 +1,23 @@
1 1
 import s3 from 's3';
2 2
 
3
+var types = {
4
+    txt: "text",
5
+    doc: "document",
6
+    pdf: "document",
7
+    epub: "document",
8
+    mp4: "video",
9
+    avi: "video",
10
+    mpg: "video",
11
+    mpeg: "video",
12
+    jpg: "image",
13
+    png: "image",
14
+    jpeg: "image",
15
+    gif: "image",
16
+    zip: "compressed",
17
+    gz: "compressed",
18
+    rar: "compressed"
19
+};
20
+
3 21
 class S3Manager {
4 22
     constructor (config) {
5 23
         this.client = s3.createClient({
@@ -55,10 +73,13 @@ class S3Manager {
55 73
                 last_data = data;
56 74
                 for (var d of data.Contents) {
57 75
                     let key = d.Key;
76
+                    let _type = key.split('.')[key.split('.').length - 1];
77
+                    console.log(d)
58 78
                     content.push({
59 79
                         key: key,
60 80
                         name: d.Key.split('/').slice(-1)[0],
61
-                        url: eval('`' + self.url_template + '`')
81
+                        url: eval('`' + self.url_template + '`'),
82
+                        type: (_type) ? types[_type] : 'unknown'
62 83
                     });
63 84
                 }
64 85
             });

+ 14
- 2
views/index.html View File

@@ -7,7 +7,7 @@
7 7
         <meta name="description" content="">
8 8
         <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
9 9
         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.0/css/bulma.min.css">
10
-        <script defer src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
10
+        <script defer src="https://use.fontawesome.com/releases/v5.0.10/js/all.js"></script>
11 11
         <link rel="stylesheet" href="<%= baseUrl %>/css/main.css">
12 12
     </head>
13 13
     <body>
@@ -47,7 +47,19 @@
47 47
                     <article class="media container">
48 48
                         <figure class="media-left">
49 49
                             <p class="image is-64x64">
50
-                            <img src="<%= content[i].url %>">
50
+                            <% if (content[i].type === 'image') { %>                               
51
+                                <img src="<%= content[i].url %>">
52
+                            <% } else if (content[i].type === 'document') { %>
53
+                                <i class="far fa-file-pdf"></i>
54
+                            <% } else if (content[i].type === 'video') { %>
55
+                                <i class="far fa-file-video"></i>
56
+                            <% } else if (content[i].type === 'compressed') { %>
57
+                                <i class="far fa-file-archive"></i>
58
+                            <% } else if (content[i].type === 'text') { %>
59
+                                <i class="far fa-file-alt"></i>
60
+                            <% } else { %>
61
+                                <i class="far fa-file"></i>
62
+                            <% } %>
51 63
                             </p>
52 64
                         </figure>
53 65
                         <div class="media-content">

Loading…
Cancel
Save