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