[Bps-public-commit] rt-extension-assetsql branch, master, updated. 08e74328e0bdf968d271974ef7c535bd3b96d735

Jim Brandt jbrandt at bestpractical.com
Tue Sep 27 10:59:25 EDT 2016


The branch, master has been updated
       via  08e74328e0bdf968d271974ef7c535bd3b96d735 (commit)
       via  233410524791273c682b234cca72fb9842ac4e8f (commit)
      from  b4b5650f93731354b717a9a5f135dae7f7684254 (commit)

Summary of changes:
 Changes                                      |  4 +++
 META.yml                                     |  5 ++--
 Makefile.PL                                  |  2 ++
 README                                       | 19 +++++++++++++
 html/Asset/Search/Bulk.html                  |  2 +-
 html/Asset/Search/Elements/BuildFormatString |  3 +-
 html/Asset/Search/Results.html               |  3 +-
 inc/Module/Install/RTx.pm                    | 29 ++++++++++++++++---
 lib/RT/Extension/AssetSQL.pm                 | 42 +++++++++++++++++++++++++++-
 9 files changed, 99 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit 233410524791273c682b234cca72fb9842ac4e8f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Sep 27 10:10:47 2016 -0400

    Add function to process AssetSearchFormat configuration
    
    The AssetSearchFormat configuration option for assets accepts
    both a single string defining a search results format and a
    hashref that defines a different format per catalog. This was
    needed for the initial asset search implementation because
    there was no other way to modify the search results format. Add a
    function to process both formats in AssetSQL.
    
    AssetSQL now provides a user interface to modify the format
    on the Advanced tab, so for the hashref version define a single
    default search result format key called AssetSearchFormat.

diff --git a/html/Asset/Search/Bulk.html b/html/Asset/Search/Bulk.html
index b12d0d9..b4d624c 100644
--- a/html/Asset/Search/Bulk.html
+++ b/html/Asset/Search/Bulk.html
@@ -114,7 +114,7 @@ else {
         Assets => $assets, Catalog => $catalog_obj, ARGSRef => \%ARGS,
     );
 }
-$search{Format} ||= RT->Config->Get('AssetSearchFormat');
+$search{Format} ||= ProcessAssetSearchFormatConfig;
 
 my $DisplayFormat = "'__CheckBox.{UpdateAsset}__',". ($ARGS{Format} || $search{'Format'});
 $DisplayFormat =~ s/\s*,\s*('?__NEWLINE__'?)/,$1,''/gi;
diff --git a/html/Asset/Search/Elements/BuildFormatString b/html/Asset/Search/Elements/BuildFormatString
index 4272b82..4e65800 100644
--- a/html/Asset/Search/Elements/BuildFormatString
+++ b/html/Asset/Search/Elements/BuildFormatString
@@ -62,7 +62,8 @@ $m->callback( Fields => \@fields, ARGSRef => \%ARGS );
 
 my ( @seen);
 
