diff --git a/data/System/NatSkinPlugin.txt b/data/System/NatSkinPlugin.txt index 88bfd85..b766425 100644 --- a/data/System/NatSkinPlugin.txt +++ b/data/System/NatSkinPlugin.txt @@ -1,4 +1,4 @@ -%META:TOPICINFO{author="ProjectContributor" comment="save topic" date="1363520449" format="1.1" version="7"}% +%META:TOPICINFO{author="ProjectContributor" comment="" date="1437155814" format="1.1" version="1"}% ---+!! The Natural Skin Plugin %TOC% @@ -181,6 +181,10 @@ See NatSkin#Installation_Instructions | Release: | %$RELEASE% | | Version: | %$VERSION% | | Change History: |   | +| 17 Jul 2015: | better integration with Foswiki:Extensions/AutoTemplatePlugin; \ + better detection of Internet Explorer versions; added edit_raw action; \ + added support for Foswiki-2.0; \ + properly searching for !WebComponents in the web holding the local !SitePreferences ... which not necessarily is the user web | | 27 Feb 2015: | finally 4.00 | | 29 Aug 2014: | third beta | | 28 Mar 2013: | second beta | diff --git a/lib/Foswiki/Plugins/NatSkinPlugin.pm b/lib/Foswiki/Plugins/NatSkinPlugin.pm index fcc0d3a..8bbe836 100755 --- a/lib/Foswiki/Plugins/NatSkinPlugin.pm +++ b/lib/Foswiki/Plugins/NatSkinPlugin.pm @@ -39,8 +39,8 @@ BEGIN { our $baseWeb; our $baseTopic; -our $VERSION = '4.00'; -our $RELEASE = '27 Feb 2015'; +our $VERSION = '4.10'; +our $RELEASE = '17 Jul 2015'; our $NO_PREFS_IN_TOPIC = 1; our $SHORTDESCRIPTION = 'Support plugin for NatSkin'; our $themeEngine; diff --git a/lib/Foswiki/Plugins/NatSkinPlugin/DEPENDENCIES b/lib/Foswiki/Plugins/NatSkinPlugin/DEPENDENCIES index da95eb5..9a5bc00 100644 --- a/lib/Foswiki/Plugins/NatSkinPlugin/DEPENDENCIES +++ b/lib/Foswiki/Plugins/NatSkinPlugin/DEPENDENCIES @@ -6,11 +6,13 @@ Foswiki::Plugins::CaptchaPlugin,>=2.0.0,perl,Optional Foswiki::Plugins::DBCachePlugin,>=1,perl,Required Foswiki::Plugins::FilterPlugin,>=3491,perl,Required Foswiki::Plugins::FlexWebListPlugin,>=3493,perl,Required +Foswiki::Plugins::GridLayoutPlugin,>=1.00,perl,Required Foswiki::Plugins::ImagePlugin,>=2.40,perl,Required Foswiki::Plugins::JQueryPlugin,>=5.00,perl,Required +Foswiki::Plugins::MetaCommentPlugin,>=2.80,perl,Optional Foswiki::Plugins::MimeIconPlugin,>=1,perl,Required +Foswiki::Plugins::MultiLingualPlugin,>=2.00,perl,Optional Foswiki::Plugins::NatEditPlugin,>=8.00,perl,Required -Foswiki::Contrib::NatSkin,>=3.99_004,perl,Required Foswiki::Plugins::PageOptimizerPlugin,>=0.10,perl,Optional Foswiki::Plugins::RenderPlugin,>=3644,perl,Required Foswiki::Plugins::TopicInteractionPlugin,>=1340,perl,Required diff --git a/lib/Foswiki/Plugins/NatSkinPlugin/ThemeEngine.pm b/lib/Foswiki/Plugins/NatSkinPlugin/ThemeEngine.pm index 80bd03f..fa871af 100644 --- a/lib/Foswiki/Plugins/NatSkinPlugin/ThemeEngine.pm +++ b/lib/Foswiki/Plugins/NatSkinPlugin/ThemeEngine.pm @@ -357,11 +357,18 @@ sub init { my $viewTemplate = $request->param('template') || Foswiki::Func::getPreferencesValue('VIEW_TEMPLATE'); + if (!$viewTemplate && $Foswiki::cfg{Plugins}{AutoTemplatePlugin}{Enabled}) { + require Foswiki::Plugins::AutoTemplatePlugin; + my $session = $Foswiki::Plugins::SESSION; + $viewTemplate = Foswiki::Plugins::AutoTemplatePlugin::getTemplateName($session->{webName}, $session->{topicName}); + } + Foswiki::Func::loadTemplate($viewTemplate) if $viewTemplate; # check if 'sidebar' is empty. if so then switch it off in the skinState my $sidebar = Foswiki::Func::expandTemplate('sidebar'); + $this->{skinState}{'sidebar'} = 'off' unless $sidebar; } } @@ -384,7 +391,7 @@ sub init { my $agent = $request->user_agent() || ''; #print STDERR "agent=$agent\n"; - if ($agent =~ /MSIE/) { + if ($agent =~ /MSIE|Trident/) { $context->{msie} = 1; # SMELL: better use Trident version to detect the physical version of the browser @@ -393,7 +400,7 @@ sub init { $context->{msie8} = 1 if $agent =~ /MSIE 8/; $context->{msie9} = 1 if $agent =~ /MSIE 9/; $context->{msie10} = 1 if $agent =~ /MSIE 10/; - $context->{msie11} = 1 if $agent =~ /MSIE 11/; + $context->{msie11} = 1 if $agent =~ /Trident\/7.0/; } elsif ($agent =~ /Chrome/) { $context->{chrome} = 1; } elsif ($agent =~ /Firefox/) { diff --git a/lib/Foswiki/Plugins/NatSkinPlugin/UserActions.pm b/lib/Foswiki/Plugins/NatSkinPlugin/UserActions.pm index bd6986e..a6511a1 100644 --- a/lib/Foswiki/Plugins/NatSkinPlugin/UserActions.pm +++ b/lib/Foswiki/Plugins/NatSkinPlugin/UserActions.pm @@ -77,12 +77,11 @@ sub render { $actionParams->{menu_footer} = $params->{menu_footer}; $actionParams->{hiderestricted} = Foswiki::Func::isTrue($params->{hiderestricted}, 0); $actionParams->{mode} = $params->{mode} || 'short'; - $actionParams->{sep} = $params->{sep} || $params->{separator}; - $actionParams->{sep} = ' | ' unless defined $actionParams->{sep}; + $actionParams->{sep} = $params->{sep} || $params->{separator} || ''; # get restrictions my $restrictedActions = $params->{restrictedactions}; - $restrictedActions = 'edit, attach, move, delete, diff, more, raw' + $restrictedActions = 'edit, edit_raw, attach, move, delete, diff, more, raw' unless defined $restrictedActions; %{$actionParams->{isRestrictedAction}} = map { $_ => 1 } split(/\s*,\s*/, $restrictedActions); @@ -93,6 +92,7 @@ sub render { # list all actions that need edit rights if ($actionParams->{isRestrictedAction}{'edit'}) { + $actionParams->{isRestrictedAction}{'edit_raw'} = 1; $actionParams->{isRestrictedAction}{'attach'} = 1; $actionParams->{isRestrictedAction}{'delete'} = 1; $actionParams->{isRestrictedAction}{'editform'} = 1; @@ -145,6 +145,7 @@ sub formatResult { $text =~ s/\$(?:editform\b|action\(editform(?:,\s*(.*?))?\))/renderEditForm($params, $1, $mode)/ge; $text =~ s/\$(?:account\b|action\(account(?:,\s*(.*?))?\))/renderAccount($params, $1, $mode)/ge; $text =~ s/\$(?:diff\b|action\(diff(?:,\s*(.*?))?\))/renderDiff($params, $1, $mode)/ge; + $text =~ s/\$(?:edit_raw\b|action\(edit_raw(?:,\s*(.*?))?\))/renderEditRaw($params, $1, $mode)/ge; $text =~ s/\$(?:edit\b|action\(edit(?:,\s*(.*?))?\))/renderEdit($params, $1, $mode)/ge; $text =~ s/\$(?:view\b|action\(view(?:,\s*(.*?))?\))/renderView($params, $1, $mode)/ge; $text =~ s/\$(?:first\b|action\(first(?:,\s*(.*?))?\))/renderFirst($params, $1, $mode)/ge; @@ -156,7 +157,7 @@ sub formatResult { $text =~ s/(\$sep)?\$(?:logout\b|action\(logout(?:,\s*(.*?))?\))/renderLogout($params, $1, $2, $mode)/ge; # normal actions / backwards compatibility - $text =~ s/\$(attach|copytopic|delete|editsettings|edittext|help|history|more|move|new|pdf|print|register|restore|users)\b/renderAction($1, $params, undef, undef, undef, $mode)/ge; + $text =~ s/\$(attach|copytopic|delete|editsettings|edittext|help|history|more|move|new|pdf|print|register|restore|users|share)\b/renderAction($1, $params, undef, undef, undef, $mode)/ge; # generic actions $text =~ s/\$action\((.*?)(?:,\s*(.*?))?\)/renderAction($1, $params, undef, undef, $2, $mode)/ge; @@ -241,6 +242,40 @@ sub renderEdit { return $result; } +############################################################################### +sub renderEditRaw { + my ($params, $context, $mode) = @_; + + return '' if (defined($context) && !Foswiki::Func::getContext()->{$context}); + + my $result = ''; + my $label; + my $themeEngine = Foswiki::Plugins::NatSkinPlugin::getThemeEngine(); + + if ($params->{isRestrictedAction}{'edit_raw'}) { + return '' if $params->{hiderestricted}; + if ($themeEngine->{skinState}{"history"}) { + $result = Foswiki::Func::expandTemplate('RESTORE_ACTION_RESTRICTED'); + $label = getLabelForAction("RESTORE", $mode); + } else { + $result = Foswiki::Func::expandTemplate('EDIT_RAW_ACTION_RESTRICTED'); + $label = getLabelForAction("EDIT_RAW", $mode); + } + } else { + if ($themeEngine->{skinState}{"history"}) { + $result = Foswiki::Func::expandTemplate('RESTORE_ACTION'); + $label = getLabelForAction("RESTORE", $mode); + } else { + $result = Foswiki::Func::expandTemplate('EDIT_RAW_ACTION'); + $label = getLabelForAction("EDIT_RAW", $mode); + } + } + + $result =~ s/\$label/$label/g; + + return $result; +} + ############################################################################### sub renderView { my ($params, $context, $mode) = @_; @@ -400,13 +435,13 @@ sub renderEditForm { if ($topicObj && $topicObj->getFormName) { if ($params->{isRestrictedAction}{'editform'}) { return '' if $params->{hiderestricted}; - $result = Foswiki::Func::expandTemplate("EDITFORM_ACTION_RESTRICTED"); + $result = Foswiki::Func::expandTemplate("EDIT_FORM_ACTION_RESTRICTED"); } - $result = Foswiki::Func::expandTemplate("EDITFORM_ACTION"); + $result = Foswiki::Func::expandTemplate("EDIT_FORM_ACTION"); } - my $label = getLabelForAction("EDITFORM", $mode); + my $label = getLabelForAction("EDIT_FORM", $mode); $result =~ s/\$label/$label/g; return $result; diff --git a/lib/Foswiki/Plugins/NatSkinPlugin/Utils.pm b/lib/Foswiki/Plugins/NatSkinPlugin/Utils.pm index c54de09..81a305d 100644 --- a/lib/Foswiki/Plugins/NatSkinPlugin/Utils.pm +++ b/lib/Foswiki/Plugins/NatSkinPlugin/Utils.pm @@ -23,6 +23,7 @@ use warnings; use Foswiki::Func (); use Foswiki::Plugins (); use Foswiki::Plugins::NatSkinPlugin (); +use Encode(); our %maxRevs = (); # cache for getMaxRevision() @@ -60,6 +61,7 @@ sub makeParams { sub urlEncode { my $text = shift; + $text = Encode::encode_utf8($text) if $Foswiki::UNICODE; $text =~ s/([^0-9a-zA-Z-_.:~!*'\/])/'%'.sprintf('%02x',ord($1))/ge; return $text; diff --git a/lib/Foswiki/Plugins/NatSkinPlugin/WebComponent.pm b/lib/Foswiki/Plugins/NatSkinPlugin/WebComponent.pm index 8c2061e..31b0bc0 100644 --- a/lib/Foswiki/Plugins/NatSkinPlugin/WebComponent.pm +++ b/lib/Foswiki/Plugins/NatSkinPlugin/WebComponent.pm @@ -95,7 +95,7 @@ sub getWebComponent { # get component for web my $text = ''; my $meta = ''; - my $usersWeb = $Foswiki::cfg{UsersWebName}; + my ($configWeb) = Foswiki::Func::normalizeWebTopicName(undef, $Foswiki::cfg{LocalSitePreferences}); my $systemWeb = $Foswiki::cfg{SystemWebName}; my $theWeb = $web; @@ -110,7 +110,7 @@ sub getWebComponent { # current ($meta, $text) = Foswiki::Func::readTopic($theWeb, $theComponent); } else { - $theWeb = $usersWeb; + $theWeb = $configWeb; $theComponent = 'Site' . $component; if ( Foswiki::Func::topicExists($theWeb, $theComponent)