From 189da4fdc1408a25b4fd68c0b7d5834232a599a2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 23 Aug 2021 10:32:48 +0000 Subject: untangle the app template into separate templates and fix bbcode view --- Zotlabs/Lib/Apps.php | 28 ++++++++++++++++++++++++++-- include/bbcode.php | 2 +- view/theme/redbasic/css/style.css | 2 +- view/tpl/app.tpl | 14 +------------- view/tpl/app_inline.tpl | 26 ++++++++++++++++++++++++++ view/tpl/app_nav.tpl | 2 +- view/tpl/app_nav_pinned.tpl | 1 + view/tpl/app_order.tpl | 3 +++ 8 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 view/tpl/app_inline.tpl create mode 100644 view/tpl/app_nav_pinned.tpl create mode 100644 view/tpl/app_order.tpl diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index a9af0812d..ba854197f 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -547,12 +547,38 @@ class Apps { } if($mode === 'navbar') { + return replace_macros(get_markup_template('app_nav_pinned.tpl'),array( + '$app' => $papp, + '$icon' => $icon, + )); + } + + if($mode === 'nav') { return replace_macros(get_markup_template('app_nav.tpl'),array( '$app' => $papp, '$icon' => $icon, )); } + if($mode === 'inline') { + return replace_macros(get_markup_template('app_inline.tpl'),array( + '$app' => $papp, + '$icon' => $icon, + '$installed' => $installed, + '$purchase' => ((isset($papp['page']) && (! $installed)) ? t('Purchase') : ''), + '$action_label' => $install_action + )); + } + + if(in_array($mode, ['nav-order', 'nav-order-pinned'])) { + return replace_macros(get_markup_template('app_order.tpl'),array( + '$app' => $papp, + '$icon' => $icon, + '$hosturl' => $hosturl, + '$mode' => $mode + )); + } + if($mode === 'install') { $papp['embed'] = true; } @@ -573,8 +599,6 @@ class Apps { '$pin' => ((isset($papp['embed']) || $mode == 'edit') ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), '$pinned' => ((strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true), - '$navapps' => (($mode == 'nav') ? true : false), - '$order' => (($mode === 'nav-order' || $mode === 'nav-order-pinned') ? true : false), '$mode' => $mode, '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray'), diff --git a/include/bbcode.php b/include/bbcode.php index 87a7e6af6..25615e385 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -308,7 +308,7 @@ function bb_parse_app($match) { $app = Zotlabs\Lib\Apps::app_decode($match[1]); if ($app) - return Zotlabs\Lib\Apps::app_render($app); + return preg_replace('/[[:cntrl:]]/', '', Zotlabs\Lib\Apps::app_render($app, 'inline')); } function bb_svg($match) { diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 811df02e4..228e7b63a 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1743,7 +1743,7 @@ dl.bb-dl > dd > li { border-left: 0.2rem solid #eee; } -.app-icon { +.app-icon i { color: #777; font-size: 80px; text-shadow: 3px 3px 3px lightgrey; diff --git a/view/tpl/app.tpl b/view/tpl/app.tpl index 69af0436b..f3f6ae58b 100644 --- a/view/tpl/app.tpl +++ b/view/tpl/app.tpl @@ -1,5 +1,3 @@ -{{if ! ($navapps || $order)}} -
{{if $app.type !== 'system'}} @@ -24,10 +22,9 @@ {{/if}}

{{$app.name}}{{if $app.price}} ({{$app.price}}){{/if}}

-
-
-{{/if}} -{{if $navapps}} -{{if $icon}}{{else}}{{/if}}{{$app.name}} -{{/if}} -{{if $order}} - - -{{if $icon}}{{else}}{{/if}}{{$app.name}}
-{{/if}} diff --git a/view/tpl/app_inline.tpl b/view/tpl/app_inline.tpl new file mode 100644 index 000000000..fc3675380 --- /dev/null +++ b/view/tpl/app_inline.tpl @@ -0,0 +1,26 @@ +

{{$app.name}}{{if $app.price}} ({{$app.price}}){{/if}}

+ + {{if $icon}} + + {{else}} + + {{/if}} + +
+ {{if $app.desc}}{{$app.desc}}{{/if}} +
+{{if $action_label}} +
+
+ + {{if $action_label}} + + {{/if}} + {{if $purchase && $app.type !== 'system'}} + + {{/if}} +
+
+{{/if}} + + diff --git a/view/tpl/app_nav.tpl b/view/tpl/app_nav.tpl index 817c74763..0d6e66892 100644 --- a/view/tpl/app_nav.tpl +++ b/view/tpl/app_nav.tpl @@ -1 +1 @@ -{{if $icon}}{{else}}{{/if}}{{$app.name}} +{{if $icon}}{{else}}{{/if}}{{$app.name}} diff --git a/view/tpl/app_nav_pinned.tpl b/view/tpl/app_nav_pinned.tpl new file mode 100644 index 000000000..817c74763 --- /dev/null +++ b/view/tpl/app_nav_pinned.tpl @@ -0,0 +1 @@ +{{if $icon}}{{else}}{{/if}}{{$app.name}} diff --git a/view/tpl/app_order.tpl b/view/tpl/app_order.tpl new file mode 100644 index 000000000..53c770cb7 --- /dev/null +++ b/view/tpl/app_order.tpl @@ -0,0 +1,3 @@ + + +{{if $icon}}{{else}}{{/if}}{{$app.name}}
-- cgit v1.2.3