mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-04 10:34:45 +02:00
This commit is contained in:
parent
0c2a21145f
commit
a8d636776b
@ -98,7 +98,7 @@ export class RenderingMWs {
|
|||||||
delete (err.details); // do not send back error object to the client side
|
delete (err.details); // do not send back error object to the client side
|
||||||
|
|
||||||
// hide error details for non developers
|
// hide error details for non developers
|
||||||
if (!(req.session.user && req.session.user.role >= UserRoles.Developer)) {
|
if (!(req.session && req.session.user && req.session.user.role >= UserRoles.Developer)) {
|
||||||
delete (err.detailsStr);
|
delete (err.detailsStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ export class Utils {
|
|||||||
.replace(new RegExp('/+', 'g'), '/');
|
.replace(new RegExp('/+', 'g'), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
static concatUrls(...args: Array<string>): string {
|
static concatUrls(...args: string[]): string {
|
||||||
let url = '';
|
let url = '';
|
||||||
for (const item of args) {
|
for (const item of args) {
|
||||||
if (item === '' || typeof item === 'undefined') {
|
if (item === '' || typeof item === 'undefined') {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Utils} from '../../../../common/Utils';
|
import {Utils} from '../../../../common/Utils';
|
||||||
import {MediaIcon} from './MediaIcon';
|
import {MediaIcon} from './MediaIcon';
|
||||||
import {Config} from '../../../../common/config/public/Config';
|
import {Config} from '../../../../common/config/public/Config';
|
||||||
import {MediaBaseDTO, MediaDTO, MediaDTOUtils} from '../../../../common/entities/MediaDTO';
|
import {MediaBaseDTO, MediaDTOUtils} from '../../../../common/entities/MediaDTO';
|
||||||
|
|
||||||
export class Media extends MediaIcon {
|
export class Media extends MediaIcon {
|
||||||
|
|
||||||
@ -54,8 +54,7 @@ export class Media extends MediaIcon {
|
|||||||
getReplacementThumbnailPath(): string {
|
getReplacementThumbnailPath(): string {
|
||||||
const size = this.getReplacementThumbnailSize();
|
const size = this.getReplacementThumbnailSize();
|
||||||
return Utils.concatUrls(Config.Client.urlBase,
|
return Utils.concatUrls(Config.Client.urlBase,
|
||||||
'/api/gallery/content/',
|
'/api/gallery/content/', this.getRelativePath(), 'thumbnail', size.toString());
|
||||||
this.media.directory.path, this.media.directory.name, this.media.name, 'thumbnail', size.toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +65,7 @@ export class Media extends MediaIcon {
|
|||||||
getThumbnailPath(): string {
|
getThumbnailPath(): string {
|
||||||
const size = this.getThumbnailSize();
|
const size = this.getThumbnailSize();
|
||||||
return Utils.concatUrls(Config.Client.urlBase,
|
return Utils.concatUrls(Config.Client.urlBase,
|
||||||
'/api/gallery/content/',
|
'/api/gallery/content/', this.getRelativePath(), 'thumbnail', size.toString());
|
||||||
this.media.directory.path, this.media.directory.name, this.media.name, 'thumbnail', size.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,19 +24,25 @@ export class MediaIcon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRelativePath(): string {
|
getRelativePath(): string {
|
||||||
return Utils.concatUrls(this.media.directory.path, this.media.directory.name, this.media.name);
|
return Utils.concatUrls(this.media.directory.path,
|
||||||
|
this.media.directory.name,
|
||||||
|
this.media.name)
|
||||||
|
// do not escape all urls with encodeURIComponent because that make the URL ugly and not needed
|
||||||
|
// do not escape before concatUrls as that would make prevent optimizations
|
||||||
|
.replace(new RegExp('%', 'g'), '%25') // order important
|
||||||
|
.replace(new RegExp('#', 'g'), '%23')
|
||||||
|
.replace(new RegExp('\\$', 'g'), '%24');
|
||||||
}
|
}
|
||||||
|
|
||||||
getIconPath(): string {
|
getIconPath(): string {
|
||||||
return Utils.concatUrls(Config.Client.urlBase,
|
return Utils.concatUrls(Config.Client.urlBase,
|
||||||
'/api/gallery/content/',
|
'/api/gallery/content/',
|
||||||
this.media.directory.path, this.media.directory.name, this.media.name, 'icon');
|
this.getRelativePath(), 'icon');
|
||||||
}
|
}
|
||||||
|
|
||||||
getMediaPath(): string {
|
getMediaPath(): string {
|
||||||
return Utils.concatUrls(Config.Client.urlBase,
|
return Utils.concatUrls(Config.Client.urlBase,
|
||||||
'/api/gallery/content/',
|
'/api/gallery/content/', this.getRelativePath());
|
||||||
this.media.directory.path, this.media.directory.name, this.media.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getBestFitMediaPath(): string {
|
getBestFitMediaPath(): string {
|
||||||
|
Loading…
Reference in New Issue
Block a user