Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13483: added support for Foswiki-2.0
also:
- indexing workflow and state facets supporting Foswiki:Extensions/WorkflowPlugin
- added author_url to solr schema
- added google image and video mime types mapping them to "image" while indexing;
  • Loading branch information
MichaelDaum committed Jul 17, 2015
1 parent efac5a0 commit 25f0ca2
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 255 deletions.
2 changes: 1 addition & 1 deletion data/System/NatSkinSolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchViewTemplate"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchView"}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/NatSkinWebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/PatternSkinSolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchBase"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchBase"}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/PatternSkinWebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand Down
3 changes: 2 additions & 1 deletion data/System/SiteChangesViewTemplate.txt
@@ -1,10 +1,11 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%

%{<verbatim class="tml">}%
%TMPL:DEF{"solr::defaultweb"}%all%TMPL:END%
%TMPL:DEF{"solr::extrafilter"}%%IF{"defined 'SOLR_EXTRAFILTER'" then="%SOLR_EXTRAFILTER%" else="-field_TopicType_lst:Category"}% type:topic%TMPL:END%
%{</verbatim>}%

%META:PREFERENCE{name="DENYTOPICVIEW" title="DENYTOPICVIEW" type="Set" value=" "}%
Expand Down
16 changes: 10 additions & 6 deletions data/System/SolrPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425056508" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
---+ Solr Plugin
%SHORTDESCRIPTION%
Expand Down Expand Up @@ -35,9 +35,9 @@ The current plugin requires *Solr 5.0.0* or later. Download it from the [[http:
%JQREQUIRE{"chili"}%

<verbatim class="bash">
tar xzf solr-5.0.0.tgz solr-5.0.0/bin/install_solr_service.sh
cd solr-5.0.0/bin/
./install_solr_service.sh ../../solr-5.0.0.tgz
tar xzf solr-5.x.x.tgz solr-5.x.x/bin/install_solr_service.sh
cd solr-5.x.x/bin/
./install_solr_service.sh ../../solr-5.x.x.tgz
service solr stop
</verbatim>

Expand Down Expand Up @@ -845,6 +845,10 @@ specific search applications. The destination fields are then analysed using the
| Home: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 17 Jul 2015: | added support for Foswiki-2.0 ;\
indexing workflow and state facets supporting Foswiki:Extensions/WorkflowPlugin; \
added =author_url= to solr schema; \
added google image and video mime types mapping them to "image" while indexing;
| 27 Feb 2015: | upgraded to solr-5.0.0 |
| 29 Sep 2014: | moved to jsrender for templating, replacing the deprecated jquery.tmpl |
| 29 Aug 2014: | fix mailto links in !WikiUsers view template; \
Expand Down Expand Up @@ -923,5 +927,5 @@ specific search applications. The destination fields are then analysed using the
| 22 Nov 2010: | fixes integration with pattern skin |
| 18 Nov 2010: | initial public release |

%META:FILEATTACHMENT{name="SolrPluginSnap1.png" attachment="SolrPluginSnap1.png" attr="" comment="" date="1425044056" size="93552" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap2.png" attachment="SolrPluginSnap2.png" attr="" comment="" date="1425044056" size="158013" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap1.png" attachment="SolrPluginSnap1.png" attr="" comment="" date="1437153664" size="93552" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap2.png" attachment="SolrPluginSnap2.png" attr="" comment="" date="1437153664" size="158013" user="ProjectContributor" version="1"}%
2 changes: 1 addition & 1 deletion data/System/SolrSearch.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%

%META:PREFERENCE{name="VIEW_TEMPLATE" title="VIEW_TEMPLATE" type="Set" value="SolrSearchView"}%
13 changes: 11 additions & 2 deletions data/System/SolrSearchBaseTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrPlugin"}%
%{<verbatim class="tml">}%
%{ ###########################################################################
Expand Down Expand Up @@ -502,6 +502,14 @@
exclude="ApplicationLicense|ApplicationTopic|DataForm|DocuTopic|TopicFunction|TopicStub|TopicTemplate|TopicType|TopicView|WebTool|WikiApplication|WikiTopic|TaggedTopic|CategorizedTopic"
title="%MAKETEXT{"Topic type"}%"
}%
%TMPL:P{"solr::facet"
id="state"
title="%MAKETEXT{"Workflow State"}%"
}%
%TMPL:P{"solr::facet"
id="preference_WORKFLOW_s"
title="%MAKETEXT{"Workflow"}%"
}%
%TMPL:P{"solr::facet"
id="language"
title="%MAKETEXT{"Language"}%"
Expand Down Expand Up @@ -654,7 +662,7 @@
solr::selection - renders the "your selection" part in the solr::sidebar
}%
%TMPL:DEF{"solr::selection"}%<!-- -->
<h2>%MAKETEXT{"Filter results"}%</h2>
<h2 class='solrFilterResultsHeading' >%MAKETEXT{"Filter results"}%</h2>
<div id='solrCurrentSelection'>
<h3>%MAKETEXT{"Your selection"}%:</h3>
<ul>
Expand Down Expand Up @@ -685,6 +693,7 @@
<select class='foswikiSelect' id='solrSorting' data-default-sort="%TMPL:P{"solr::defaultsort"}%">
<option class='foswikiOption' value='score desc'>%MAKETEXT{"Relevance"}%</option>
<option class='foswikiOption' value='date desc'>%MAKETEXT{"Last changed"}%</option>
<option class='foswikiOption' value='createdate desc'>%MAKETEXT{"Create date"}%</option>
<option class='foswikiOption' value='title_sort asc'>%MAKETEXT{"Name"}%</option>
</select>
</td>
Expand Down
2 changes: 1 addition & 1 deletion data/System/SolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchBase"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchBase"}%
Expand Down
6 changes: 4 additions & 2 deletions data/System/SolrSideBar.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
---+!! %TOPIC%

This is a set of widgets to be used in a sidebar navigation. This is used like this:
Expand All @@ -20,8 +20,10 @@ Default sidebar implementation that includes all of the components listed below.

<verbatim class="tml">
%STARTINCLUDE%<noautolink>
<div class="solrSideBar">
%INCLUDE{"%WEB%.%TOPIC%" section="solrsimilar"}%<!-- -->
%INCLUDE{"%WEB%.%TOPIC%" section="recentchanges"}%<!-- -->
</div>
</noautolink>%STOPINCLUDE%
</verbatim>

Expand All @@ -34,7 +36,7 @@ part of the %SYSTEMWEB%.SolrPlugin documentation.
<verbatim class="tml">
%STARTSECTION{"solrsimilar"}%<!-- -->
%SOLRSIMILAR{"id:%BASEWEB%.%BASETOPIC%"
filter="web:%BASEWEB% type:topic %IF{"defined FILTER" then="%FILTER%"}%"
filter="web:%BASEWEB% type:topic %IF{"defined FILTER" then="%FILTER%"}% -preference_BASETRANSLATION_s:%BASETOPIC% -webtopic:%BASEWEB%.%BASETRANSLATION%"
like="%SOLRSIMILAR_LIKE{default="field_Category_flat_lst^5,tag"}%"
fields="web,topic,title,score,summary"
rows="5"
Expand Down
4 changes: 2 additions & 2 deletions data/System/SolrWikiUsersViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchView"}%
Expand Down Expand Up @@ -69,7 +69,7 @@
%{<verbatim>}%
%TMPL:DEF{"solr::templates::userimage"}%<script id="solrHitTemplate_userimage" type="text/x-jsrender">
<div class='foswikiImage foswikiLeft' style='background-image:url({{if thumbnail}}
%SCRIPTURLPATH{"rest"}%/ImagePlugin/resize?topic={{:web}}.{{:topic}};file={{:~encodeURIComponent(thumbnail)}};size=80x100>;crop=on
%SCRIPTURLPATH{"rest"}%/ImagePlugin/resize?topic={{:web}}.{{:topic}};file={{:~encodeURIComponent(thumbnail)}};size=80x100;crop=on
{{else}}
%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/images/nobody.gif
{{/if}})'>
Expand Down
4 changes: 2 additions & 2 deletions data/System/WebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1425044056" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437153664" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchBase"}%
%{</verbatim>}%
Expand All @@ -10,7 +10,7 @@
%TMPL:DEF{"solr::defaultrows"}%20%TMPL:END%
%TMPL:DEF{"solr::defaultquerytype"}%standard%TMPL:END%
%TMPL:DEF{"solr::defaultsort"}%date desc%TMPL:END%
%TMPL:DEF{"solr::extrafilter"}%%IF{"defined 'SOLR_EXTRAFILTER'" then="%SOLR_EXTRAFILTER%" else="-field_TopicType_lst:Category"}% type:topic%TMPL:END%
%TMPL:DEF{"solr::extrafilter"}%%IF{"defined 'SOLR_EXTRAFILTER'" then="%SOLR_EXTRAFILTER%" else="-field_TopicType_lst:Category"}% type:topic web:%FORMATLIST{"%BASEWEB%" split="/" separator="."}%%TMPL:END%
%{</verbatim>}%

%{<verbatim class="tml">}%
Expand Down
1 change: 0 additions & 1 deletion lib/Foswiki/Plugins/SolrPlugin.pm
Expand Up @@ -10,7 +10,6 @@
# 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.

package Foswiki::Plugins::SolrPlugin;

use strict;
Expand Down
1 change: 0 additions & 1 deletion lib/Foswiki/Plugins/SolrPlugin/Autosuggest.pm
Expand Up @@ -10,7 +10,6 @@
# 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.

package Foswiki::Plugins::SolrPlugin::Autosuggest;

use strict;
Expand Down
73 changes: 17 additions & 56 deletions lib/Foswiki/Plugins/SolrPlugin/Base.pm
Expand Up @@ -10,7 +10,6 @@
# 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.

package Foswiki::Plugins::SolrPlugin::Base;

use strict;
Expand All @@ -22,20 +21,10 @@ use Foswiki::Plugins::SolrPlugin ();
use WebService::Solr ();
use Error qw( :try );
use Encode ();
use HTML::Entities ();

our $STARTWW = qr/^|(?<=[\s\(])/m;
our $ENDWW = qr/$|(?=[\s,.;:!?)])/m;


BEGIN {
if ($Foswiki::cfg{Site}{CharSet} =~ /^utf-?8$/i) {
$WebService::Solr::ENCODE = 0; # don't encode to utf8 in WebService::Solr
}

#print STDERR "Any::Moose prefers $Any::Moose::PREFERRED\n"
}

##############################################################################
sub new {
my $class = shift;
Expand Down Expand Up @@ -75,15 +64,6 @@ sub connect {
),
autocommit => 0,
});

# SMELL: WebServices::Solr somehow does not degrade nicely
if ($this->{solr}->ping()) {

#$this->log("got ping reply");
} else {
$this->log("WARNING: can't ping solr");
$this->{solr} = undef;
}
};

