Skip to content

Commit

Permalink
#4 - fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lele9h0st committed Aug 18, 2022
2 parents bde4b04 + 4ad5fdc commit ff8832e
Show file tree
Hide file tree
Showing 26 changed files with 563 additions and 28 deletions.
2 changes: 1 addition & 1 deletion db.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@
"id": 10
}
]
}
}
434 changes: 422 additions & 12 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@emailjs/browser": "^3.6.2",
"@fortawesome/fontawesome-free": "^6.0.0",
"chart.js": "^3.1.1",
"cheerio": "^1.0.0-rc.12",
"mdb-angular-calendar": "file:mdb-angular-calendar-2.0.0.tgz",
"mdb-angular-cookies-management": "file:mdb-angular-cookies-management-2.0.0.tgz",
"mdb-angular-drag-and-drop": "file:mdb-angular-drag-and-drop-2.0.0.tgz",
Expand Down
3 changes: 3 additions & 0 deletions src/app/post/advertisement/advertisement.component.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/app/post/advertisement/advertisement.component.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/app/post/advertisement/advertisement.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="{{url}}" alt="" srcset="" class="w-100">
Empty file.
25 changes: 25 additions & 0 deletions src/app/post/advertisement/advertisement.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AdvertisementComponent } from './advertisement.component';

