Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
craigkai committed Aug 28, 2020
0 parents commit 9094487
Show file tree
Hide file tree
Showing 25 changed files with 3,743 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blib*
Makefile
Makefile.old
pm_to_blib*
*.tar.gz
.lwpcookies
cover_db
pod2htm*.tmp
/RT-Extension-ToggleTheme*
*.bak
*.swp
/MYMETA.*
/t/tmp
/xt/tmp
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Revision history for RT-Extension-ToggleTheme

0.01 08-28-2020
- Initial version
29 changes: 29 additions & 0 deletions META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
abstract: 'RT-Extension-ToggleTheme Extension'
author:
- 'Craig Kaiser <[email protected]>'
build_requires:
ExtUtils::MakeMaker: 6.59
configure_requires:
ExtUtils::MakeMaker: 6.59
distribution_type: module
dynamic_config: 1
generated_by: 'Module::Install version 1.19'
license: gpl_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: RT-Extension-ToggleTheme
no_index:
directory:
- html
- inc
- static
requires:
perl: 5.10.1
resources:
repository: https://github.com/bestpractical/rt-extension-toggletheme
version: '0.01'
x_module_install_rtx_version: '0.41'
x_requires_rt: 4.4.0
x_rt_too_new: 5.2.0
12 changes: 12 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use lib '.';
use inc::Module::Install;

RTx 'RT-Extension-ToggleTheme';
license 'gpl_2';
repository 'https://github.com/craigkai/rt-extension-toggletheme';

requires_rt '5.0.0';
rt_too_new '5.2.0';

sign;
WriteAll;
28 changes: 28 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
NAME
RT-Extension-ToggleTheme - Toggle elevator light and dark theme.

DESCRIPTION
To save your eyes in the dark.

RT VERSION
Works with RT 5

INSTALLATION
perl Makefile.PL
make
make install
May need root permissions

Edit your /opt/rt4/etc/RT_SiteConfig.pm
Add this line:

Plugin('RT::Extension::ToggleTheme');

Clear your mason cache
rm -rf /opt/rt5/var/mason_data/obj

Restart your webserver

AUTHOR
Craig Kaiser <[email protected]>

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

<%init>
my $style = $session{'CurrentUser'}
? $session{'CurrentUser'}->Stylesheet
: RT->Config->Get('WebDefaultStylesheet');

if ( RT->Config->Get('DevelMode') ) {
if ( $style eq 'elevator-light' ) {
push @{$CSSFiles}, "/static/css/elevator-dark/main.css";
}
}
elsif ( $style eq 'elevator-light' ) {
my $key = RT::Interface::Web::SquishedCSS( 'elevator-dark' )->Key;
push @{$CSSFiles}, "/NoAuth/css/$style/squished-$key.css";
}
</%init>

<%args>
$CSSFiles
</%args>
13 changes: 13 additions & 0 deletions html/Callbacks/RT-Extension-ToggleTheme/Elements/Tabs/Privileged
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%init>
# Only show theme toggle for either of the elevator themes light/dark
if ( RT->Config->Get('WebDefaultStylesheet', $session{CurrentUser}) =~ /elevator-/ ) {
my $theme = RT->Config->Get('WebDefaultStylesheet', $session{CurrentUser}) =~ /-dark$/ ? 'fa-sun' : 'fa-moon';
my $toggle = Menu->child(
toggle => title => 'toggle_theme',
raw_html => qq[<a href="javascript:" id="theme_toggle"><span id="theme_toggle_icon" class="].qq[fas $theme"></span></a>],
sort_order => 100
);
}
</%init>
<%args>
</%args>
8 changes: 8 additions & 0 deletions html/Helpers/Toggle/Theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%init>
my $new_theme = RT->Config->Get('WebDefaultStylesheet', $session{'CurrentUser'}) =~ /-dark$/ ? 'elevator-light' : 'elevator-dark';

my ($ok, $msg) = $session{'CurrentUser'}->SetPreferences( $RT::System => { %{ $session{'CurrentUser'}->Preferences( $RT::System ) || {}}, WebDefaultStylesheet => $new_theme } );
RT::Logger->error( "$msg" ) unless $ok;

$m->abort();
</%init>
Loading

0 comments on commit 9094487

Please sign in to comment.