aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2020-03-22 16:31:20 +0100
committerGravatar GitHub <noreply@github.com> 2020-03-22 16:31:20 +0100
commitcd49e9819bea35a4db05e3e76910b739898c2219 (patch)
tree437b36b429357f90d2a168d4ba2ae016708cc54d /lib
parentc03e097dae7e7a2026bde7ef96e5f05b139d758d (diff)
New core-extensions to allow Docker volumes for third-party extensions (#2837)
* New core-extensions to allow Docker volumes for third-party extensions #Fix https://github.com/FreshRSS/FreshRSS/issues/2650 Split our extensions directory into two: 1) Core extensions shipped with FreshRSS in ./lib/core-extensions/ 2) Third-party extensions modified by end-users in ./extensions/ which can easily be mounted as a Docker volume * Example of Docker Compose with extensions * Back-compatibility + fix array merge bug
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ExtensionManager.php17
-rw-r--r--lib/core-extensions/README.md5
-rw-r--r--lib/core-extensions/Tumblr-GDPR/README.md4
-rw-r--r--lib/core-extensions/Tumblr-GDPR/extension.php13
-rw-r--r--lib/core-extensions/Tumblr-GDPR/metadata.json8
5 files changed, 39 insertions, 8 deletions
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index e6b8dafb0..b2814e4a3 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -1,7 +1,7 @@
<?php
/**
- * An extension manager to load extensions present in EXTENSIONS_PATH.
+ * An extension manager to load extensions present in CORE_EXTENSIONS_PATH and THIRDPARTY_EXTENSIONS_PATH.
*
* @todo see coding style for methods!!
*/
@@ -78,16 +78,17 @@ class Minz_ExtensionManager {
* inherit from Minz_Extension class.
*/
public static function init() {
- $list_potential_extensions = array_values(array_diff(
- scandir(EXTENSIONS_PATH),
- array('..', '.')
- ));
+ $list_core_extensions = array_diff(scandir(CORE_EXTENSIONS_PATH), [ '..', '.' ]);
+ $list_thirdparty_extensions = array_diff(scandir(THIRDPARTY_EXTENSIONS_PATH), [ '..', '.' ], $list_core_extensions);
+ array_walk($list_core_extensions, function (&$s) { $s = CORE_EXTENSIONS_PATH . '/' . $s; });
+ array_walk($list_thirdparty_extensions, function (&$s) { $s = THIRDPARTY_EXTENSIONS_PATH . '/' . $s; });
+
+ $list_potential_extensions = array_merge($list_core_extensions, $list_thirdparty_extensions);
$system_conf = Minz_Configuration::get('system');
self::$ext_auto_enabled = $system_conf->extensions_enabled;
- foreach ($list_potential_extensions as $ext_dir) {
- $ext_pathname = EXTENSIONS_PATH . '/' . $ext_dir;
+ foreach ($list_potential_extensions as $ext_pathname) {
if (!is_dir($ext_pathname)) {
continue;
}
@@ -111,7 +112,7 @@ class Minz_ExtensionManager {
// Try to load extension itself
$extension = self::load($meta_json);
- if (!is_null($extension)) {
+ if ($extension != null) {
self::register($extension);
}
}
diff --git a/lib/core-extensions/README.md b/lib/core-extensions/README.md
new file mode 100644
index 000000000..7d48fbffd
--- /dev/null
+++ b/lib/core-extensions/README.md
@@ -0,0 +1,5 @@
+# FreshRSS core extensions
+
+This directory contains some core extensions shipped with FreshRSS.
+
+For custom third-party extensions, use the `./FreshRSS/extensions/` directory instead.
diff --git a/lib/core-extensions/Tumblr-GDPR/README.md b/lib/core-extensions/Tumblr-GDPR/README.md
new file mode 100644
index 000000000..fc5e4dd50
--- /dev/null
+++ b/lib/core-extensions/Tumblr-GDPR/README.md
@@ -0,0 +1,4 @@
+# Tumblr-GDPR
+
+Needed for accessing [Tumblr](https://www.tumblr.com/) RSS feeds from the European Union:
+bypass the [GPDR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) check, implying consent.
diff --git a/lib/core-extensions/Tumblr-GDPR/extension.php b/lib/core-extensions/Tumblr-GDPR/extension.php
new file mode 100644
index 000000000..83bdf2189
--- /dev/null
+++ b/lib/core-extensions/Tumblr-GDPR/extension.php
@@ -0,0 +1,13 @@
+<?php
+
+class TumblrGdprExtension extends Minz_Extension {
+ public function init() {
+ $this->registerHook('simplepie_before_init', array('TumblrGdprExtension', 'curlHook'));
+ }
+
+ public static function curlHook($simplePie, $feed) {
+ if (preg_match('#^https?://[a-zA-Z_0-9-]+.tumblr.com/#i', $feed->url())) {
+ $simplePie->set_useragent(FRESHRSS_USERAGENT . ' like Baiduspider');
+ }
+ }
+}
diff --git a/lib/core-extensions/Tumblr-GDPR/metadata.json b/lib/core-extensions/Tumblr-GDPR/metadata.json
new file mode 100644
index 000000000..b5c33787b
--- /dev/null
+++ b/lib/core-extensions/Tumblr-GDPR/metadata.json
@@ -0,0 +1,8 @@
+{
+ "name": "Tumblr-GDPR",
+ "author": "Alkarex",
+ "description": "Bypass Tumblr’ GPDR check (implying consent) for the European Union",
+ "version": 1.0,
+ "entrypoint": "TumblrGdpr",
+ "type": "system"
+}