1
0
Fork 0

Simplify client syndications

This commit is contained in:
Chocobozzz 2018-04-17 10:35:08 +02:00
parent e6f627975b
commit cc1561f9f7
No known key found for this signature in database
GPG key ID: 583A612D890159BE
13 changed files with 102 additions and 115 deletions

View file

@ -47,7 +47,7 @@
"@types/sanitize-html": "^1.14.0",
"@types/video.js": "6.2.4",
"@types/webtorrent": "^0.98.4",
"angular2-notifications": "^0.9.6",
"angular2-notifications": "^1.0.0",
"awesome-typescript-loader": "5.0.0",
"bootstrap-sass": "^3.3.7",
"codelyzer": "^4.0.2",

View file

@ -27,8 +27,6 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
totalItems: null
}
syndicationItems = {}
protected baseVideoWidth = -1
protected baseVideoHeight = 155
@ -43,6 +41,8 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
ngOnInit () {
super.ngOnInit()
// this.generateSyndicationList()
}
ngOnDestroy () {

View file

@ -8,9 +8,12 @@
}
}
.title-page.title-page-single {
margin-right: 5px;
}
my-video-feed {
display: inline-block;
margin-left: -45px;
}
@media screen and (max-width: 500px) {

View file

@ -3,7 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router'
import { isInMobileView } from '@app/shared/misc/utils'
import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
import { NotificationsService } from 'angular2-notifications'
import { PopoverModule } from 'ngx-bootstrap/popover'
import 'rxjs/add/operator/debounceTime'
import { Observable } from 'rxjs/Observable'
import { fromEvent } from 'rxjs/observable/fromEvent'
@ -12,8 +11,6 @@ import { AuthService } from '../../core/auth'
import { ComponentPagination } from '../rest/component-pagination.model'
import { SortField } from './sort-field.type'
import { Video } from './video.model'
import { FeedFormat } from '../../../../../shared'
import { VideoFeedComponent } from '@app/shared/video/video-feed.component'
export abstract class AbstractVideoList implements OnInit, OnDestroy {
private static LINES_PER_PAGE = 4
@ -28,7 +25,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
}
sort: SortField = '-createdAt'
defaultSort: SortField = '-createdAt'
syndicationItems = {}
syndicationItems = []
loadOnInit = true
pageHeight: number

View file

@ -1,14 +1,13 @@
<div class="video-feed">
<span *ngIf="(syndicationItems | myObjectLength) >= 1" class="icon icon-syndication"
<span *ngIf="syndicationItems.length !== 0" class="icon icon-syndication"
[popover]="feedsList"
placement="bottom"
[outsideClick]="true">
</span>
<ng-template #feedsList>
<div *ngFor="let key of syndicationItems | keys">
<a [href]="syndicationItems[key]">{{ key }}</a>
<div *ngFor="let item of syndicationItems">
<a [href]="item.url" target="_blank" rel="noopener noreferrer">{{ item.label }}</a>
</div>
</ng-template>
</div>

View file

@ -1,14 +1,10 @@
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'
import { Component, Input } from '@angular/core'
@Component({
selector: 'my-video-feed',
styleUrls: [ './video-feed.component.scss' ],
templateUrl: './video-feed.component.html'
})
export class VideoFeedComponent implements OnChanges {
export class VideoFeedComponent {
@Input() syndicationItems
ngOnChanges (changes: SimpleChanges) {
this.syndicationItems = changes.syndicationItems.currentValue
}
}

View file

@ -117,45 +117,53 @@ export class VideoService {
.catch((res) => this.restExtractor.handleError(res))
}
baseFeed () {
const feed = {}
buildBaseFeedUrls () {
const feeds = [
{
label: 'rss 2.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
},
{
label: 'atom 1.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
},
{
label: 'json 1.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
}
]
for (let item in FeedFormat) {
feed[FeedFormat[item]] = VideoService.BASE_FEEDS_URL + item.toLowerCase()
}
return feed
return feeds
}
getFeed (
filter?: VideoFilter
) {
getVideoFeedUrls (filter?: VideoFilter) {
let params = this.restService.addRestGetParams(new HttpParams())
const feed = this.baseFeed()
const feeds = this.buildBaseFeedUrls()
if (filter) {
params = params.set('filter', filter)
}
for (let item in feed) {
feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString()
if (filter) params = params.set('filter', filter)
if (params.keys().length !== 0) {
for (let item of feeds) {
item.url += `?${params.toString()}`
}
}
return feed
return feeds
}
getAccountFeed (
accountId: number,
host?: string
) {
getAccountFeedUrls (accountId: number) {
let params = this.restService.addRestGetParams(new HttpParams())
const feed = this.baseFeed()
const feeds = this.buildBaseFeedUrls()
params = params.set('accountId', accountId.toString())
for (let item in feed) {
feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString()
if (params.keys().length !== 0) {
for (let item of feeds) {
item.url += `?${params.toString()}`
}
}
return feed
return feeds
}
searchVideos (

View file

@ -1,4 +1,4 @@
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild, OnChanges } from '@angular/core'
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { RedirectService } from '@app/core/routing/redirect.service'
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
@ -9,20 +9,18 @@ import { Subscription } from 'rxjs/Subscription'
import * as videojs from 'video.js'
import 'videojs-hotkeys'
import * as WebTorrent from 'webtorrent'
import { UserVideoRateType, VideoRateType, FeedFormat } from '../../../../../shared'
import { UserVideoRateType, VideoRateType } from '../../../../../shared'
import '../../../assets/player/peertube-videojs-plugin'
import { AuthService, ConfirmService } from '../../core'
import { VideoBlacklistService } from '../../shared'
import { Account } from '../../shared/account/account.model'
import { VideoDetails } from '../../shared/video/video-details.model'
import { VideoFeedComponent } from '../../shared/video/video-feed.component'
import { Video } from '../../shared/video/video.model'
import { VideoService } from '../../shared/video/video.service'
import { MarkdownService } from '../shared'
import { VideoDownloadComponent } from './modal/video-download.component'
import { VideoReportComponent } from './modal/video-report.component'
import { VideoShareComponent } from './modal/video-share.component'
import { environment } from '../../../environments/environment'
import { getVideojsOptions } from '../../../assets/player/peertube-player'
@Component({
@ -248,13 +246,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
}
generateSyndicationList () {
const feeds = this.videoService.getAccountFeed(
this.video.account.id,
(this.video.isLocal) ? environment.apiUrl : this.video.account.host
)
this.syndicationItems['rss 2.0'] = feeds[FeedFormat.RSS]
this.syndicationItems['atom 1.0'] = feeds[FeedFormat.ATOM]
this.syndicationItems['json 1.0'] = feeds[FeedFormat.JSON]
this.syndicationItems = this.videoService.getAccountFeedUrls(this.video.account.id)
}
isVideoRemovable () {

View file

@ -30,6 +30,7 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
ngOnInit () {
super.ngOnInit()
this.generateSyndicationList()
}
@ -44,9 +45,6 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
}
generateSyndicationList () {
const feeds = this.videoService.getFeed('local')
this.syndicationItems['rss 2.0'] = feeds[FeedFormat.RSS]
this.syndicationItems['atom 1.0'] = feeds[FeedFormat.ATOM]
this.syndicationItems['json 1.0'] = feeds[FeedFormat.JSON]
this.syndicationItems = this.videoService.getVideoFeedUrls('local')
}
}

View file

@ -29,6 +29,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
ngOnInit () {
super.ngOnInit()
this.generateSyndicationList()
}
@ -43,9 +44,6 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
}
generateSyndicationList () {
const feeds = this.videoService.getFeed('local')
this.syndicationItems['rss 2.0'] = feeds[FeedFormat.RSS]
this.syndicationItems['atom 1.0'] = feeds[FeedFormat.ATOM]
this.syndicationItems['json 1.0'] = feeds[FeedFormat.JSON]
this.syndicationItems = this.videoService.getVideoFeedUrls()
}
}

View file

@ -6,8 +6,6 @@ import { AuthService } from '../../core/auth'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
import { SortField } from '../../shared/video/sort-field.type'
import { VideoService } from '../../shared/video/video.service'
import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
import * as url from 'url'
@Component({
selector: 'my-videos-trending',
@ -29,6 +27,7 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
ngOnInit () {
super.ngOnInit()
this.generateSyndicationList()
}
@ -42,9 +41,6 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
}
generateSyndicationList () {
const feeds = this.videoService.getFeed('local')
this.syndicationItems['rss 2.0'] = feeds[FeedFormat.RSS]
this.syndicationItems['atom 1.0'] = feeds[FeedFormat.ATOM]
this.syndicationItems['json 1.0'] = feeds[FeedFormat.JSON]
this.syndicationItems = this.videoService.getVideoFeedUrls()
}
}

View file

@ -28,8 +28,8 @@
rxjs "^5.5.6"
"@angular/animations@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-5.2.9.tgz#220db9fb5a52a193db0023d721b23ddd25a75770"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-5.2.10.tgz#61718792e0922ac622fd7c6dfb0afbb996638692"
dependencies:
tslib "^1.7.1"
@ -99,14 +99,14 @@
node-sass "^4.7.2"
"@angular/common@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/common/-/common-5.2.9.tgz#beb25d4434498abae56bd8dc2c01ade3f6c45e81"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/common/-/common-5.2.10.tgz#828308df8505a31f219a6895ff91dbb178ebac98"
dependencies:
tslib "^1.7.1"
"@angular/compiler-cli@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-5.2.9.tgz#36a069937d50a8a294eda233b5b1b2c71139751f"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-5.2.10.tgz#7e9dead0730dc20f7658e110a558b557b60e7be2"
dependencies:
chokidar "^1.4.2"
minimist "^1.2.0"
@ -114,54 +114,54 @@
tsickle "^0.27.2"
"@angular/compiler@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-5.2.9.tgz#1d03bc1e8b38c259bc58114d691c2140d244f8f5"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-5.2.10.tgz#1cd9914436f0707957823531c4418ce5b7e6a130"
dependencies:
tslib "^1.7.1"
"@angular/core@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/core/-/core-5.2.9.tgz#3daf13ef9aa754b9954ed21da3eb322e8b20f667"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/core/-/core-5.2.10.tgz#a6eba06cae7267efbd2666e3fa5e42b84c2261de"
dependencies:
tslib "^1.7.1"
"@angular/forms@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/forms/-/forms-5.2.9.tgz#12c45b3a02c398b354f09cc740d914cd904c0c9c"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/forms/-/forms-5.2.10.tgz#6a4cf9c87b57005599c0ec59a79b7f1b06375591"
dependencies:
tslib "^1.7.1"
"@angular/http@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/http/-/http-5.2.9.tgz#2ffea536e181bc97e2867593d57425ea7853285b"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/http/-/http-5.2.10.tgz#d80d60fc205b043f72bd61ba22e7aa386d6a51ec"
dependencies:
tslib "^1.7.1"
"@angular/language-service@^5.1.0":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-5.2.9.tgz#4838bb6319c99e8f5beb08bdfb392ee9a1173766"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-5.2.10.tgz#5699af9d46033faccefeb21d4d168524d2180a8c"
"@angular/platform-browser-dynamic@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-5.2.9.tgz#86075b7bb694861f722ceda29aae186b045c6b7d"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-5.2.10.tgz#bec4c0ca9fb16c34adee851caa187989953216ca"
dependencies:
tslib "^1.7.1"
"@angular/platform-browser@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/platform-browser/-/platform-browser-5.2.9.tgz#9ee76327b1b3affad68ffa839058661b7704bc2c"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/platform-browser/-/platform-browser-5.2.10.tgz#92883803de7362e635748a440dd5f6172fc2394a"
dependencies:
tslib "^1.7.1"
"@angular/router@~5.2.2":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/router/-/router-5.2.9.tgz#0369df6e60c6da3a5842c6eb35e3958d4ffe727e"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/router/-/router-5.2.10.tgz#cb36c32de0a233a9b49789e11ca0f96c5304f25a"
dependencies:
tslib "^1.7.1"
"@angular/service-worker@^5.2.4":
version "5.2.9"
resolved "https://registry.yarnpkg.com/@angular/service-worker/-/service-worker-5.2.9.tgz#47ee439f2f896ac701fee271d046589a6c46b6af"
version "5.2.10"
resolved "https://registry.yarnpkg.com/@angular/service-worker/-/service-worker-5.2.10.tgz#ef861929e2ca5f1241f44be1ad5295544486514c"
dependencies:
tslib "^1.7.1"
@ -397,9 +397,9 @@ amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
angular2-notifications@^0.9.6:
version "0.9.8"
resolved "https://registry.yarnpkg.com/angular2-notifications/-/angular2-notifications-0.9.8.tgz#04e4744fcd7f6ada2eeeb8897fc9e3d5eb6e08c7"
angular2-notifications@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/angular2-notifications/-/angular2-notifications-1.0.0.tgz#07e2f970e32f0a67d67419a4dca21ecc9a452e3f"
ansi-escapes@^1.0.0:
version "1.4.0"
@ -1759,8 +1759,8 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
supports-color "^2.0.0"
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"
version "2.4.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
@ -3864,8 +3864,8 @@ html-entities@^1.2.0:
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.2.1.tgz#0df29351f0721163515dfb9e5543e5f6eed5162f"
html-minifier@^3.2.3:
version "3.5.14"
resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.5.14.tgz#88653b24b344274e3e3d7052f1541ebea054ac60"
version "3.5.15"
resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.5.15.tgz#f869848d4543cbfd84f26d5514a2a87cbf9a05e0"
dependencies:
camel-case "3.0.x"
clean-css "4.1.x"
@ -6206,8 +6206,8 @@ postcss-load-plugins@^2.3.0:
object-assign "^4.1.0"
postcss-loader@^2.0.10:
version "2.1.3"
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-2.1.3.tgz#eb210da734e475a244f76ccd61f9860f5bb3ee09"
version "2.1.4"
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-2.1.4.tgz#f44a6390e03c84108b2b2063182d1a1011b2ce76"
dependencies:
loader-utils "^1.1.0"
postcss "^6.0.0"
@ -6410,8 +6410,8 @@ postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.14, postcss@^6.0.16, postcss@^6.0.1
supports-color "^5.3.0"
prebuild-install@~2.5.0:
version "2.5.1"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.1.tgz#0f234140a73760813657c413cdccdda58296b1da"
version "2.5.3"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.3.tgz#9f65f242782d370296353710e9bc843490c19f69"
dependencies:
detect-libc "^1.0.3"
expand-template "^1.0.2"
@ -6442,8 +6442,8 @@ preserve@^0.2.0:
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prettier@^1.5.3:
version "1.12.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.0.tgz#d26fc5894b9230de97629b39cae225b503724ce8"
version "1.12.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325"
pretty-bytes@^4.0.2:
version "4.0.2"
@ -6695,8 +6695,8 @@ rc@^1.1.6, rc@^1.1.7:
strip-json-comments "~2.0.1"
react-dom@^16.2.0:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.1.tgz#6a3c90a4fb62f915bdbcf6204422d93a7d4ca573"
version "16.3.2"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.2.tgz#cb90f107e09536d683d84ed5d4888e9640e0e4df"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
@ -6704,8 +6704,8 @@ react-dom@^16.2.0:
prop-types "^15.6.0"
react@^16.2.0:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.1.tgz#4a2da433d471251c69b6033ada30e2ed1202cfd8"
version "16.3.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
@ -7956,8 +7956,8 @@ supports-color@^4.0.0, supports-color@^4.2.1:
has-flag "^2.0.0"
supports-color@^5.1.0, supports-color@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0"
version "5.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54"
dependencies:
has-flag "^3.0.0"
@ -8071,8 +8071,8 @@ timed-out@^4.0.0, timed-out@^4.0.1:
resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f"
timers-browserify@^2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.6.tgz#241e76927d9ca05f4d959819022f5b3664b64bae"
version "2.0.7"
resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.7.tgz#e74093629cb62c20332af587ddc0c86b4ba97a05"
dependencies:
setimmediate "^1.0.4"

View file

@ -4,4 +4,4 @@ set -eu
NODE_ENV=test concurrently -k \
"npm run tsc -- --sourceMap && npm run nodemon -- --delay 2 --watch ./dist dist/server" \
"npm run tsc -- --sourceMap -w"
"npm run tsc -- --sourceMap --preserveWatchOutput -w"