diff --git a/podcast/podcast-tests.ts b/podcast/podcast-tests.ts new file mode 100644 index 0000000000..c8989d7a86 --- /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 0000000000..cfe4766ad7 --- /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; +}