2016-05-26 02:17:42 +08:00
|
|
|
import {AuthenticationMWs} from "../middlewares/user/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";
|
2017-05-28 18:33:18 +08:00
|
|
|
import {ThumbnailGeneratorMWs} from "../middlewares/thumbnail/ThumbnailGeneratorMWs";
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2016-05-09 23:04:56 +08:00
|
|
|
export class GalleryRouter {
|
2017-06-11 04:32:56 +08:00
|
|
|
public static route(app: any) {
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
this.addGetImageIcon(app);
|
|
|
|
this.addGetImageThumbnail(app);
|
|
|
|
this.addGetImage(app);
|
|
|
|
this.addDirectoryList(app);
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
this.addSearch(app);
|
|
|
|
this.addInstantSearch(app);
|
|
|
|
this.addAutoComplete(app);
|
|
|
|
}
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addDirectoryList(app) {
|
|
|
|
app.get(["/api/gallery/content/:directory(*)", "/api/gallery/", "/api/gallery//"],
|
|
|
|
AuthenticationMWs.authenticate,
|
2017-07-04 01:17:49 +08:00
|
|
|
AuthenticationMWs.authoriseDirectory,
|
2017-06-11 04:32:56 +08:00
|
|
|
GalleryMWs.listDirectory,
|
|
|
|
ThumbnailGeneratorMWs.addThumbnailInformation,
|
|
|
|
GalleryMWs.removeCyclicDirectoryReferences,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addGetImage(app) {
|
|
|
|
app.get(["/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))"],
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.loadImage,
|
|
|
|
RenderingMWs.renderFile
|
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addGetImageThumbnail(app) {
|
|
|
|
app.get("/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))/thumbnail/:size?",
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.loadImage,
|
|
|
|
ThumbnailGeneratorMWs.generateThumbnail,
|
|
|
|
RenderingMWs.renderFile
|
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addGetImageIcon(app) {
|
|
|
|
app.get("/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))/icon",
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.loadImage,
|
|
|
|
ThumbnailGeneratorMWs.generateIcon,
|
|
|
|
RenderingMWs.renderFile
|
|
|
|
);
|
|
|
|
};
|
2017-01-23 05:31:29 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addSearch(app) {
|
|
|
|
app.get("/api/search/:text",
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.search,
|
|
|
|
ThumbnailGeneratorMWs.addThumbnailInformation,
|
|
|
|
GalleryMWs.removeCyclicDirectoryReferences,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addInstantSearch(app) {
|
|
|
|
app.get("/api/instant-search/:text",
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.instantSearch,
|
|
|
|
ThumbnailGeneratorMWs.addThumbnailInformation,
|
|
|
|
GalleryMWs.removeCyclicDirectoryReferences,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
};
|
2016-05-10 01:14:33 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addAutoComplete(app) {
|
|
|
|
app.get("/api/autocomplete/:text",
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
GalleryMWs.autocomplete,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|