first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
<?php
/**
* @file
* feeds_news.features.field.inc
*/
/**
* Implementation of hook_field_default_fields().
*/
function feeds_news_field_default_fields() {
$fields = array();
// Exported field: 'node-feed_item-field_feed_item_description'
$fields['node-feed_item-field_feed_item_description'] = array(
'field_config' => array(
'active' => '1',
'cardinality' => '1',
'deleted' => '0',
'entity_types' => array(),
'field_name' => 'field_feed_item_description',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',
),
'table' => 'filter_format',
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'module' => 'text',
'settings' => array(),
'translatable' => '1',
'type' => 'text_with_summary',
),
'field_instance' => array(
'bundle' => 'feed_item',
'default_value' => NULL,
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => '0',
),
'full' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'rss' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'teaser' => array(
'label' => 'hidden',
'module' => 'text',
'settings' => array(
'trim_length' => 600,
),
'type' => 'text_trimmed',
'weight' => '0',
),
),
'entity_type' => 'node',
'field_name' => 'field_feed_item_description',
'label' => 'Description',
'required' => 0,
'settings' => array(
'display_summary' => 0,
'text_processing' => '1',
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'rows' => '20',
'summary_rows' => 5,
),
'type' => 'text_textarea_with_summary',
'weight' => '-4',
),
),
);
// Translatables
// Included for use with string extractors like potx.
t('Description');
return $fields;
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* @file
* feeds_news.features.inc
*/
/**
* Implementation of hook_ctools_plugin_api().
*/
function feeds_news_ctools_plugin_api() {
list($module, $api) = func_get_args();
if ($module == "feeds" && $api == "feeds_importer_default") {
return array("version" => 1);
}
}
/**
* Implementation of hook_views_api().
*/
function feeds_news_views_api() {
list($module, $api) = func_get_args();
if ($module == "views" && $api == "views_default") {
return array("version" => 3.0);
}
}
/**
* Implementation of hook_node_info().
*/
function feeds_news_node_info() {
$items = array(
'feed' => array(
'name' => t('Feed'),
'base' => 'node_content',
'description' => t('Subscribe to RSS or Atom feeds. Creates nodes of the content type "Feed item" from feed content.'),
'has_title' => '1',
'title_label' => t('Title'),
'help' => '',
),
'feed_item' => array(
'name' => t('Feed item'),
'base' => 'node_content',
'description' => t('This content type is being used for automatically aggregated content from feeds.'),
'has_title' => '1',
'title_label' => t('Title'),
'help' => '',
),
);
return $items;
}

View File

@@ -0,0 +1,124 @@
<?php
/**
* @file
* feeds_news.feeds_importer_default.inc
*/
/**
* Implementation of hook_feeds_importer_default().
*/
function feeds_news_feeds_importer_default() {
$export = array();
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'feed';
$feeds_importer->config = array(
'name' => 'Feed',
'description' => 'Import RSS or Atom feeds, create nodes from feed items.',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => 1,
'use_pubsubhubbub' => 0,
'designated_hub' => '',
),
),
'parser' => array(
'plugin_key' => 'FeedsSyndicationParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'feed_item',
'update_existing' => '0',
'expire' => '-1',
'mappings' => array(
0 => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
1 => array(
'source' => 'timestamp',
'target' => 'created',
'unique' => FALSE,
),
2 => array(
'source' => 'url',
'target' => 'url',
'unique' => 1,
),
3 => array(
'source' => 'guid',
'target' => 'guid',
'unique' => 1,
),
4 => array(
'source' => 'description',
'target' => 'field_feed_item_description',
'unique' => FALSE,
),
),
'input_format' => 'filtered_html',
'author' => 0,
),
),
'content_type' => 'feed',
'update' => 0,
'import_period' => '1800',
'expire_period' => 3600,
'import_on_create' => 1,
'process_in_background' => FALSE,
);
$export['feed'] = $feeds_importer;
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'opml';
$feeds_importer->config = array(
'name' => 'OPML import',
'description' => 'Import subscriptions from OPML files. Use together with "Feed" configuration.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'direct' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsOPMLParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'feed',
'update_existing' => 0,
'expire' => '-1',
'mappings' => array(
0 => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
1 => array(
'source' => 'xmlurl',
'target' => 'feeds_source',
'unique' => 1,
),
),
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['opml'] = $feeds_importer;
return $export;
}

