diff options
43 files changed, 55 insertions, 765 deletions
@@ -1,122 +1,15 @@ -ttrss_plugin-af_feedmod -======================= - -This is a plugin for Tiny Tiny RSS (tt-rss). It allows you to replace an article's contents by the contents of an element on the linked URL's page, i.e. create a "full feed". +YAFPP - Yet Another Full Post Plugin +==================================== +This is a Tiny Tiny RSS plugin that uses [full-text-rss](http://code.fivefilters.org/full-text-rss) to get the full article content. Installation ------------ -Checkout the directory into your plugins folder like this (from tt-RSS root directory): - -```sh -$ cd /var/www/ttrss -$ git clone git://github.com/mbirth/ttrss_plugin-af_feedmod.git plugins/af_feedmod -``` - -Then enable the plugin in preferences. +Checkout the directory into your plugins folder, then enable the plugin in preferences. Configuration ------------- -The configuration is done in JSON format. In the preferences, you'll find a new tab called *FeedMod*. Use the large field to enter/modify the configuration data and click the **Save** button to store it. - -A configuration looks like this: - -```json -{ - -"heise.de": { - "type": "xpath", - "xpath": "div[@class='meldung_wrapper']", - "force_charset": "utf-8" -}, -"berlin.de/polizei": { - "type": "xpath", - "xpath": "div[@class='bacontent']" -}, -"n24.de": { - "type": "xpath", - "xpath": "div[@class='news']" -}, -"golem0Bde0C": { - "type": "xpath", - "xpath": "article" -}, -"oatmeal": { - "type": "xpath", - "xpath": "div[@id='comic']" -}, -"blog.beetlebum.de": { - "type": "xpath", - "xpath": "div[@class='entry-content']", - "cleanup": [ "header", "footer" ], -} - -} -``` - -The *array key* is part of the URL of the article links(!). You'll notice the `golem0Bde0C` in the last entry: That's because all their articles link to something like `http://rss.feedsportal.com/c/33374/f/578068/p/1/s/3f6db44e/l/0L0Sgolem0Bde0Cnews0Cthis0Eis0Ean0Eexample0A10Erss0Bhtml/story01.htm` and to have the plugin match that URL and not interfere with other feeds using *feedsportal.com*, I used the part `golem0Bde0C`. - -**type** has to be `xpath` for now. Maybe there will be more types in the future. - -The **xpath** value is the actual Xpath-element to fetch from the linked page. Omit the leading `//` - they will get prepended automatically. - -If **type** was set to `xpath` there is an additional option **cleanup** available. Its an array of Xpath-elements (relative to the fetched node) to remove from the fetched node. Omit the leading `//` - they will get prepended automatically. - -**force_charset** allows to override automatic charset detection. If it is omitted, the charset will be parsed from the HTTP headers or loadHTML() will decide on its own. - - -If you get an error about "Invalid JSON!", you can use [JSONLint](http://jsonlint.com/) to locate the erroneous part. - - -XPath ------ - -### Tools - -To test your XPath expressions, you can use these Chrome extensions: - -* [XPath Helper](https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl) -* [xPath Viewer](https://chrome.google.com/webstore/detail/xpath-viewer/oemacabgcknpcikelclomjajcdpbilpf) -* [xpathOnClick](https://chrome.google.com/webstore/detail/xpathonclick/ikbfbhbdjpjnalaooidkdbgjknhghhbo) - - -### Examples - -Some XPath expressions you could need (the `//` is automatically prepended and must be omitted in the FeedMod configuration): - -##### HTML5 <article> tag - -```html -<article>…article…</article> -``` - -```xslt -//article -``` - -##### DIV inside DIV - -```html -<div id="content"><div class="box_content">…article…</div></div>` -``` - -```xslt -//div[@id='content']/div[@class='box_content'] -``` - -##### Multiple classes - -```html -<div class="post-body entry-content xh-highlight">…article…</div> -``` - -```xslt -//div[starts-with(@class ,'post-body')] -``` -or -```xslt -//div[contains(@class, 'entry-content')] -``` +Enter the URL to your Full-text-RSS installation in the preferences. @@ -1,6 +1,6 @@ <?php -class Af_Feedmod extends Plugin implements IHandler +class YAFPP extends Plugin implements IHandler { private $host; @@ -8,9 +8,8 @@ class Af_Feedmod extends Plugin implements IHandler { return array( 1.0, // version - 'Replace feed contents by contents from the linked page', // description - 'mbirth', // author - false, // is_system + 'Replace feed contents by contents from the linked page using full-text-rss', // description + 'schneefux' // author ); } @@ -23,8 +22,7 @@ class Af_Feedmod extends Plugin implements IHandler { $this->host = $host; - $host->add_hook($host::HOOK_PREFS_TABS, $this); -# only allowed for system plugins: $host->add_handler('pref-feedmod', '*', $this); + $host->add_hook($host::HOOK_PREFS_TAB, $this); $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); } @@ -49,168 +47,70 @@ class Af_Feedmod extends Plugin implements IHandler function hook_article_filter($article) { - global $fetch_last_content_type; + $ftr = $this->host->get($this, "ftr_url"); + $url = trim($article['link']); + $request = $ftr.'makefulltextfeed.php?format=json&url='.urlencode($url); - $json_conf = $this->host->get($this, 'json_conf'); - $owner_uid = $article['owner_uid']; - $data = json_decode($json_conf, true); + if (version_compare(VERSION, '1.7.9', '>=')) { + $result = fetch_file_contents($request); + } else { + // fallback to file_get_contents() + $result = file_get_contents($request); + } + $result = json_decode($result, true); + $content = $result['rss']['channel']['item']['description']; - if (!is_array($data)) { - // no valid JSON or no configuration at all - return $article; + if (!(strcmp($content, "[unable to retrieve full-text content]") == 0)) { + $article['title'] = $result['rss']['channel']['item']['title']; + $article['content'] = $content; } + return $article; + } - foreach ($data as $urlpart=>$config) { - if (strpos($article['link'], $urlpart) === false) continue; // skip this config if URL not matching - if (strpos($article['plugin_data'], "feedmod,$owner_uid:") !== false) { - // do not process an article more than once - if (isset($article['stored']['content'])) $article['content'] = $article['stored']['content']; - break; - } - - switch ($config['type']) { - case 'xpath': - $doc = new DOMDocument(); - $link = trim($article['link']); - - if (version_compare(VERSION, '1.7.9', '>=')) { - $html = fetch_file_contents($link); - $content_type = $fetch_last_content_type; - } else { - // fallback to file_get_contents() - $html = file_get_contents($link); - - // try to fetch charset from HTTP headers - $headers = $http_response_header; - $content_type = false; - foreach ($headers as $h) { - if (substr(strtolower($h), 0, 13) == 'content-type:') { - $content_type = substr($h, 14); - // don't break here to find LATEST (if redirected) entry - } - } - } - - $charset = false; - if (!isset($config['force_charset'])) { - if ($content_type) { - preg_match('/charset=(\S+)/', $content_type, $matches); - if (isset($matches[1]) && !empty($matches[1])) $charset = $matches[1]; - } - } else { - // use forced charset - $charset = $config['force_charset']; - } - - if ($charset && isset($config['force_unicode']) && $config['force_unicode']) { - $html = iconv($charset, 'utf-8', $html); - $charset = 'utf-8'; - } - - if ($charset) { - $html = '<?xml encoding="' . $charset . '">' . $html; - } - - - - + function hook_prefs_tab($args) { + if ($args != "prefPrefs") return; - @$doc->loadHTML($html); + print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__("YAFPP: full-text-rss")."\">"; - if ($doc) { - $basenode = false; - $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//'.$config['xpath'].')'); // find main DIV according to config + print "<br/>"; - if ($entries->length > 0) $basenode = $entries->item(0); + $ftr_url = $this->host->get($this, "ftr_url"); + print "<form dojoType=\"dijit.form.Form\">"; - if ($basenode) { - // remove nodes from cleanup configuration - if (isset($config['cleanup'])) { - if (!is_array($config['cleanup'])) { - $config['cleanup'] = array($config['cleanup']); - } - foreach ($config['cleanup'] as $cleanup) { - $nodelist = $xpath->query('//'.$cleanup, $basenode); - foreach ($nodelist as $node) { - if ($node instanceof DOMAttr) { - $node->ownerElement->removeAttributeNode($node); - } - else { - $node->parentNode->removeChild($node); - } - } + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> + evt.preventDefault(); + if (this.validate()) { + console.log(dojo.objectToQuery(this.getValues())); + new Ajax.Request('backend.php', { + parameters: dojo.objectToQuery(this.getValues()), + onComplete: function(transport) { + notify_info(transport.responseText); } - } - $article['content'] = $doc->saveXML($basenode); - $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; - } - } - break; + }); + } + </script>"; - default: - // unknown type or invalid config - continue; - } + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">"; + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">"; + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"yafpp\">"; + print "<table width=\"100%\" class=\"prefPrefsList\">"; + print "<tr><td width=\"40%\">".__("URL to full-text-rss")."</td>"; + print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" name=\"ftr_url\" regExp='^(http|https)://.*' value=\"$ftr_url\"></td></tr>"; + print "</table>"; + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".__("Save")."</button>"; - break; // if we got here, we found the correct entry in $data, do not process more - } + print "</form>"; - return $article; - } + print "</div>"; #pane - function hook_prefs_tabs($args) - { - print '<div id="feedmodConfigTab" dojoType="dijit.layout.ContentPane" - href="backend.php?op=af_feedmod" - title="' . __('FeedMod') . '"></div>'; } - function index() - { - $pluginhost = PluginHost::getInstance(); - $json_conf = $pluginhost->get($this, 'json_conf'); - - print "<form dojoType=\"dijit.form.Form\">"; - - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> - evt.preventDefault(); - if (this.validate()) { - new Ajax.Request('backend.php', { - parameters: dojo.objectToQuery(this.getValues()), - onComplete: function(transport) { - if (transport.responseText.indexOf('error')>=0) notify_error(transport.responseText); - else notify_info(transport.responseText); - } - }); - //this.reset(); - } - </script>"; - - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">"; - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">"; - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_feedmod\">"; - - print "<table width='100%'><tr><td>"; - print "<textarea dojoType=\"dijit.form.SimpleTextarea\" name=\"json_conf\" style=\"font-size: 12px; width: 99%; height: 500px;\">$json_conf</textarea>"; - print "</td></tr></table>"; - - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".__("Save")."</button>"; - - print "</form>"; - } function save() { - $json_conf = $_POST['json_conf']; - - if (is_null(json_decode($json_conf))) { - echo __("error: Invalid JSON!"); - return false; - } - - $this->host->set($this, 'json_conf', $json_conf); - echo __("Configuration saved."); + $ftr_url = db_escape_string($_POST["ftr_url"]); + $this->host->set($this, "ftr_url", $ftr_url); + echo __("YAFPP configuration saved."); } } diff --git a/mods/androidpit.de.json b/mods/androidpit.de.json deleted file mode 100644 index 411364c..0000000 --- a/mods/androidpit.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "AndroidPIT", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.androidpit.de/feed/main.xml", - "match": "androidpit\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='left']" - } -} diff --git a/mods/cad-comic.com.json b/mods/cad-comic.com.json deleted file mode 100644 index 6bc482a..0000000 --- a/mods/cad-comic.com.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Ctrl+Alt+Del", - "author": "Roland Angerer", - "stamp": 1371647734, - "feed": "http://cdn.cad-comic.com/rss.xml", - "match": "cad-comic.com/cad", - "config": { - "type": "xpath", - "xpath": "div[@id='content']", - "cleanup": [ "div[@id='menu']", "div[contains(@class, 'navigation')]", "div[contains(@class, 'addthis_toolbar')]" ] - } -} diff --git a/mods/chaoslife.json b/mods/chaoslife.json deleted file mode 100644 index c9fc71f..0000000 --- a/mods/chaoslife.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ChaosLife", - "author": "Roland Angerer", - "stamp": 1371815572, - "feed": "http://chaoslife.findchaos.com/feed", - "match": "chaoslife.findchaos.com", - "config": { - "type": "xpath", - "xpath": "div[@id='comic']" - } -} diff --git a/mods/chip.de-topnews.json b/mods/chip.de-topnews.json deleted file mode 100644 index 8a466e9..0000000 --- a/mods/chip.de-topnews.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Chip.de Top News", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.chip.de/rss/rss_topnews.xml", - "match": "chip\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='col478-le']" -// "xpath": "div[starts-with(@class, 'col478-le']" - } -} diff --git a/mods/der-postillon.json b/mods/der-postillon.json deleted file mode 100644 index 77d6882..0000000 --- a/mods/der-postillon.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Der Postillon", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://www.der-postillon.com/feeds/posts/default", - "match": "blogspot/rkEL", - "config": { - "type": "xpath", - "xpath": "div[@itemprop='articleBody']" - } -} diff --git a/mods/dilbert.json b/mods/dilbert.json deleted file mode 100644 index d908d3c..0000000 --- a/mods/dilbert.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Dilbert", - "author": "Roland Angerer", - "stamp": 1376903915, - "feed": "http://feeds.feedburner.com/DilbertDailyStrip", - "match": "DilbertDailyStrip", - "config": { - "type": "xpath", - "xpath": "div[contains(@class, 'STR_Image')]" - } -} diff --git a/mods/dsl-magazin.de.json b/mods/dsl-magazin.de.json deleted file mode 100644 index c14ad63..0000000 --- a/mods/dsl-magazin.de.json +++ /dev/null @@ -1,6 +0,0 @@ -{ -"www.dsl-magazin.de":{ -"type": "xpath", -"xpath": "div[@class='content']" -} -} diff --git a/mods/github.com.json b/mods/github.com.json deleted file mode 100644 index 411f82f..0000000 --- a/mods/github.com.json +++ /dev/null @@ -1,6 +0,0 @@ -{ -"github.com":{ -"type": "xpath", -"xpath": "div[@id='js-repo-pjax-container']" -} -} diff --git a/mods/golem.de.json b/mods/golem.de.json deleted file mode 100644 index 87814ef..0000000 --- a/mods/golem.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Golem", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://rss.golem.de/rss.php?feed=RSS2.0", - "match": "golem0Bde0C", - "config": { - "type": "xpath", - "xpath": "article" - } -} diff --git a/mods/golem.de2.json b/mods/golem.de2.json deleted file mode 100644 index 7187bc2..0000000 --- a/mods/golem.de2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Golem 2", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://rss.golem.de/rss.php?feed=RSS2.0", - "match": "golem0Bde0C", - "config": { - "type": "xpath", - "xpath": "div[@class='g g4 g-ie6']" - } -} diff --git a/mods/habrahabr.ru.json b/mods/habrahabr.ru.json deleted file mode 100644 index d990b02..0000000 --- a/mods/habrahabr.ru.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "habrahabr.ru":{ - "type": "xpath", - "xpath": "div[@class='content html_format']" - } -} diff --git a/mods/heise.de.json b/mods/heise.de.json deleted file mode 100644 index ce8f5c7..0000000 --- a/mods/heise.de.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "heise.de", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://www.heise.de/newsticker/heise-atom.xml", - "match": "heise.de", - "config": { - "type": "xpath", - "xpath": "div[@class='meldung_wrapper']", - "force_charset": "utf-8" - } -} diff --git a/mods/heise.de2.json b/mods/heise.de2.json deleted file mode 100644 index 695f884..0000000 --- a/mods/heise.de2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "heise.de 2", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.heise.de/newsticker/heise-atom.xml", - "match": "heise\.de/tr", - "config": { - "type": "xpath", - "xpath": "div[@id='artikel']" - } -} diff --git a/mods/hitb.org.json b/mods/hitb.org.json deleted file mode 100644 index 5f08244..0000000 --- a/mods/hitb.org.json +++ /dev/null @@ -1,6 +0,0 @@ -{ -"news.hitb.org":{ -"type": "xpath", -"xpath": "div[@class='field-items']" -} -} diff --git a/mods/jojosblog.json b/mods/jojosblog.json deleted file mode 100644 index a81029a..0000000 --- a/mods/jojosblog.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Jojo's illustrierter Blog", - "author": "Markus Birth", - "stamp": 1371635271, - "feed": "http://blog.beetlebum.de/feed/", - "match": "blog.beetlebum.de", - "config": { - "type": "xpath", - "xpath": "div[@id='content']/article", - "cleanup": [ "header", "footer" ] - } -} diff --git a/mods/katzenfuttergeleespritzer.de.json b/mods/katzenfuttergeleespritzer.de.json deleted file mode 100644 index bff77e4..0000000 --- a/mods/katzenfuttergeleespritzer.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Katzenfuttergeleespritzer.de", - "author": "Roland Angerer", - "stamp": 1371643613, - "feed": "http://www.katzenfuttergeleespritzer.de/feed/", - "match": "katzenfuttergeleespritzer.de/comics", - "config": { - "type": "xpath", - "xpath": "div[@id='comic']" - } -} diff --git a/mods/kojote-magazin.json b/mods/kojote-magazin.json deleted file mode 100644 index ded6807..0000000 --- a/mods/kojote-magazin.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Der Kojote", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://www.kojote-magazin.de/feed/rss2", - "match": "kojote-magazin.de", - "config": { - "type": "xpath", - "xpath": "div[@class='post']" - } -}
\ No newline at end of file diff --git a/mods/littleteacup.net.json b/mods/littleteacup.net.json deleted file mode 100644 index 1f30014..0000000 --- a/mods/littleteacup.net.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Fall on Me", - "author": "Roland Angerer", - "stamp": 1371642100, - "feed": "http://www.littleteacup.net/fallonme/feed/", - "match": "littleteacup.net/fallonme", - "config": { - "type": "xpath", - "xpath": "div[@id='comic']" - } -} diff --git a/mods/n24.de.json b/mods/n24.de.json deleted file mode 100644 index 174c6a3..0000000 --- a/mods/n24.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "N24.de", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://feeds.n24.de/n24/homepage", - "match": "n24.de", - "config": { - "type": "xpath", - "xpath": "div[@class='c2a']" - } -} diff --git a/mods/news.orf.at.json b/mods/news.orf.at.json deleted file mode 100644 index 58afa97..0000000 --- a/mods/news.orf.at.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "news.ORF.at", - "author": "Roland Angerer", - "stamp": 1371640419, - "feed": "http://rss.orf.at/news.xml", - "match": "news.orf.at", - "config": { - "type": "xpath", - "xpath": "div[contains(@class, 'storyText')]", - "cleanup": [ "h1", "div[contains(@class, 'storyMeta')]" ] - } -} diff --git a/mods/nichtdiewelt.json b/mods/nichtdiewelt.json deleted file mode 100644 index c37a052..0000000 --- a/mods/nichtdiewelt.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "NichtDieWelt", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://nicht-die-welt.de/feed/rss/", - "match": "NichtDieWelt", - "config": { - "type": "xpath", - "xpath": "div[@id='content-area']" - } -} diff --git a/mods/paralleluniversum.net.json b/mods/paralleluniversum.net.json deleted file mode 100644 index c5dbf30..0000000 --- a/mods/paralleluniversum.net.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Paralleluniversum", - "author": "Roland Angerer", - "stamp": 1371642493, - "feed": "http://www.paralleluniversum.net/feed/", - "match": "paralleluniversum.net", - "config": { - "type": "xpath", - "xpath": "div[@id='comic']" - } -} diff --git a/mods/peanuts.json b/mods/peanuts.json deleted file mode 100644 index 9c79829..0000000 --- a/mods/peanuts.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Peanuts", - "author": "Roland Angerer", - "stamp": 1371650174, - "feed": "http://feeds.feedburner.com/uclick/peanuts?format=xml", - "match": "gocomics.com/peanuts", - "config": { - "type": "xpath", - "xpath": "p[contains(@class, 'feature_item')]" - } -} diff --git a/mods/polizei-berlin.json b/mods/polizei-berlin.json deleted file mode 100644 index d893915..0000000 --- a/mods/polizei-berlin.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Polizei Berlin", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://www.berlin.de/polizei/presse-fahndung/_rss_presse.xml", - "match": "berlin.de/polizei", - "config": { - "type": "xpath", - "xpath": "div[@class='bacontent']" - } -} diff --git a/mods/polizei-brandenburg-hvl.json b/mods/polizei-brandenburg-hvl.json deleted file mode 100644 index 5b6813e..0000000 --- a/mods/polizei-brandenburg-hvl.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Polizei Havelland", - "author": "Markus Birth", - "stamp": 1369500284, - "feed": "http://www.internetwache.brandenburg.de/sixcms/list.php?page=rss_hvl", - "match": "internetwache.brandenburg.de", - "config": { - "type": "xpath", - "xpath": "div[@id='content']/div[@class='box_content']" - } -} diff --git a/mods/rutracker.org.json b/mods/rutracker.org.json deleted file mode 100644 index 24c5dbb..0000000 --- a/mods/rutracker.org.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "rutracker.org":{ - "type": "xpath", - "xpath": "td[@class='message td2']" - } -} diff --git a/mods/schlogger.de.json b/mods/schlogger.de.json deleted file mode 100644 index 764cb42..0000000 --- a/mods/schlogger.de.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "schlogger", - "author": "Roland Angerer", - "stamp": 1371642811, - "feed": "http://schlogger.de/wordpress/feed/", - "match": "schlogger.de", - "config": { - "type": "xpath", - "xpath": "div[contains(@class, 'entry-content')]", - "cleanup": [ "iframe", "div[contains(@class, 'sharedaddy')]" ] - } -} diff --git a/mods/selektive-erinnerung.com.json b/mods/selektive-erinnerung.com.json deleted file mode 100644 index eb0e6a6..0000000 --- a/mods/selektive-erinnerung.com.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Selektive Erinnerung", - "author": "Roland Angerer", - "stamp": 1371642811, - "feed": "http://www.selektive-erinnerung.com/rss", - "match": "selektive-erinnerung.com", - "config": { - "type": "xpath", - "xpath": "div[@id='post']", - "cleanup": [ "div[@id='postinfo']" ] - } -} diff --git a/mods/spiegel.de-einestages.json b/mods/spiegel.de-einestages.json deleted file mode 100644 index 15b8ce0..0000000 --- a/mods/spiegel.de-einestages.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Spiegel einestages", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.spiegel.de/einestages/index.rss", - "match": "einestages\.spiegel\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='huNewAlbum']" - } -} diff --git a/mods/spiegel.de.json b/mods/spiegel.de.json deleted file mode 100644 index 2ac6cc8..0000000 --- a/mods/spiegel.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Spiegel Online", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.spiegel.de/schlagzeilen/index.rss", - "match": "www\.spiegel\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='spArticleColumn']" - } -} diff --git a/mods/tagesspiegel.de1.json b/mods/tagesspiegel.de1.json deleted file mode 100644 index 621ed3e..0000000 --- a/mods/tagesspiegel.de1.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Tagesspiegel 1", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.tagesspiegel.de/contentexport/feed/home", - "match": "tagesspiegel0Bde0C", - "config": { - "type": "xpath", - "xpath": "div[@class='hcf-main-col hcf-detail']" - } -} diff --git a/mods/tagesspiegel.de2.json b/mods/tagesspiegel.de2.json deleted file mode 100644 index 80b47a0..0000000 --- a/mods/tagesspiegel.de2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Tagesspiegel 2", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.tagesspiegel.de/contentexport/feed/home", - "match": "tagesspiegel\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='hcf-main-col hcf-detail']" - } -} diff --git a/mods/tagesspiegel.de3.json b/mods/tagesspiegel.de3.json deleted file mode 100644 index b1dd535..0000000 --- a/mods/tagesspiegel.de3.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Tagesspiegel 3", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.tagesspiegel.de/contentexport/feed/home", - "match": "tagesspiegel\.feedsportal\.com", - "config": { - "type": "xpath", - "xpath": "div[@class='hcf-main-col hcf-detail']" - } -} diff --git a/mods/teltarif.de.json b/mods/teltarif.de.json deleted file mode 100644 index 290c8fe..0000000 --- a/mods/teltarif.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "teltarif.de", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://www.teltarif.de/feed/news/20.rss2", - "match": "teltarif\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='roman4']" - } -} diff --git a/mods/theoatmeal.json b/mods/theoatmeal.json deleted file mode 100644 index 418ce10..0000000 --- a/mods/theoatmeal.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "The Oatmeal", - "author": "Markus Birth", - "stamp": 1371635271, - "feed": "http://theoatmeal.com/feed/rss", - "match": "oatmeal", - "config": { - "type": "xpath", - "xpath": "div[@id='comic']", - "cleanup": [ "div[@id='content_footer2']" ] - } -} diff --git a/mods/zaf.de.json b/mods/zaf.de.json deleted file mode 100644 index e4f29ef..0000000 --- a/mods/zaf.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Zombies and Fairytales", - "author": "Roland Angerer", - "stamp": 1371644173, - "feed": "http://166612.webhosting66.1blu.de/zaf_de/wordpress/feed/", - "match": "zaf_de/wordpress/comic", - "config": { - "type": "xpath", - "xpath": "div[@id='comic']" - } -} diff --git a/mods/zeit.de.json b/mods/zeit.de.json deleted file mode 100644 index d5d3459..0000000 --- a/mods/zeit.de.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Zeit.de", - "author": "Andreas Steinhoff", - "stamp": 1369484764, - "feed": "http://newsfeed.zeit.de/all", - "match": "zeit\.de", - "config": { - "type": "xpath", - "xpath": "div[@class='article']" - } -} diff --git a/tests/charset.php b/tests/charset.php deleted file mode 100644 index f429241..0000000 --- a/tests/charset.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -$config = array( - 'type' => 'xpath', - 'xpath' => 'div[@class="meldung_wrapper"]', -); - -// http://www.heise.de/newsticker/heise-atom.xml - -$article = array( - 'link' => 'http://www.heise.de/newsticker/meldung/Fruehjahrspatches-Microsoft-9-Adobe-3-1838175.html/from/atom10', - 'content' => 'This is the feed content', - 'plugin_data' => '', -); - -$doc = new DOMDocument(); - -$html = file_get_contents($article['link']); - -// BEGIN --- New code -$headers = $http_response_header; -$content_type = false; -foreach ($headers as $h) { - if (substr(strtolower($h), 0, 13) == 'content-type:') { - $content_type = substr($h, 14); - // don't break here to find LATEST (if redirected) entry - } -} - -$charset = false; -if ($content_type) { - preg_match('/charset=(\S+)/', $content_type, $matches); - if (isset($matches[1]) && !empty($matches[1])) $charset = $matches[1]; -} - -// END --- New code - -echo 'CHARSET: ' . $charset . PHP_EOL; - - -$doc->loadHTML('<?xml encoding="' . $charset . '">' . $html); - -echo 'ENCODING: ' . $doc->encoding . PHP_EOL; - -if ($doc) { - $basenode = false; - $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//'.$config['xpath'].')'); // find main DIV according to config - - var_dump($entries); - - if ($entries->length > 0) $basenode = $entries->item(0); - - if ($basenode) { - $article['content'] = $doc->saveXML($basenode); - $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; - } -} - -print_r($article); diff --git a/tests/charsetcurl.php b/tests/charsetcurl.php deleted file mode 100644 index 9db93e8..0000000 --- a/tests/charsetcurl.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -$ch = curl_init('http://www.heise.de/newsticker/meldung/Fruehjahrspatches-Microsoft-9-Adobe-3-1838175.html/from/atom10'); -#curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); -#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -#curl_setopt($ch, CURLINFO_HEADER_OUT, true); - -curl_exec($ch); - -var_dump(curl_getinfo($ch,CURLINFO_CONTENT_TYPE)); - diff --git a/tests/showmods.php b/tests/showmods.php deleted file mode 100644 index 3408435..0000000 --- a/tests/showmods.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -$mods = glob('../mods/*.json'); - -foreach ($mods as $mod) { - $json = file_get_contents($mod); - $data = json_decode($json, true); - echo $mod . ': ' . $data['name'] . PHP_EOL; -} diff --git a/tests/xpath.php b/tests/xpath.php deleted file mode 100644 index 4e422ad..0000000 --- a/tests/xpath.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -$config = array( - 'type' => 'xpath', - 'xpath' => 'div[@itemprop="articleBody"]', -); - -$article = array( - 'link' => 'http://www.der-postillon.com/2013/04/nordkoreas-armee-nach-wochenlangem.html', - 'content' => 'This is the feed content', - 'plugin_data' => '', -); - -$doc = new DOMDocument(); -$html = file_get_contents($article['link']); -$doc->loadHTML($html); - -if ($doc) { - $basenode = false; - $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//'.$config['xpath'].')'); // find main DIV according to config - - var_dump($entries); - - if ($entries->length > 0) $basenode = $entries->item(0); - - if ($basenode) { - $article['content'] = $doc->saveXML($basenode); - $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; - } -} - -print_r($article);
\ No newline at end of file |