describe('AdvertisementComponent', () => {
let component: AdvertisementComponent;
let fixture: ComponentFixture<AdvertisementComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AdvertisementComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(AdvertisementComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/post/advertisement/advertisement.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, Input, OnInit } from '@angular/core';

@Component({
selector: 'app-advertisement',
templateUrl: './advertisement.component.html',
styleUrls: ['./advertisement.component.scss']
})
export class AdvertisementComponent implements OnInit {
@Input() url = '';
constructor() { }

ngOnInit(): void {
}

}
15 changes: 14 additions & 1 deletion src/app/post/post-list/post-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ <h6 class="hot-post">{{posts_list?.[0]?.title}}</h6>
</p>
</div>
</div>
<div class="row">
<div class="d-flex justify-content-center">
<app-advertisement [url]="'../../../assets/images/ads1.png'"></app-advertisement>
</div>
<div class="d-flex justify-content-center mt-3">
<app-advertisement [url]="'../../../assets/images/ads6.png'"></app-advertisement>
</div>
</div>
</div>
<div class="col-md-3 ">
<div class="row">
Expand Down Expand Up @@ -65,6 +73,11 @@ <h6 class="hot-post">{{posts_list?.[1]?.title}}</h6>
</p>
</div>
</div>
<div class="row">
<div class="d-flex justify-content-center mt-3">
<app-advertisement [url]="'../../../assets/images/ads7.jpeg'"></app-advertisement>
</div>
</div>
</div>
<div class="col-md-3">
<div *ngFor="let item of get_posts_with_amount(2,4) ;index as ind">
Expand Down Expand Up @@ -117,7 +130,7 @@ <h6 class="new__post">{{item?.title}}</h6>
<h1>Mới nhất</h1>
</div>
<div class="mb-4"></div>
<div class="row mt-5 lazy" *ngFor="let item of get_posts_with_amount(9,posts_list.length)">
<div class="row mt-5 lazy" *ngFor="let item of get_posts_with_amount(9,posts_list.length);index as i">
<div class="col-md-2">
<div class="d-flex justify-content-start">
<p class="fw-light fs-11">{{get_time_in_words(item?.pubDate||"")}}
Expand Down
6 changes: 4 additions & 2 deletions src/app/post/post-list/post-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { API_SUB } from 'src/app/_api/apiURL';
import { Article, ArticleResponse } from 'src/app/_model/post.model';
import { PostService } from '../post.service';


@Component({
selector: 'app-post-list',
templateUrl: './post-list.component.html',
Expand Down Expand Up @@ -63,9 +62,12 @@ export class PostListComponent implements OnInit {
var andSymbol = singleQuote.split("&amp;amp;").join("&");
var finalTitle = andSymbol;

var finalDescription = curr.description[0].trim().split("&amp;apos;").join("'");
finalDescription = finalDescription.split("&amp;amp;").join("&");

let currentItem: Article = {
category: curr.category[0].trim(),
description: curr.description[0].trim(),
description: finalDescription,
guid: curr.guid[0].trim(),
link: curr.link[0].trim(),
media: "",
Expand Down
3 changes: 2 additions & 1 deletion src/app/post/post-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { MdbLazyLoadingModule } from 'mdb-angular-ui-kit/lazy-loading';
import { AuthGuard } from '../_guard/auth.guard';
import { PostListComponent } from './post-list/post-list.component';
import { SearchResultComponent } from './search-result/search-result.component';
import { TestPostCommentComponent } from './test-post-comment/test-post-comment.component';

const routes: Routes = [
{ path: 'search/:keyword/:tag', component: SearchResultComponent },
{ path: 'chu-de/:title', component: PostListComponent },
{ path: 'post-comment-test', component: TestPostCommentComponent },
{ path: 'post-comment-test', component: TestPostCommentComponent, canActivate: [AuthGuard] },
];

@NgModule({
Expand Down
18 changes: 9 additions & 9 deletions src/app/post/post.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PostRoutingModule } from './post-routing.module';
import { SharedModule } from '../shared/shared.module';
import { SearchResultComponent } from './search-result/search-result.component';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { MdbLazyLoadingModule } from 'code/mdb-angular-ui-kit/lazy-loading';
import { PostService } from './post.service';
import { PostListComponent } from './post-list/post-list.component';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { SharedModule } from '../shared/shared.module';
import { PostListComponent } from './post-list/post-list.component';
import { PostRoutingModule } from './post-routing.module';
import { PostService } from './post.service';
import { SearchResultComponent } from './search-result/search-result.component';
import { TestPostCommentComponent } from './test-post-comment/test-post-comment.component';
import { ReactiveFormsModule } from '@angular/forms';

import { AdvertisementComponent } from './advertisement/advertisement.component';
@NgModule({
declarations: [SearchResultComponent, PostListComponent, TestPostCommentComponent],
declarations: [SearchResultComponent, PostListComponent, TestPostCommentComponent, AdvertisementComponent],
imports: [
CommonModule,
PostRoutingModule,
Expand Down
7 changes: 7 additions & 0 deletions src/app/post/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ export class PostService {
return this.http.get<Comment[]>(`${API_URL.COMMENT}?article_id=${post_id}`)
.pipe(catchError(err => this.commonService.handleError(err, "Lỗi khi lấy bình luận")));
}

get_news_details(url: string) {
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
return this.http.get(`https://api-news-vietnamnet.herokuapp.com/article/${url}`, { headers, responseType: 'text' })
.pipe(catchError(err => this.commonService.handleError(err, "Lỗi khi lay du lieu bai viet ")));
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/app/post/test-post-comment/test-post-comment.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@
<input type="text" name="aid">
<div class="comments" *ngFor="let item of comments_list">
<p>{{item?.content}}</p>
</div>

<div>
<button (click)="get_data()">get data</button>
<p>data news</p>
<div class="post_details container w-50">
<div class="row">
<div [innerHtml]="post_details"></div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.green {
color: green;
}
@media only screen and (max-width: 768px) {
.post_details {
width: 100% !important;
}
}
25 changes: 24 additions & 1 deletion src/app/post/test-post-comment/test-post-comment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { PostService } from '../post.service';
import { Comment } from "../../_model/comment.model";
import { Cheerio, load } from 'cheerio'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';

declare var $: any;

Expand All @@ -14,8 +16,9 @@ export class TestPostCommentComponent implements OnInit {

public testForm!: FormGroup;
comments_list!: Comment[];
post_details!: any;

constructor(private formBuilder: FormBuilder, private service: PostService) {
constructor(private formBuilder: FormBuilder, private service: PostService, private domSanitizer: DomSanitizer) {
this.comments_list = [];
}

Expand All @@ -26,6 +29,26 @@ export class TestPostCommentComponent implements OnInit {
fullname: new FormControl('', [Validators.required]),
content: new FormControl('', [Validators.required]),
});
this.get_data();
}


sanitize(html: any): SafeHtml {
return this.domSanitizer.bypassSecurityTrustHtml(html);
}

get_data() {
this.service.get_news_details("cuu-thu-tuong-ehud-barak-israel-tim-moi-cach-de-phat-hien-cham-soc-tung-nhan-tai-2049939.html").subscribe(res => {
const $dom = load(res);
$dom(".newsFeature__header-title").addClass("green");
$dom(".newsFeature__boxAuthor").remove();
$dom(".controll__box").remove();
$dom(".vnn-template-noneditable").remove();
$dom("table").remove();
$dom("head").append('<link rel="stylesheet" href="/assets/css/style.css">');
this.post_details = this.sanitize($dom.html());
console.log($dom.html())
});
}

postComment() {
Expand Down
7 changes: 7 additions & 0 deletions src/assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.green {
color: green;
}

.newsFeature__main img {
width: 100%;
}
Binary file added src/assets/images/ads1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/ads3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/ads4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/ads5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/ads6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/ads7.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ff8832e

Please sign in to comment.