Skip to content

Commit

Permalink
Item14097: don't trash WebLeftBar
Browse files Browse the repository at this point in the history
added parameter to configure which topics should be exempted from trashing
  • Loading branch information
MichaelDaum committed Jun 14, 2016
1 parent 66d9655 commit a834ab4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 42 deletions.
35 changes: 19 additions & 16 deletions data/System/TrashPlugin.txt
@@ -1,6 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1375877703" format="1.1" reprev="2" version="3"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1465918739" format="1.1" version="1"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%
%FORMFIELD{"Description"}%

%TOC%

Expand Down Expand Up @@ -38,21 +38,24 @@ Optionally add an "Empty Trash" button to [[%TRASHWEB%.%HOMETOPIC%][%TRASHWEB%.%
}%
</verbatim>

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

| Author(s): | Michael Daum|
| Copyright: | &copy; 2013-2014 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
| 14 Jun 2016: | added parameter to configure which topics should be exempted from trashing; adding <nop>WebLeftBar by default now |
| 29 Aug 2014: | fully specify rest security |
| 04 Apr 2014: | flag rest handlers that don't require authentication |
| 05 Sep 2013: | fixed tainted issue |
| 06 Aug 2013: | 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; 2013-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/%TOPIC%"}%
%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="%$RELEASE%"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%TOPIC%"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%TOPIC%"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/TrashPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# TrashPlugin is Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
# TrashPlugin is Copyright (C) 2013-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 @@ -20,8 +20,8 @@ use warnings;

use Foswiki::Func ();

our $VERSION = '1.10';
our $RELEASE = '1.10';
our $VERSION = '2.00';
our $RELEASE = '14 Jun 2016';
our $SHORTDESCRIPTION = 'Maintain the Trash web';
our $NO_PREFS_IN_TOPIC = 1;
our $core;
Expand Down
6 changes: 5 additions & 1 deletion lib/Foswiki/Plugins/TrashPlugin/Config.spec
Expand Up @@ -20,6 +20,10 @@ $Foswiki::cfg{SwitchBoard}{cleanup_trash} = {
# <li>1y: delete items older than 1 year</li>
# <li>30d: delete items older than 30 days</li>
# </ul>
$Foswiki::cfg{TrashPlugin}{Expire} = "1M";
$Foswiki::cfg{TrashPlugin}{Expire} = '1M';

# **REGEX EXPERT**
# A regular expression of topics that should not be deleted from trash.
$Foswiki::cfg{TrashPlugin}{ExcludeTopic} = '^(WebAtom|WebRss|WebSearch.*|WebChanges|WebHome|WebNotify|WebTopicList|WebIndex|WebLeftBar|WebSideBar|WebPreferences|TrashAttachment|WebLeftBar.*)$';

1;
18 changes: 11 additions & 7 deletions lib/Foswiki/Plugins/TrashPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# TrashPlugin is Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
# TrashPlugin is Copyright (C) 2013-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 Down Expand Up @@ -30,10 +30,14 @@ sub new {
my $class = shift;

my $this = bless({
debug => $Foswiki::cfg{TrashPlugin}{Debug},
dry => 0,
@_
}, $class);
debug => $Foswiki::cfg{TrashPlugin}{Debug},
expire => $Foswiki::cfg{TrashPlugin}{Expire} || '1M',
excludeTopic => $Foswiki::cfg{TrashPlugin}{ExcludeTopic} || '^(WebAtom|WebRss|WebSearch.*|WebChanges|WebHome|WebNotify|WebTopicList|WebIndex|WebLeftBar|WebSideBar|WebPreferences|TrashAttachment|WebLeftBar.*)$',
dry => 0,
@_
},
$class
);

return $this;
}
Expand All @@ -55,7 +59,7 @@ sub cleanUp {
$this->{debug} = Foswiki::Func::isTrue(scalar $request->param("debug"), $this->{debug});

my $expire = $request->param("expire");
$expire = ($Foswiki::cfg{TrashPlugin}{Expire} || '1M') unless defined $expire;
$expire = $this->{expire} unless defined $expire;
$expire =~ s/^\+\-//;
$expire = "0s" if $expire eq "0"; # special case: empty all
$expire = '-' . $expire;
Expand All @@ -69,7 +73,7 @@ sub cleanUp {

# cleaning up topics
foreach my $topic (Foswiki::Func::getTopicList($web)) {
next if $topic =~ /^(WebAtom|WebRss|WebSearch.*|WebChanges|WebHome|WebNotify|WebTopicList|WebIndex|WebLeftBar|WebSideBar|WebPreferences|TrashAttachment)$/;
next if $topic =~ /$this->{excludeTopic}/;

my ($date) = Foswiki::Func::getRevisionInfo($web, $topic);
next unless $date < $this->{expire};
Expand Down
16 changes: 1 addition & 15 deletions lib/Foswiki/Plugins/TrashPlugin/build.pl
@@ -1,24 +1,10 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
BEGIN { unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} ); }
use Foswiki::Contrib::Build;

# Create the build object
$build = new Foswiki::Contrib::Build('TrashPlugin');

# (Optional) Set the details of the repository for uploads.
# This can be any web on any accessible Foswiki installation.
# These defaults will be used when expanding tokens in .txt
# files, but be warned, they can be overridden at upload time!

# name of web to upload to
$build->{UPLOADTARGETWEB} = 'Extensions';
# Full URL of pub directory
$build->{UPLOADTARGETPUB} = 'http://foswiki.org/pub';
# Full URL of bin directory
$build->{UPLOADTARGETSCRIPT} = 'http://foswiki.org/bin';
# Script extension
$build->{UPLOADTARGETSUFFIX} = '';

# Build the target on the command line, or the default target
$build->build($build->{target});

0 comments on commit a834ab4

Please sign in to comment.