2016-03-20 00:31:42 +08:00
|
|
|
///<reference path="../../typings/main.d.ts"/>
|
|
|
|
|
|
|
|
import {AuthenticationMWs} from "../middlewares/AuthenticationMWs";
|
2016-03-20 02:59:19 +08:00
|
|
|
import {GalleryMWs} from "../middlewares/GalleryMWs";
|
2016-03-26 18:19:10 +08:00
|
|
|
import {RenderingMWs} from "../middlewares/RenderingMWs";
|
2016-03-30 03:46:44 +08:00
|
|
|
import {ThumbnailGeneratorMWs} from "../middlewares/ThumbnailGeneratorMWs";
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2016-05-09 23:04:56 +08:00
|
|
|
export class GalleryRouter {
|
|
|
|
constructor(private app) {
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
this.addGetImageThumbnail();
|
|
|
|
this.addGetImage();
|
2016-03-27 02:24:12 +08:00
|
|
|
this.addDirectoryList();
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
this.addSearch();
|
2016-05-10 01:14:33 +08:00
|
|
|
this.addInstantSearch();
|
2016-03-20 00:31:42 +08:00
|
|
|
this.addAutoComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private addDirectoryList() {
|
2016-05-09 23:04:56 +08:00
|
|
|
this.app.get(["/api/gallery/content/:directory(*)", "/api/gallery/", "/api/gallery//"],
|
2016-05-13 05:00:38 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.listDirectory,
|
|
|
|
RenderingMWs.renderResult
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private addGetImage() {
|
2016-05-05 00:34:54 +08:00
|
|
|
this.app.get(["/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))"],
|
2016-03-20 23:54:30 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.loadImage,
|
|
|
|
RenderingMWs.renderFile
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
private addGetImageThumbnail() {
|
2016-05-05 00:34:54 +08:00
|
|
|
this.app.get("/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))/thumbnail/:size?",
|
2016-03-20 02:59:19 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-30 03:46:44 +08:00
|
|
|
GalleryMWs.loadImage,
|
|
|
|
ThumbnailGeneratorMWs.generateThumbnail,
|
2016-03-26 18:19:10 +08:00
|
|
|
RenderingMWs.renderFile
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
private addSearch() {
|
2016-05-10 01:14:33 +08:00
|
|
|
this.app.get("/api/gallery/search/:text",
|
2016-03-20 02:59:19 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.search,
|
|
|
|
RenderingMWs.renderResult
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2016-05-10 01:14:33 +08:00
|
|
|
private addInstantSearch() {
|
|
|
|
this.app.get("/api/gallery/instant-search/:text",
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.instantSearch,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2016-03-20 00:31:42 +08:00
|
|
|
private addAutoComplete() {
|
2016-05-05 00:34:54 +08:00
|
|
|
this.app.get("/api/gallery/autocomplete/:text",
|
2016-05-16 01:36:23 +08:00
|
|
|
// AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.autocomplete,
|
|
|
|
RenderingMWs.renderResult
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|