From 88cc788c9b8acc2143c28c5ca3bc4727709a4c05 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 4 Apr 2023 22:21:27 +0000 Subject: [PATCH] Fixed NPF, new OAuth library added --- composer.json | 1 + composer.lock | 57 +++++++++++++++++++++++++++++++++++++++- src/Content/Text/NPF.php | 27 +++++++++---------- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index bb675c651e..0a31151fdd 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "friendica/json-ld": "^1.0", "geekwright/po": "^2.0", "guzzlehttp/guzzle": "^6.5", + "guzzlehttp/oauth-subscriber": "^0.6", "kornrunner/blurhash": "^1.2", "league/html-to-markdown": "^4.8", "level-2/dice": "^4", diff --git a/composer.lock b/composer.lock index 280e979e9e..10fa756386 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "456d14e3ad9be265c5c9e6172a0d18d8", + "content-hash": "c208d7f5176358ea157f109c1c7d68dd", "packages": [ { "name": "asika/simple-console", @@ -967,6 +967,61 @@ ], "time": "2022-06-20T22:16:07+00:00" }, + { + "name": "guzzlehttp/oauth-subscriber", + "version": "0.6.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/oauth-subscriber.git", + "reference": "8d6cab29f8397e5712d00a383eeead36108a3c1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/oauth-subscriber/zipball/8d6cab29f8397e5712d00a383eeead36108a3c1f", + "reference": "8d6cab29f8397e5712d00a383eeead36108a3c1f", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.5|^7.2", + "guzzlehttp/psr7": "^1.7|^2.0", + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|^9.3.3" + }, + "suggest": { + "ext-openssl": "Required to sign using RSA-SHA1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Subscriber\\Oauth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle OAuth 1.0 subscriber", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "Guzzle", + "oauth" + ], + "time": "2021-07-13T12:01:32+00:00" + }, { "name": "guzzlehttp/promises", "version": "1.5.2", diff --git a/src/Content/Text/NPF.php b/src/Content/Text/NPF.php index d60b3a8e79..a919562c74 100644 --- a/src/Content/Text/NPF.php +++ b/src/Content/Text/NPF.php @@ -185,9 +185,6 @@ class NPF static private function getLevelByCallstack($callstack): int { - // Deactivated, since Tumblr seems to have issues with the indent level - return 0; - $level = 0; foreach ($callstack as $entry) { if (in_array($entry, ['ol', 'ul', 'blockquote'])) { @@ -235,7 +232,7 @@ class NPF break; case 'blockquote': - $subtype = strlen($text) < 100 ? 'quote' : 'indented'; + $subtype = mb_strlen($text) < 100 ? 'quote' : 'indented'; break; case 'pre': @@ -293,10 +290,9 @@ class NPF 'text' => $text, ]; - // Deactivated since Tumblr has got issues with it - //if (!empty($formatting)) { - // $block['formatting'] = $formatting; - //} + if (!empty($formatting)) { + $block['formatting'] = $formatting; + } $level = self::getLevelByCallstack($callstack); if ($level > 0) { @@ -491,13 +487,14 @@ class NPF $block = [ 'type' => 'text', 'text' => $element->textContent, - // Deactivated, since Tumblr has got issues with the formatting - //'formatting' => [ - // 'start' => 0, - // 'end' => strlen($element->textContent), - // 'type' => 'link', - // 'url' => $attributes['href'] - //] + 'formatting' => [ + [ + 'start' => 0, + 'end' => mb_strlen($element->textContent), + 'type' => 'link', + 'url' => $attributes['href'] + ] + ] ]; }