From 771eca0e7db693c4675cb3b78e3e2b2c5b53eea3 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Sat, 20 Sep 2014 10:10:07 +0200 Subject: [PATCH 1/2] Add podcast --- podcast/podcast-tests.ts | 56 ++++++++++++++++++++++++++++ podcast/podcast.d.ts | 80 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 podcast/podcast-tests.ts create mode 100644 podcast/podcast.d.ts diff --git a/podcast/podcast-tests.ts b/podcast/podcast-tests.ts new file mode 100644 index 000000000..c8989d7a8 --- /dev/null +++ b/podcast/podcast-tests.ts @@ -0,0 +1,56 @@ +/// + +import Podcast = require('podcast'); + +/* lets create an rss feed */ +var feed = new Podcast({ + title: 'title', + description: 'description', + feed_url: 'http://example.com/rss.xml', + site_url: 'http://example.com', + image_url: 'http://example.com/icon.png', + docs: 'http://example.com/rss/docs.html', + author: 'Dylan Greene', + managingEditor: 'Dylan Greene', + webMaster: 'Dylan Greene', + copyright: '2013 Dylan Greene', + language: 'en', + categories: ['Category 1','Category 2','Category 3'], + pubDate: new Date('May 20, 2012 04:00:00 GMT'), + ttl: 60, + itunesAuthor: 'Max Nowack', + itunesSubtitle: 'I am a sub title', + itunesSummary: 'I am a summary', + itunesOwner: { name: 'Max Nowack', email:'max@unsou.de' }, + itunesExplicit: false, + itunesCategory: { + "name": "Entertainment", + "subcats": null + }, + itunesImage: 'http://link.to/image.png' +}); + +/* loop over data and add to feed */ +feed.item({ + title: 'item title', + description: 'use this for the content. It can include html.', + url: 'http://example.com/article4?this&that', // link to the item + guid: '1123', // optional - defaults to url + categories: ['Category 1','Category 2','Category 3','Category 4'], // optional - array of item categories + author: 'Guest Author', // optional - defaults to feed author property + date: new Date('May 27, 2012'), + lat: 33.417974, //optional latitude field for GeoRSS + long: -111.933231, //optional longitude field for GeoRSS + enclosure : {url:'...', file:'path-to-file'}, // optional enclosure + itunesAuthor: 'Max Nowack', + itunesExplicit: false, + itunesSubtitle: 'I am a sub title', + itunesSummary: 'I am a summary', + itunesDuration: 12345, + itunesKeywords: ['javascript','podcast'] +}); + +// cache the xml to send to clients +var xml = feed.xml(); + +console.log(xml); diff --git a/podcast/podcast.d.ts b/podcast/podcast.d.ts new file mode 100644 index 000000000..cfe4766ad --- /dev/null +++ b/podcast/podcast.d.ts @@ -0,0 +1,80 @@ +// Type definitions for podcast v0.1.0 +// Project: http://github.com/maxnowack/node-podcast +// Definitions by: Niklas Mollenhauer +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface PodcastStatic +{ + new(options: IFeedOptions): PodcastStatic; + + item(options: IItemOptions): void; + xml(indent?: string): string; +} + +interface IFeedOptions +{ + title: string; + description?: string; + generator?: string; + feed_url: string; + site_url: string; + image_url?: string; + docs?: string; + author: string; + managingEditor?: string; + webMaster?: string; + copyright?: string; + language?: string; + categories?: string[]; + pubDate?: Date; + ttl?: number; + itunesAuthor?: string; + itunesSubtitle?: string; + itunesSummary?: string; + itunesOwner?: IItunesOwner; + itunesExplicit?: boolean; + itunesCategory?: IItunesCategory; + itunesImage?: string; +} + +interface IItunesOwner +{ + name: string; + email: string; +} +interface IItunesCategory +{ + name: string; + subcats: IItunesSubCategory[] +} +interface IItunesSubCategory +{ + name: string; + subcat: string[] /* ? */ +} + +interface IItemOptions +{ + title: string; + description: string; + url: string; + guid: string; + categories?: string[]; + author?: string; + date: Date; + lat?: number; + long?: number; + itunesAuthor?: string; + itunesExplicit?: boolean; + itunesSubtitle?: string; + itunesSummary?: string; + itunesDuration?: number; + itunesKeywords?: string[]; +} + +declare var Podcast: PodcastStatic; + +declare module "podcast" +{ + export = Podcast; +} From 2a63a2d7102eee1659f596f8655fbe4ff577583c Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Sat, 20 Sep 2014 10:13:53 +0200 Subject: [PATCH 2/2] Add myself to contributors --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 10ebf956d..540d91252 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -288,6 +288,7 @@ All definitions files include a header with the author and editors, so at some p * [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) * [PixiJS](https://github.com/GoodBoyDigital/pixi.js) (by [Pedro Casaubon](https://github.com/xperiments)) * [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH)) +* [podcast](http://github.com/maxnowack/node-podcast) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/)) * [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [ProgressJs](http://usablica.github.io/progress.js/) (by [Shunsuke Ohtani](https://github.com/zaneli))