]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_comics updates:
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Mon, 5 Jun 2017 09:53:06 +0000 (12:53 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Mon, 5 Jun 2017 09:53:06 +0000 (12:53 +0300)
1. move preferences to Feeds tab
2. update CAD comic with support for sillies
3. add support for loading updated/third-party filters from filters.local (would override bundled filters)

plugins/af_comics/filters.local/.empty [new file with mode: 0644]
plugins/af_comics/filters/af_comics_cad.php
plugins/af_comics/init.php

diff --git a/plugins/af_comics/filters.local/.empty b/plugins/af_comics/filters.local/.empty
new file mode 100644 (file)
index 0000000..e69de29
index 7c06709187c1e3e5c1a66d94aabe821593b2b54b..6846f3cb0631b17ae97ac3cb8360a0311374b5cb 100644 (file)
@@ -6,14 +6,23 @@ class Af_Comics_Cad extends Af_ComicFilter {
        }
 
        function process(&$article) {
-               if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) {
+               if (strpos($article["link"], "cad-comic.com") !== FALSE) {
                        if (strpos($article["title"], "News:") === FALSE) {
 
+                               global $fetch_last_error_content;
+
                                $doc = new DOMDocument();
 
-                               if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+                               $res = fetch_file_contents($article["link"], false, false, false,
+                                       false, false, 0,
+                                       "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
+
+                               if (!$res && $fetch_last_error_content)
+                                       $res = $fetch_last_error_content;
+
+                               if (@$doc->loadHTML($res)) {
                                        $xpath = new DOMXPath($doc);
-                                       $basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0);
+                                       $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0);
 
                                        if ($basenode) {
                                                $article["content"] = $doc->saveXML($basenode);
index 15af1d1a6d6dd4b83cd88f4bed9757679a1c21cd..09e9033794875c1f7ce3b60b58c24ebcb08809df 100644 (file)
@@ -19,23 +19,31 @@ class Af_Comics extends Plugin {
 
                require_once __DIR__ . "/filter_base.php";
 
-               $filters = glob(__DIR__ . "/filters/*.php");
+               $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php"));
+               $names = [];
 
                foreach ($filters as $file) {
-                       require_once $file;
                        $filter_name = preg_replace("/\..*$/", "", basename($file));
 
-                       $filter = new $filter_name();
+                       if (array_search($filter_name, $names) === FALSE) {
+                               if (!class_exists($filter_name)) {
+                                       require_once $file;
+                               }
+
+                               array_push($names, $filter_name);
+
+                               $filter = new $filter_name();
 
-                       if (is_subclass_of($filter, "Af_ComicFilter")) {
-                               array_push($this->filters, $filter);
+                               if (is_subclass_of($filter, "Af_ComicFilter")) {
+                                       array_push($this->filters, $filter);
+                                       array_push($names, $filter_name);
+                               }
                        }
                }
-
        }
 
        function hook_prefs_tab($args) {
-               if ($args != "prefPrefs") return;
+               if ($args != "prefFeeds") return;
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">";
 
@@ -59,6 +67,8 @@ class Af_Comics extends Plugin {
 
                print "<p>".__('GoComics requires a specific URL to workaround their lack of feed support: <code>http://feeds.feedburner.com/uclick/<em>comic_name</em></code> (e.g. <code>http://www.gocomics.com/garfield</code> uses <code>http://feeds.feedburner.com/uclick/garfield</code>).')."</p>";
 
+               print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>";
+
                print "</div>";
        }