diff options
| author | Markus Birth <github.com@birth-online.de> | 2013-06-20 03:01:22 -0700 |
|---|---|---|
| committer | Markus Birth <github.com@birth-online.de> | 2013-06-20 03:01:22 -0700 |
| commit | 8fe0bdd8431fa39c1e3e2b98459c6f0699081378 (patch) | |
| tree | c2aba229c192bd03f66dfc2ac1b4bd50b5eef6d2 | |
| parent | ff7ae3c171aa6562891e9defad88be60a22e20d4 (diff) | |
| parent | 9c8da97a1ab8eca80c8b579816e4d287cff6f840 (diff) | |
| download | yafpp-8fe0bdd8431fa39c1e3e2b98459c6f0699081378.tar.gz yafpp-8fe0bdd8431fa39c1e3e2b98459c6f0699081378.zip | |
Merge pull request #9 from rangerer/cleanup
added new cleanup feature by rangerer, thanks!
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | init.php | 9 | ||||
| -rw-r--r-- | mods/jojosblog.json | 5 | ||||
| -rw-r--r-- | mods/theoatmeal.json | 5 |
4 files changed, 19 insertions, 5 deletions
@@ -50,7 +50,8 @@ A configuration looks like this: }, "blog.beetlebum.de": { "type": "xpath", - "xpath": "div[@class='entry-content']" + "xpath": "div[@class='entry-content']", + "cleanup": [ "header", "footer" ], } } @@ -62,6 +63,8 @@ The *array key* is part of the URL of the article links(!). You'll notice the `g 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. @@ -116,6 +116,15 @@ class Af_Feedmod extends Plugin implements IHandler if ($entries->length > 0) $basenode = $entries->item(0); if ($basenode) { + // remove nodes from cleanup configuration + if (isset($config['cleanup'])) { + foreach ($config['cleanup'] as $cleanup) { + $nodelist = $xpath->query('//'.$cleanup, $basenode); + foreach ($nodelist as $node) { + $node->parentNode->removeChild($node); + } + } + } $article['content'] = $doc->saveXML($basenode); $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; } diff --git a/mods/jojosblog.json b/mods/jojosblog.json index dc8f6fc..a81029a 100644 --- a/mods/jojosblog.json +++ b/mods/jojosblog.json @@ -1,11 +1,12 @@ { "name": "Jojo's illustrierter Blog", "author": "Markus Birth", - "stamp": 1369500284, + "stamp": 1371635271, "feed": "http://blog.beetlebum.de/feed/", "match": "blog.beetlebum.de", "config": { "type": "xpath", - "xpath": "div[@class='entry-content']" + "xpath": "div[@id='content']/article", + "cleanup": [ "header", "footer" ] } } diff --git a/mods/theoatmeal.json b/mods/theoatmeal.json index 628af3c..418ce10 100644 --- a/mods/theoatmeal.json +++ b/mods/theoatmeal.json @@ -1,11 +1,12 @@ { "name": "The Oatmeal", "author": "Markus Birth", - "stamp": 1369500284, + "stamp": 1371635271, "feed": "http://theoatmeal.com/feed/rss", "match": "oatmeal", "config": { "type": "xpath", - "xpath": "div[@id='comic']" + "xpath": "div[@id='comic']", + "cleanup": [ "div[@id='content_footer2']" ] } } |
