1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Improve blog UI #711

This commit is contained in:
Patrik J. Braun 2023-09-06 22:24:43 +02:00
parent 040154502e
commit d94753c252
5 changed files with 82 additions and 51 deletions

View File

@ -184,6 +184,7 @@ import {
SortingMethodSettingsEntryComponent SortingMethodSettingsEntryComponent
} from './ui/settings/template/settings-entry/sorting-method/sorting-method.settings-entry.component'; } from './ui/settings/template/settings-entry/sorting-method/sorting-method.settings-entry.component';
import {ContentLoaderService} from './ui/gallery/contentLoader.service'; import {ContentLoaderService} from './ui/gallery/contentLoader.service';
import {FileDTOToRelativePathPipe} from './pipes/FileDTOToRelativePathPipe';
@Injectable() @Injectable()
export class MyHammerConfig extends HammerGestureConfig { export class MyHammerConfig extends HammerGestureConfig {
@ -325,6 +326,7 @@ Marker.prototype.options.icon = MarkerFactory.defIcon;
StringifyEnum, StringifyEnum,
StringifySearchType, StringifySearchType,
FileDTOToPathPipe, FileDTOToPathPipe,
FileDTOToRelativePathPipe,
PhotoFilterPipe, PhotoFilterPipe,
ParseIntPipe, ParseIntPipe,
UsersComponent, UsersComponent,

View File

@ -0,0 +1,17 @@
import { Pipe, PipeTransform } from '@angular/core';
import { FileDTO } from '../../../common/entities/FileDTO';
import { Utils } from '../../../common/Utils';
@Pipe({ name: 'toRelativePath' })
export class FileDTOToRelativePathPipe implements PipeTransform {
transform(metaFile: FileDTO): string | null {
if (!metaFile) {
return null;
}
return Utils.concatUrls(
metaFile.directory.path,
metaFile.directory.name,
metaFile.name
);
}
}

View File

@ -28,3 +28,7 @@
display: block; display: block;
overflow: hidden; overflow: hidden;
} }
hr {
margin: auto 0;
}

View File

@ -3,17 +3,21 @@
<div class="card"> <div class="card">
<div class="card-body" style="min-height: 77px" [style.height]="!open ? '77px':''"> <div class="card-body" style="min-height: 77px" [style.height]="!open ? '77px':''">
<ng-container *ngFor="let md of markdowns; let last = last; let first = first"> <ng-container *ngFor="let md of markdowns; let last = last; let first = first">
<ng-container *ngIf="open">
<div *ngIf="markdowns.length > 1" class="row">
<hr class="col">
<div class="col-auto">{{md.file | toRelativePath}}</div>
</div>
<markdown <markdown
*ngIf="open"
[data]="md.text"> [data]="md.text">
</markdown> </markdown>
</ng-container>
<span *ngIf="!open && first" class="text-preview"> <span *ngIf="!open && first" class="text-preview">
<markdown <markdown
[inline]="true" [inline]="true"
[data]="md.textShort"> [data]="md.textShort">
</markdown> </markdown>
</span> </span>
<hr *ngIf="open && !last">
</ng-container> </ng-container>
</div> </div>
</div> </div>

View File

@ -31,7 +31,11 @@ export class BlogService {
} }
private async splitMarkDown(file: FileDTO, dates: number[]): Promise<GroupedMarkdown[]> { private async splitMarkDown(file: FileDTO, dates: number[]): Promise<GroupedMarkdown[]> {
const markdown = await this.getMarkDown(file); const markdown = (await this.getMarkDown(file)).trim();
if (!markdown) {
return [];
}
if (dates.length == 0) { if (dates.length == 0) {
return [{ return [{