-$Format ||= RT->Config->Get('AssetSearchFormat');
+$Format ||= ProcessAssetSearchFormatConfig;
+
 my @format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $Format);
 foreach my $field (@format) {
     # "title" is for columns like NEWLINE, which doesn't have "attribute"
diff --git a/html/Asset/Search/Results.html b/html/Asset/Search/Results.html
index 8c4f5ba..e5c74f3 100644
--- a/html/Asset/Search/Results.html
+++ b/html/Asset/Search/Results.html
@@ -49,7 +49,8 @@ $m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
 
 # These variables are what define a search_hash; this is also
 # where we give sane defaults.
-$Format ||= RT->Config->Get('AssetSearchFormat');
+
+$Format ||= ProcessAssetSearchFormatConfig;
 
 # Some forms pass in "RowsPerPage" rather than "Rows"
 # We call it RowsPerPage everywhere else.
diff --git a/lib/RT/Extension/AssetSQL.pm b/lib/RT/Extension/AssetSQL.pm
index 0434887..644df93 100644
--- a/lib/RT/Extension/AssetSQL.pm
+++ b/lib/RT/Extension/AssetSQL.pm
@@ -134,6 +134,46 @@ as well:
 
 =back
 
+=head1 METHODS
+
+=head2 ProcessAssetSearchFormatConfig
+
+Process the $AssetSearchFormat configuration value.
+
+AssetSQL uses the search formats defined via C<$AssetSearchFormat>
+to format search results. This option accepts one format to use for
+all assets or a hashref with formats defined per catalog. This
+function processes the configuration option and returns the appropriate
+format.
+
+For the hashref version, AssetSQL looks only for the key
+C<AssetSearchFormat> for the default search format. To customize
+the format of the search results for individual searches, use the
+Advanced tab in the Query Builder.
+
+See RT's documentation for C<$AssetSearchFormat> in C<RT_Config.pm>
+for details on setting the search format.
+
+Returns: string with a search format
+
+=cut
+
+package HTML::Mason::Commands;
+
+sub ProcessAssetSearchFormatConfig {
+    my %args = ( @_ );
+
+    my $format = RT->Config->Get('AssetSearchFormat');
+    return $format unless ref $format;
+
+    if( not exists $format->{'AssetSearchFormat'} ){
+        RT::Logger->error("Asset search results format hashref found, but no 'AssetSearchFormat' defined."
+        . " Add an 'AssetSearchFormat' key to your configuration with a default asset search result format.");
+        return;
+    }
+    return $format->{'AssetSearchFormat'};
+}
+
 =head1 AUTHOR
 
 Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>

commit 08e74328e0bdf968d271974ef7c535bd3b96d735
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Sep 27 10:37:40 2016 -0400

    Prep for .04 release

diff --git a/Changes b/Changes
index 014fd80..6dae019 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+0.04
+  - Parse all forms of the AssetSearchFormat config option.
+    Add a new default key, AssetSearchFormat, for the hashref form.
+
 0.03
   - add asset support for RT's upcoming CustomDateRanges
 
diff --git a/META.yml b/META.yml
index 05861ca..0166050 100644
--- a/META.yml
+++ b/META.yml
@@ -26,7 +26,8 @@ requires:
   perl: 5.10.1
 resources:
   license: http://opensource.org/licenses/gpl-license.php
-version: '0.03'
-x_module_install_rtx_version: '0.37'
+  repository: https://github.com/bestpractical/rt-extension-assetsql
+version: '0.04'
+x_module_install_rtx_version: '0.38'
 x_requires_rt: '4.4'
 x_rt_too_new: '4.6'
diff --git a/Makefile.PL b/Makefile.PL
index 245f11f..d327d57 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -9,6 +9,8 @@ rt_too_new '4.6';
 
 perl_version '5.010001';
 
+repository('https://github.com/bestpractical/rt-extension-assetsql');
+
 my ($loaded) = ($INC{'RT.pm'} =~ /^(.*)[\\\/]/);
 my $lib_path = join( ' ', "$RT::LocalPath/lib", $loaded );
 
diff --git a/README b/README
index 00c9612..7093e8a 100644
--- a/README
+++ b/README
@@ -41,6 +41,25 @@ INSTALLATION
 
     Restart your webserver
 
+METHODS
+  ProcessAssetSearchFormatConfig
+    Process the $AssetSearchFormat configuration value.
+
+    AssetSQL uses the search formats defined via $AssetSearchFormat to
+    format search results. This option accepts one format to use for all
+    assets or a hashref with formats defined per catalog. This function
+    processes the configuration option and returns the appropriate format.
+
+    For the hashref version, AssetSQL looks only for the key
+    AssetSearchFormat for the default search format. To customize the format
+    of the search results for individual searches, use the Advanced tab in
+    the Query Builder.
+
+    See RT's documentation for $AssetSearchFormat in RT_Config.pm for
+    details on setting the search format.
+
+    Returns: string with a search format
+
 AUTHOR
     Best Practical Solutions, LLC <modules at bestpractical.com>
 
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index 97acf77..80538d3 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -8,7 +8,7 @@ no warnings 'once';
 
 use Module::Install::Base;
 use base 'Module::Install::Base';
-our $VERSION = '0.37';
+our $VERSION = '0.38';
 
 use FindBin;
 use File::Glob     ();
@@ -37,6 +37,13 @@ sub RTx {
     }
     $self->add_metadata("x_module_install_rtx_version", $VERSION );
 
+    my $installdirs = $ENV{INSTALLDIRS};
+    for ( @ARGV ) {
+        if ( /INSTALLDIRS=(.*)/ ) {
+            $installdirs = $1;
+        }
+    }
+
     # Try to find RT.pm
     my @prefixes = qw( /opt /usr/local /home /usr /sw /usr/share/request-tracker4);
     $ENV{RTHOME} =~ s{/RT\.pm$}{} if defined $ENV{RTHOME};
@@ -71,7 +78,13 @@ sub RTx {
 
     # Installation locations
     my %path;
-    $path{$_} = $RT::LocalPluginPath . "/$name/$_"
+    my $plugin_path;
+    if ( $installdirs && $installdirs eq 'vendor' ) {
+        $plugin_path = $RT::PluginPath;
+    } else {
+        $plugin_path = $RT::LocalPluginPath;
+    }
+    $path{$_} = $plugin_path . "/$name/$_"
         foreach @DIRS;
 
     # Copy RT 4.2.0 static files into NoAuth; insufficient for
@@ -85,7 +98,7 @@ sub RTx {
     my %index = map { $_ => 1 } @INDEX_DIRS;
     $self->no_index( directory => $_ ) foreach grep !$index{$_}, @DIRS;
 
-    my $args = join ', ', map "q($_)", map { ($_, $path{$_}) }
+    my $args = join ', ', map "q($_)", map { ($_, "\$(DESTDIR)$path{$_}") }
         sort keys %path;
 
     printf "%-10s => %s\n", $_, $path{$_} for sort keys %path;
@@ -131,6 +144,7 @@ install ::
     if ( $path{lib} ) {
         $self->makemaker_args( INSTALLSITELIB => $path{'lib'} );
         $self->makemaker_args( INSTALLARCHLIB => $path{'lib'} );
+        $self->makemaker_args( INSTALLVENDORLIB => $path{'lib'} )
     } else {
         $self->makemaker_args( PM => { "" => "" }, );
     }
@@ -139,6 +153,13 @@ install ::
     $self->makemaker_args( INSTALLSITEMAN3DIR => "$RT::LocalPath/man/man3" );
     $self->makemaker_args( INSTALLSITEARCH => "$RT::LocalPath/man" );
 
+    # INSTALLDIRS=vendor should install manpages into /usr/share/man.
+    # That is the default path in most distributions. Need input from
+    # Redhat, Centos etc.
+    $self->makemaker_args( INSTALLVENDORMAN1DIR => "/usr/share/man/man1" );
+    $self->makemaker_args( INSTALLVENDORMAN3DIR => "/usr/share/man/man3" );
+    $self->makemaker_args( INSTALLVENDORARCH => "/usr/share/man" );
+
     if (%has_etc) {
         print "For first-time installation, type 'make initdb'.\n";
         my $initdb = '';
@@ -258,4 +279,4 @@ sub _load_rt_handle {
 
 __END__
 
-#line 390
+#line 428
diff --git a/lib/RT/Extension/AssetSQL.pm b/lib/RT/Extension/AssetSQL.pm
index 644df93..dbf1640 100644
--- a/lib/RT/Extension/AssetSQL.pm
+++ b/lib/RT/Extension/AssetSQL.pm
@@ -3,7 +3,7 @@ use warnings;
 package RT::Extension::AssetSQL;
 use 5.010_001;
 
-our $VERSION = '0.03';
+our $VERSION = '0.04';
 
 require RT::Extension::AssetSQL::Assets;
 

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


More information about the Bps-public-commit mailing list