You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-11-29 22:48:28 +02:00
Improve on blog handling #1001
This commit is contained in:
@@ -32,13 +32,30 @@ export class BlogService {
|
||||
Math.min(Utils.getTimeMS(m.metadata.creationDate, m.metadata.creationDateOffset, Config.Gallery.ignoreTimestampOffset), p), Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
|
||||
const files = this.mdFilesFilterPipe.transform(content.metaFile)
|
||||
const files = (this.mdFilesFilterPipe.transform(content.metaFile) || [])
|
||||
.map(f => this.splitMarkDown(f, dates, firstMedia));
|
||||
|
||||
return (await Promise.all(files)).flat();
|
||||
}), shareReplay(1));
|
||||
}
|
||||
|
||||
public getMarkDown(file: FileDTO): Promise<string> {
|
||||
const filePath = Utils.concatUrls(
|
||||
file.directory.path,
|
||||
file.directory.name,
|
||||
file.name
|
||||
);
|
||||
if (!this.cache[filePath]) {
|
||||
this.cache[filePath] = this.networkService.getText(
|
||||
'/gallery/content/' + filePath
|
||||
);
|
||||
(this.cache[filePath] as Promise<string>).then((val: string) => {
|
||||
this.cache[filePath] = val;
|
||||
});
|
||||
}
|
||||
return Promise.resolve(this.cache[filePath]);
|
||||
}
|
||||
|
||||
private async splitMarkDown(file: MDFileDTO, dates: number[], firstMedia: number): Promise<GroupedMarkdown[]> {
|
||||
const markdown = (await this.getMarkDown(file)).trim();
|
||||
|
||||
@@ -134,23 +151,6 @@ export class BlogService {
|
||||
ret.forEach(md => md.textShort = md.text.substring(0, 200));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public getMarkDown(file: FileDTO): Promise<string> {
|
||||
const filePath = Utils.concatUrls(
|
||||
file.directory.path,
|
||||
file.directory.name,
|
||||
file.name
|
||||
);
|
||||
if (!this.cache[filePath]) {
|
||||
this.cache[filePath] = this.networkService.getText(
|
||||
'/gallery/content/' + filePath
|
||||
);
|
||||
(this.cache[filePath] as Promise<string>).then((val: string) => {
|
||||
this.cache[filePath] = val;
|
||||
});
|
||||
}
|
||||
return Promise.resolve(this.cache[filePath]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user