View File

@@ -0,0 +1,25 @@
core = "7.x"
dependencies[] = "features"
dependencies[] = "feeds"
dependencies[] = "views"
description = "A news aggregator built with feeds, creates nodes from imported feed items. With OPML import."
features[ctools][] = "feeds:feeds_importer_default:1"
features[ctools][] = "views:views_default:3.0"
features[feeds_importer][] = "feed"
features[feeds_importer][] = "opml"
features[field][] = "node-feed_item-field_feed_item_description"
features[node][] = "feed"
features[node][] = "feed_item"
features[views_view][] = "feeds_defaults_feed_items"
files[] = "feeds_news.module"
files[] = "feeds_news.test"
name = "Feeds News"
package = "Feeds"
php = "5.2.4"
; Information added by drupal.org packaging script on 2012-10-24
version = "7.x-2.0-alpha7"
core = "7.x"
project = "feeds"
datestamp = "1351111319"

View File

@@ -0,0 +1,8 @@
<?php
/**
* @file
* Empty module file.
*/
include_once('feeds_news.features.inc');

View File

@@ -0,0 +1,127 @@
<?php
/**
* @file
* Tests for feeds_news feature.
*/
/**
* Test Feed configuration.
*/
class FeedsExamplesFeedTestCase extends FeedsWebTestCase {
public static function getInfo() {
return array(
'name' => 'Feature: Feed',
'description' => 'Test "Feed" default configuration.',
'group' => 'Feeds',
'dependencies' => array('features', 'views'),
);
}
public function setUp() {
parent::setUp(array('features', 'views', 'feeds_news'));
}
/**
* Run tests.
*/
public function test() {
$nid = $this->createFeedNode('feed', NULL, '', 'feed');
// Assert menu tabs for feed nodes does not show up on non-feed nodes.
$this->drupalGet("node/{$nid}/feed-items");
$this->assertResponse(200);
$not_feed_node = $this->drupalCreateNode();
$this->drupalGet("node/{$not_feed_node->nid}/feed-items");
$this->assertResponse(404);
// Assert results.
$count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'")->fetchField();
$this->assertEqual($count, 10, 'Found the correct number of feed item nodes in database.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node'")->fetchField();
$this->assertEqual($count, 10, 'Found the correct number of records in feeds_item.');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Open Atrium Translation Workflow: Two Way Translation Updates'")->fetchField();
$this->assertEqual($count, 1, 'Found title.');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Week in DC Tech: October 5th Edition'")->fetchField();
$this->assertEqual($count, 1, 'Found title.');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Integrating the Siteminder Access System in an Open Atrium-based Intranet'")->fetchField();
$this->assertEqual($count, 1, 'Found title.');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Scaling the Open Atrium UI'")->fetchField();
$this->assertEqual($count, 1, 'Found title.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND url = 'http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating'")->fetchField();
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND url = 'http://developmentseed.org/blog/2009/oct/05/week-dc-tech-october-5th-edition'")->fetchField();
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND guid = '974 at http://developmentseed.org'")->fetchField();
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND guid = '970 at http://developmentseed.org'")->fetchField();
$this->assertEqual($count, 1, 'Found feed_node_item record.');
// Remove all items
$this->drupalPost("node/$nid/delete-items", array(), 'Delete');
$this->assertText('Deleted 10 nodes');
// Import again.
$this->drupalPost("node/$nid/import", array(), 'Import');
$this->assertText('Created 10 nodes');
// Delete and assert all items gone.
$this->drupalPost("node/$nid/delete-items", array(), 'Delete');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'")->fetchField();
$this->assertEqual($count, 0, 'Found the correct number of feed item nodes in database.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node'")->fetchField();
$this->assertEqual($count, 0, 'Found the correct number of records in feeds_item.');
// Create a batch of nodes.
$this->createFeedNodes('feed', 10, 'feed');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'")->fetchField();
$this->assertEqual($count, 100, 'Imported 100 nodes.');
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node'")->fetchField();
$this->assertEqual($count, 100, 'Found 100 records in feeds_item.');
}
}
/**
* Test OPML import configuration.
*/
class FeedsExamplesOPMLTestCase extends FeedsWebTestCase {
public static function getInfo() {
return array(
'name' => 'Feature: OPML import',
'description' => 'Test "OPML import" default configuration.',
'group' => 'Feeds',
);
}
/**
* Enable feeds_news feature.
*/
public function setUp() {
parent::setUp(array('feeds_news'));
}
/**
* Run tests.
*/
public function test() {
// Import OPML and assert.
$file = $this->generateOPML();
$this->importFile('opml', $file);
$this->assertText('Created 3 nodes');
$count = db_query("SELECT COUNT(*) FROM {feeds_source}")->fetchField();
$this->assertEqual($count, 4, 'Found correct number of items.');
// Import a feed and then delete all items from it.
$this->drupalPost('node/1/import', array(), 'Import');
$this->assertText('Created 10 nodes');
$this->drupalPost('node/1/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 nodes');
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* @file
* feeds_news.views_default.inc
*/
/**
* Implementation of hook_views_default_views().
*/
function feeds_news_views_default_views() {
$export = array();
$view = new view;
$view->name = 'feeds_defaults_feed_items';
$view->description = 'Show feed items for a feed node. Use together with default importer configuration "Feed".';
$view->tag = 'Feeds defaults';
$view->base_table = 'node';
$view->human_name = '';
$view->core = 0;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
$handler->display->display_options['row_options']['links'] = 1;
$handler->display->display_options['row_options']['comments'] = 0;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['text']['id'] = 'area';
$handler->display->display_options['empty']['text']['table'] = 'views';
$handler->display->display_options['empty']['text']['field'] = 'area';
$handler->display->display_options['empty']['text']['empty'] = FALSE;
$handler->display->display_options['empty']['text']['content'] = 'There are no items for this feed at the moment.';
$handler->display->display_options['empty']['text']['format'] = '1';
/* Relationship: Feeds item: Owner feed */
$handler->display->display_options['relationships']['feed_nid_1']['id'] = 'feed_nid_1';
$handler->display->display_options['relationships']['feed_nid_1']['table'] = 'feeds_item';
$handler->display->display_options['relationships']['feed_nid_1']['field'] = 'feed_nid';
$handler->display->display_options['relationships']['feed_nid_1']['required'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['relationship'] = 'feed_nid_1';
$handler->display->display_options['arguments']['nid']['default_action'] = 'not found';
$handler->display->display_options['arguments']['nid']['title_enable'] = 1;
$handler->display->display_options['arguments']['nid']['title'] = 'Articles from %1';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['specify_validation'] = 1;
$handler->display->display_options['arguments']['nid']['validate']['type'] = 'node';
$handler->display->display_options['arguments']['nid']['validate_options']['types'] = array(
'feed' => 'feed',
);
$handler->display->display_options['arguments']['nid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['nid']['not'] = 0;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'feed_item' => 'feed_item',
);
$handler->display->display_options['filters']['type']['expose']['operator'] = FALSE;
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['path'] = 'node/%/feed-items';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'View items';
$handler->display->display_options['menu']['weight'] = '-9';
$translatables['feeds_defaults_feed_items'] = array(
t('Defaults'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('There are no items for this feed at the moment.'),
t('Owner feed'),
t('All'),
t('Articles from %1'),
t('Page'),
);
$export['feeds_defaults_feed_items'] = $view;
return $export;
}