plugins: add HOOK_GET_FULL_TEXT which may be used to provide full text extraction to core code and other plugins, instead of trying to invoke af_readability specifically

remotes/origin/weblate-integration
Andrew Dolgov 4 years ago
parent 525298569e
commit 6955b2e02d
  1. 11
      classes/article.php
  2. 1
      classes/pluginhost.php
  3. 13
      plugins/af_readability/init.php

@ -100,7 +100,7 @@ class Article extends Handler_Protected {
$pluginhost->load_all(PluginHost::KIND_ALL, $owner_uid);
$pluginhost->load_data();
$af_readability = $pluginhost->get_plugin("Af_Readability");
/*$af_readability = $pluginhost->get_plugin("Af_Readability");
if ($af_readability) {
$enable_share_anything = $pluginhost->get($af_readability, "enable_share_anything");
@ -110,6 +110,15 @@ class Article extends Handler_Protected {
if ($extracted_content) $content = $extracted_content;
}
}*/
foreach ($pluginhost->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) {
$extracted_content = $p->hook_get_full_text($url);
if ($extracted_content) {
$content = $extracted_content;
break;
}
}
}

@ -58,6 +58,7 @@ class PluginHost {
const HOOK_UNSUBSCRIBE_FEED = 38;
const HOOK_SEND_MAIL = 39;
const HOOK_FILTER_TRIGGERED = 40;
const HOOK_GET_FULL_TEXT = 41;
const KIND_ALL = 1;
const KIND_SYSTEM = 2;

@ -38,6 +38,13 @@ class Af_Readability extends Plugin {
$host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this);
$host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this);
$enable_share_anything = $this->host->get($this, "enable_share_anything");
// provide full text services to external code
// TODO: option that controls this needs a better caption
if ($enable_share_anything)
$host->add_hook($host::HOOK_GET_FULL_TEXT, $this);
$host->add_filter_action($this, "action_inline", __("Inline content"));
}
@ -237,6 +244,12 @@ class Af_Readability extends Plugin {
}
function hook_get_full_text($link) {
$extracted_content = $this->extract_content($link);
return trim(strip_tags(sanitize($extracted_content)));
}
function api_version() {
return 2;
}

Loading…
Cancel
Save