@peertube/feed
Advanced tools
Comparing version 5.0.2 to 5.1.0
@@ -1,6 +0,8 @@ | ||
import { Author, Extension, FeedOptions, Item } from "./typings"; | ||
export { Author, Extension, FeedOptions, Item }; | ||
import { Author, Extension, FeedOptions, Item, PodcastItem, PodcastLiveItem } from "./typings"; | ||
export { Author, Extension, FeedOptions, Item, PodcastItem, PodcastLiveItem }; | ||
export declare class Feed { | ||
options: FeedOptions; | ||
items: Item[]; | ||
podcastItems: PodcastItem[]; | ||
podcastLiveItems: PodcastLiveItem[]; | ||
categories: string[]; | ||
@@ -11,2 +13,4 @@ contributors: Author[]; | ||
addItem: (item: Item) => number; | ||
addPodcastItem: (podcastItem: PodcastItem) => number; | ||
addPodcastLiveItem: (podcastLiveItem: PodcastLiveItem) => number; | ||
addCategory: (category: string) => number; | ||
@@ -17,3 +21,4 @@ addContributor: (contributor: Author) => number; | ||
rss2: () => string; | ||
podcast: () => string; | ||
json1: () => string; | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
var json_1 = require("./json"); | ||
var podcast_1 = require("./podcast"); | ||
var rss2_1 = require("./rss2"); | ||
@@ -12,2 +13,4 @@ var Feed = (function () { | ||
this.items = []; | ||
this.podcastItems = []; | ||
this.podcastLiveItems = []; | ||
this.categories = []; | ||
@@ -17,2 +20,4 @@ this.contributors = []; | ||
this.addItem = function (item) { return _this.items.push(item); }; | ||
this.addPodcastItem = function (podcastItem) { return _this.podcastItems.push(podcastItem); }; | ||
this.addPodcastLiveItem = function (podcastLiveItem) { return _this.podcastLiveItems.push(podcastLiveItem); }; | ||
this.addCategory = function (category) { return _this.categories.push(category); }; | ||
@@ -23,2 +28,3 @@ this.addContributor = function (contributor) { return _this.contributors.push(contributor); }; | ||
this.rss2 = function () { return (0, rss2_1.default)(_this); }; | ||
this.podcast = function () { return (0, podcast_1.default)(_this); }; | ||
this.json1 = function () { return (0, json_1.default)(_this); }; | ||
@@ -25,0 +31,0 @@ this.options = options; |
@@ -62,2 +62,42 @@ export interface Item { | ||
} | ||
export interface PodcastItem { | ||
title: string; | ||
id?: string; | ||
link: string; | ||
date: Date; | ||
description?: string; | ||
content?: string; | ||
category?: Category[]; | ||
guid?: string; | ||
media: Media[]; | ||
author?: Author[]; | ||
person?: Person[]; | ||
published?: Date; | ||
copyright?: string; | ||
subTitle?: { | ||
url: string; | ||
type: string; | ||
language?: string; | ||
rel?: string; | ||
}[]; | ||
thumbnails?: { | ||
url: string; | ||
width?: number; | ||
}[]; | ||
stunServers?: string[]; | ||
trackers?: string[]; | ||
socialInteract?: SocialInteract[]; | ||
nsfw?: boolean; | ||
customTags?: CustomTag[]; | ||
} | ||
export interface PodcastLiveItem extends PodcastItem { | ||
status: LiveItemStatus; | ||
start?: string; | ||
end?: string; | ||
} | ||
export declare enum LiveItemStatus { | ||
pending = "pending", | ||
live = "live", | ||
ended = "ended" | ||
} | ||
export interface Enclosure { | ||
@@ -70,2 +110,33 @@ url: string; | ||
} | ||
export interface Media { | ||
type: string; | ||
codecs?: string; | ||
length?: number; | ||
bitrate?: number; | ||
height?: number; | ||
title?: string; | ||
rel?: string; | ||
language?: string; | ||
sources: Source[]; | ||
integrity?: SourceIntegrity[]; | ||
} | ||
export interface Source { | ||
uri: string; | ||
contentType?: string; | ||
} | ||
export interface SourceIntegrity { | ||
type: IntegrityType; | ||
value: string; | ||
} | ||
export declare enum IntegrityType { | ||
sri = "sri", | ||
pgpSignature = "pgp-signature" | ||
} | ||
export interface SocialInteract { | ||
uri: string; | ||
protocol: string; | ||
accountId?: string; | ||
accountUrl?: string; | ||
priority?: number; | ||
} | ||
export interface Author { | ||
@@ -76,2 +147,9 @@ name?: string; | ||
} | ||
export interface Person { | ||
name: string; | ||
href?: string; | ||
img?: string; | ||
role?: string; | ||
group?: string; | ||
} | ||
export interface Category { | ||
@@ -84,3 +162,4 @@ name?: string; | ||
export interface FeedOptions { | ||
id: string; | ||
id?: string; | ||
guid?: string; | ||
title: string; | ||
@@ -95,3 +174,11 @@ updated?: Date; | ||
docs?: string; | ||
medium?: string; | ||
author?: Author; | ||
managingEditor?: Author; | ||
webMaster?: Author; | ||
person?: Person[]; | ||
locked?: { | ||
isLocked: boolean; | ||
email: string; | ||
}; | ||
link?: string; | ||
@@ -102,2 +189,7 @@ description?: string; | ||
copyright: string; | ||
nsfw?: boolean; | ||
stunServers?: string[]; | ||
trackers?: string[]; | ||
customXMLNS?: CustomXMLNS[]; | ||
customTags?: CustomTag[]; | ||
} | ||
@@ -108,1 +200,13 @@ export interface Extension { | ||
} | ||
export interface CustomXMLNS { | ||
name: string; | ||
value: string; | ||
} | ||
export interface CustomTag { | ||
name: string; | ||
attributes?: { | ||
[key: string]: string; | ||
}; | ||
value?: string | CustomTag[]; | ||
cdata?: boolean; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IntegrityType = exports.LiveItemStatus = void 0; | ||
var LiveItemStatus; | ||
(function (LiveItemStatus) { | ||
LiveItemStatus["pending"] = "pending"; | ||
LiveItemStatus["live"] = "live"; | ||
LiveItemStatus["ended"] = "ended"; | ||
})(LiveItemStatus = exports.LiveItemStatus || (exports.LiveItemStatus = {})); | ||
var IntegrityType; | ||
(function (IntegrityType) { | ||
IntegrityType["sri"] = "sri"; | ||
IntegrityType["pgpSignature"] = "pgp-signature"; | ||
})(IntegrityType = exports.IntegrityType || (exports.IntegrityType = {})); | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,7 @@ "use strict"; | ||
if (typeof url === 'string') { | ||
return url.replace(/&/g, '&'); | ||
return url.replace(/&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, '''); | ||
} | ||
@@ -9,0 +13,0 @@ return url; |
{ | ||
"name": "@peertube/feed", | ||
"version": "5.0.2", | ||
"version": "5.1.0", | ||
"description": "Feed - PeerTube fork", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Chocobozzz/feed", |
@@ -27,3 +27,10 @@ import { Feed } from "../feed"; | ||
link: "https://example.com/johndoe?link=sanitized&value=2" | ||
} | ||
}, | ||
customXMLNS: [ | ||
{ | ||
name: "biz", | ||
value: "http://example.com/biz-xmlns" | ||
}, | ||
], | ||
}); | ||
@@ -30,0 +37,0 @@ |
import renderAtom from "./atom1"; | ||
import renderJSON from "./json"; | ||
import renderPodcastRSS from "./podcast"; | ||
import renderRSS from "./rss2"; | ||
import { Author, Extension, FeedOptions, Item } from "./typings"; | ||
import { Author, Extension, FeedOptions, Item, PodcastItem, PodcastLiveItem } from "./typings"; | ||
export { Author, Extension, FeedOptions, Item }; | ||
export { Author, Extension, FeedOptions, Item, PodcastItem, PodcastLiveItem }; | ||
@@ -14,2 +15,4 @@ /** | ||
items: Item[] = []; | ||
podcastItems: PodcastItem[] = []; | ||
podcastLiveItems: PodcastLiveItem[] = []; | ||
categories: string[] = []; | ||
@@ -30,2 +33,14 @@ contributors: Author[] = []; | ||
/** | ||
* Add a feed podcast item | ||
* @param podcastItem | ||
*/ | ||
public addPodcastItem = (podcastItem: PodcastItem) => this.podcastItems.push(podcastItem); | ||
/** | ||
* Add a feed podcast liveItem | ||
* @param podcastLiveItem | ||
*/ | ||
public addPodcastLiveItem = (podcastLiveItem: PodcastLiveItem) => this.podcastLiveItems.push(podcastLiveItem); | ||
/** | ||
* Add a category | ||
@@ -59,2 +74,8 @@ * @param category | ||
/** | ||
* | ||
* Returns a RSS 2.0 feed using the Podcast Namespace | ||
*/ | ||
public podcast = (): string => renderPodcastRSS(this); | ||
/** | ||
* Returns a JSON1 feed | ||
@@ -61,0 +82,0 @@ */ |
@@ -79,2 +79,56 @@ export interface Item { | ||
export interface PodcastItem { | ||
title: string | ||
id?: string | ||
link: string | ||
date: Date | ||
description?: string | ||
content?: string | ||
category?: Category[] | ||
guid?: string | ||
media: Media[] | ||
author?: Author[] | ||
person?: Person[] | ||
published?: Date | ||
copyright?: string | ||
subTitle?: { | ||
url: string | ||
type: string | ||
language?: string | ||
rel?: string | ||
}[] | ||
thumbnails?: { | ||
url: string | ||
width?: number | ||
}[] | ||
stunServers?: string[] | ||
trackers?: string[] | ||
socialInteract?: SocialInteract[] | ||
nsfw?: boolean | ||
customTags?: CustomTag[] | ||
} | ||
export interface PodcastLiveItem extends PodcastItem { | ||
status: LiveItemStatus | ||
start?: string | ||
end?: string | ||
} | ||
export enum LiveItemStatus { | ||
pending = "pending", | ||
live = "live", | ||
ended = "ended", | ||
} | ||
export interface Enclosure { | ||
@@ -88,2 +142,40 @@ url: string | ||
export interface Media { | ||
type: string | ||
codecs?: string | ||
length?: number | ||
bitrate?: number | ||
height?: number | ||
title?: string | ||
rel?: string | ||
language?: string | ||
sources: Source[] | ||
integrity?: SourceIntegrity[] | ||
} | ||
export interface Source { | ||
uri: string | ||
contentType?: string | ||
} | ||
export interface SourceIntegrity { | ||
type: IntegrityType | ||
value: string | ||
} | ||
export enum IntegrityType { | ||
sri = "sri", | ||
pgpSignature = "pgp-signature" | ||
} | ||
export interface SocialInteract { | ||
uri: string | ||
protocol: string | ||
accountId?: string | ||
accountUrl?: string | ||
priority?: number | ||
} | ||
export interface Author { | ||
@@ -95,2 +187,10 @@ name?: string | ||
export interface Person { | ||
name: string | ||
href?: string | ||
img?: string | ||
role?: string | ||
group?: string | ||
} | ||
export interface Category { | ||
@@ -104,3 +204,4 @@ name?: string | ||
export interface FeedOptions { | ||
id: string | ||
id?: string | ||
guid?: string | ||
title: string | ||
@@ -116,4 +217,9 @@ updated?: Date | ||
docs?: string | ||
medium?: string | ||
author?: Author | ||
managingEditor?: Author, | ||
webMaster?: Author, | ||
person?: Person[] | ||
locked?: { isLocked: boolean, email: string } | ||
link?: string | ||
@@ -124,2 +230,9 @@ description?: string | ||
copyright: string | ||
nsfw?: boolean, | ||
stunServers?: string[] | ||
trackers?: string[] | ||
customXMLNS?: CustomXMLNS[] | ||
customTags?: CustomTag[] | ||
} | ||
@@ -131,1 +244,13 @@ | ||
} | ||
export interface CustomXMLNS { | ||
name: string, | ||
value: string | ||
} | ||
export interface CustomTag { | ||
name: string | ||
attributes?: { [key: string]: string } | ||
value?: string | CustomTag[] | ||
cdata?: boolean | ||
} |
@@ -1,6 +0,10 @@ | ||
export function sanitize (url: string | undefined | null): string | undefined | null { | ||
export function sanitize(url: string | undefined | null): string | undefined | null { | ||
if (typeof url === 'string') { | ||
return url.replace(/&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, ''') | ||
} | ||
return url | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
356762
49
3740