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:
parent
040154502e
commit
d94753c252
@ -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 {
|
||||||
@ -197,7 +198,7 @@ export class MyHammerConfig extends HammerGestureConfig {
|
|||||||
|
|
||||||
export class CustomUrlSerializer implements UrlSerializer {
|
export class CustomUrlSerializer implements UrlSerializer {
|
||||||
private defaultUrlSerializer: DefaultUrlSerializer =
|
private defaultUrlSerializer: DefaultUrlSerializer =
|
||||||
new DefaultUrlSerializer();
|
new DefaultUrlSerializer();
|
||||||
|
|
||||||
parse(url: string): UrlTree {
|
parse(url: string): UrlTree {
|
||||||
// Encode parentheses
|
// Encode parentheses
|
||||||
@ -208,9 +209,9 @@ export class CustomUrlSerializer implements UrlSerializer {
|
|||||||
|
|
||||||
serialize(tree: UrlTree): string {
|
serialize(tree: UrlTree): string {
|
||||||
return this.defaultUrlSerializer
|
return this.defaultUrlSerializer
|
||||||
.serialize(tree)
|
.serialize(tree)
|
||||||
.replace(/%28/g, '(')
|
.replace(/%28/g, '(')
|
||||||
.replace(/%29/g, ')');
|
.replace(/%29/g, ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +326,7 @@ Marker.prototype.options.icon = MarkerFactory.defIcon;
|
|||||||
StringifyEnum,
|
StringifyEnum,
|
||||||
StringifySearchType,
|
StringifySearchType,
|
||||||
FileDTOToPathPipe,
|
FileDTOToPathPipe,
|
||||||
|
FileDTOToRelativePathPipe,
|
||||||
PhotoFilterPipe,
|
PhotoFilterPipe,
|
||||||
ParseIntPipe,
|
ParseIntPipe,
|
||||||
UsersComponent,
|
UsersComponent,
|
||||||
|
17
src/frontend/app/pipes/FileDTOToRelativePathPipe.ts
Normal file
17
src/frontend/app/pipes/FileDTOToRelativePathPipe.ts
Normal 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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +1,34 @@
|
|||||||
.btn-blog-details {
|
.btn-blog-details {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-blog-details:hover {
|
.btn-blog-details:hover {
|
||||||
background-image: linear-gradient(transparent, rgba(var(--bs-body-color-rgb), 0.5));
|
background-image: linear-gradient(transparent, rgba(var(--bs-body-color-rgb), 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
.blog {
|
.blog {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blog:hover {
|
.blog:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-body {
|
.card-body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-preview {
|
.text-preview {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
display: block;
|
display: block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
margin: auto 0;
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,29 @@
|
|||||||
<ng-container *ngIf="mkObservable | async as markdowns">
|
<ng-container *ngIf="mkObservable | async as markdowns">
|
||||||
<div class="blog" *ngIf="markdowns.length > 0">
|
<div class="blog" *ngIf="markdowns.length > 0">
|
||||||
<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">
|
||||||
<markdown
|
<ng-container *ngIf="open">
|
||||||
*ngIf="open"
|
<div *ngIf="markdowns.length > 1" class="row">
|
||||||
[data]="md.text">
|
<hr class="col">
|
||||||
</markdown>
|
<div class="col-auto">{{md.file | toRelativePath}}</div>
|
||||||
<span *ngIf="!open && first" class="text-preview">
|
</div>
|
||||||
|
<markdown
|
||||||
|
[data]="md.text">
|
||||||
|
</markdown>
|
||||||
|
</ng-container>
|
||||||
|
<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>
|
|
||||||
|
|
||||||
<button class="btn btn-blog-details text-body" (click)="toggleCollapsed()">
|
<button class="btn btn-blog-details text-body" (click)="toggleCollapsed()">
|
||||||
<ng-icon [name]="open ? 'ionChevronUpOutline' : 'ionChevronDownOutline'"></ng-icon>
|
<ng-icon [name]="open ? 'ionChevronUpOutline' : 'ionChevronDownOutline'"></ng-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -16,22 +16,26 @@ export class BlogService {
|
|||||||
private mdFilesFilterPipe: MDFilesFilterPipe) {
|
private mdFilesFilterPipe: MDFilesFilterPipe) {
|
||||||
|
|
||||||
this.groupedMarkdowns = this.galleryService.sortedFilteredContent.pipe(
|
this.groupedMarkdowns = this.galleryService.sortedFilteredContent.pipe(
|
||||||
mergeMap(async content => {
|
mergeMap(async content => {
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const dates = content.mediaGroups.map(g => g.date)
|
const dates = content.mediaGroups.map(g => g.date)
|
||||||
.filter(d => !!d).map(d => d.getTime());
|
.filter(d => !!d).map(d => d.getTime());
|
||||||
|
|
||||||
const files = this.mdFilesFilterPipe.transform(content.metaFile)
|
const files = this.mdFilesFilterPipe.transform(content.metaFile)
|
||||||
.map(f => this.splitMarkDown(f, dates));
|
.map(f => this.splitMarkDown(f, dates));
|
||||||
|
|
||||||
return (await Promise.all(files)).flat();
|
return (await Promise.all(files)).flat();
|
||||||
}), shareReplay(1));
|
}), shareReplay(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
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 [{
|
||||||
@ -101,13 +105,13 @@ export class BlogService {
|
|||||||
|
|
||||||
public getMarkDown(file: FileDTO): Promise<string> {
|
public getMarkDown(file: FileDTO): Promise<string> {
|
||||||
const filePath = Utils.concatUrls(
|
const filePath = Utils.concatUrls(
|
||||||
file.directory.path,
|
file.directory.path,
|
||||||
file.directory.name,
|
file.directory.name,
|
||||||
file.name
|
file.name
|
||||||
);
|
);
|
||||||
if (!this.cache[filePath]) {
|
if (!this.cache[filePath]) {
|
||||||
this.cache[filePath] = this.networkService.getText(
|
this.cache[filePath] = this.networkService.getText(
|
||||||
'/gallery/content/' + filePath
|
'/gallery/content/' + filePath
|
||||||
);
|
);
|
||||||
(this.cache[filePath] as Promise<string>).then((val: string) => {
|
(this.cache[filePath] as Promise<string>).then((val: string) => {
|
||||||
this.cache[filePath] = val;
|
this.cache[filePath] = val;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user