forked from ratwix/PhotoTwixNodeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_gallery.js
35 lines (27 loc) · 933 Bytes
/
server_gallery.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var fs = require('fs');
var Canvas = require('canvas');
var path_photo = "./public/photos/result";
var path_public_photo = "photos/result";
var path_public_thumb = "photos/thumbs";
/**
* Return list of all photos formated for canvas
*/
function getAllPhotos() {
var result = "";
var files = fs.readdirSync(path_photo);
var first = true;
files.forEach( function (file) {
stats = fs.lstatSync(path_photo + '/' + file);
if (!stats.isDirectory()) { //conditing for identifying folders
if (first) {
result = result + "<div class='thumb thumb_current'>";
} else {
result = result + "<div class='thumb'>";
}
result = result + "<img src='" + path_public_thumb + "/" + file + "' src_big='" + path_public_photo + "/" + file + "' src_small='" + path_public_thumb + "/" + file + "'/>\n</div>\n";
first = false;
}
});
return result;
}
exports.getAllPhotos = getAllPhotos;