Skip to content

Commit

Permalink
Item14267: always at least assign a view template
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jan 16, 2017
1 parent 766b764 commit 2e5d37e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion data/System/AutoTemplatePlugin.txt
Expand Up @@ -151,6 +151,7 @@ The following settings can be defined in configure
---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 16 Jan 2017: | always at least assign a view template |
| 01 Sep 2016: | do not override the template url param |
| 13 Oct 2015: | bail out early when not in view, edit or print mode |
| 25 Sep 2015: | added support for PRINT_TEMPLATE |
Expand All @@ -177,7 +178,7 @@ The following settings can be defined in configure

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Foswiki:Main.MichaelDaum"}%
%META:FIELD{name="Copyright" title="Copyright" value="© 2008-2016, Oliver Krüger, Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="© 2008-2017, Oliver Krüger, Michael Daum"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%TOPIC%"}%
%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%"}%
Expand Down
14 changes: 4 additions & 10 deletions lib/Foswiki/Plugins/AutoTemplatePlugin.pm
@@ -1,7 +1,7 @@
# Plugin for Foswiki
#
# Copyright (C) 2008 Oliver Krueger <oliver@wiki-one.net>
# Copyright (C) 2008-2016 Foswiki Contributors
# Copyright (C) 2008-2017 Foswiki Contributors
# All Rights Reserved.
#
# This program is distributed in the hope that it will be useful,
Expand All @@ -15,8 +15,8 @@ package Foswiki::Plugins::AutoTemplatePlugin;
use strict;
use warnings;

our $VERSION = '5.11';
our $RELEASE = '01 Sep 2016';
our $VERSION = '5.20';
our $RELEASE = '16 Jan 2017';
our $SHORTDESCRIPTION = 'Automatically sets VIEW_TEMPLATE, EDIT_TEMPLATE and PRINT_TEMPLATE';
our $NO_PREFS_IN_TOPIC = 1;
our $debug;
Expand All @@ -33,9 +33,7 @@ sub initPlugin {


# is this an edit action?
my $templateVar = _isEditAction()?'EDIT_TEMPLATE':_isViewAction()?'VIEW_TEMPLATE':_isPrintAction()?'PRINT_TEMPLATE':undef;

return 1 unless $templateVar;
my $templateVar = _isEditAction()?'EDIT_TEMPLATE':_isPrintAction()?'PRINT_TEMPLATE':'VIEW_TEMPLATE';

# back off if there is a view template already and we are not in override mode
my $currentTemplate = Foswiki::Func::getPreferencesValue($templateVar);
Expand Down Expand Up @@ -156,10 +154,6 @@ sub _isPrintAction {
return $contentType eq 'application/pdf' || $cover =~ /print/ ? 1:0;
}

sub _isViewAction {
return Foswiki::Func::getContext()->{view}?1:0;
}

sub _isEditAction {
return Foswiki::Func::getContext()->{edit}?1:0;
}
Expand Down

0 comments on commit 2e5d37e

Please sign in to comment.