Skip to content

Commit

Permalink
Item13477: added support for Foswiki-2.0
Browse files Browse the repository at this point in the history
- added support for Foswiki:Extensions/WebDAVContrib
  • Loading branch information
MichaelDaum committed Jul 17, 2015
1 parent aec7ecb commit d51acdb
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 86 deletions.
15 changes: 8 additions & 7 deletions data/System/TopicInteractionPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1418746985" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437154320" format="1.1" version="1"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

Expand Down Expand Up @@ -148,11 +148,12 @@ generates:
-->

| Author(s): | Michael Daum|
| Copyright: | © 2010-2014 Michael Daum http://michaeldaumconsulting.com |
| Copyright: | © 2010-2015 Michael Daum http://michaeldaumconsulting.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 17 Jul 2015: | added support for Foswiki-2.0; added support for Foswiki:Extensions/WebDAVContrib |
| 16 Dec 2014: | add support for Foswiki:Extensions/MediaElementPlugin to preview audio and video attachments |
| 29 Aug 2014: | fully specify rest security |
| 28 May 2014: | improve performance on bulk operations on attachments; fixed tooltip poping up automatically |
Expand Down Expand Up @@ -192,8 +193,8 @@ generates:
| Home page: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |

%META:FILEATTACHMENT{name="TopicInteractionPluginSnap5.png" attachment="TopicInteractionPluginSnap5.png" attr="" comment="" date="1418746985" size="36218" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap4.png" attachment="TopicInteractionPluginSnap4.png" attr="" comment="" date="1418746985" size="45039" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap3.png" attachment="TopicInteractionPluginSnap3.png" attr="" comment="" date="1418746985" size="99574" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap2.png" attachment="TopicInteractionPluginSnap2.png" attr="" comment="" date="1418746985" size="111026" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap1.png" attachment="TopicInteractionPluginSnap1.png" attr="" comment="" date="1418746985" size="16199" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap5.png" attachment="TopicInteractionPluginSnap5.png" attr="" comment="" date="1437154320" size="36218" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap4.png" attachment="TopicInteractionPluginSnap4.png" attr="" comment="" date="1437154320" size="45039" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap3.png" attachment="TopicInteractionPluginSnap3.png" attr="" comment="" date="1437154320" size="99574" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap2.png" attachment="TopicInteractionPluginSnap2.png" attr="" comment="" date="1437154320" size="111026" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap1.png" attachment="TopicInteractionPluginSnap1.png" attr="" comment="" date="1437154320" size="16199" user="ProjectContributor" version="1"}%
13 changes: 10 additions & 3 deletions lib/Foswiki/Plugins/TopicInteractionPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2014 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2009-2015 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 @@ package Foswiki::Plugins::TopicInteractionPlugin;
use strict;
use warnings;

our $VERSION = '3.70';
our $RELEASE = '3.70';
our $VERSION = '4.00';
our $RELEASE = '17 Jul 2015';
our $SHORTDESCRIPTION = 'Improved interaction with attachments and !DataForms';
our $NO_PREFS_IN_TOPIC = 1;

Expand All @@ -42,6 +42,7 @@ BEGIN {
sub initPlugin {

Foswiki::Func::registerTagHandler('ATTACHMENTS', \&handleATTACHMENTS);
Foswiki::Func::registerTagHandler('WEBDAVURL', \&handleWEBDAVURL);

Foswiki::Func::registerRESTHandler('changeproperties', \&restChangeProperties,
authenticate => 1,
Expand Down Expand Up @@ -138,6 +139,12 @@ sub handleATTACHMENTS {
return Foswiki::Plugins::TopicInteractionPlugin::Attachments::handle(@_);
}

##############################################################################
sub handleWEBDAVURL {
require Foswiki::Plugins::TopicInteractionPlugin::WebDAVUrl;
return Foswiki::Plugins::TopicInteractionPlugin::WebDAVUrl::handle(@_);
}

##############################################################################
sub restChangeProperties {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
Expand Down
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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 @@ -65,12 +65,12 @@ sub handle {
next unless $fileName;
$fileName = Foswiki::Plugins::TopicInteractionPlugin::Core::sanitizeAttachmentName($fileName);

unless ($fromObj->hasAttachment($fileName)) {
Foswiki::Plugins::TopicInteractionPlugin::Core::writeDebug("oops $fileName does not exist at $web.$topic");
#Foswiki::Plugins::TopicInteractionPlugin::Core::printJSONRPC($response, 102, "Attachment $fileName does not exist", $id);
#last;
next;
}
# Disabled to be able to clear up wrong META data
# unless ($fromObj->hasAttachment($fileName)) {
# Foswiki::Plugins::TopicInteractionPlugin::Core::writeDebug("oops $fileName does not exist at $web.$topic");
# $error = "Attachment $fileName does not exist";
# last;
# }

try {

Expand Down
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
8 changes: 5 additions & 3 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Attachments.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2005-2014 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2005-2015 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,6 +18,7 @@ use strict;
use warnings;

use POSIX ();
use Encode ();

#use Data::Dump qw(dump);

Expand Down Expand Up @@ -274,9 +275,10 @@ sub handle {

##############################################################################
sub urlEncode {
my ($infoOrText, $property) = @_;
my ($info, $property) = @_;

my $text = defined($property)?$infoOrText->{$property}:$infoOrText;
my $text = defined($property)?$info->{$property}:$info;
$text = Encode::encode_utf8($text) if $Foswiki::UNICODE;
$text =~ s/([^0-9a-zA-Z-_.:~!*\/])/'%'.sprintf('%02X',ord($1))/ge;

return $text;
Expand Down
53 changes: 18 additions & 35 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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 @@ -240,49 +240,32 @@ sub getRequestParams {
foreach my $key ($request->param()) {
if ($key eq 'filename') { #SMELL: hard coded multi-val
my @val = $request->multi_param($key);
$params{$key} = urlDecode($val[0]);
$params{$key."s"} = [map {urlDecode($_)} @val];
$params{$key} = $val[0];
$params{$key."s"} = [@val];
} else {
my $val = $request->param($key);
$params{$key} = urlDecode($val) if defined $val;
$params{$key} = $val if defined $val;
writeDebug("param $key=$val") unless $key eq 'POSTDATA';
}
}

my $queryString = $ENV{QUERY_STRING} || '';

foreach my $item (split(/[&;]/, $queryString)) {
if ($item =~ /^(.+?)=(.*)$/ && !defined($params{$1})) {
my $key = $1;
my $val = $2;
$params{$key} = urlDecode($val);
if ($key eq 'filename') { #SMELL: hard coded multi-val
$params{$key."s"} = [map {urlDecode($_)} split(/\s*,\s*/, $val)];
}
writeDebug("param $key=$params{$key}");
}
}
# my $queryString = $ENV{QUERY_STRING} || '';
#
# foreach my $item (split(/[&;]/, $queryString)) {
# if ($item =~ /^(.+?)=(.*)$/ && !defined($params{$1})) {
# my $key = $1;
# my $val = $2;
# $params{$key} = urlDecode($val);
# if ($key eq 'filename') { #SMELL: hard coded multi-val
# $params{$key."s"} = [map {urlDecode($_)} split(/\s*,\s*/, $val)];
# }
# writeDebug("param $key=$params{$key}");
# }
# }

return \%params;
}

##############################################################################
# this one handles url params that are url-encoded and/or utf8 encoded
sub urlDecode {
my $value = shift;

$value =~ s/%([\da-f]{2})/chr(hex($1))/gei;
my $session = $Foswiki::Plugins::SESSION;
my $downgradedValue = $session->UTF82SiteCharSet($value);
$value = $downgradedValue if defined $downgradedValue;

$value =~ s/^\s+//g;
$value =~ s/\s+$//g;

return $value;
}


##############################################################################
sub writeDebug {
print STDERR "- TopicInteractionPlugin - $_[0]\n" if TRACE;
Expand Down Expand Up @@ -400,7 +383,7 @@ sub sanitizeAttachmentName {

$fileName =~ s{[\\/]+$}{}; # Get rid of trailing slash/backslash (unlikely)
$fileName =~ s!^.*[\\/]!!; # Get rid of leading directory components
$fileName =~ s/[\*?~^\$@%`"'&;|<>\[\]#\x00-\x1f\(\)]//g; # Get rid of a subset of Namefilter
$fileName =~ s/[\s\*?~^\$@%`"'&;|<>\[\]#\x00-\x1f\(\)]+/_/g; # Get rid of a subset of Namefilter

return Foswiki::Sandbox::untaintUnchecked($fileName);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/MANIFEST
Expand Up @@ -11,8 +11,10 @@ lib/Foswiki/Plugins/TopicInteractionPlugin/Action/UploadAttachment.pm 0644
lib/Foswiki/Plugins/TopicInteractionPlugin/Attachments.pm 0644
lib/Foswiki/Plugins/TopicInteractionPlugin/Config.spec 0644
lib/Foswiki/Plugins/TopicInteractionPlugin/Core.pm 0644
lib/Foswiki/Plugins/TopicInteractionPlugin/DEPENDENCIES 0644
lib/Foswiki/Plugins/TopicInteractionPlugin.pm 0644
lib/Foswiki/Plugins/TopicInteractionPlugin/Uploader.pm 0644
lib/Foswiki/Plugins/TopicInteractionPlugin/WebDAVUrl.pm 0644
locale/TopicInteractionPlugin/de.po 0644
locale/TopicInteractionPlugin/Foswiki.pot 0644
pub/System/TopicInteractionPlugin/browserplus.init.js 0644
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/TopicInteractionPlugin/Uploader.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2010-2014 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2010-2015 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
48 changes: 48 additions & 0 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/WebDAVUrl.pm
@@ -0,0 +1,48 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2005-2015 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. 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.

package Foswiki::Plugins::TopicInteractionPlugin::WebDAVUrl;

use strict;
use warnings;

use POSIX ();

#use Data::Dump qw(dump);

###############################################################################
sub handle {
my ($session, $params, $theTopic, $theWeb) = @_;

#writeDebug("called handleWEBDAVURL($theTopic, $theWeb)");
my $url = $Foswiki::cfg{TopicInteractionPlugin}{WebDAVUrl} || 'webdav://$host/dav/$web/$topic_files/$attachment';

my $host = Foswiki::Func::getUrlHost();
$host =~ s/^https?:\/+//;

my $

$url =~ s/\$host/$host/g;
$url =~ s/\$web/$thisWeb/g;
$url =~ s/\$topic/$thisTopic/g;
$url =~ s/\$attachment/$encName/g;


my $result = '<a rel="nofollow" href="' . $url . '" ' . 'title="%MATETEXT{"Edit this attachment" args="<nop>' . $info->{name} . '"}%">' . '%MAKETEXT{"edit"}%</a>';

return $result;
}

1;

@@ -1,7 +1,7 @@
/**
* jquery.uploader.js
*
* Copyright 2010-2014, Michael Daum http://michaeldaumconsulting.com
* Copyright 2010-2015, Michael Daum http://michaeldaumconsulting.com
*
* based on jquery.plupload.queue.js Copyright 2009, Moxiecode Systems AB
*
Expand Down Expand Up @@ -290,11 +290,11 @@
}

if (typeof(name) !== 'undefined' && typeof(val) !== 'undefined') {
params[name] = encodeURI(val);
params[name] = val;
}
});

params.topic = encodeURI(foswiki.getPreference("WEB")) + "." + encodeURI(foswiki.getPreference("TOPIC"));
params.topic = foswiki.getPreference("WEB") + "." + foswiki.getPreference("TOPIC");
params.id = (new Date()).getTime();

if (uploader.features.multipart && uploader.settings.multipart) {
Expand Down
10 changes: 0 additions & 10 deletions pub/System/TopicInteractionPlugin/metadata.uncompressed.css
Expand Up @@ -52,16 +52,6 @@
.foswikiAttachmentsOptions b {
padding:0.1538em 0.3846em; /* 2px 5px */
}
a.foswikiAttachmentsOptionsToggle:hover {
background-color:transparent;
color:red;
}
a.foswikiAttachmentsOptionsToggle {
color:inherit;
text-decoration:underline;
height:23px;
line-height:23px;
}
.foswikiFormSteps .foswikiAttachmentsOptions .foswikiCheckbox {
margin-right:0px;
}
Expand Down

0 comments on commit d51acdb

Please sign in to comment.