Skip to content

Commit

Permalink
Item14222: oo-ify core, as well as many other improvements
Browse files Browse the repository at this point in the history
   * improved webdav integration for one-click editing office documents
   * added registry entry to use register LibreOffice to be used for one-click edits on windows
   * fixed sanitizing attachemnt names during upload using the standard mechanism again
   * removed (optional) dependency on FlexPaperPlugin (flash) in favour of DocumentViewerPlugin (html5)
   * fixed url construction in javascript land
   * add support for JQPhotoSwipeContrib, a much nicer lightbox image preview
   * added support for LikePlugin to rate attachments
   * replaced famfamfam icons with fontawsome ones
  • Loading branch information
MichaelDaum committed Nov 18, 2016
1 parent d51acdb commit 8a2f33f
Show file tree
Hide file tree
Showing 45 changed files with 1,377 additions and 1,084 deletions.
15 changes: 8 additions & 7 deletions .gitignore
@@ -1,3 +1,4 @@
*,v
igp_*
*.gz
*.swp
Expand All @@ -14,10 +15,10 @@ pub/System/TopicInteractionPlugin/plupload.js
pub/System/TopicInteractionPlugin/metadata.css
pub/System/TopicInteractionPlugin/metadata.js
pub/System/TopicInteractionPlugin/gears.init.js
TopicInteractionPlugin.md5
TopicInteractionPlugin.sha1
TopicInteractionPlugin.tgz
TopicInteractionPlugin.txt
TopicInteractionPlugin.zip
TopicInteractionPlugin_installer
TopicInteractionPlugin_installer.pl
/TopicInteractionPlugin.md5
/TopicInteractionPlugin.sha1
/TopicInteractionPlugin.tgz
/TopicInteractionPlugin.txt
/TopicInteractionPlugin.zip
/TopicInteractionPlugin_installer
/TopicInteractionPlugin_installer.pl
49 changes: 32 additions & 17 deletions data/System/TopicInteractionPlugin.txt
@@ -1,6 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437154320" format="1.1" version="1"}%
%META:TOPICINFO{author="micha" comment="gainedLibreOfficeWebDAV.reg" date="1470922302" format="1.1" version="2"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%
%FORMFIELD{"Description"}%

%TOC%

Expand Down Expand Up @@ -80,7 +80,7 @@ limit the number of attachments to be listed.
| =nullformat="..."= | format string to be used when no attachments have been found and =hidenull= is switched off |
| =nullheader="..."= | header string to be used when no attachments have been found and =hidenull= is switched off |
| =nullfooter="..."= | footer string to be used when no attachments have been found and =hidenull= is switched off |
| =sort="name,date,size,user,comment,comment:name"= | sort results by specified field |
| =sort="name,date,size,user,comment,comment:name,random"= | sort results by specified property |
| =reverse="on/off"= | enable reverse sorting |
| =limit="..."= | limit the number of attachments to the given number; by default show all |

Expand All @@ -102,8 +102,10 @@ The following variables can be used in the format parameter:
* $props: the action to change the properties of the current attachment
* $propsUrl: the url used in the props action
* $size: the size in bytes
* $sizeH: file size in a humanized display (using KB, MB, GB, etc) as needed
* $sizeK: the size in kilo bytes
* $sizeM: the size in mega bytes
* $sizeG: the size in giga bytes
* $topic: the name of the topic of whose attachments are listed
* $url: the attachments url
* $urlpath: the attachments urlpath
Expand Down Expand Up @@ -142,17 +144,22 @@ generates:

%$INSTALL_INSTRUCTIONS%

---++ Info
<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->

| Author(s): | Michael Daum|
| Copyright: | &copy; 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; |
---++ Dependencies
%$DEPENDENCIES%

---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 18 Nov 2016: | oo-ified core; \
added humanized file size display, removed flash backend from default; \
improved webdav integration for one-click editing office documents; \
fixed sanitizing attachemnt names during upload using the standard mechanism again; \
removed (optional) dependency on <nop>FlexPaperPlugin (flash) in favour of <nop>DocumentViewerPlugin (html5); \
fixed url construction in javascript land; \
add support for <nop>JQPhotoSwipeContrib, a much nicer lightbox image preview; \
added support for <nop>LikePlugin to rate attachments; \
replaced famfamfam icons with fontawsome ones; \
added registry entry to use register <nop>LibreOffice to be used for one-click edits on windows |
| 11 Oct 2016: | using jquery-i18n for translations now |
| 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 |
Expand Down Expand Up @@ -189,12 +196,20 @@ generates:
fixed dependency on Foswiki:Extensions/RenderPlugin; \
fixed interaction with Foswiki:Extensions/MetaCommentPlugin |
| 26 Apr 2012: | initial release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2010-2016 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%25TOPIC%25"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25TOPIC%25"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%25TOPIC%25"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%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"}%
%META:FILEATTACHMENT{name="LibreOfficeWebDAV.reg" attachment="LibreOfficeWebDAV.reg" attr="" comment="" date="1470917899" moveby="micha" movedto="System.TopicInteractionPlugin.LibreOfficeWebDAV.reg" movedwhen="1470922302" movefrom="Sandbox.OpenToEditTest.LibreOfficeWebDAV.reg" size="1126" user="micha" version="2"}%
139 changes: 60 additions & 79 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-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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,10 +18,11 @@ package Foswiki::Plugins::TopicInteractionPlugin;
use strict;
use warnings;

