From da0d1a679fd24df4d61d8607787e4bd2b2b16736 Mon Sep 17 00:00:00 2001 From: transcaffeine Date: Sun, 28 Jul 2024 17:57:30 +0200 Subject: [PATCH] initial commit --- appinfo/info.xml | 21 ++++++++++ appinfo/routes.php | 7 ++++ css/pride.css | 3 ++ js/pride.js | 66 +++++++++++++++++++++++++++++++ lib/AppConstants.php | 9 +++++ lib/AppInfo/Application.php | 28 +++++++++++++ lib/Settings/PersonalSection.php | 29 ++++++++++++++ lib/Settings/PersonalSettings.php | 24 +++++++++++ templates/settings.php | 15 +++++++ 9 files changed, 202 insertions(+) create mode 100644 appinfo/info.xml create mode 100644 appinfo/routes.php create mode 100644 css/pride.css create mode 100644 js/pride.js create mode 100644 lib/AppConstants.php create mode 100644 lib/AppInfo/Application.php create mode 100644 lib/Settings/PersonalSection.php create mode 100644 lib/Settings/PersonalSettings.php create mode 100644 templates/settings.php 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..d7f9475 --- /dev/null +++ b/appinfo/routes.php @@ -0,0 +1,7 @@ + [ +// ['name' => '', 'url' => '', 'verb' => ''] + ] +]; 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.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/Settings/PersonalSection.php b/lib/Settings/PersonalSection.php new file mode 100644 index 0000000..02395f4 --- /dev/null +++ b/lib/Settings/PersonalSection.php @@ -0,0 +1,29 @@ +urlGenerator->imagePath('core', 'settings-dark.svg'); + } +} diff --git a/lib/Settings/PersonalSettings.php b/lib/Settings/PersonalSettings.php new file mode 100644 index 0000000..b8a9297 --- /dev/null +++ b/lib/Settings/PersonalSettings.php @@ -0,0 +1,24 @@ + +
+
+

Personal preferences

+

Configure which pride flags you want where

+ +
+