From 7480fcc916d261136b388938bf7b15204c6a4171 Mon Sep 17 00:00:00 2001 From: craig kaiser Date: Fri, 18 Dec 2020 10:30:12 -0500 Subject: [PATCH] Remove patch that is no longer needed in RT 5.0.1 --- MANIFEST | 4 +++- META.yml | 4 ++-- README | 6 ++---- README.md | 6 +----- inc/Module/Install/RTx.pm | 34 ++++++++++++++++++++++++--------- lib/RT/Extension/ToggleTheme.pm | 4 ---- patches/header-callback.patch | 18 ----------------- 7 files changed, 33 insertions(+), 43 deletions(-) delete mode 100644 patches/header-callback.patch diff --git a/MANIFEST b/MANIFEST index 5e31db1..ff7319c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,6 +1,7 @@ Changes html/Callbacks/RT-Extension-ToggleTheme/Elements/Header/MassageCSSFiles html/Callbacks/RT-Extension-ToggleTheme/Elements/Tabs/Privileged +html/Callbacks/RT-Extension-ToggleTheme/Elements/Tabs/SelfService html/Helpers/Toggle/Theme inc/Module/Install.pm inc/Module/Install/Base.pm @@ -19,7 +20,8 @@ lib/RT/Extension/ToggleTheme.pm Makefile.PL MANIFEST This list of files META.yml -patches/header-callback.patch README +README.md +static/images/demo.gif static/js/fontawesome-icons.js static/js/themes.js diff --git a/META.yml b/META.yml index 4a01c84..883eb5b 100644 --- a/META.yml +++ b/META.yml @@ -23,7 +23,7 @@ requires: perl: 5.10.1 resources: repository: https://github.com/craigkai/rt-extension-toggletheme -version: '0.01' -x_module_install_rtx_version: '0.41' +version: '0.02' +x_module_install_rtx_version: '0.42' x_requires_rt: 5.0.0 x_rt_too_new: 5.2.0 diff --git a/README b/README index b7abbf3..dd7294c 100644 --- a/README +++ b/README @@ -2,7 +2,8 @@ NAME RT-Extension-ToggleTheme - Toggle elevator light and dark theme. DESCRIPTION - To save your eyes in the dark. + To save your eyes in the dark. The theme toggle button only displays for + users who have the ModifySelf right. RT VERSION Works with RT 5 @@ -18,9 +19,6 @@ INSTALLATION Plugin('RT::Extension::ToggleTheme'); - Apply patch to RT5 - patch -d /opt/r5 -p1 < patches/header-callback.patch - Clear your mason cache rm -rf /opt/rt5/var/mason_data/obj diff --git a/README.md b/README.md index 0161ef4..29973c3 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,12 @@ users who have the ModifySelf right. ##### May need root permissions -##### Edit your /opt/rt4/etc/RT_SiteConfig.pm +##### Edit your /opt/rt5/etc/RT_SiteConfig.pm ##### Add this line: Plugin('RT::Extension::ToggleTheme'); -##### Apply patch to RT5 - - patch -d /opt/r5 -p1 < patches/header-callback.patch - ##### Clear your mason cache rm -rf /opt/rt5/var/mason_data/obj diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm index d371af9..2dd9489 100644 --- a/inc/Module/Install/RTx.pm +++ b/inc/Module/Install/RTx.pm @@ -6,9 +6,10 @@ use strict; use warnings; no warnings 'once'; +use Term::ANSIColor qw(:constants); use Module::Install::Base; use base 'Module::Install::Base'; -our $VERSION = '0.41'; +our $VERSION = '0.42'; use FindBin; use File::Glob (); @@ -76,6 +77,22 @@ sub RTx { $self->requires_rt('4.0.0'); } + my $package = $name; + $package =~ s/-/::/g; + if ( $RT::CORED_PLUGINS{$package} ) { + my ($base_version) = $RT::VERSION =~ /(\d+\.\d+\.\d+)/; + die RED, <<"EOT"; + +**** Error: Your installed version of RT ($RT::VERSION) already + contains this extension in core, so you don't need to + install it. + + Check https://docs.bestpractical.com/rt/$base_version/RT_Config.html + to configure it. + +EOT + } + # Installation locations my %path; my $plugin_path; @@ -223,7 +240,7 @@ sub requires_rt { my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION; if ($sorted[-1] eq $version) { - die <<"EOT"; + die RED, <<"EOT"; **** Error: This extension requires RT $version. Your installed version of RT ($RT::VERSION) is too old. @@ -249,12 +266,12 @@ sub requires_rt_plugin { unshift @INC, $path; } else { my $name = $self->name; - warn <<"EOT"; + my $msg = <<"EOT"; **** Warning: $name requires that the $plugin plugin be installed and enabled; it does not appear to be installed. - EOT + warn RED, $msg, RESET, "\n"; } $self->requires(@_); } @@ -264,9 +281,8 @@ sub rt_too_new { my $name = $self->name; $msg ||= <add_metadata("x_rt_too_new", $version) if $self->is_admin; @@ -274,7 +290,7 @@ EOT my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION; if ($sorted[0] eq $version) { - die sprintf($msg,$RT::VERSION,$version); + warn RED, sprintf($msg,$RT::VERSION), RESET, "\n"; } } @@ -297,4 +313,4 @@ sub _load_rt_handle { __END__ -#line 468 +#line 484 diff --git a/lib/RT/Extension/ToggleTheme.pm b/lib/RT/Extension/ToggleTheme.pm index 7fdd039..c189ab3 100644 --- a/lib/RT/Extension/ToggleTheme.pm +++ b/lib/RT/Extension/ToggleTheme.pm @@ -38,10 +38,6 @@ Add this line: Plugin('RT::Extension::ToggleTheme'); -=item Apply patch to RT5 - - patch -d /opt/r5 -p1 < patches/header-callback.patch - =item Clear your mason cache rm -rf /opt/rt5/var/mason_data/obj diff --git a/patches/header-callback.patch b/patches/header-callback.patch deleted file mode 100644 index 0be4590..0000000 --- a/patches/header-callback.patch +++ /dev/null @@ -1,18 +0,0 @@ -commit b8042c9c0c1ece46fbc0177bf1791f86386558f0 -Author: craig kaiser -Date: Fri Aug 28 15:40:04 2020 -0400 - - Add callback to edit CSS files loaded in header - -diff --git a/share/html/Elements/Header b/share/html/Elements/Header -index e93f27999..43bb62ac9 100644 ---- a/share/html/Elements/Header -+++ b/share/html/Elements/Header -@@ -145,6 +145,7 @@ else { - RT::Interface::Web::SquishedCSS( $style )->Key; - @css_files = "/NoAuth/css/$style/squished-$key.css"; - } -+$m->callback( CallbackName => "MassageCSSFiles", CSSFiles => \@css_files ); - - # We use BodyClass in its $ARGS form so that callbacks have a chance to - # massage it