Add RSS feed to subscribe button

pull/1104/merge
Chocobozzz 2018-09-26 09:39:41 +02:00
parent a71de50bbc
commit 39ba2e8e3a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 62 additions and 18 deletions

View File

@ -1,5 +1,4 @@
<form novalidate [formGroup]="form" <form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
(ngSubmit)="formValidated()">
<div class="form-group"> <div class="form-group">
<input type="email" <input type="email"
formControlName="text" formControlName="text"
@ -7,17 +6,17 @@
(keyup.control.enter)="onValidKey()" (keyup.meta.enter)="onValidKey()" (keyup.control.enter)="onValidKey()" (keyup.meta.enter)="onValidKey()"
placeholder="jane_doe@example.com"> placeholder="jane_doe@example.com">
</div> </div>
<button type="submit"
[disabled]="!form.valid" <button type="submit" [disabled]="!form.valid" class="btn btn-sm btn-remote-follow" i18n>
class="btn btn-sm btn-remote-follow"
i18n>
<span *ngIf="!interact">Remote subscribe</span> <span *ngIf="!interact">Remote subscribe</span>
<span *ngIf="interact">Remote interact</span> <span *ngIf="interact">Remote interact</span>
</button> </button>
<my-help *ngIf="!interact && showHelp" <my-help *ngIf="!interact && showHelp"
helpType="custom" helpType="custom"
i18n-customHtml customHtml="You can subscribe to the channel via any ActivityPub-capable fediverse instance. For instance with Mastodon or Pleroma you can type the channel URL in the search box and subscribe there."> i18n-customHtml customHtml="You can subscribe to the channel via any ActivityPub-capable fediverse instance. For instance with Mastodon or Pleroma you can type the channel URL in the search box and subscribe there.">
</my-help> </my-help>
<my-help *ngIf="showHelp && interact" <my-help *ngIf="showHelp && interact"
helpType="custom" helpType="custom"
i18n-customHtml customHtml="You can interact with this via any ActivityPub-capable fediverse instance. For instance with Mastodon or Pleroma you can type the current URL in the search box and interact with it there."> i18n-customHtml customHtml="You can interact with this via any ActivityPub-capable fediverse instance. For instance with Mastodon or Pleroma you can type the current URL in the search box and interact with it there.">

View File

@ -1,5 +1,6 @@
@import '_mixins'; @import '_mixins';
.btn-remote-follow { .btn-remote-follow {
@include peertube-button;
@include orange-button; @include orange-button;
} }

View File

@ -10,11 +10,16 @@
{{ videoChannel.followersCount | myNumberFormatter }} {{ videoChannel.followersCount | myNumberFormatter }}
</span> </span>
</button> </button>
<button *ngIf="subscribed === true" type="button"
class="btn btn-sm" role="button"
(click)="unsubscribe()" i18n>Unsubscribe</button>
<div class="btn-group" ngbDropdown autoClose="outside" <button
*ngIf="subscribed === true" type="button"
class="btn btn-sm" role="button"
(click)="unsubscribe()" i18n
>
Unsubscribe
</button>
<div class="btn-group" ngbDropdown autoClose="outside"
placement="bottom-right" role="group" placement="bottom-right" role="group"
aria-label="Multiple ways to subscribe to the current channel"> aria-label="Multiple ways to subscribe to the current channel">
<button class="btn btn-sm dropdown-toggle-split" ngbDropdownToggle> <button class="btn btn-sm dropdown-toggle-split" ngbDropdownToggle>
@ -25,16 +30,20 @@
{{ videoChannel.followersCount | myNumberFormatter }} {{ videoChannel.followersCount | myNumberFormatter }}
</span> </span>
</button> </button>
<div class="dropdown-menu" ngbDropdownMenu> <div class="dropdown-menu" ngbDropdownMenu>
<h6 class="dropdown-header" i18n>Using an ActivityPub-compatible account</h6> <h6 class="dropdown-header" i18n>Using an ActivityPub-compatible account</h6>
<button class="dropdown-item" (click)="subscribe()" <button class="dropdown-item" (click)="subscribe()"
*ngIf="subscribed === false"> *ngIf="subscribed === false">
<span *ngIf="!isUserLoggedIn()" i18n>Subscribe with an account on {{ videoChannel.host }}</span> <span *ngIf="!isUserLoggedIn()" i18n>Subscribe with an account on {{ videoChannel.host }}</span>
<span *ngIf="isUserLoggedIn()" i18n>Subscribe with your local account</span> <span *ngIf="isUserLoggedIn()" i18n>Subscribe with your local account</span>
</button> </button>
<button class="dropdown-item" i18n>Subscribe with a remote account:</button> <button class="dropdown-item" i18n>Subscribe with a remote account:</button>
<my-remote-subscribe showHelp="true" account="{{ uriAccount }}"></my-remote-subscribe> <my-remote-subscribe showHelp="true" account="{{ uriAccount }}"></my-remote-subscribe>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<h6 class="dropdown-header" i18n>Using a syndication feed</h6> <h6 class="dropdown-header" i18n>Using a syndication feed</h6>