our $VERSION = '4.00';
our $RELEASE = '17 Jul 2015';
our $VERSION = '5.00';
our $RELEASE = '18 Nov 2016';
our $SHORTDESCRIPTION = 'Improved interaction with attachments and !DataForms';
our $NO_PREFS_IN_TOPIC = 1;
our $core;

use Foswiki::Func ();
use Foswiki::Plugins::JQueryPlugin ();
Expand All @@ -37,62 +38,86 @@ BEGIN {
}
}


##############################################################################
sub initPlugin {

Foswiki::Func::registerTagHandler('ATTACHMENTS', \&handleATTACHMENTS);
Foswiki::Func::registerTagHandler('WEBDAVURL', \&handleWEBDAVURL);
Foswiki::Func::registerTagHandler('ATTACHMENTS', sub {
require Foswiki::Plugins::TopicInteractionPlugin::Attachments;
return Foswiki::Plugins::TopicInteractionPlugin::Attachments::handle(@_);
});

Foswiki::Func::registerTagHandler('WEBDAVURL', sub {
require Foswiki::Plugins::TopicInteractionPlugin::WebDAVUrl;
return Foswiki::Plugins::TopicInteractionPlugin::WebDAVUrl::handle(@_);
});

Foswiki::Func::registerRESTHandler('changeproperties', \&restChangeProperties,
Foswiki::Func::registerRESTHandler('changeproperties', sub {
return getCore(shift)->restChangeProperties(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('delete', \&restDelete,
Foswiki::Func::registerRESTHandler('delete', sub {
return getCore(shift)->restDelete(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('move', \&restMove,
Foswiki::Func::registerRESTHandler('move', sub {
return getCore(shift)->restMove(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('upload', \&restUpload,
Foswiki::Func::registerRESTHandler('upload', sub {
return getCore(shift)->restUpload(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('createlink', \&restCreateLink,
Foswiki::Func::registerRESTHandler('createlink', sub {
return getCore(shift)->restCreateLink(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('createimagegallery', \&restCreateImageGallery,
Foswiki::Func::registerRESTHandler('createimagegallery', sub {
return getCore(shift)->restCreateImageGallery(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('download', \&restDownload,
Foswiki::Func::registerRESTHandler('download', sub {
return getCore(shift)->restDownload(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('hide', \&restHide,
Foswiki::Func::registerRESTHandler('hide', sub {
return getCore(shift)->restHide(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
);

Foswiki::Func::registerRESTHandler('unhide', \&restUnhide,
Foswiki::Func::registerRESTHandler('unhide', sub {
return getCore(shift)->restUnhide(@_);
},
authenticate => 1,
validate => 0,
http_allow => 'POST',
Expand All @@ -101,9 +126,28 @@ sub initPlugin {
# just in case it did not make it to LocalSite.cfg in time
Foswiki::Plugins::JQueryPlugin::registerPlugin("uploader", 'Foswiki::Plugins::TopicInteractionPlugin::Uploader');

# init
getCore();

return 1;
}

##############################################################################
sub finishPlugin {
undef $core;
}
##############################################################################
sub getCore {
my $session = shift;

unless ($core) {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
$core = Foswiki::Plugins::TopicInteractionPlugin::Core->new($session);
}

return $core;
}

##############################################################################
# keep a t=thumbnail attr in attachments
sub beforeUploadHandler {
Expand All @@ -116,6 +160,7 @@ sub beforeUploadHandler {
}
}

##############################################################################
sub afterUploadHandler {
my ($attachment, $meta) = @_;

Expand All @@ -133,70 +178,6 @@ sub afterUploadHandler {
}
}
}
##############################################################################
sub handleATTACHMENTS {
require Foswiki::Plugins::TopicInteractionPlugin::Attachments;
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;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restChangeProperties(@_);
}

##############################################################################
sub restDelete {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restDelete(@_);
}

##############################################################################
sub restMove {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restMove(@_);
}

##############################################################################
sub restUpload {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restUpload(@_);
}

##############################################################################
sub restCreateLink {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restCreateLink(@_);
}

##############################################################################
sub restCreateImageGallery {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restCreateImageGallery(@_);
}

##############################################################################
sub restDownload {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restDownload(@_);
}

##############################################################################
sub restHide {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restHide(@_);
}

##############################################################################
sub restUnhide {
require Foswiki::Plugins::TopicInteractionPlugin::Core;
return Foswiki::Plugins::TopicInteractionPlugin::Core::restUnhide(@_);
}

1;

0 comments on commit 8a2f33f

Please sign in to comment.