Skip to content

Commit

Permalink
Item11402: Add configure checkers, fix Config.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul.W Harvey authored and Paul.W Harvey committed Jan 9, 2012
1 parent 970b61e commit 5a5c371
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 3 deletions.
50 changes: 50 additions & 0 deletions lib/Foswiki/Configure/Checkers/SolrPlugin/SolrHome.pm
@@ -0,0 +1,50 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::SolrPlugin::SolrHome;

use strict;
use warnings;

use File::Spec();
use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

sub check {
my $this = shift;
my $mess = '';

unless ( $Foswiki::cfg{SolrPlugin}{SolrHome}
&& $Foswiki::cfg{SolrPlugin}{SolrHome} ne 'NOT SET' )
{
my ( $vol, $dir ) =
File::Spec->splitpath( $Foswiki::cfg{ScriptUrlPath}, 1 );
my @dirs = File::Spec->splitdir($dir);

pop(@dirs);
$Foswiki::cfg{SolrPlugin}{SolrHome} =
File::Spec->catpath( $vol, File::Spec->catdir( @dirs, 'solr' ), '' );
$mess .= $this->guessed(0);
}
$mess .= $this->showExpandedValue( $Foswiki::cfg{SolrPlugin}{SolrHome} );

return $mess;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2012-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
35 changes: 35 additions & 0 deletions lib/Foswiki/Configure/Checkers/SolrPlugin/SolrStartCmd.pm
@@ -0,0 +1,35 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::SolrPlugin::SolrStartCmd;

use strict;
use warnings;

use File::Spec();
use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

sub check {
my $this = shift;

return $this->showExpandedValue( $Foswiki::cfg{SolrPlugin}{SolrStartCmd} );
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2012-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
71 changes: 71 additions & 0 deletions lib/Foswiki/Configure/Checkers/SolrPlugin/SupportedLanguages.pm
@@ -0,0 +1,71 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::SolrPlugin::SupportedLanguages;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

sub check {
my $this = shift;

unless ( $Foswiki::cfg{Plugins}{SolrPlugin}{SupportedLanguages}
&& ref( $Foswiki::cfg{Plugins}{SolrPlugin}{SupportedLanguages} ) )
{
$Foswiki::cfg{Plugins}{SolrPlugin}{SupportedLanguages} = {
'en' => 'en',
'english' => 'en',
'cjk' => 'cjk',
'chinese' => 'cjk',
'japanese' => 'cjk',
'korean' => 'cjk',
'da' => 'da',
'danish' => 'da',
'de' => 'de',
'german' => 'de',
'es' => 'es',
'spanish' => 'es',
'fi' => 'fi',
'finish' => 'fi',
'fr' => 'fr',
'french' => 'fr',
'it' => 'it',
'italian' => 'it',
'nl' => 'nl',
'dutch' => 'nl',
'pt' => 'pt',
'portuguese' => 'pt',
'ru' => 'ru',
'russian' => 'ru',
'se' => 'se',
'swedish' => 'se',
'tr' => 'tr',
'turkish' => 'tr'
};

return $this->guessed(0);
}

return;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2012-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/SolrPlugin/Config.spec
Expand Up @@ -67,12 +67,12 @@ $Foswiki::cfg{SolrPlugin}{AutoStartDaemon} = 0;
# **COMMAND**
# Command used to start the solr instance. Note that <code>solrstart</code> is a shell script wrapping
# around the actual startup routine
$Foswiki::cfg{SolrPlugin}{SolrStartCmd} = $Foswiki::cfg{ToolsDir}.'/solrstart %SOLRHOME|F%';
$Foswiki::cfg{SolrPlugin}{SolrStartCmd} = '$Foswiki::cfg{ToolsDir}/solrstart %SOLRHOME|F%';

# **PATH**
# Path to the directory containing the <code>start.jar</code> file. That's where the jetty engine is
# located and where solr puts its data further down the directory structure
$Foswiki::cfg{SolrPlugin}{SolrHome} = '/home/www-data/foswiki/solr';
$Foswiki::cfg{SolrPlugin}{SolrHome} = '';

# **STRING**
# Default collection where to put foswiki content to (including topic text as well as all attachments)
Expand Down
29 changes: 28 additions & 1 deletion lib/Foswiki/Plugins/SolrPlugin/Index.pm
Expand Up @@ -560,8 +560,35 @@ sub getContentLanguage {
my $prefsLanguage = Foswiki::Func::getPreferencesValue('CONTENT_LANGUAGE') || '';
my $siteLanguage = $Foswiki::cfg{Site}{Locale} || 'en';
$siteLanguage =~ s/_.*$//; # the prefix: e.g. de, en
my $supportedLanguages = {
'en' => 'en', 'english' => 'en',
'cjk' => 'cjk', 'chinese' => 'cjk',
'japanese' => 'cjk', 'korean' => 'cjk',
'da' => 'da', 'danish' => 'da',
'de' => 'de', 'german' => 'de',
'es' => 'es', 'spanish' => 'es',
'fi' => 'fi', 'finish' => 'fi',
'fr' => 'fr', 'french' => 'fr',
'it' => 'it', 'italian' => 'it',
'nl' => 'nl', 'dutch' => 'nl',
'pt' => 'pt', 'portuguese' => 'pt',
'ru' => 'ru', 'russian' => 'ru',
'se' => 'se', 'swedish' => 'se',
'tr' => 'tr', 'turkish' => 'tr'
};

if ( $Foswiki::cfg{SolrPlugin}{SupportedLanguages}
&& ref($Foswiki::cfg{SolrPlugin}{SupportedLanguages}) ) {
$supportedLanguages = $Foswiki::cfg{SolrPlugin}{SupportedLanguages};
}
my $lang = $prefsLanguage || $siteLanguage || '';
my $contentLanguage = $supportedLanguages->{$lang};

my $contentLanguage = $Foswiki::cfg{SolrPlugin}{SupportedLanguages}{$prefsLanguage || $siteLanguage};
if (!$contentLanguage) {
$this->log(
"ERROR: No mapping for language '$lang', check SolrPlugin config");
$contentLanguage = $lang;
}

#$this->log("contentLanguage=$contentLanguage");

Expand Down
3 changes: 3 additions & 0 deletions lib/Foswiki/Plugins/SolrPlugin/MANIFEST
Expand Up @@ -9,6 +9,9 @@ data/System/SolrSearch.txt 0644
data/System/SolrSearchViewTemplate.txt 0644
data/System/WebChangesViewTemplate.txt 0644
lib/CharsetDetector.pm 0644
lib/Foswiki/Configure/Checkers/SolrPlugin/SolrHome.pm 0644
lib/Foswiki/Configure/Checkers/SolrPlugin/SolrStartCmd.pm 0644
lib/Foswiki/Configure/Checkers/SolrPlugin/SupportedLanguages.pm 0644
lib/Foswiki/Plugins/SolrPlugin/Base.pm 0644
lib/Foswiki/Plugins/SolrPlugin/Config.spec 0644
lib/Foswiki/Plugins/SolrPlugin/Index.pm 0644
Expand Down

0 comments on commit 5a5c371

Please sign in to comment.