View File

@ -4,15 +4,32 @@
.btn-group-subscribe { .btn-group-subscribe {
@include peertube-button; @include peertube-button;
@include disable-default-a-behaviour; @include disable-default-a-behaviour;
float: right; float: right;
padding: 0; padding: 0;
&.btn-group > .btn:not(.dropdown-toggle) { & > .btn,
padding-right: 5px; & > .dropdown > .dropdown-toggle {
font-size: 15px; font-size: 15px;
} }
&.btn-group > .btn-group:not(:first-child) > .btn {
padding-left: 2px; // Unlogged
& > .dropdown > .dropdown-toggle span {
padding-right: 3px;
}
// Logged
& > .btn {
padding-right: 4px;
& + .dropdown > button {
padding-left: 2px;
&::after {
position: relative;
top: 1px;
}
}
} }
&.subscribe-button { &.subscribe-button {
@ -22,7 +39,7 @@
} }
span.followers-count { span.followers-count {
padding-left:5px; padding-left: 5px;
} }
} }
&.unsubscribe-button { &.unsubscribe-button {
@ -32,6 +49,14 @@
} }
} }
.dropdown-menu {
cursor: default;
button {
cursor: pointer;
}
}
.dropdown-header { .dropdown-header {
padding-left: 1rem; padding-left: 1rem;
} }

View File

@ -5,6 +5,8 @@ import { UserSubscriptionService } from '@app/shared/user-subscription/user-subs
import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
import { I18n } from '@ngx-translate/i18n-polyfill' import { I18n } from '@ngx-translate/i18n-polyfill'
import { VideoService } from '@app/shared/video/video.service'
import { FeedFormat } from '../../../../../shared/models/feeds'
@Component({ @Component({
selector: 'my-subscribe-button', selector: 'my-subscribe-button',
@ -23,7 +25,8 @@ export class SubscribeButtonComponent implements OnInit {
private router: Router, private router: Router,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private userSubscriptionService: UserSubscriptionService, private userSubscriptionService: UserSubscriptionService,
private i18n: I18n private i18n: I18n,
private videoService: VideoService
) { } ) { }
get uri () { get uri () {
@ -100,6 +103,10 @@ export class SubscribeButtonComponent implements OnInit {
} }
rssOpen () { rssOpen () {
window.open('') const rssFeed = this.videoService
.getVideoChannelFeedUrls(this.videoChannel.id)
.find(i => i.format === FeedFormat.RSS)
window.open(rssFeed.url)
} }
} }

View File

@ -28,7 +28,7 @@ import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service' import { AccountService } from '@app/shared/account/account.service'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
import { ServerService } from '@app/core' import { ServerService } from '@app/core'
import { UserSubscriptionService } from '@app/shared/user-subscription' import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { I18n } from '@ngx-translate/i18n-polyfill' import { I18n } from '@ngx-translate/i18n-polyfill'
@ -210,14 +210,17 @@ export class VideoService implements VideosProvider {
buildBaseFeedUrls (params: HttpParams) { buildBaseFeedUrls (params: HttpParams) {
const feeds = [ const feeds = [
{ {
format: FeedFormat.RSS,
label: 'rss 2.0', label: 'rss 2.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase() url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
}, },
{ {
format: FeedFormat.ATOM,
label: 'atom 1.0', label: 'atom 1.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase() url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
}, },
{ {
format: FeedFormat.JSON,
label: 'json 1.0', label: 'json 1.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase() url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
} }