Skip to content

Commit

Permalink
Item12497:
Browse files Browse the repository at this point in the history
   * implemented jquery.autosuggest
   * removed nonfunctional term sugestion rest handler
   * removed support for deprecated old autocomplete library
   * added size parameter to mapToIconFileName
   * don't remove newlines from stringified texts
   



git-svn-id: http://svn.foswiki.org/trunk/SolrPlugin@16721 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed May 13, 2013
1 parent dbe4715 commit d586d9d
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 119 deletions.
19 changes: 9 additions & 10 deletions lib/Foswiki/Plugins/SolrPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2012 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2009-2013 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -18,8 +18,8 @@ use Foswiki::Func ();
use Foswiki::Plugins ();
use Error qw(:try);

our $VERSION = '1.10';
our $RELEASE = '1.10';
our $VERSION = '1.20';
our $RELEASE = '1.20';
our $SHORTDESCRIPTION = 'Enterprise Search Engine for Foswiki based on [[http://lucene.apache.org/solr/][Solr]]';
our $NO_PREFS_IN_TOPIC = 1;
our $baseWeb;
Expand Down Expand Up @@ -79,29 +79,28 @@ sub initPlugin {
});


Foswiki::Func::registerRESTHandler('terms', sub {
Foswiki::Func::registerRESTHandler('similar', sub {
my $session = shift;

my $web = $session->{webName};
my $topic = $session->{topicName};
return getSearcher($session)->restSOLRTERMS($web, $topic);
return getSearcher($session)->restSOLRSIMILAR($web, $topic);
});


Foswiki::Func::registerRESTHandler('similar', sub {
Foswiki::Func::registerRESTHandler('autocomplete', sub {
my $session = shift;

my $web = $session->{webName};
my $topic = $session->{topicName};
return getSearcher($session)->restSOLRSIMILAR($web, $topic);
return getSearcher($session)->restSOLRAUTOCOMPLETE($web, $topic);
});

Foswiki::Func::registerRESTHandler('autocomplete', sub {
Foswiki::Func::registerRESTHandler('autosuggest', sub {
my $session = shift;

my $web = $session->{webName};
my $topic = $session->{topicName};
return getSearcher($session)->restSOLRAUTOCOMPLETE($web, $topic);
return getSearcher($session)->restSOLRAUTOSUGGEST($web, $topic);
});


Expand Down
43 changes: 43 additions & 0 deletions lib/Foswiki/Plugins/SolrPlugin/Autosuggest.pm
@@ -0,0 +1,43 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2013 Michael Daum http://michaeldaumconsulting.com
#
# 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.
#
# 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;
use warnings;

use Foswiki::Plugins::JQueryPlugin::Plugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

sub new {
my $class = shift;

my $this = bless(
$class->SUPER::new(
name => 'Autosuggest',
version => '1.10',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/SolrPlugin',
css => ['jquery.autosuggest.css'],
javascript => ['jquery.autosuggest.js', ],
puburl => '%PUBURLPATH%/%SYSTEMWEB%/SolrPlugin',
dependencies => ['ui::autocomplete', 'tmpl', 'blockUI'],
),
$class
);

return $this;
}

1;

10 changes: 6 additions & 4 deletions lib/Foswiki/Plugins/SolrPlugin/Base.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2012 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2009-2013 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -351,7 +351,9 @@ sub putBackBlocks {

##############################################################################
sub mapToIconFileName {
my ($this, $type) = @_;
my ($this, $type, $size) = @_;

$size ||= 16;

my $pubUrlPath = $Foswiki::cfg{PubUrlPath}.'/'.$Foswiki::cfg{SystemWebName}.'/FamFamFamSilkIcons/';

Expand All @@ -361,7 +363,7 @@ sub mapToIconFileName {

if (Foswiki::Func::getContext()->{MimeIconPluginEnabled}) {
require Foswiki::Plugins::MimeIconPlugin;
my ($iconName, $iconPath) = Foswiki::Plugins::MimeIconPlugin::getIcon($type, "oxygen", 16);
my ($iconName, $iconPath) = Foswiki::Plugins::MimeIconPlugin::getIcon($type, "oxygen", $size);
return $iconPath;
}

Expand Down Expand Up @@ -430,6 +432,7 @@ sub getTopicSummary {
my $charset = $Foswiki::cfg{Site}{CharSet};
$summary = Encode::decode($charset, $summary);
$summary = $this->plainify($summary, $web, $topic, 1);
$summary =~ s/\n/ /g;
$summary = Encode::encode($charset, $summary);

return $summary;
Expand Down Expand Up @@ -514,7 +517,6 @@ sub plainify {
$text =~ s/#+//g;
$text =~ s/\$perce?nt//g;
$text =~ s/\$dollar//g;
$text =~ s/\n/ /g;
$text =~ s/~~~/ /g;
$text =~ s/^$//gs;

Expand Down
8 changes: 8 additions & 0 deletions lib/Foswiki/Plugins/SolrPlugin/Config.spec
Expand Up @@ -116,4 +116,12 @@ $Foswiki::cfg{SolrPlugin}{SupportedLanguages} = {
'uk' => 'detect',
};

# ---++ JQueryPlugin
# ---+++ Extra plugins
# **STRING**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Autosuggest}{Module} = 'Foswiki::Plugins::SolrPlugin::Autosuggest';

# **BOOLEAN**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Autosuggest}{Enabled} = 1;

1;
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/SolrPlugin/Index.pm
Expand Up @@ -556,7 +556,7 @@ sub indexTopic {
if (!defined $thumbnail && $attachment->{isthumbnail}) {
$thumbnail = $name;
}
if (!defined $firstImage && $name =~ /(png|jpe?g|gif|bmp$)/i) {
if (!defined $firstImage && $name =~ /\.(png|jpe?g|gif|bmp|svg)$/i) {
$firstImage = $name;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Foswiki/Plugins/SolrPlugin/MANIFEST
Expand Up @@ -29,6 +29,7 @@ lib/WebService/Solr/Field.pm 0644
lib/WebService/Solr.pm 0644
lib/WebService/Solr/Query.pm 0644
lib/WebService/Solr/Response.pm 0644
lib/Foswiki/Plugins/SolrPlugin/Autosuggest.pm 0644
locale/SolrPlugin/de.po 0644
locale/SolrPlugin/Foswiki.pot 0644
pub/System/SolrPlugin/ajax-solr/ASL-LICENSE 0644
Expand Down Expand Up @@ -64,6 +65,8 @@ pub/System/SolrPlugin/ajax-solr-widgets.js.gz 0644
pub/System/SolrPlugin/ajax-solr-widgets.uncompressed.js 0644
pub/System/SolrPlugin/ajax-solr/widgets/yui/ParameterYUIStore.js 0644
pub/System/SolrPlugin/Makefile 0644
pub/System/SolrPlugin/jquery.autosuggest.uncompressed.css 0644
pub/System/SolrPlugin/jquery.autosuggest.uncompressed.js 0644
pub/System/SolrPlugin/pattern.css 0644
pub/System/SolrPlugin/pattern.css.gz 0644
pub/System/SolrPlugin/pattern.uncompressed.css 0644
Expand Down

0 comments on commit d586d9d

Please sign in to comment.