Skip to content

Commit

Permalink
Item14059: add support for newer Foswiki engines
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Apr 29, 2016
1 parent 97dddfd commit 5b2a6ad
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 25 deletions.
16 changes: 7 additions & 9 deletions data/System/RenderPlugin.txt
@@ -1,6 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="autosave" date="1356278778" format="1.1" version="4"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%
%FORMFIELD{"Description"}%

%TOC%

Expand Down Expand Up @@ -135,13 +135,11 @@ Okay, your turn to create an example calling SEARCH.
---++ Installation Instructions
%$INSTALL_INSTRUCTIONS%

---++ Plugin Info
<!--
One line description, required for extensions repository catalog.
* Set SHORTDESCRIPTION = Render <nop>WikiApplications asynchronously
-->
---++ Dependencies
%$DEPENDENCIES%

| Change History: | <!-- versions below in reverse order -->&nbsp; |
---++ Change History
| 29 Apr 2016: | added support for newer Foswiki engines |
| 31 Aug 2015: | implemeted JSON-Template REST handler |
| 04 Apr 2014: | flag rest handlers that don't require authentication |
| 18 Mar 2014: | removed duplicate http header from =render= rest handler |
Expand All @@ -152,11 +150,11 @@ One line description, required for extensions repository catalog.
| 07 Jan 2009: | added upload rest handler; \
fixes for foswiki and <nop>FastCGIContrib |
| 11 Jul 2008: | initial version |
| Dependencies: | %$DEPENDENCIES% |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="2006-2015, Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Copyright" title="Copyright" value="2006-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="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
Expand Down
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/RenderPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2008-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2008-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 @@ -22,8 +22,8 @@ use Foswiki::Func ();
use Foswiki::Sandbox() ;
use Encode ();

our $VERSION = '4.00';
our $RELEASE = '31 Aug 2015';
our $VERSION = '4.10';
our $RELEASE = '29 Apr 2016';
our $SHORTDESCRIPTION = 'Render <nop>WikiApplications asynchronously';
our $NO_PREFS_IN_TOPIC = 1;
our $core;
Expand Down
40 changes: 29 additions & 11 deletions lib/Foswiki/Plugins/RenderPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2008-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2008-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 @@ -58,23 +58,15 @@ sub json {
sub getZoneObject {
my ($this, $zone, $meta) = @_;

my @total;
my %visited;
my @zoneIDs = values %{$this->{session}{_zones}{$zone}};

foreach my $zoneID (@zoneIDs) {
$this->{session}->_visitZoneID($zoneID, \%visited, \@total);
}

my @zone = ();
my $excludeFromZone = $Foswiki::cfg{AngularPlugin}{ExcludeFromZone} || $Foswiki::cfg{RenderPlugin}{ExcludeFromZone};

foreach my $item (grep { $_->{text} } @total) {
foreach my $item (grep { $_->{text} } $this->getZoneItems($zone)) {
if ($excludeFromZone && $item->{id} =~ /$excludeFromZone/g) {
#print STDERR "excluding $item->{id}\n";
next;
}
#print STDERR "loading $item->{id}\n";
#print STDERR "id=$item->{id}\n";
my @requires = map { $_->{id} } @{$item->{requires}};

my $text = $meta->renderTML($meta->expandMacros($item->{text}));
Expand All @@ -90,6 +82,32 @@ sub getZoneObject {
return \@zone;
}

###############################################################################
sub getZoneItems {
my ($this, $zone) = @_;

my $session = $Foswiki::Plugins::SESSION;
my $zonesHandler;

if ($session->can("zones")) {
# Foswiki > 2.0.3: zones are stored in a sub-component
$zonesHandler = $session->zones();
} else {
# Foswiki <= 2.0.3: zones are stored in the session object
$zonesHandler = $session;
}

my @zoneItems = values %{$zonesHandler->{_zones}{$zone}};
my %visited = ();
my @result = ();

foreach my $item (@zoneItems) {
$zonesHandler->_visitZoneID($item, \%visited, \@result);
}

return @result;
}

###############################################################################
sub restTag {
my ($this, $subject, $verb) = @_;
Expand Down
4 changes: 2 additions & 2 deletions pub/System/RenderPlugin/foswikiTemplate.uncompressed.js
@@ -1,5 +1,5 @@
/*
* foswiki template loader 1.0
* foswiki template loader 1.1
*
* (c)opyright 2015 Michael Daum http://michaeldaumconsulting.com
*
Expand All @@ -26,7 +26,7 @@

self.successFunc = opts.success || function() {},
self.errorFunc = opts.error || function() {},
self.url = opts.url || foswiki.getPreference("SCRIPTURL")+"/rest/RenderPlugin/jsonTemplate";
self.url = opts.url || foswiki.getScriptUrl("rest", "RenderPlugin", "jsonTemplate");

delete opts.success;
delete opts.error;
Expand Down

0 comments on commit 5b2a6ad

Please sign in to comment.