[Rt-commit] rt branch, 4.2/auto-discover-stylesheets, created. rt-4.2.4-15-gf52d92c

Alex Vandiver alexmv at bestpractical.com
Thu May 22 13:14:50 EDT 2014


The branch, 4.2/auto-discover-stylesheets has been created
        at  f52d92c7e0b65532d50833891d2a042f78e66a25 (commit)

- Log -----------------------------------------------------------------
commit f52d92c7e0b65532d50833891d2a042f78e66a25
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat May 17 15:35:03 2014 +0800

    auto discover available stylesheets
    
    they are actually directory names in static/css/
    see also #14667

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 40dcec1..7842e57 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -51,8 +51,10 @@ package RT::Config;
 use strict;
 use warnings;
 
+use 5.010;
 use File::Spec ();
 use Symbol::Global::Name;
+use List::MoreUtils 'uniq';
 
 =head1 NAME
 
@@ -201,8 +203,26 @@ our %META;
         Widget          => '/Widgets/Form/Select',
         WidgetArguments => {
             Description => 'Theme',                  #loc
-            # XXX: we need support for 'get values callback'
-            Values => [qw(rudder web2 aileron ballard)],
+            Callback    => sub {
+                state @stylesheets;
+                unless (@stylesheets) {
+                    for my $static_path ( RT::Interface::Web->StaticRoots ) {
+                        my $css_path =
+                          File::Spec->catdir( $static_path, 'css' );
+                        next unless -d $css_path;
+                        if ( opendir my $dh, $css_path ) {
+                            push @stylesheets, grep {
+                                -e File::Spec->catfile( $css_path, $_, 'base.css' )
+                            } readdir $dh;
+                        }
+                        else {
+                            RT->Logger->error("Can't read $css_path: $!");
+                        }
+                    }
+                    @stylesheets = sort { lc $a cmp lc $b } uniq @stylesheets;
+                }
+                return { Values => \@stylesheets };
+            },
         },
         PostLoadCheck => sub {
             my $self = shift;

-----------------------------------------------------------------------


More information about the rt-commit mailing list