if ($@) {
Expand Down Expand Up @@ -265,12 +245,10 @@ sub inlineError {

##############################################################################
sub entityDecode {
my ($this, $text, $skipDecode) = @_;
my ($this, $text) = @_;

my $charset = $Foswiki::cfg{Site}{CharSet};
$text = Encode::decode($charset, $text) unless $skipDecode;
$text = HTML::Entities::decode_entities($text);
$text = Encode::encode($charset, $text) unless $skipDecode;
return "" unless defined $text;
$text =~ s/&#(\d+);/chr($1)/ge;

return $text;
}
Expand Down Expand Up @@ -365,7 +343,13 @@ sub getTopicTitle {
$topicTitle = $field->{value} if $field && $field->{value};
}

$topicTitle ||= $topic;
if (!defined($topicTitle) || $topicTitle eq '') {
if ($topic eq $Foswiki::cfg{HomeTopicName}) {
$topicTitle = $web;
} else {
$topicTitle = $topic;
}
}

# bit of cleanup
$topicTitle =~ s/<!--.*?-->//g;
Expand Down Expand Up @@ -398,11 +382,8 @@ sub getTopicSummary {

return '' unless defined $summary;

my $charset = $Foswiki::cfg{Site}{CharSet};
$summary = Encode::decode($charset, $summary);
$summary = $this->plainify($summary, $web, $topic, 1);
$summary = $this->plainify($summary, $web, $topic);
$summary =~ s/\n/ /g;
$summary = Encode::encode($charset, $summary);

return $summary;
}
Expand All @@ -423,7 +404,7 @@ sub getScriptUrlPath {

################################################################################
sub plainify {
my ($this, $text, $web, $topic, $skipDecode) = @_;
my ($this, $text, $web, $topic) = @_;

return '' unless defined $text;

Expand Down Expand Up @@ -489,35 +470,16 @@ sub plainify {
$text =~ s/~~~/ /g;
$text =~ s/^$//gs;

return $this->discardIllegalChars($text, $skipDecode);
}


################################################################################
sub substr {
my ($this, $string, $offset, $length, $skipDecode) = @_;

my $charset = $Foswiki::cfg{Site}{CharSet};

$string = Encode::decode($charset, $string) unless $skipDecode;
$string = substr($string, $offset, $length);
$string = Encode::encode($charset, $string) unless $skipDecode;

return $string;
return $this->discardIllegalChars($text);
}

################################################################################
sub discardIllegalChars {
my ($this, $string, $skipDecode) = @_;

my $charset = $Foswiki::cfg{Site}{CharSet};
$string = Encode::decode($charset, $string) unless $skipDecode;
my ($this, $string) = @_;

# remove illegal characters
$string =~ s/\p{C}/ /g;

$string = Encode::encode($charset, $string) unless $skipDecode;

return $string;
}

Expand All @@ -543,10 +505,9 @@ sub fromUtf8 {
sub toUtf8 {
my ($this, $string) = @_;

my $charset = $Foswiki::cfg{Site}{CharSet};
my $octets = Encode::decode($charset, $string);
$octets = Encode::encode('utf-8', $octets);
return $octets;
# my $charset = $Foswiki::cfg{Site}{CharSet};
# $string = Encode::decode($charset, $string);
return Encode::encode('utf-8', $string);
}

1;
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/SolrPlugin/Crawler.pm
Expand Up @@ -10,8 +10,8 @@
# 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.

package Foswiki::Plugins::SolrPlugin::Crawler;

use strict;
use warnings;

Expand Down
Expand Up @@ -10,8 +10,8 @@
# 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.

package Foswiki::Plugins::SolrPlugin::Crawler::FileSystemCrawler;

use strict;
use warnings;

Expand Down

0 comments on commit 25f0ca2

Please sign in to comment.