Skip to content

Commit

Permalink
initial feeds_meetup module commit
Browse files Browse the repository at this point in the history
still has bugs with loading correctly and is missing the regular
expression for parsing meetup description for event date and converting
to unix timestamp
  • Loading branch information
tecto committed Feb 16, 2012
1 parent 4ff67a9 commit 76f1efc
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
77 changes: 77 additions & 0 deletions www/sites/all/modules/feeds_meetup/MeetupParser.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

/**
* Class definition for Meetup RSS Parser.
*
* Parses Meetup RSS feeds.
*/
class MeetupParser 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->timestamp = '1327317711';
$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.'),
),
'author_name' => array(
'name' => t('Author name'),
'description' => t('Name of the feed item\'s author.'),
),
// 'timestamp' => array(
// 'name' => t('Event date'),
// 'description' => t('Event date as UNIX time GMT, parsed from the description.'),
// ),
'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();
}
}
6 changes: 6 additions & 0 deletions www/sites/all/modules/feeds_meetup/feeds_meetup.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = Feeds Meetup
description = Meetup Event RSS Support
dependencies[] = feeds
package = Feeds
core = 7.x
files[] = feeds_meetup.module
29 changes: 29 additions & 0 deletions www/sites/all/modules/feeds_meetup/feeds_meetup.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* @file feeds_meetup.module
* Support Meetup RSS event feeds
*/

/**
* Implements hook_feeds_plugins().
*/
function feeds_meetup_feeds_plugins() {
$info = array();
$info['MeetupParser'] = array(
'name' => 'Meetup parser',
'description' => 'Parse Meetup RSS.',
'help' => 'Parse event date from meetup description.',
'handler' => array(
'parent' => 'FeedsParser', // Being directly or indirectly an extension of FeedsParser makes a plugin a parser plugin.
'class' => 'MeetupParser',
'file' => 'MeetupParser.inc',
'path' => drupal_get_path('module', 'feeds_meetup'),
),
);
return $info;
}

function feeds_meetup_enable() {
//clear the cache to display in Feeds as available plugin.
cache_clear_all('plugins:feeds:plugins', 'cache');
}

0 comments on commit 76f1efc

Please sign in to comment.