Skip to content

Commit

Permalink
Item14294: move from Any::Moose to Moo
Browse files Browse the repository at this point in the history
also:
   * fixed documentation for iwatch realtime indexing
   * documentation of SOLRSCRIPTURL macro
   * using jquery.i18n for javascript translations now
   * new facet filter to search in facet values
   * improved indexing of user profile pages and their thumbnail image
   * indexing image geometry now
   * improved jquery.autosugest widget
   * improved ToggleFacetWidget
   * improved boosting of query ingrediences
   * mapping all office documents to a combined attachment type (document, presentation, spreadsheet, chart, ...)
   * better support for plenv in system services and cron jobs
  • Loading branch information
MichaelDaum committed Jan 23, 2017
1 parent 573f0bc commit 69a896f
Show file tree
Hide file tree
Showing 75 changed files with 100,162 additions and 630 deletions.
17 changes: 10 additions & 7 deletions .gitignore
@@ -1,3 +1,4 @@
*~
*.gz
*.swp
igp_*
Expand All @@ -13,13 +14,15 @@ pub/System/SolrPlugin/ajax-solr.js
pub/System/SolrPlugin/wikiusers.js
pub/System/SolrPlugin/wikiusers.css
pub/System/SolrPlugin/ajax-solr-helpers.js
SolrPlugin.md5
SolrPlugin.sha1
SolrPlugin.tgz
SolrPlugin.txt
SolrPlugin.zip
SolrPlugin_installer
SolrPlugin_installer.pl
/SolrPlugin.md5
/SolrPlugin.sha1
/SolrPlugin.tgz
/SolrPlugin.txt
/SolrPlugin.zip
/SolrPlugin_installer
/SolrPlugin_installer.pl
pub/System/SolrPlugin/ajax-solr/README.md
pub/System/SolrPlugin/ajax-solr/Rakefile
genpdf_*
/webservice-solr
pub/System/SolrPlugin/ajax-solr.evolvingweb
19 changes: 19 additions & 0 deletions Makefile
@@ -0,0 +1,19 @@
WEBSERVICE_SOURCES= \
lib/WebService/Solr.pm \
lib/WebService/Solr/Document.pm \
lib/WebService/Solr/Field.pm \
lib/WebService/Solr/Query.pm \
lib/WebService/Solr/Response.pm

all: $(WEBSERVICE_SOURCES)

git:
git clone https://github.com/ilmari/webservice-solr.git

ifneq (,$(wildcard webservice-solr))
lib/WebService/%: webservice-solr/lib/WebService/%
cp $^ $@
lib/WebService/Solr/%: webservice-solr/lib/WebService/Solr/%
cp $^ $@
endif

122 changes: 122 additions & 0 deletions WebService-Solr-Moo.patch
@@ -0,0 +1,122 @@
diff --git a/lib/WebService/Solr.pm b/lib/WebService/Solr.pm
index d1d0d81..24f6b88 100644
--- a/lib/WebService/Solr.pm
+++ b/lib/WebService/Solr.pm
@@ -4,7 +4,7 @@ use Moo;

use Types::Standard qw(InstanceOf Object Bool HashRef Maybe);
use Scalar::Util qw(blessed);
-use Encode qw(encode);
+use Encode ();
use URI;
use LWP::UserAgent;
use WebService::Solr::Response;
@@ -14,6 +14,9 @@ use XML::Easy::Element;
use XML::Easy::Content;
use XML::Easy::Text ();

