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"
(ngSubmit)="formValidated()">
<form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
<div class="form-group">
<input type="email"
formControlName="text"
@ -7,17 +6,17 @@
(keyup.control.enter)="onValidKey()" (keyup.meta.enter)="onValidKey()"
placeholder="jane_doe@example.com">
</div>
<button type="submit"
[disabled]="!form.valid"
class="btn btn-sm btn-remote-follow"
i18n>
<button type="submit" [disabled]="!form.valid" class="btn btn-sm btn-remote-follow" i18n>
<span *ngIf="!interact">Remote subscribe</span>
<span *ngIf="interact">Remote interact</span>
</button>
<my-help *ngIf="!interact && showHelp"
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.">
</my-help>
<my-help *ngIf="showHelp && interact"
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.">

View File

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

View File

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

View File

@ -4,15 +4,32 @@
.btn-group-subscribe {
@include peertube-button;
@include disable-default-a-behaviour;
float: right;
padding: 0;
&.btn-group > .btn:not(.dropdown-toggle) {
padding-right: 5px;
& > .btn,
& > .dropdown > .dropdown-toggle {
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 {
@ -22,7 +39,7 @@
}
span.followers-count {
padding-left:5px;
padding-left: 5px;
}
}
&.unsubscribe-button {
@ -32,6 +49,14 @@
}
}
.dropdown-menu {
cursor: default;
button {
cursor: pointer;
}
}
.dropdown-header {
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 { NotificationsService } from 'angular2-notifications'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { VideoService } from '@app/shared/video/video.service'
import { FeedFormat } from '../../../../../shared/models/feeds'
@Component({
selector: 'my-subscribe-button',
@ -23,7 +25,8 @@ export class SubscribeButtonComponent implements OnInit {
private router: Router,
private notificationsService: NotificationsService,
private userSubscriptionService: UserSubscriptionService,
private i18n: I18n
private i18n: I18n,
private videoService: VideoService
) { }
get uri () {
@ -100,6 +103,10 @@ export class SubscribeButtonComponent implements OnInit {
}
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 { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
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 { I18n } from '@ngx-translate/i18n-polyfill'
@ -210,14 +210,17 @@ export class VideoService implements VideosProvider {
buildBaseFeedUrls (params: HttpParams) {
const feeds = [
{
format: FeedFormat.RSS,
label: 'rss 2.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
},
{
format: FeedFormat.ATOM,
label: 'atom 1.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
},
{
format: FeedFormat.JSON,
label: 'json 1.0',
url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
}