diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c99348a..acb9a40 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,6 +12,7 @@ import { SplashScreen } from '@ionic-native/splash-screen'; import { IonicStorageModule } from '@ionic/storage'; import { Device } from '@ionic-native/device'; import { TimeagoPipe } from '../pipes/timeago/timeago'; +import { ParserPipe } from '../pipes/parser/parser'; @NgModule({ declarations: [ @@ -20,7 +21,8 @@ import { TimeagoPipe } from '../pipes/timeago/timeago'; StreamPage, ThreadPage, TimeagoPipe, - NewPostModal + NewPostModal, + ParserPipe ], imports: [ BrowserModule, diff --git a/src/pages/stream/stream.html b/src/pages/stream/stream.html index 95ada91..1ff8778 100644 --- a/src/pages/stream/stream.html +++ b/src/pages/stream/stream.html @@ -38,7 +38,10 @@ -

{{ post.is_deleted ? '{post deleted}' : post.content.text }}

+
+ +
+
diff --git a/src/pipes/parser/parser.ts b/src/pipes/parser/parser.ts new file mode 100644 index 0000000..f60e8bf --- /dev/null +++ b/src/pipes/parser/parser.ts @@ -0,0 +1,20 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import {DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl} from '@angular/platform-browser'; + +/** + * Generated class for the ParserPipe pipe. + * + * See https://angular.io/docs/ts/latest/guide/pipes.html for more info on + * Angular Pipes. + */ +@Pipe({ + name: 'parser', +}) +export class ParserPipe implements PipeTransform { + + constructor(protected _sanitizer: DomSanitizer) {} + + transform(value: string, ...args): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl { + return this._sanitizer.bypassSecurityTrustHtml(value); + } +} diff --git a/src/pipes/timeago/timeago.ts b/src/pipes/timeago/timeago.ts index 60ac239..1bd4dd8 100644 --- a/src/pipes/timeago/timeago.ts +++ b/src/pipes/timeago/timeago.ts @@ -12,9 +12,7 @@ import * as moment from 'moment'; }) export class TimeagoPipe implements PipeTransform { now: any; - /** - * Takes a value and makes it lowercase. - */ + transform(value: string, ...args) { this.now = moment(value).fromNow(true); return this.now;