Skip to content

Commit

Permalink
Hacking Feeds module to have a meetup.com version of the RSS feed parser
Browse files Browse the repository at this point in the history
  • Loading branch information
shrop committed Nov 17, 2011
1 parent 95b5f04 commit 1692ec4
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
11 changes: 11 additions & 0 deletions www/sites/all/modules/feeds/feeds.plugins.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ function _feeds_feeds_plugins() {
'path' => $path,
),
);
$info['FeedsSyndicationParserMeetup'] = array(
'name' => 'Common syndication parser for meetup.com',
'description' => 'Parse RSS and Atom feeds on meetup.com.',
'help' => 'Parse meetup.com XML feeds in RSS 1, RSS 2 and Atom format.',
'handler' => array(
'parent' => 'FeedsParser',
'class' => 'FeedsSyndicationParserMeetup',
'file' => 'FeedsSyndicationParserMeetup.inc',
'path' => $path,
),
);
$info['FeedsOPMLParser'] = array(
'name' => 'OPML parser',
'description' => 'Parse OPML files.',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/**
* Class definition for Common Syndication Parser Meetup.
*
* Parses RSS and Atom feeds.
*/
class FeedsSyndicationParserMeetup extends FeedsParser {

/**
* Implements FeedsParser::parse().
*/
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
$feed = common_syndication_parser_parse($fetcher_result->getRaw());
$result = new FeedsParserResult();
$result->title = $feed['title'];
$result->description = $feed['description'];
$result->time = $feed['description'];
$result->link = $feed['link'];
if (is_array($feed['items'])) {
foreach ($feed['items'] as $item) {
if (isset($item['geolocations'])) {
foreach ($item['geolocations'] as $k => $v) {
$item['geolocations'][$k] = new FeedsGeoTermElement($v);
}
}
$result->items[] = $item;
}
}
return $result;
}

/**
* Return mapping sources.
*
* At a future point, we could expose data type information here,
* storage systems like Data module could use this information to store
* parsed data automatically in fields with a correct field type.
*/
public function getMappingSources() {
return array(
'title' => array(
'name' => t('Title'),
'description' => t('Title of the feed item.'),
),
'description' => array(
'name' => t('Description'),
'description' => t('Description of the feed item.'),
),
'description' => array(
'name' => t('Event date/time'),
'description' => t('Event date/time parsed from the description field.'),
),
'author_name' => array(
'name' => t('Author name'),
'description' => t('Name of the feed item\'s author.'),
),
'timestamp' => array(
'name' => t('Published date'),
'description' => t('Published date as UNIX time GMT of the feed item.'),
),
'url' => array(
'name' => t('Item URL (link)'),
'description' => t('URL of the feed item.'),
),
'guid' => array(
'name' => t('Item GUID'),
'description' => t('Global Unique Identifier of the feed item.'),
),
'tags' => array(
'name' => t('Categories'),
'description' => t('An array of categories that have been assigned to the feed item.'),
),
'geolocations' => array(
'name' => t('Geo Locations'),
'description' => t('An array of geographic locations with a name and a position.'),
),
) + parent::getMappingSources();
}
}

0 comments on commit 1692ec4

Please sign in to comment.