NetNewsWire RSS Clipboard Formats
24 Sep 2002
The Pitch
Here’s the simple—and, I hope, self-evident—pitch to developers of other RSS news readers, weblog editors, and so on:
Apps that work well with other apps are more valuable than apps that isolate themselves.
One of the most basic levels of working together is being able to read each other’s clipboard and drag-and-drop formats.
If you’re writing a text editor, this isn’t a big deal, since there’s plenty of built-in support for text on the clipboard. But in the case of RSS news readers and weblog editors there are no built-in RSS item and RSS source clipboard flavors.
This page documents (with sample code) the formats NetNewsWire exports. (It uses the same formats for copying and dragging.)
(Note: both NetNewsWire and NetNewsWire Lite use these formats.)
Two data flavors
NetNewsWire has three main drag and copy sources: the Subscriptions pane, the Headlines pane, and the Sites Drawer.
The Subscriptions pane and Sites Drawer both contain RSS sources. An RSS source contains information about a site that has an RSS feed.
The Headlines pane contains RSS items. An RSS item contains information about a single item in an RSS feed.
RSS Sources
The RSS Source flavor is always an array of dictionaries. It contains one or more individual sources.
Each item in the array (each individual source, each dictionary) contains three required elements (all strings):
sourceName: the name of the sourcesourceHomeURL: the URL of the source’s home pagesourceRSSURL: the URL of the source’s RSS feed
sourceName and sourceHomeURL may be empty strings, but they are required. sourceRSSURL must not be empty.
sourceDescription may also be included, but it’s optional.
An application may include additional elements in an individual source. For instance, NetNewsWire sometimes includes a sourceSessionID element which identifies a current source for the duration of the current session. Other applications should not count on the presence or meaning of this or any other additional elements.
However, this leaves room for the spec to grow. If certain conventions are created by consensus, then they can be formally listed as optional elements.
The RSS Source flavor is identified in Carbon apps as 'RSSs.' In Cocoa apps it’s "CorePasteboardFlavorType 0x52535373."
The raw data that’s put on the clipboard is in XML format: it uses Apple’s plist format. See the sample code for demonstrations of how to get data from the clipboard.
RSS Items
An RSS Item describes a single item in a news feed.
As with the RSS Source flavor, it’s always an array. It contains one or more items (dictionaries, again), each one of which describes a single headline.
Each item contains three required elements:
rssItemLink: the URL this item links torssItemTitle: the title of this itemrssItemDescription: the description for this item
Any one or more of the required items may be empty strings, but they must all be present.
An application may include additional information, but, again, other applications should not rely on the presence or meaning of any additional information. (And, again, this allows this spec to grow in the future.)
Also, each individual item may contain information about the source it comes from by following the RSS Sources section above. In other words, an individual item may contain sourceName, sourceHomeURL, and sourceRSSURL items. This is recommended—if for no other reason than that it allows weblog editors to add attribution to an RSS item being posted to a weblog. It’s recommended but it’s optional.
The RSS Item flavor is identified in Carbon apps as 'RSSi.' In Cocoa apps it’s "CorePasteboardFlavorType 0x52535369."
As with RSS Sources, the raw data on the clipboard is in Apple’s property list format. The sample code shows how to get information from this format.
Sample code
The sample code (download) includes source for two applications.
- GetRSSCarbon is a Carbon application that gets an RSS item or RSS source from the clipboard and displays the info in a window.
- RSSDropCocoa is a Cocoa application that accepts an RSS item or RSS source via drag-and-drop and display the info in a window.
So that no mistake is made: you are utterly free to use this code, adapted however you like, in your applications, whether commercial, shareware, freeware, or open source. The code is provided under the BSD license. (Note that step one would be to add better error handling—this is, after all, sample code rather than production code.)
To test GetRSSCarbon: launch NetNewsWire and launch GetRSSCarbon. In NetNewsWire, copy from the Subscriptions pane or the Headlines pane. In GetRSSCarbon click the Get RSS From Clipboard button. The information on the clipboard will then be displayed in GetRSSCarbon’s window.
To test RSSDropCocoa: launch NetNewsWire and launch RSSDropCocoa. Drag a subscription, headline, or site in the Sites Drawer to the little box in the RSSDropCocoa app that says Drop Here. The info contained in the dropped item will be displayed in RSSDropCocoa’s window.
Thanks To
Special thanks to Steve Ivy, who intially contacted me about coming up with common clipboard formats for RSS sources and RSS items. His feedback on earlier drafts of this spec was immensely helpful.