aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/css/style.css4
-rw-r--r--app/img/directory.pngbin0 -> 888 bytes
-rw-r--r--app/img/html.pngbin0 -> 3744 bytes
-rw-r--r--app/img/image.pngbin0 -> 2218 bytes
-rw-r--r--app/img/pdf.pngbin0 -> 3221 bytes
-rw-r--r--app/img/text.pngbin0 -> 1673 bytes
-rw-r--r--app/img/unknown.pngbin0 -> 1416 bytes
-rw-r--r--app/img/video.pngbin0 -> 1638 bytes
-rw-r--r--app/index.html3
-rw-r--r--app/js/app.js26
10 files changed, 30 insertions, 3 deletions
diff --git a/app/css/style.css b/app/css/style.css
index b7e5742..13c6533 100644
--- a/app/css/style.css
+++ b/app/css/style.css
@@ -32,4 +32,8 @@ pre {
32 32
33.hand { 33.hand {
34 cursor: hand; 34 cursor: hand;
35}
36
37th {
38 vertical-align: middle !important;
35} \ No newline at end of file 39} \ No newline at end of file
diff --git a/app/img/directory.png b/app/img/directory.png
new file mode 100644
index 0000000..8630079
--- /dev/null
+++ b/app/img/directory.png
Binary files differ
diff --git a/app/img/html.png b/app/img/html.png
new file mode 100644
index 0000000..51153ea
--- /dev/null
+++ b/app/img/html.png
Binary files differ
diff --git a/app/img/image.png b/app/img/image.png
new file mode 100644
index 0000000..22939ff
--- /dev/null
+++ b/app/img/image.png
Binary files differ
diff --git a/app/img/pdf.png b/app/img/pdf.png
new file mode 100644
index 0000000..95e2308
--- /dev/null
+++ b/app/img/pdf.png
Binary files differ
diff --git a/app/img/text.png b/app/img/text.png
new file mode 100644
index 0000000..daf010d
--- /dev/null
+++ b/app/img/text.png
Binary files differ
diff --git a/app/img/unknown.png b/app/img/unknown.png
new file mode 100644
index 0000000..c5dac42
--- /dev/null
+++ b/app/img/unknown.png
Binary files differ
diff --git a/app/img/video.png b/app/img/video.png
new file mode 100644
index 0000000..6c01aea
--- /dev/null
+++ b/app/img/video.png
Binary files differ
diff --git a/app/index.html b/app/index.html
index 4557fcb..f6c91c9 100644
--- a/app/index.html
+++ b/app/index.html
@@ -138,8 +138,7 @@
138 </tr> 138 </tr>
139 <tr v-for="entry in entries" v-on:click="open(entry)" class="hand"> 139 <tr v-for="entry in entries" v-on:click="open(entry)" class="hand">
140 <th> 140 <th>
141 <i class="fa fa-folder-o" v-show="entry.isDirectory"></i> 141 <img v-bind:src="entry.previewUrl" height="48px" width="48px"/>
142 <i class="fa fa-file-o" v-show="entry.isFile"></i>
143 </th> 142 </th>
144 <th>{{ entry.filePath }}</th> 143 <th>{{ entry.filePath }}</th>
145 <th>{{ entry.size }}</th> 144 <th>{{ entry.size }}</th>
diff --git a/app/js/app.js b/app/js/app.js
index 0d6144e..c942e60 100644
--- a/app/js/app.js
+++ b/app/js/app.js
@@ -43,6 +43,27 @@ function encode(filePath) {
43 return filePath.split('/').map(encodeURIComponent).join('/'); 43 return filePath.split('/').map(encodeURIComponent).join('/');
44} 44}
45 45
46var mimeTypes = {
47 images: [ '.png', '.jpg', '.jpeg', '.tiff', '.gif' ],
48 text: [ '.txt', '.md' ],
49 pdf: [ '.pdf' ],
50 html: [ '.html', '.htm', '.php' ],
51 video: [ '.mp4', '.mpg', '.mpeg', '.ogg', '.mkv' ]
52};
53
54function getPreviewUrl(entry, basePath) {
55 var path = '/_admin/img/';
56
57 if (entry.isDirectory) return path + 'directory.png';
58 if (mimeTypes.images.some(function (e) { return entry.filePath.endsWith(e); })) return sanitize(basePath + '/' + entry.filePath);
59 if (mimeTypes.text.some(function (e) { return entry.filePath.endsWith(e); })) return path +'text.png';
60 if (mimeTypes.pdf.some(function (e) { return entry.filePath.endsWith(e); })) return path + 'pdf.png';
61 if (mimeTypes.html.some(function (e) { return entry.filePath.endsWith(e); })) return path + 'html.png';
62 if (mimeTypes.video.some(function (e) { return entry.filePath.endsWith(e); })) return path + 'video.png';
63
64 return path + 'unknown.png';
65}
66
46function refresh() { 67function refresh() {
47 loadDirectory(app.path); 68 loadDirectory(app.path);
48} 69}
@@ -60,7 +81,10 @@ function loadDirectory(filePath) {
60 if (error) return console.error(error); 81 if (error) return console.error(error);
61 if (result.statusCode === 401) return logout(); 82 if (result.statusCode === 401) return logout();
62 83
63 app.entries = result.body.entries; 84 app.entries = result.body.entries.map(function (entry) {
85 entry.previewUrl = getPreviewUrl(entry, filePath);
86 return entry;
87 });
64 app.path = filePath; 88 app.path = filePath;
65 app.pathParts = filePath.split('/').filter(function (e) { return !!e; }); 89 app.pathParts = filePath.split('/').filter(function (e) { return !!e; });
66 90