From 64fddf7da4c2c525a35dcd4d0c7bd74b66953771 Mon Sep 17 00:00:00 2001 From: trendschau Date: Thu, 2 Mar 2023 14:50:02 +0100 Subject: [PATCH] Activate Plugins and Themes --- .../ControllerApiSystemExtensions.php | 14 +- .../Controllers/ControllerWebSystem.php | 25 ++- system/typemill/author/css/output.css | 172 +++++++++++++++--- system/typemill/author/js/vue-plugins.js | 23 ++- system/typemill/author/js/vue-themes.js | 141 +++++++++++--- themes/cyanine/cyanine.yaml | 2 +- 6 files changed, 298 insertions(+), 79 deletions(-) diff --git a/system/typemill/Controllers/ControllerApiSystemExtensions.php b/system/typemill/Controllers/ControllerApiSystemExtensions.php index f7b825e..7f15cc5 100644 --- a/system/typemill/Controllers/ControllerApiSystemExtensions.php +++ b/system/typemill/Controllers/ControllerApiSystemExtensions.php @@ -51,7 +51,7 @@ class ControllerApiSystemExtensions extends ControllerData if(!isset($licenseScope[$definitions['license']])) { $response->getBody()->write(json_encode([ - 'message' => 'We can not activate this plugin because you need a valid '. $definitions['license'] .'-license and your website must run under the domain of your license.', + 'message' => 'Activation failed because you need a valid '. $definitions['license'] .'-license for this and your website must run under the domain of your license.', ])); return $response->withHeader('Content-Type', 'application/json')->withStatus(400); @@ -60,9 +60,15 @@ class ControllerApiSystemExtensions extends ControllerData } $objectdata = []; - $objectdata[$params['type']][$params['name']] = $this->settings[$params['type']][$params['name']]; - $objectdata[$params['type']][$params['name']]['active'] = $params['checked']; - + if($params['type'] == 'plugins') + { + $objectdata[$params['type']][$params['name']] = $this->settings[$params['type']][$params['name']]; + $objectdata[$params['type']][$params['name']]['active'] = $params['checked']; + } + elseif($params['type'] == 'themes') + { + $objectdata['theme'] = $params['name']; + } # store updated settings here $updatedSettings = Settings::updateSettings($objectdata); diff --git a/system/typemill/Controllers/ControllerWebSystem.php b/system/typemill/Controllers/ControllerWebSystem.php index 057523e..6ad833e 100644 --- a/system/typemill/Controllers/ControllerWebSystem.php +++ b/system/typemill/Controllers/ControllerWebSystem.php @@ -34,16 +34,21 @@ class ControllerWebSystem extends ControllerData public function showThemes($request, $response, $args) { - $storage = new StorageWrapper('\Typemill\Models\Storage'); - $translations = $this->c->get('translations'); - $themeSettings = $this->getThemeDetails(); - - $themedata = []; + $storage = new StorageWrapper('\Typemill\Models\Storage'); + $translations = $this->c->get('translations'); + $themeDefinitions = $this->getThemeDetails(); + $themeSettings = []; foreach($this->settings['themes'] as $themename => $themeinputs) { - $themedata[$themename] = $themeinputs; - $themedata[$themename]['customcss'] = $storage->getFile('cache', $themename . '-custom.css'); + $themeSettings[$themename] = $themeinputs; + $themeSettings[$themename]['customcss'] = $storage->getFile('cache', $themename . '-custom.css'); + } + + $license = []; + if(is_array($this->settings['license'])) + { + $license = array_keys($this->settings['license']); } return $this->c->get('view')->render($response, 'system/themes.twig', [ @@ -51,8 +56,10 @@ class ControllerWebSystem extends ControllerData 'mainnavi' => $this->getMainNavigation($request->getAttribute('c_userrole')), 'systemnavi' => $this->getSystemNavigation($request->getAttribute('c_userrole')), 'jsdata' => [ - 'settings' => $themedata, - 'themes' => $themeSettings, + 'settings' => $themeSettings, + 'definitions' => $themeDefinitions, + 'theme' => $this->settings['theme'], + 'license' => $license, 'labels' => $translations, 'urlinfo' => $this->c->get('urlinfo') ] diff --git a/system/typemill/author/css/output.css b/system/typemill/author/css/output.css index 932faa5..daad61b 100644 --- a/system/typemill/author/css/output.css +++ b/system/typemill/author/css/output.css @@ -743,6 +743,10 @@ video { margin-bottom: 0.75rem; } +.mr-3 { + margin-right: 0.75rem; +} + .mt-5 { margin-top: 1.25rem; } @@ -763,10 +767,6 @@ video { margin-top: 0.5rem; } -.mr-3 { - margin-right: 0.75rem; -} - .mt-4 { margin-top: 1rem; } @@ -791,6 +791,10 @@ video { margin-right: 0.5rem; } +.ml-3 { + margin-left: 0.75rem; +} + .block { display: block; } @@ -831,14 +835,14 @@ video { height: 2rem; } -.h-12 { - height: 3rem; -} - .h-6 { height: 1.5rem; } +.h-12 { + height: 3rem; +} + .h-5 { height: 1.25rem; } @@ -851,6 +855,14 @@ video { height: 16rem; } +.h-0 { + height: 0px; +} + +.h-48 { + height: 12rem; +} + .max-h-80 { max-height: 20rem; } @@ -923,6 +935,10 @@ video { width: 25%; } +.w-0 { + width: 0px; +} + .max-w-md { max-width: 28rem; } @@ -935,6 +951,10 @@ video { max-width: 72rem; } +.flex-1 { + flex: 1 1 0%; +} + .flex-shrink { flex-shrink: 1; } @@ -963,6 +983,12 @@ video { resize: both; } +.appearance-none { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; +} + .flex-col { flex-direction: column; } @@ -999,6 +1025,18 @@ video { justify-content: space-around; } +.space-x-8 > :not([hidden]) ~ :not([hidden]) { + --tw-space-x-reverse: 0; + margin-right: calc(2rem * var(--tw-space-x-reverse)); + margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse))); +} + +.space-x-4 > :not([hidden]) ~ :not([hidden]) { + --tw-space-x-reverse: 0; + margin-right: calc(1rem * var(--tw-space-x-reverse)); + margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse))); +} + .overflow-auto { overflow: auto; } @@ -1033,6 +1071,11 @@ video { border-width: 2px; } +.border-x-8 { + border-left-width: 8px; + border-right-width: 8px; +} + .border-b { border-bottom-width: 1px; } @@ -1057,6 +1100,14 @@ video { border-left-width: 4px; } +.border-b-8 { + border-bottom-width: 8px; +} + +.border-t-8 { + border-top-width: 8px; +} + .border-solid { border-style: solid; } @@ -1121,6 +1172,26 @@ video { border-color: rgb(226 232 240 / var(--tw-border-opacity)); } +.border-x-transparent { + border-left-color: transparent; + border-right-color: transparent; +} + +.border-b-blue-600 { + --tw-border-opacity: 1; + border-bottom-color: rgb(37 99 235 / var(--tw-border-opacity)); +} + +.border-b-white { + --tw-border-opacity: 1; + border-bottom-color: rgb(255 255 255 / var(--tw-border-opacity)); +} + +.border-t-white { + --tw-border-opacity: 1; + border-top-color: rgb(255 255 255 / var(--tw-border-opacity)); +} + .bg-teal-600 { --tw-bg-opacity: 1; background-color: rgb(13 148 136 / var(--tw-bg-opacity)); @@ -1232,6 +1303,26 @@ video { padding-bottom: 0.75rem; } +.px-8 { + padding-left: 2rem; + padding-right: 2rem; +} + +.py-2 { + padding-top: 0.5rem; + padding-bottom: 0.5rem; +} + +.py-4 { + padding-top: 1rem; + padding-bottom: 1rem; +} + +.px-4 { + padding-left: 1rem; + padding-right: 1rem; +} + .px-2 { padding-left: 0.5rem; padding-right: 0.5rem; @@ -1242,26 +1333,6 @@ video { padding-right: 0.25rem; } -.px-4 { - padding-left: 1rem; - padding-right: 1rem; -} - -.py-2 { - padding-top: 0.5rem; - padding-bottom: 0.5rem; -} - -.px-8 { - padding-left: 2rem; - padding-right: 2rem; -} - -.py-4 { - padding-top: 1rem; - padding-bottom: 1rem; -} - .pl-3 { padding-left: 0.75rem; } @@ -1302,6 +1373,14 @@ video { padding-bottom: 0.75rem; } +.pr-8 { + padding-right: 2rem; +} + +.pb-4 { + padding-bottom: 1rem; +} + .text-left { text-align: left; } @@ -1445,6 +1524,18 @@ video { text-decoration-line: underline; } +.accent-pink-300 { + accent-color: #f9a8d4; +} + +.accent-white { + accent-color: #fff; +} + +.accent-teal-500 { + accent-color: #14b8a6; +} + .opacity-0 { opacity: 0; } @@ -1507,6 +1598,26 @@ video { transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); } +.checked\:bg-white:checked { + --tw-bg-opacity: 1; + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); +} + +.checked\:bg-blue-500:checked { + --tw-bg-opacity: 1; + background-color: rgb(59 130 246 / var(--tw-bg-opacity)); +} + +.checked\:bg-teal-500:checked { + --tw-bg-opacity: 1; + background-color: rgb(20 184 166 / var(--tw-bg-opacity)); +} + +.checked\:text-white:checked { + --tw-text-opacity: 1; + color: rgb(255 255 255 / var(--tw-text-opacity)); +} + .hover\:border-b-4:hover { border-bottom-width: 4px; } @@ -1541,6 +1652,11 @@ video { background-color: rgb(13 148 136 / var(--tw-bg-opacity)); } +.hover\:bg-teal-700:hover { + --tw-bg-opacity: 1; + background-color: rgb(15 118 110 / var(--tw-bg-opacity)); +} + .hover\:bg-rose-500:hover { --tw-bg-opacity: 1; background-color: rgb(244 63 94 / var(--tw-bg-opacity)); diff --git a/system/typemill/author/js/vue-plugins.js b/system/typemill/author/js/vue-plugins.js index 78755e7..d30bf86 100644 --- a/system/typemill/author/js/vue-plugins.js +++ b/system/typemill/author/js/vue-plugins.js @@ -7,7 +7,7 @@ const app = Vue.createApp({

