commit 9cd917f18ef27edf3cb583572da6ceeeddfafd58 Author: transcaffeine Date: Sun Jul 28 17:57:30 2024 +0200 initial commit diff --git a/appinfo/info.xml b/appinfo/info.xml new file mode 100644 index 0000000..3be9885 --- /dev/null +++ b/appinfo/info.xml @@ -0,0 +1,21 @@ + + + pride_flags + Pride Flags + Add pride flags to your nextcloud + + 0.1.2 + cnvpl + + PrideFlags + customization + https://github.com/finallycoffee/nextcloud-pride/issues + + + + + OCA\PrideFlags\Settings\PersonalSection + OCA\PrideFlags\Settings\PersonalSettings + + diff --git a/appinfo/routes.php b/appinfo/routes.php new file mode 100644 index 0000000..589680d --- /dev/null +++ b/appinfo/routes.php @@ -0,0 +1,8 @@ + [ + ['name' => 'settings#get', 'url' => '/settings', 'verb' => 'GET'], + ['name' => 'settings#set', 'url' => '/settings', 'verb' => 'POST'], + ] +]; diff --git a/css/pride.css b/css/pride.css new file mode 100644 index 0000000..06982fa --- /dev/null +++ b/css/pride.css @@ -0,0 +1,3 @@ +.files-list__row-icon .folder-icon svg { + fill: url("#gradient-pride"); +} diff --git a/js/pride-settings.js b/js/pride-settings.js new file mode 100644 index 0000000..8102da0 --- /dev/null +++ b/js/pride-settings.js @@ -0,0 +1,29 @@ +const folder_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.folder-flavour select'); +const button_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.button-flavour select'); +const submit_button = document.querySelectorAll('.pride_flags_user_settings .settings-pride-submit'); + +fetch('/index.php/apps/pride_flags/settings') + .then(res => JSON.parse(res)) + .then(({folderPrideVariant, buttonPrideVariant}) => { + folder_selector.value = folderPrideVariant; + button_selector.value = buttonPrideVariant; + }); + +function save() { + const payload = { + folderVariant: folder_selector.value, + buttonVariant: button_selector.value, + } + fetch('index.php/apps/pride_flags/settings', { + method: 'POST', + body: JSON.stringify(payload), + headers: { + "Content-Type": "application/json", + } + }).then(response => { + if (response.ok) { + window.location.reload(); + } + }) +} +submit_button.on('click', e => save()); diff --git a/js/pride.js b/js/pride.js new file mode 100644 index 0000000..4d6cfc6 --- /dev/null +++ b/js/pride.js @@ -0,0 +1,66 @@ +const flags = [ + { + id: 'pride', + colors: ['#E04641', '#DE7E41', '#E4D56F', '#55B85F', '#2473B5', '#6F5DA5'], + transform: 'rotate(90)' + }, { + id: 'trans', + colors: ['#55CDFC', '#F7A8B8', '#FFFFFF', '#F7A8B8', '#55CDFC'], + transform: 'rotate(90)' + } +]; + +const generateGradient = colors => { + const steps = colors.length; + return colors.map((color, index) => { return [ + [color, (index / steps)], + [color, (index + 1) / steps] + ]}).flat(); +}; + +const generateStops = (colors, opacity) => { + return generateGradient(colors).map(([color, offset]) => { + return ``; + }); +}; + +const makeLinearGradientSvg = (id, colors, opacity, transform) => { + return ` + + + ${generateStops(colors, opacity).join('\n')} + + + + + `; +}; + +flags.forEach(flag => { + const svg_html = makeLinearGradientSvg(flag.id, flag.colors, flag.opacity ?? '0.8', flag.transform ?? 'rotate(0)'); + const container = document.createElement('div'); + container.classList.add('hidden-visually'); + container.ariaHidden = true; + container.innerHTML = svg_html; + const style_c = document.createElement('style'); + style_c.textContent = ` + body { + --image-background-pride-${flag.id}: url('data:image/svg+xml;base64,${btoa(svg_html)}'); + } + #app-navigation ul > li.active, + .button-vue--vue-primary, + .preview-card__header, + .profile__primary-action-button, + .app-navigation-entry.active { + background-image: var(--image-background-pride-trans) !important; + } + .material-design-icon__svg, + .checkbox-radio-switch svg { + fill: url(#gradient-trans); + } + `; + document.body.prepend(container); + document.head.prepend(style_c); +}); diff --git a/lib/AppConstants.php b/lib/AppConstants.php new file mode 100644 index 0000000..e2be724 --- /dev/null +++ b/lib/AppConstants.php @@ -0,0 +1,9 @@ +get(IConfig::class); + } + + public function boot(IBootContext $ctx): void { + Util::addStyle(AppConstants::APP_ID, 'pride'); + Util::addScript(AppConstants::APP_ID, 'pride'); + } +} diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php new file mode 100644 index 0000000..a05df23 --- /dev/null +++ b/lib/Controller/PageController.php @@ -0,0 +1,23 @@ +settings->getAll(); + } + public function set(string $folderVariant, string $buttonVariant): JSONResponse { + return $this->settings->set($folderVariant, $buttonVariant); + } +} diff --git a/lib/Settings/AppSettings.php b/lib/Settings/AppSettings.php new file mode 100644 index 0000000..f369f9a --- /dev/null +++ b/lib/Settings/AppSettings.php @@ -0,0 +1,39 @@ +config->getAppValue(AppConstants::APP_ID, $key) ?: $default; + } + + public function setStringSetting(string $key, string $value): string { + return $this->config->getAppValue(AppConstants::APP_ID, $key, $value); + } + + public function getAll(): JsonSerializable { + return [ + AppSettings::FOLDER_VARIANT => $this->getStringSetting(AppSettings::FOLDER_VARIANT, 'pride'), + AppSettings::BUTTON_VARIANT => $this->getStringSetting(AppSettings::BUTTON_VARIANT, 'trans'), + ] + } + + public function set($folder, $button): JsonSerializable { + $this->setStringSetting(AppSettings::FOLDER_VARIANT, $folder); + $this->setStringSetting(AppSettings::BUTTON_VARIANT, $button); + return $this->getAll(); + } + + public function jsonSerialize(): array { + return $this->getAll(); + } +} diff --git a/lib/Settings/PersonalSection.php b/lib/Settings/PersonalSection.php new file mode 100644 index 0000000..dc41505 --- /dev/null +++ b/lib/Settings/PersonalSection.php @@ -0,0 +1,30 @@ +urlGenerator->imagePath('core', 'actions/settings-dark.svg'); + } +} diff --git a/lib/Settings/PersonalSettings.php b/lib/Settings/PersonalSettings.php new file mode 100644 index 0000000..26b5321 --- /dev/null +++ b/lib/Settings/PersonalSettings.php @@ -0,0 +1,25 @@ + +
+
+

Personal preferences

+ + + +
+