summaryrefslogtreecommitdiff
path: root/init.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-06-09 18:28:37 +0300
committerAndrew Dolgov <[email protected]>2023-06-09 18:28:37 +0300
commit9a92931e9be0bacdcc8a026c79dbf1f4185266a5 (patch)
treeac08ec880f20db7f92b1d60e30d99dae66969229 /init.php
parentc898802a8d9dfac5cc100b84325b0308619521c6 (diff)
enable readability
Diffstat (limited to 'init.php')
-rw-r--r--init.php34
1 files changed, 14 insertions, 20 deletions
diff --git a/init.php b/init.php
index 6af66cd..3cfde14 100644
--- a/init.php
+++ b/init.php
@@ -380,30 +380,24 @@ class Af_Lemmy extends Plugin {
*/
private function readability(array $article, string $url, DOMDocument $doc, DOMXpath $xpath, bool $debug = false) : array {
- if (function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
- mb_strlen(strip_tags($article["content"])) <= 150) {
+ if (function_exists("curl_init") && mb_strlen(strip_tags($article["content"])) <= 150) {
- // do not try to embed posts linking back to other reddit posts
- // readability.php requires PHP 5.6
- if ($url && strpos($url, "reddit.com") === false) {
+ /* link may lead to a huge video file or whatever, we need to check content type before trying to
+ parse it which p much requires curl */
- /* link may lead to a huge video file or whatever, we need to check content type before trying to
- parse it which p much requires curl */
+ $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
+ $content_type = $this->get_content_type($url, $useragent_compat);
- $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
- $content_type = $this->get_content_type($url, $useragent_compat);
+ if ($content_type && strpos($content_type, "text/html") !== false) {
- if ($content_type && strpos($content_type, "text/html") !== false) {
-
- $this->host->run_hooks_callback(PluginHost::HOOK_GET_FULL_TEXT,
- function ($result) use (&$article) {
- if ($result) {
- $article["content"] = $result;
- return true;
- }
- },
- $url);
- }
+ $this->host->run_hooks_callback(PluginHost::HOOK_GET_FULL_TEXT,
+ function ($result) use (&$article) {
+ if ($result) {
+ $article["content"] = $result;
+ return true;
+ }
+ },
+ $url);
}
}