mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-11 19:15:33 +03:00
de8cee6a1c
* Debug mode improvements - Improve debug warning message - Restore error reporting in debug mode - Fix 'notice' messages for unset fields * Add parsing utility functions html.php - extractFromDelimiters - stripWithDelimiters - stripRecursiveHTMLSection - markdownToHtml (partial) bridges - remove now-duplicate functions - call functions from html.php instead * [Anidex] New bridge Anime torrent tracker * [Anime-Ultime] Restore thumbnail * [CNET] Recreate bridge Full rewrite as the previous one was broken * [Dilbert] Minor URI fix Use new self::URI property * [EstCeQuonMetEnProd] Fix content extraction Bridge was broken * [Facebook] Fix "SpSonsSoriSsés" label ... which was taking space in item title * [Futura-Sciences] Use HTTPS, More cleanup Use HTTPS as FS now offer HTTPS Clean additional useless HTML elements * [GBATemp] Multiple fixes - Fix categories: missing "break" statements - Restore thumbnail as enclosure - Fix date extraction - Fix user blog post extraction - Use getSimpleHTMLDOMCached * [JapanExpo] Fix bridge, HTTPS, thumbnails - Fix getSimpleHTMLDOMCached call - Upgrade to HTTPS as JE now offers HTTPS - Restore thumbnails as enclosures * [LeMondeInformatique] Fix bridge, HTTPS - Upgrade to HTTPS as LMI now offers HTTPS - Restore thumbnails using small images - Fix content extraction - Fix text encoding issue * [Nextgov] Fix content extraction - Restore thumbnail and use small image - Field extraction fixes * [NextInpact] Add categories and filtering by type - Offer all RSS feeds - Allow filtering by article type - Implement extraction for brief articles - Remove article limit, many brief articles are publied all at once * [NyaaTorrents] New bridge Anime torrent tracker * [Releases3DS] Cache content, restore thumbnail - Use getSimpleHTMLDOMCached - Restore thumbnail as enclosure * [TheHackerNews] Fix bridge - Fix content extraction including article body - Restore thumbnail as enclosure * [WeLiveSecurity] HTTPS, Fix content extraction - Upgrade to HTTPS as WLS now offers HTTPS - Fix content extraction including article body * [WordPress] Reduce timeout, more content selectors - Reduce timeout to use default one (1h) - Add new content selector (articleBody) - Find thumbnail and set as enclosure - Fix <script> cleanup * [YGGTorrent] Increase limit, use cache - Increase item limit as uploads are very frequent - Use getSimpleHTMLDOMCached * [ZDNet] Rewrite with FeedExpander - Upgrade to HTTPS as ZD now offers HTTPS - Use FeedExpander for secondary fields - Fix content extraction for article body * [Main] Handle MIME type for enclosures Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content). One can force enclosure type using #.ext anchor (hacky, needs improving) * [FeedExpander] Improve field extraction - Add support for passing enclosures - Improve author and uri extraction - Fix 'notice' PHP error messages * [Pull] Coding style fixes for #802 * [Pull] Implementing changes for #802 - Fix coding style issues with str append - Remove useless CACHE_TIMEOUT - Use count() instead of $limit - Use defaultLinkTo() + handle strings - Use http_build_query() - Fix missing </em> - Remove error_reporting(0) - warning CSS (@LogMANOriginal) - Fix typo in FeedExpander comment * [Main] More documentation for markdownToHtml See #802 for more details
70 lines
2.1 KiB
PHP
70 lines
2.1 KiB
PHP
<?php
|
|
class NextgovBridge extends FeedExpander {
|
|
|
|
const MAINTAINER = 'ORelio';
|
|
const NAME = 'Nextgov Bridge';
|
|
const URI = 'https://www.nextgov.com/';
|
|
const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.';
|
|
|
|
const PARAMETERS = array( array(
|
|
'category' => array(
|
|
'name' => 'Category',
|
|
'type' => 'list',
|
|
'values' => array(
|
|
'All' => 'all',
|
|
'Technology News' => 'technology-news',
|
|
'CIO Briefing' => 'cio-briefing',
|
|
'Emerging Tech' => 'emerging-tech',
|
|
'Cloud' => 'cloud-computing',
|
|
'Cybersecurity' => 'cybersecurity',
|
|
'Mobile' => 'mobile',
|
|
'Health' => 'health',
|
|
'Defense' => 'defense',
|
|
'Big Data' => 'big-data'
|
|
)
|
|
)
|
|
));
|
|
|
|
public function collectData(){
|
|
$this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10);
|
|
}
|
|
|
|
protected function parseItem($newsItem){
|
|
$item = parent::parseItem($newsItem);
|
|
|
|
$article_thumbnail = 'https://cdn.nextgov.com/nextgov/images/logo.png';
|
|
$item['content'] = '<p><b>' . $item['content'] . '</b></p>';
|
|
|
|
$namespaces = $newsItem->getNamespaces(true);
|
|
if(isset($namespaces['media'])) {
|
|
$media = $newsItem->children($namespaces['media']);
|
|
if(isset($media->content)) {
|
|
$attributes = $media->content->attributes();
|
|
$item['content'] = '<p><img src="' . $attributes['url'] . '"></p>' . $item['content'];
|
|
$article_thumbnail = str_replace(
|
|
'large.jpg',
|
|
'small.jpg',
|
|
strval($attributes['url'])
|
|
);
|
|
}
|
|
}
|
|
|
|
$item['enclosures'] = array($article_thumbnail);
|
|
$item['content'] .= $this->extractContent($item['uri']);
|
|
return $item;
|
|
}
|
|
|
|
private function extractContent($url){
|
|
$article = getSimpleHTMLDOMCached($url);
|
|
|
|
if (!is_object($article))
|
|
return 'Could not request Nextgov: ' . $url;
|
|
|
|
$contents = $article->find('div.wysiwyg', 0);
|
|
$contents->find('svg.content-tombstone', 0)->outertext = '';
|
|
$contents = $contents->innertext;
|
|
$contents = stripWithDelimiters($contents, '<div class="ad-container">', '</div>');
|
|
$contents = stripWithDelimiters($contents, '<div', '</div>'); //ad outer div
|
|
return trim(stripWithDelimiters($contents, '<script', '</script>'));
|
|
}
|
|
}
|