This commit is contained in:
_Bastler 2021-10-06 12:56:10 +02:00
parent 33de9c48eb
commit 845039f9df
4 changed files with 38 additions and 2 deletions

View File

@ -15,7 +15,7 @@ import { AutofocusDirective } from './material/autofocus';
import { I18nPipe } from './utils/i18n.pipe'; import { I18nPipe } from './utils/i18n.pipe';
import { MomentPipe } from './utils/moment.pipe'; import { MomentPipe } from './utils/moment.pipe';
import { UrlTextPipe } from './utils/urltext.pipe'; import { UrlBasePipe, UrlTextPipe } from './utils/urltext.pipe';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { PageBookmarks } from './pages/bookmarks/bookmarks.page'; import { PageBookmarks } from './pages/bookmarks/bookmarks.page';
import { PageComment } from './pages/comment/comment.page'; import { PageComment } from './pages/comment/comment.page';
@ -80,6 +80,7 @@ export class XhrInterceptor implements HttpInterceptor {
AutofocusDirective, AutofocusDirective,
I18nPipe, I18nPipe,
MomentPipe, MomentPipe,
UrlBasePipe,
UrlTextPipe, UrlTextPipe,
AppComponent, AppComponent,
PageBookmarks, PageBookmarks,

View File

@ -3,6 +3,7 @@
<mat-icon inline="true">{{'entryType.' + entry.entryType + '.icon' | i18n}}</mat-icon> <mat-icon inline="true">{{'entryType.' + entry.entryType + '.icon' | i18n}}</mat-icon>
<a class="title" *ngIf="entry.url" [href]="entry.url" target="_blank">{{entry.title}}</a> <a class="title" *ngIf="entry.url" [href]="entry.url" target="_blank">{{entry.title}}</a>
<a class="title" *ngIf="!entry.url" routerLink="/e/{{entry.id}}">{{entry.title}}</a> <a class="title" *ngIf="!entry.url" routerLink="/e/{{entry.id}}">{{entry.title}}</a>
<span *ngIf="entry.url" class="urlbase">(<a [href]="entry.url">{{entry.url | urlbase}}</a>)</span>
</div> </div>
<div mat-line> <div mat-line>
<small> <small>

View File

@ -4,6 +4,20 @@ a.title {
white-space: break-spaces; white-space: break-spaces;
} }
span.urlbase {
margin-left: 5px;
font-size: 0.7em;
color: $accent;
a {
color: $accent;
}
a::after {
display: none;
}
}
small a { small a {
color: inherit !important; color: inherit !important;
text-decoration: none; text-decoration: none;

View File

@ -12,3 +12,23 @@ export class UrlTextPipe implements PipeTransform {
return value; return value;
} }
} }
@Pipe({ name: 'urlbase' })
export class UrlBasePipe implements PipeTransform {
httpPattern = /(\b(https?:\/\/)([-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]))/ig;
transform(value: string): any {
if (!value.match(this.httpPattern)) {
return '';
}
const parts = value.split( '/' )
if (parts.length < 3) {
return '';
}
return parts[2];
}
}