From fef3a414b518a4d1d01fcb1dbc6e8a54144085b9 Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Sun, 11 May 2025 14:03:30 +0200 Subject: [PATCH] Freeplane: parse changelog file --- PatchBase.php | 5 +++++ modules/Freeplane.php | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/PatchBase.php b/PatchBase.php index 5269e37..2fbfdbd 100644 --- a/PatchBase.php +++ b/PatchBase.php @@ -125,6 +125,11 @@ abstract class PatchBase { $this->data = $str; } } + protected function str_extract(int $n) { + $lines = explode("\r\n", $this->data); + if (count($lines) > $n) + $this->data = $lines[$n]; + } private function curl(string $url, array $opts) { if ($ch = curl_init()) { curl_setopt($ch, CURLOPT_URL, $url); diff --git a/modules/Freeplane.php b/modules/Freeplane.php index 9181e5f..1be5739 100644 --- a/modules/Freeplane.php +++ b/modules/Freeplane.php @@ -5,8 +5,10 @@ class Freeplane extends PatchBase { parent::__construct('Freeplane Team', 'Freeplane', 'https://docs.freeplane.org/'); } function check() : bool { - if ($this->fetch_json('https://sourceforge.net/projects/freeplane/best_release.json')) - return $this->parse_json('filename', '/-([\d\.]+[u\d]*)\.[a-z]+$/'); + if ($this->fetch('https://www.freeplane.org/info/history/history_en.txt')) { + $this->str_extract(1); + return $this->parse('/^([\d\.]+)/m'); + } return false; } }