License: {{ plugin.license }}

- @@ -20,9 +20,12 @@ const app = Vue.createApp({

{{plugin.description}}

- - Buy a license - Donate + + Buy a license + Donate {{plugin.amount}},-
@@ -51,10 +54,10 @@ const app = Vue.createApp({
{{ message }}
- @@ -93,13 +96,15 @@ const app = Vue.createApp({ eventBus.$on('forminput', formdata => { this.formData[this.current][formdata.name] = formdata.value; }); + + console.info(this.formData); }, methods: { getActiveClass: function(pluginname) { if(this.formData[pluginname]['active']) { - return 'bg-teal-500 text-white'; + return 'bg-stone-200'; } }, getLinkToLicense: function() diff --git a/system/typemill/author/js/vue-themes.js b/system/typemill/author/js/vue-themes.js index 13b29de..c030887 100644 --- a/system/typemill/author/js/vue-themes.js +++ b/system/typemill/author/js/vue-themes.js @@ -3,75 +3,160 @@ const app = Vue.createApp({
  • -
    -
    - +
    +

    License: {{ theme.license }}

    +
    + +
    -
    -
    +
    +
    +
    +

    {{theme.name}}

    -
    author: {{theme.author}} | version: {{theme.version}} | {{theme.licence}}
    +
    author: {{theme.author}} | version: {{theme.version}}

    {{theme.description}}

    -
    - - +
    +
    +
    + + Buy a license + Donate {{theme.amount}},- +
    {{ fieldDefinition.legend }} + :key="subfieldname" + :is="selectComponent(subfieldDefinition.type)" + :errors="errors" + :name="subfieldname" + :userroles="userroles" + :value="formData[themename][subfieldname]" + v-bind="subfieldDefinition">
    + :key="fieldname" + :is="selectComponent(fieldDefinition.type)" + :errors="errors" + :name="fieldname" + :userroles="userroles" + :value="formData[themename][fieldname]" + v-bind="fieldDefinition">
    {{ message }}
    -
    - - +
+
+ + + + + +
`, data() { return { current: '', - formDefinitions: data.themes, + formDefinitions: data.definitions, formData: data.settings, + theme: data.theme, + license: data.license, message: '', messageClass: '', errors: {}, - userroles: false + userroles: false, + showModal: false, + modalMessage: 'default', } }, mounted() { eventBus.$on('forminput', formdata => { this.formData[this.current][formdata.name] = formdata.value; }); + this.deactivateThemes(); + this.formData[this.theme].active = true; }, methods: { + deactivateThemes: function() + { + for (const theme in this.formData) { + delete this.formData[theme].active; + } + }, + getActiveClass: function(themename) + { + if(this.formData[themename]['active']) + { + return 'bg-stone-200'; + } + }, + getLinkToLicense: function() + { + return tmaxios.defaults.baseURL + "/tm/license"; + }, + checkLicense: function(haystack, needle) + { + if(needle == 'MAKER' || needle == 'BUSINESS') + { + if(haystack.indexOf(needle) == -1) + { + return false; + } + } + return true; + }, + activate: function(themename) + { + var self = this; + + tmaxios.post('/api/v1/extensions',{ + 'csrf_name': document.getElementById("csrf_name").value, + 'csrf_value': document.getElementById("csrf_value").value, + 'type': 'themes', + 'name': themename, + 'checked': this.formData[themename]['active'] + }) + .then(function (response) + { + var status = self.formData[themename]['active']; + self.deactivateThemes(); + self.formData[themename]['active'] = status; + }) + .catch(function (error) + { + self.modalMessage = error.response.data.message; + self.showModal = true; + }); + }, setCurrent: function(name) { if(this.current == name) diff --git a/themes/cyanine/cyanine.yaml b/themes/cyanine/cyanine.yaml index 4f4f8ff..0dc7d8b 100644 --- a/themes/cyanine/cyanine.yaml +++ b/themes/cyanine/cyanine.yaml @@ -3,7 +3,7 @@ version: 1.1.12 description: Cyanine is a modern and flexible multi-purpose theme and the standard theme for typemill. author: Trendschau homepage: https://trendschau.net -licence: MIT +license: MIT paypal: https://paypal.me/typemill amount: 25