Skip to content

Commit

Permalink
Item14714: proper support for proxy/noproxy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jun 11, 2018
1 parent 497b847 commit 6977010
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 40 deletions.
13 changes: 7 additions & 6 deletions data/System/HarvestPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1418734826" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1528718493" format="1.1" version="1"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%

Expand All @@ -9,7 +9,7 @@ Upon selection it, download and attach all resources to the current topic for lo

You'll enter the harvest process using the =harvestplugin= template like this

%SCRIPTURL{"view"}%/%WEB%/%TOPIC%?template=harvesplugin
%SCRIPTURL{"view"}%/%WEB%/%TOPIC%?template=harvestplugin

This plugin is best integrated in [[Foswiki:Extensions/NatSkin][NatSkin's]] menu concept. For now, you'll
have to modify your local !PatternSkin to add this tool to your site.
Expand All @@ -27,6 +27,7 @@ have to modify your local !PatternSkin to add this tool to your site.
%$DEPENDENCIES%

---++ Change History
| 11 Jun 2018 | added proper support for =PROXY= / =NOPROXY= network settings in Foswiki |
| 02 Sep 2016 | oo-ify core of plugin; work around broken mime types for images, fix encoding problems and make it work with newer <nop>JsonRpcContrib |
| 12 Jan 2015 | sort results returned from external web page |
| 16 Dec 2014 | ignore ssl certificate problems when downloading stuff |
Expand All @@ -35,12 +36,12 @@ have to modify your local !PatternSkin to add this tool to your site.
| 04 Apr 2014 | flag rest handlers that don't require authentication |
| 12 Dec 2013 | first dot.oh release |

%META:FILEATTACHMENT{name="HarvestPluginSnap3.png" attachment="HarvestPluginSnap3.png" attr="" comment="" date="1418734826" size="101095" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="HarvestPluginSnap2.png" attachment="HarvestPluginSnap2.png" attr="" comment="" date="1418734826" size="51494" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="HarvestPluginSnap1.png" attachment="HarvestPluginSnap1.png" attr="" comment="" date="1418734826" size="43468" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="HarvestPluginSnap3.png" attachment="HarvestPluginSnap3.png" attr="" comment="" date="1528718493" size="101095" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="HarvestPluginSnap2.png" attachment="HarvestPluginSnap2.png" attr="" comment="" date="1528718493" size="51494" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="HarvestPluginSnap1.png" attachment="HarvestPluginSnap1.png" attr="" comment="" date="1528718493" size="43468" 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; 2012-2016 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2012-2018 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%TOPIC%"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
Expand Down
10 changes: 5 additions & 5 deletions lib/Foswiki/Plugins/HarvestPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HarvestPlugin is Copyright (C) 2011-2016 Michael Daum http://michaeldaumconsulting.com
# HarvestPlugin is Copyright (C) 2011-2018 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 @@ -27,8 +27,8 @@ use warnings;
use Foswiki::Func ();
use Foswiki::Contrib::JsonRpcContrib ();

our $VERSION = '2.00';
our $RELEASE = '02 Sep 2016';
our $VERSION = '2.10';
our $RELEASE = '11 Jun 2018';
our $SHORTDESCRIPTION = 'Download and archive resources from the web';
our $NO_PREFS_IN_TOPIC = 1;
our $core;
Expand All @@ -45,15 +45,15 @@ sub initPlugin {
Foswiki::Contrib::JsonRpcContrib::registerMethod('HarvestPlugin', 'attach', sub { return getCore()->jsonRpcAttach(@_); });

Foswiki::Func::registerRESTHandler('purgeCache', sub { return getCore()->purgeCache(@_); },
authenticate => 0,
authenticate => 1,
validate => 0,
http_allow => 'GET,POST',
);

Foswiki::Func::registerRESTHandler('url2tml', sub {
return getCore()->restUrl2Tml(@_);
},
authenticate => 0,
authenticate => 1,
validate => 0,
http_allow => 'GET,POST',
); # TODO: convert to JsonRpcContrib
Expand Down
21 changes: 8 additions & 13 deletions lib/Foswiki/Plugins/HarvestPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HarvestPlugin is Copyright (C) 2011-2016 Michael Daum http://michaeldaumconsulting.com
# HarvestPlugin is Copyright (C) 2011-2018 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 @@ -227,22 +227,19 @@ sub jsonRpcAttach {

writeDebug("topic=$web.$topic");

my $selection = $request->param("selection");
my @selection = $request->param("selection");

throw Foswiki::Contrib::JsonRpcContrib::Error(1005, "empty selection")
unless $selection;
unless @selection;

writeDebug("selection=$selection");
unless (ref($selection) eq 'ARRAY') {
$selection = [$selection];
}
writeDebug("selection=@selection");

foreach my $url (@$selection) {
foreach my $url (@selection) {

$url = URI->new($url);
writeDebug("url=$url");

my ($content, $contentType) = $this->getExternalResource($url);
my ($content, $contentType) = $this->getExternalResource($url->as_string);
next unless $content;

# SMELL: first have to write it to a temp file before being able to attach it
Expand Down Expand Up @@ -285,7 +282,7 @@ sub jsonRpcAttach {
});
}

return "Successfully downloaded ".scalar(@$selection)." item(s) to $web.$topic";
return "Successfully downloaded ".scalar(@selection)." item(s) to $web.$topic";
}

=begin TML
Expand Down Expand Up @@ -639,11 +636,9 @@ sub client {

my $proxy = $Foswiki::cfg{PROXY}{HOST};
if ($proxy) {
my $port = $Foswiki::cfg{PROXY}{PORT};
$proxy .= ':' . $port if $port;
$ua->proxy([ 'http', 'https' ], $proxy);

my $proxySkip = $Foswiki::cfg{PROXY}{SkipProxyForDomains} || $Foswiki::cfg{PROXY}{NoProxy};
my $proxySkip = $Foswiki::cfg{PROXY}{NoProxy};
if ($proxySkip) {
my @skipDomains = split(/\s*,\s*/, $proxySkip);
$ua->no_proxy(@skipDomains);
Expand Down
1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/HarvestPlugin/MANIFEST
@@ -1,3 +1,4 @@
!noci
data/System/HarvestPlugin.txt 0644
lib/Foswiki/Plugins/HarvestPlugin/Config.spec 0644
lib/Foswiki/Plugins/HarvestPlugin/Core.pm 0644
Expand Down
12 changes: 1 addition & 11 deletions pub/System/HarvestPlugin/harvest.uncompressed.css
Expand Up @@ -21,16 +21,6 @@
visibility:hidden;
}
.harvestResults tr:hover input,
.harvestResults tr.selected input {
.harvestResults tr.foswikiSelected input {
visibility:visible;
}
.harvestResults tr:hover td {
background-color:#EFECEB;
}
.harvestResults tr.selected td {
background-color:#FBE3E4;
color:#764546;
}
.harvestResults tr:hover.selected td {
background-color:#EBCBCD;
}
10 changes: 5 additions & 5 deletions pub/System/HarvestPlugin/harvest.uncompressed.js
Expand Up @@ -8,12 +8,12 @@ jQuery(function($) {
if ($this.is(":checked")) {
$this.parent().find("#selectall").hide();
$this.parent().find("#clearall").show();
$(".harvestResults input").parent().parent().addClass("selected");
$(".harvestResults input").parent().parent().addClass("foswikiSelected");
$(".harvestResults input").prop('checked', true);
} else {
$this.parent().find("#selectall").show();
$this.parent().find("#clearall").hide();
$(".harvestResults input").parent().parent().removeClass('selected');
$(".harvestResults input").parent().parent().removeClass('foswikiSelected');
$(".harvestResults input").prop('checked', false);
}
});
Expand All @@ -32,7 +32,7 @@ jQuery(function($) {
$.unblockUI();
$.pnotify({
pnotify_history: false,
pnotify_text: len+" images found",
pnotify_text: len+" item(s) found",
pnotify_delay: 2000,
pnotify_opacity: 0.9
});
Expand Down Expand Up @@ -103,9 +103,9 @@ jQuery(function($) {
var $row = elem.parents("tr:first");

if (elem.is(":checked")) {
$row.addClass("selected");
$row.addClass("foswikiSelected");
} else {
$row.removeClass("selected");
$row.removeClass("foswikiSelected");
}
}

Expand Down
1 change: 1 addition & 0 deletions templates/harvestplugin.tmpl
Expand Up @@ -5,6 +5,7 @@
%TMPL:DEF{"heading"}%<h1 >%MAKETEXT{"Download and archive external resources"}%</h1>%TMPL:END%
%TMPL:DEF{"breadcrumbs::tail"}%%TMPL:P{"sep"}%<a href="%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?%QUERYSTRING%">%MAKETEXT{"Download"}%</a>%TMPL:END%
%TMPL:DEF{"contentfooter"}%%TMPL:END%
%TMPL:DEF{"banner"}%%TMPL:END%

%TMPL:DEF{"content"}%<!-- -->
%TMPL:P{"heading"}%
Expand Down

0 comments on commit 6977010

Please sign in to comment.