af_comics updates:

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)
This commit is contained in:
Andrew Dolgov 2017-06-05 12:53:06 +03:00
parent 1d61994776
commit 6f398dcfc6
3 changed files with 29 additions and 10 deletions

View file

View file

@ -6,14 +6,23 @@ class Af_Comics_Cad extends Af_ComicFilter {
} }
function process(&$article) { 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) { if (strpos($article["title"], "News:") === FALSE) {
global $fetch_last_error_content;
$doc = new DOMDocument(); $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); $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) { if ($basenode) {
$article["content"] = $doc->saveXML($basenode); $article["content"] = $doc->saveXML($basenode);

View file

@ -19,23 +19,31 @@ class Af_Comics extends Plugin {
require_once __DIR__ . "/filter_base.php"; 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) { foreach ($filters as $file) {
require_once $file;
$filter_name = preg_replace("/\..*$/", "", basename($file)); $filter_name = preg_replace("/\..*$/", "", basename($file));
if (array_search($filter_name, $names) === FALSE) {
if (!class_exists($filter_name)) {
require_once $file;
}
array_push($names, $filter_name);
$filter = new $filter_name(); $filter = new $filter_name();
if (is_subclass_of($filter, "Af_ComicFilter")) { if (is_subclass_of($filter, "Af_ComicFilter")) {
array_push($this->filters, $filter); array_push($this->filters, $filter);
array_push($names, $filter_name);
}
} }
} }
} }
function hook_prefs_tab($args) { 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')."\">"; 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>".__('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>"; print "</div>";
} }