initial commit
This commit is contained in:
commit
db2d8ac606
21
appinfo/info.xml
Normal file
21
appinfo/info.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
|
||||
<id>pride_flags</id>
|
||||
<name>Pride Flags</name>
|
||||
<summary>Add pride flags to your nextcloud</summary>
|
||||
<description><![CDATA[Diversity and inclusion are what makes the world worth living in! Let's show some pride!]]></description>
|
||||
<version>0.1.2</version>
|
||||
<licence>cnvpl</licence>
|
||||
<author mail="" homepage="https://github.com/finallycoffee/nextcloud-pride"></author>
|
||||
<namespace>PrideFlags</namespace>
|
||||
<category>customization</category>
|
||||
<bugs>https://github.com/finallycoffee/nextcloud-pride/issues</bugs>
|
||||
<dependencies>
|
||||
<nextcloud min-version="26" max-version="28"/>
|
||||
</dependencies>
|
||||
<settings>
|
||||
<personal-section>OCA\PrideFlags\Settings\PersonalSection</personal-section>
|
||||
<personal>OCA\PrideFlags\Settings\PersonalSettings</personal>
|
||||
</settings>
|
||||
</info>
|
7
appinfo/routes.php
Normal file
7
appinfo/routes.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?
|
||||
|
||||
return [
|
||||
'routes' => [
|
||||
// ['name' => '', 'url' => '', 'verb' => '']
|
||||
]
|
||||
];
|
3
css/pride.css
Normal file
3
css/pride.css
Normal file
@ -0,0 +1,3 @@
|
||||
.files-list__row-icon .folder-icon svg {
|
||||
fill: url("#gradient-pride");
|
||||
}
|
66
js/pride.js
Normal file
66
js/pride.js
Normal file
@ -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 `<stop stop-color="${color}" stop-opacity="${opacity}" offset="${offset * 100}%"></stop>`;
|
||||
});
|
||||
};
|
||||
|
||||
const makeLinearGradientSvg = (id, colors, opacity, transform) => {
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" id="svg-${id}" preserveAspectRatio="none" width="100%" height="100%">
|
||||
<defs>
|
||||
<linearGradient id="gradient-${id}" gradientTransform="${transform}">
|
||||
${generateStops(colors, opacity).join('\n')}
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<style>
|
||||
rect { height: 100%; width: 100%; }
|
||||
</style>
|
||||
<rect fill="url(#gradient-${id})" width="100%" height="100%" />
|
||||
</svg>`;
|
||||
};
|
||||
|
||||
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);
|
||||
});
|
9
lib/AppConstants.php
Normal file
9
lib/AppConstants.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\PrideFlags;
|
||||
|
||||
abstract class AppConstants {
|
||||
public const APP_ID = 'pride_flags';
|
||||
}
|
27
lib/AppInfo/Application.php
Normal file
27
lib/AppInfo/Application.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Pride\AppInfo;
|
||||
|
||||
use OCP\Util;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\IConfig;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
const APP_ID = 'pride';
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct(self::APP_ID, $urlParams);
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $ctx): void {
|
||||
$config = \OC::$server->get(IConfig::class);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $ctx): void {
|
||||
Util::addStyle(self::APP_ID, 'pride');
|
||||
Util::addScript(self::APP_ID, 'pride');
|
||||
}
|
||||
}
|
29
lib/Settings/PersonalSection.php
Normal file
29
lib/Settings/PersonalSection.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_tyes=1);
|
||||
|
||||
namespace OCA\PrideFlags\Settings;
|
||||
|
||||
use OCA\PrideFlags\AppConstants;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
class PersonalSection implements IIconSection {
|
||||
public function __construct(private IL10N $l10n, private IURLGenerator $urlGenerator) {}
|
||||
|
||||
public function getId(): string {
|
||||
return AppConstants::APP_ID;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return 'Pride';
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 100;
|
||||
}
|
||||
|
||||
public function getIcon(): string {
|
||||
return $this->urlGenerator->imagePath('core', 'settings-dark.svg');
|
||||
}
|
||||
}
|
24
lib/Settings/PersonalSettings.php
Normal file
24
lib/Settings/PersonalSettings.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\PrideFlags\Settings;
|
||||
|
||||
use OCA\PrideFlags\AppConstants;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\Util;
|
||||
|
||||
class PersonalSettings implements ISettings {
|
||||
public function getForm(): TemplateResponse {
|
||||
return new TemplateResponse(AppConstants::APP_ID, 'settings', []);
|
||||
}
|
||||
|
||||
public function getSection(): string {
|
||||
return AppConstant::APP_ID;
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 50;
|
||||
}
|
||||
}
|
15
templates/settings.php
Normal file
15
templates/settings.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div class="pride_flags_user_settings">
|
||||
<div class="settings-section">
|
||||
<h2 class="settings_section__name">Personal preferences</h2>
|
||||
<p class="settings_section__desc">Configure which pride flags you want where</p>
|
||||
<div class="user-settings">
|
||||
<select>
|
||||
<option value='pride'>Pride</option>
|
||||
<option value='trans'>Trans Pride</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user