From 8a69a5c3c7bd0188228d5c1c8580e5331a66e2da Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 26 Feb 2017 21:01:20 +0100 Subject: add a minversion to the theme and fallback to default if requirement is not met. mark incompatible themes in the theme selector --- Zotlabs/Module/Admin/Site.php | 9 ++++++++- Zotlabs/Module/Admin/Themes.php | 2 +- Zotlabs/Module/Settings/Display.php | 12 +++++++++--- Zotlabs/Render/Theme.php | 7 ++++++- view/theme/redbasic/.MINVERSION | 1 + view/theme/redbasic/php/theme.php | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 view/theme/redbasic/.MINVERSION diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 829ca71e4..3bb384ec5 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -163,6 +163,13 @@ class Site { foreach($files as $file) { $vars = ''; $f = basename($file); + + $min_version = ((file_exists('view/theme/' . $f . '/.MINVERSION')) ? file_get_contents('view/theme/' . $f . '/.MINVERSION') : 0); + if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $theme_choices[$f] = $theme_choices_mobile[$f] = sprintf(t('%s - (Incompatible)'), $f); + continue; + } + if (file_exists($file . '/library')) continue; if (file_exists($file . '/mobile')) @@ -310,4 +317,4 @@ class Site { )); } -} \ No newline at end of file +} diff --git a/Zotlabs/Module/Admin/Themes.php b/Zotlabs/Module/Admin/Themes.php index 63a9a1670..fc908ec8b 100644 --- a/Zotlabs/Module/Admin/Themes.php +++ b/Zotlabs/Module/Admin/Themes.php @@ -230,4 +230,4 @@ class Themes { -} \ No newline at end of file +} diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index 67cecf1f5..d5be07a81 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -130,12 +130,19 @@ class Display { if($allowed_themes) { foreach($allowed_themes as $th) { $f = $th; + + $min_version = ((file_exists('view/theme/' . $th . '/.MINVERSION')) ? file_get_contents('view/theme/' . $th . '/.MINVERSION') : 0); + if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $mobile_themes[$f] = $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); + continue; + } + $is_experimental = file_exists('view/theme/' . $th . '/experimental'); $unsupported = file_exists('view/theme/' . $th . '/unsupported'); $is_mobile = file_exists('view/theme/' . $th . '/mobile'); $is_library = file_exists('view/theme/'. $th . '/library'); - $mobile_themes["---"] = t("No special theme for mobile devices"); - + $mobile_themes['---'] = t("No special theme for mobile devices"); + if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ $theme_name = (($is_experimental) ? sprintf(t('%s - (Experimental)'), $f) : $f); if (! $is_library) { @@ -147,7 +154,6 @@ class Display { } } } - } } diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index dadb18051..53bcfe664 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -69,8 +69,13 @@ class Theme { if(array_key_exists('theme_preview',$_GET)) $chosen_theme = $_GET['theme_preview']; - // Allow theme selection of the form 'theme_name:schema_name' + // Check if $chosen_theme is compatible with core. If not fall back to default + $min_version = ((file_exists('view/theme/' . $chosen_theme . '/.MINVERSION')) ? file_get_contents('view/theme/' . $chosen_theme . '/.MINVERSION') : 0); + if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $chosen_theme = ''; + } + // Allow theme selection of the form 'theme_name:schema_name' $themepair = explode(':', $chosen_theme); if($chosen_theme && (file_exists('view/theme/' . $themepair[0] . '/css/style.css') || file_exists('view/theme/' . $themepair[0] . '/php/style.php'))) { diff --git a/view/theme/redbasic/.MINVERSION b/view/theme/redbasic/.MINVERSION new file mode 100644 index 000000000..8bbe6cf74 --- /dev/null +++ b/view/theme/redbasic/.MINVERSION @@ -0,0 +1 @@ +2.2 diff --git a/view/theme/redbasic/php/theme.php b/view/theme/redbasic/php/theme.php index 997b59750..0f0c43484 100644 --- a/view/theme/redbasic/php/theme.php +++ b/view/theme/redbasic/php/theme.php @@ -3,7 +3,7 @@ /** * * Name: Redbasic * * Description: Hubzilla standard theme - * * Version: 1.0 + * * Version: 2.0 * * Author: Fabrixxm * * Maintainer: Mike Macgirvin * * Maintainer: Mario Vavti -- cgit v1.2.3 From 8e3e90ddd243011828b9dbb44e7c4abc00655b28 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 10:13:08 +0100 Subject: set minversion and maxversion for themes in view/theme/themename/php/theme.php instead of separate file. --- Zotlabs/Module/Admin/Site.php | 5 +++-- Zotlabs/Module/Settings/Display.php | 5 +++-- Zotlabs/Render/Theme.php | 5 +++-- include/plugin.php | 2 ++ view/theme/redbasic/.MINVERSION | 1 - view/theme/redbasic/php/theme.php | 2 ++ 6 files changed, 13 insertions(+), 7 deletions(-) delete mode 100644 view/theme/redbasic/.MINVERSION diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 3bb384ec5..b71e63030 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -164,8 +164,9 @@ class Site { $vars = ''; $f = basename($file); - $min_version = ((file_exists('view/theme/' . $f . '/.MINVERSION')) ? file_get_contents('view/theme/' . $f . '/.MINVERSION') : 0); - if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $info = get_theme_info($f); + $compatible = check_plugin_versions($info); + if(!$compatible) { $theme_choices[$f] = $theme_choices_mobile[$f] = sprintf(t('%s - (Incompatible)'), $f); continue; } diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index d5be07a81..ee404daba 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -131,8 +131,9 @@ class Display { foreach($allowed_themes as $th) { $f = $th; - $min_version = ((file_exists('view/theme/' . $th . '/.MINVERSION')) ? file_get_contents('view/theme/' . $th . '/.MINVERSION') : 0); - if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $info = get_theme_info($th); + $compatible = check_plugin_versions($info); + if(!$compatible) { $mobile_themes[$f] = $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); continue; } diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 53bcfe664..7464a0db2 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -70,8 +70,9 @@ class Theme { $chosen_theme = $_GET['theme_preview']; // Check if $chosen_theme is compatible with core. If not fall back to default - $min_version = ((file_exists('view/theme/' . $chosen_theme . '/.MINVERSION')) ? file_get_contents('view/theme/' . $chosen_theme . '/.MINVERSION') : 0); - if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $info = get_theme_info($chosen_theme); + $compatible = check_plugin_versions($info); + if(!$compatible) { $chosen_theme = ''; } diff --git a/include/plugin.php b/include/plugin.php index 045efb805..29474735e 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -471,6 +471,8 @@ function get_theme_info($theme){ 'description' => '', 'author' => array(), 'version' => '', + 'minversion' => '', + 'maxversion' => '', 'compat' => '', 'credits' => '', 'maintainer' => array(), diff --git a/view/theme/redbasic/.MINVERSION b/view/theme/redbasic/.MINVERSION deleted file mode 100644 index 8bbe6cf74..000000000 --- a/view/theme/redbasic/.MINVERSION +++ /dev/null @@ -1 +0,0 @@ -2.2 diff --git a/view/theme/redbasic/php/theme.php b/view/theme/redbasic/php/theme.php index 0f0c43484..ac762502b 100644 --- a/view/theme/redbasic/php/theme.php +++ b/view/theme/redbasic/php/theme.php @@ -4,6 +4,8 @@ * * Name: Redbasic * * Description: Hubzilla standard theme * * Version: 2.0 + * * MinVersion: 2.2 + * * MaxVersion: 3.0 * * Author: Fabrixxm * * Maintainer: Mike Macgirvin * * Maintainer: Mario Vavti -- cgit v1.2.3 From b6c4e6a6d08dd88a3d86b5b509a2cd0f5e72ef83 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 10:18:05 +0100 Subject: lower version requirement to 2.2RC --- view/theme/redbasic/php/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/redbasic/php/theme.php b/view/theme/redbasic/php/theme.php index ac762502b..95d5a2001 100644 --- a/view/theme/redbasic/php/theme.php +++ b/view/theme/redbasic/php/theme.php @@ -4,7 +4,7 @@ * * Name: Redbasic * * Description: Hubzilla standard theme * * Version: 2.0 - * * MinVersion: 2.2 + * * MinVersion: 2.2RC * * MaxVersion: 3.0 * * Author: Fabrixxm * * Maintainer: Mike Macgirvin -- cgit v1.2.3 From 24676980450908d22b56d2eb3c146ad1f991c97c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 10:44:50 +0100 Subject: do not mess up schemas --- Zotlabs/Render/Theme.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 7464a0db2..71eef50c3 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -69,16 +69,18 @@ class Theme { if(array_key_exists('theme_preview',$_GET)) $chosen_theme = $_GET['theme_preview']; + + + // Allow theme selection of the form 'theme_name:schema_name' + $themepair = explode(':', $chosen_theme); + // Check if $chosen_theme is compatible with core. If not fall back to default - $info = get_theme_info($chosen_theme); + $info = get_theme_info($themepair[0]); $compatible = check_plugin_versions($info); if(!$compatible) { $chosen_theme = ''; } - // Allow theme selection of the form 'theme_name:schema_name' - $themepair = explode(':', $chosen_theme); - if($chosen_theme && (file_exists('view/theme/' . $themepair[0] . '/css/style.css') || file_exists('view/theme/' . $themepair[0] . '/php/style.php'))) { return($themepair); } -- cgit v1.2.3 From 1070f3ed6b1f92f6909767089d7bccf401baeda9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 10:54:43 +0100 Subject: missing clear --- view/tpl/hdr.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/hdr.tpl b/view/tpl/hdr.tpl index 6a14906f6..577269b6f 100644 --- a/view/tpl/hdr.tpl +++ b/view/tpl/hdr.tpl @@ -1,5 +1,5 @@ -- cgit v1.2.3 From 805cae7b3128a796b45e406f83dcd835e0d291f2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 11:11:53 +0100 Subject: whitespace --- Zotlabs/Render/Theme.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 71eef50c3..3a0116abe 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -69,8 +69,6 @@ class Theme { if(array_key_exists('theme_preview',$_GET)) $chosen_theme = $_GET['theme_preview']; - - // Allow theme selection of the form 'theme_name:schema_name' $themepair = explode(':', $chosen_theme); -- cgit v1.2.3 From 1a28720c56d2bde96e4b710d19cde30518aa6793 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 11:41:58 +0100 Subject: update changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 5b29b875d..487dd4331 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Hubzilla 2.2 (2017-??-??) + - Provide version compatibility check for themes (minversion, maxversion) - Use chanlink_hash() instead of chanlink_url() where appropriate - Use head_add_link() for feed discovery - Provide HTTP header parser which honours continuation lines -- cgit v1.2.3 From 69e145a630cdb5a11252b9043b8c8486fae7e54d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 13:52:08 +0100 Subject: fix js issue in markdown mimetype wikis if content contains quotes --- Zotlabs/Module/Wiki.php | 8 +++----- view/tpl/wiki.tpl | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 32b484eea..15806ffc3 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -234,10 +234,8 @@ class Wiki extends \Zotlabs\Web\Controller { $mimeType = $p['mimeType']; - $rawContent = (($p['mimeType'] == 'text/bbcode') - ? htmlspecialchars_decode(json_decode($p['content']),ENT_COMPAT) - : htmlspecialchars_decode($p['content'],ENT_COMPAT) - ); + $rawContent = htmlspecialchars_decode(json_decode($p['content']),ENT_COMPAT); + $content = ($p['content'] !== '' ? $rawContent : '"# New page\n"'); // Render the Markdown-formatted page content in HTML if($mimeType == 'text/bbcode') { @@ -245,7 +243,7 @@ class Wiki extends \Zotlabs\Web\Controller { } else { require_once('library/markdown.php'); - $html = Zlib\NativeWikiPage::generate_toc(zidify_text(purify_html(Markdown(Zlib\NativeWikiPage::bbcode(json_decode($content)))))); + $html = Zlib\NativeWikiPage::generate_toc(zidify_text(purify_html(Markdown(Zlib\NativeWikiPage::bbcode($content))))); $renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName); } $showPageControls = $wiki_editor; diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index af6b6800e..ea31c23a3 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -107,7 +107,7 @@