+our $ENCODE = 1;
+our $DECODE = 0;
+
has 'url' => (
is => 'ro',
isa => InstanceOf['URI'],
@@ -42,7 +45,7 @@ has 'last_response' => (
isa => Maybe[InstanceOf['WebService::Solr::Response']],
);

-our $VERSION = '0.23';
+our $VERSION = '0.24';

sub BUILDARGS {
my ( $self, $url, $options ) = @_;
@@ -183,13 +186,15 @@ sub _send_update {
my ( $self, $xml, $params, $autocommit ) = @_;
$autocommit = $self->autocommit unless defined $autocommit;

+ $xml= _encode($xml);
+
$params ||= {};
my $url = $self->_gen_url( 'update' );
$url->query_form( { $self->default_params, %$params } );
my $req = HTTP::Request->new(
POST => $url,
HTTP::Headers->new( Content_Type => 'text/xml; charset=utf-8' ),
- '<?xml version="1.0" encoding="UTF-8"?>' . encode( 'utf8', "$xml" )
+ '<?xml version="1.0" encoding="UTF-8"?>' . $xml
);

my $http_response = $self->agent->request( $req );
@@ -204,6 +209,16 @@ sub _send_update {
return $self->last_response;
}

+sub _encode {
+ return $ENCODE?Encode::encode_utf8($_[0]):$_[0];
+}
+
+sub _decode {
+ return $DECODE?Encode::decode_utf8($_[0]):$_[0];
+}
+
+
+
no Moo;

1;
diff --git a/lib/WebService/Solr/Field.pm b/lib/WebService/Solr/Field.pm
index 0f95876..7917392 100644
--- a/lib/WebService/Solr/Field.pm
+++ b/lib/WebService/Solr/Field.pm
@@ -1,5 +1,6 @@
package WebService::Solr::Field;

+use WebService::Solr ();
use XML::Easy::Element;
use XML::Easy::Content;
use XML::Easy::Text ();
@@ -13,7 +14,7 @@ sub new {

my $self = {
name => $name,
- value => $value,
+ value => WebService::Solr::_decode($value),
%{ $opts },
};

@@ -28,7 +29,7 @@ sub name {

sub value {
my $self = shift;
- $self->{ value } = $_[ 0 ] if @_;
+ $self->{ value } = WebService::Solr::_decode($_[ 0 ]) if @_;
return $self->{ value };
}

diff --git a/lib/WebService/Solr/Response.pm b/lib/WebService/Solr/Response.pm
index 08fc3db..e399488 100644
--- a/lib/WebService/Solr/Response.pm
+++ b/lib/WebService/Solr/Response.pm
@@ -4,8 +4,6 @@ use Moo;

use Types::Standard qw(Object HashRef Maybe InstanceOf ArrayRef);
use WebService::Solr::Document;
-use Data::Page;
-use Data::Pageset;
use JSON::XS ();

has 'raw_response' => (
@@ -30,13 +28,6 @@ around docs => sub {
return wantarray ? @$ret : $ret;
};

-has 'pager' => ( is => 'lazy', isa => Maybe[InstanceOf['Data::Page']] );
-
-has '_pageset_slide' =>
- ( is => 'rw', isa => Maybe[InstanceOf['Data::Pageset']], predicate => 1 );
-has '_pageset_fixed' =>
- ( is => 'rw', isa => Maybe[InstanceOf['Data::Pageset']], predicate => 1 );
-
sub BUILDARGS {
my ( $self, $res ) = @_;
return { raw_response => $res };
5 changes: 3 additions & 2 deletions data/System/NatSkinSolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1442835433" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1485183295" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchViewTemplate"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchView"}%
Expand All @@ -10,6 +10,7 @@
%TMPL:DEF{"topicactions"}%%TMPL:END%
%TMPL:DEF{"revinfo"}%%TMPL:END%
%TMPL:DEF{"form"}%%TMPL:END%
%TMPL:DEF{"metadata"}%%TMPL:END%
%TMPL:DEF{"bodyclass"}%natViewBody natSolrBody%TMPL:END%
%{</verbatim>}%

Expand All @@ -25,5 +26,5 @@
}%%TMPL:END%
%{</verbatim>}%

%META:PREFERENCE{name="DENYTOPICVIEW" title="DENYTOPICVIEW" type="Set" value=" "}%
%META:PREFERENCE{name="ALLOWTOPICVIEW" title="ALLOWTOPICVIEW" type="Set" value="*"}%
%META:PREFERENCE{name="PERMSET_VIEW" title="PERMSET_VIEW" type="Local" value="everybody"}%
2 changes: 1 addition & 1 deletion data/System/NatSkinWebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1442835433" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1485183295" 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="1442835433" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1485183295" 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="1442835433" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1485183295" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand Down
4 changes: 2 additions & 2 deletions data/System/SiteChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1442835433" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1485183295" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand All @@ -8,5 +8,5 @@
%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=" "}%
%META:PREFERENCE{name="ALLOWTOPICVIEW" title="ALLOWTOPICVIEW" type="Set" value="*"}%
%META:PREFERENCE{name="PERMSET_VIEW" title="PERMSET_VIEW" type="Local" value="everybody"}%
55 changes: 40 additions & 15 deletions data/System/SolrPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1445162450" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1485183295" format="1.1" version="1"}%
---+ Solr Plugin
%FORMFIELD{"Description"}%

Expand Down Expand Up @@ -59,6 +59,7 @@ mv /var/solr/logs /var/log/solr
* set =SOLR_LOGS_DIR=/var/log/solr=
* edit =/var/solr/log4j.properties=
* set =solr.log=/var/log/solr=
* set log level from =INFO= to =WARN=: =log4j.rootLogger=WARN, file, CONSOLE=

---+++ Install Foswiki configuration set

Expand Down Expand Up @@ -228,7 +229,7 @@ The service is configured by placing below configuration script at =/etc/iwatch/
<watchlist>
<title>Foswiki</title>
<contactpoint email="root@localhost" name="Administrator"/>
<path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su <httpd-user> -c '<foswiki-dir>/tools/solrjob'"><foswiki-dir>/data</path>
<path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="sudo -u <httpd-user> <foswiki-dir>/tools/solrjob"><foswiki-dir>/data</path>
<path type="regexception">\.tmp|\.sw\w|\.svn|\.lease|\.lock|,$|\.changes|,v|^_[0-9]|^log|^Temporary|^UnitTestCheck</path>
</watchlist>
</config>
Expand All @@ -247,12 +248,12 @@ For !VirtualHostingContrib use:
<contactpoint email="root@localhost" name="Administrator"/>

<!-- watch directories shared among all virtual domains -->
<path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su <httpd-user> -c '<foswiki-dir>/tools/solrjob --host all'"><foswiki-dir>/data/System</path>
<!-- <path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su <httpd-user> -c '<foswiki-dir>/tools/solrjob --host all'"><foswiki-dir>/data/Applications</path> -->
<path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="sudo -u <httpd-user> <foswiki-dir>/tools/solrjob --host all"><foswiki-dir>/data/System</path>
<!-- <path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="sudo -u <httpd-user> <foswiki-dir>/tools/solrjob --host all"><foswiki-dir>/data/Applications</path> -->

<!-- watch each virtual domain for changes -->
<path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su <httpd-user> -c '<foswiki-dir>/tools/solrjob --host <domain1>'"><vhosts-dir>/<domain1>/data</path>
<!-- <path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su <httpd-user> -c '<foswiki-dir>/tools/solrjob --host <domain2>'"><vhosts-dir>/<domain2>/data</path> -->
<path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su -l <httpd-user> -c '<foswiki-dir>/tools/solrjob --host <domain1>'"><vhosts-dir>/<domain1>/data</path>
<!-- <path type="recursive" filter=".*\.txt$" alert="off" syslog="on" exec="su -l <httpd-user> -c '<foswiki-dir>/tools/solrjob --host <domain2>'"><vhosts-dir>/<domain2>/data</path> -->

<path type="regexception">\.tmp|\.sw\w|\.svn|\.lease|\.lock|,$|\.changes|,v|^_[0-9]|^log|^Temporary|^UnitTestCheck</path>
</watchlist>
Expand Down Expand Up @@ -596,9 +597,22 @@ SOLRSIMILAR allows to return a list of similar topics given the current one.
rows="5"
}%<!-- solrsimilar -->

<verbatim class="foswikiHidden">
---++++ SOLRSCRIPTURL

returns a link to a SolrSearch with the given parameters pre-set.

| *Parameter* | *Description* | *Default* |
| "..." or search | search string to render a link for | |
| id | get a link to the search defined by SOLRSEARCH | |
| topic | name of the search topic to jump to | <nop>WebSearch |
| union | a list of fields whose values can be selected in a union (using an "or" operator) | |
| multivalued | a list of fields that may be searched by multiple values | |
| start | | |
| sort | | |
| &lt;field_name> | any field defined in in solr's schema.xml | |

<verbatim class="foswikiHidden">

---+++ Rest inteface

---++++ search
Expand Down Expand Up @@ -721,7 +735,6 @@ useful for spatial search.
| web | string | | stored | name of the web this document is located in |
| webtopic | string | | stored | concatenation of the web and topic part |


---+++ Dynamic fields

Dynamic fields are generated based on the content properties of the document to
Expand Down Expand Up @@ -847,6 +860,18 @@ specific search applications. The destination fields are then analysed using the

---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 23 Jan 2017: | converted WebServices::Solr to Moo; \
fixed documentation for iwatch realtime indexing; \
documentation of SOLRSCRIPTURL macro; \
using jquery.i18n for javascript translations now; \
new facet filter to search in facet values; \
improved indexing of user profile pages and their thumbnail image; \
indexing image geometry now; \
improved jquery.autosugest widget; \
improved <nop>ToggleFacetWidget; \
improved boosting of query ingrediences; \
mapping all office documents to a combined attachment type (document, presentation, spreadsheet, chart, ...); \
better support for plenv in system services and cron jobs |
| 18 Oct 2015: | fixed backwards compatibility with pre-unicode Foswiki; \
bring back =solr::queryfields= in <nop>SolrSearchBaseTemplate; \
fixed language facet to properly match language tags to their name; \
Expand Down Expand Up @@ -947,15 +972,15 @@ 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" attr="" comment="" date="1445162454" size="93552" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap2.png" attr="" comment="" date="1445162454" size="158013" user="ProjectContributor" version="1"}%
%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2009-2015, Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/SolrPlugin"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/SolrPlugin"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2009-2017, Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/SolrPlugin"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/SolrPlugin"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
%META:FILEATTACHMENT{name="SolrPluginSnap1.png" attr="" comment="" date="1485183295" size="93552" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap2.png" attr="" comment="" date="1485183295" 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="1442835433" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1485183295" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%

%META:PREFERENCE{name="VIEW_TEMPLATE" title="VIEW_TEMPLATE" type="Set" value="SolrSearchView"}%

0 comments on commit 69a896f

Please sign in to comment.