diff options
Diffstat (limited to 'plugins/af_readability/init.php')
| -rwxr-xr-x | plugins/af_readability/init.php | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 32c54a2c7..8bb368389 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -38,6 +38,10 @@ class Af_Readability extends Plugin { $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); + // Note: we have to install the hook even if disabled because init() is being run before plugin data has loaded + // so we can't check for our storage-set options here + $host->add_hook($host::HOOK_GET_FULL_TEXT, $this); + $host->add_filter_action($this, "action_inline", __("Inline content")); } @@ -80,7 +84,7 @@ class Af_Readability extends Plugin { print "<fieldset>"; print "<label class='checkbox'> "; print_checkbox("enable_share_anything", $enable_share_anything); - print " " . __("Use Readability for pages shared via bookmarklet."); + print " " . __("Provide full-text services to core code (bookmarklets) and other plugins"); print "</label>"; print "</fieldset>"; @@ -169,7 +173,7 @@ class Af_Readability extends Plugin { if ($tmp && mb_strlen($tmp) < 1024 * 500) { $tmpdoc = new DOMDocument("1.0", "UTF-8"); - if (!$tmpdoc->loadHTML($tmp)) + if (!@$tmpdoc->loadHTML($tmp)) return false; // this is the worst hack yet :( @@ -237,6 +241,24 @@ class Af_Readability extends Plugin { } + function hook_get_full_text($link) + { + $enable_share_anything = $this->host->get($this, "enable_share_anything"); + + if ($enable_share_anything) { + $extracted_content = $this->extract_content($link); + + # let's see if there's anything of value in there + $content_test = trim(strip_tags(sanitize($extracted_content))); + + if ($content_test) { + return $extracted_content; + } + } + + return false; + } + function api_version() { return 2; } |