Skip to content

Commit

Permalink
Item14277: add a filename parameter to override it
Browse files Browse the repository at this point in the history
... in content-disposition
  • Loading branch information
MichaelDaum committed Jan 16, 2017
1 parent 5b2a6ad commit 45222bf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
14 changes: 7 additions & 7 deletions .gitignore
@@ -1,10 +1,10 @@
*.gz
*.swp
RenderPlugin.md5
RenderPlugin.sha1
RenderPlugin.tgz
RenderPlugin.txt
RenderPlugin.zip
RenderPlugin_installer
RenderPlugin_installer.pl
/RenderPlugin.md5
/RenderPlugin.sha1
/RenderPlugin.tgz
/RenderPlugin.txt
/RenderPlugin.zip
/RenderPlugin_installer
/RenderPlugin_installer.pl
pub/System/RenderPlugin/foswikiTemplate.js
10 changes: 6 additions & 4 deletions data/System/RenderPlugin.txt
Expand Up @@ -34,15 +34,15 @@ a parametrized =INCLUDE=, as it is used on server side <nop>WikiApplications (se
The available REST handlers are:

| *Handler* | *Parameters* | *Description* |
| =expand= | =text= | expands common variables in the submitted =text= fragment |
| =expand= | =text= | expands common variables in the submitted =text= fragment, =filename= |
| =render= | =text= | same as =expand= but also renders <nop>TopicMarkup converting it to HTML |
| =tag= | =name=, %BR% =param=, %BR% =<named-params>*=, %BR% =render= | this is a convenience function to expand one specific \
| =tag= | =name=, %BR% =param=, %BR% =<named-params>*=, %BR% =render=, %BR% =filename= | this is a convenience function to expand one specific \
variable instead of having to build up a snippet of code that you want to =expand= or =render=; \
The =param= parameter specifies the default parameters to this tag; the =named-params= are additional \
named parameters; the =render= flag indicates if the result is to be expanded only \
or if it should be renderd into HTML; default is off, that is only expand common tags but don't interpret \
<nop>TopicMarkup |
| =template= | =name=, %BR% =expand=, %BR% =render= | this handler loads the template =name= and expands the macro \
| =template= | =name=, %BR% =expand=, %BR% =render=, %BR% =filename= | this handler loads the template =name= and expands the macro \
given in =expand=; the =render= flag indicates whether the result is to be rendered in addition to common tags being interpreted |
| =jsonTemplate= | =name=, %BR%, =expand=, %BR% =render= | same as =template= handler, but returns a json object holding css and js zones required to properly format the template; used via =foswiki.loadTemplate()= |

Expand Down Expand Up @@ -139,6 +139,8 @@ Okay, your turn to create an example calling SEARCH.
%$DEPENDENCIES%

---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 16 Jan 2017: | added =filename= to rest handler to override it in the content-dispisition header |
| 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 |
Expand All @@ -153,7 +155,7 @@ Okay, your turn to create an example calling SEARCH.

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="2006-2016, Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Copyright" title="Copyright" value="2006-2017, 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]])"}%
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-2016 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2008-2017 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.10';
our $RELEASE = '29 Apr 2016';
our $VERSION = '5.00';
our $RELEASE = '16 Jan 2017';
our $SHORTDESCRIPTION = 'Render <nop>WikiApplications asynchronously';
our $NO_PREFS_IN_TOPIC = 1;
our $core;
Expand Down
30 changes: 29 additions & 1 deletion 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-2016 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2008-2017 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 @@ -153,6 +153,13 @@ sub restTag {
#writeDebug("result=$result");

my $contentType = $query->param("contenttype");
my $fileName = $query->param("filename");
if ($fileName) {
$this->{session}{response}->header(
-type => $contentType || "text/html",
-content_disposition => "attachment; filename=\"$fileName\"",
);
}
$this->{session}->writeCompletePage($result, undef, $contentType);

return;
Expand All @@ -179,6 +186,13 @@ sub restRender {
$result = Foswiki::Func::renderText($result, $web, $topic);

my $contentType = $query->param("contenttype");
my $fileName = $query->param("filename");
if ($fileName) {
$this->{session}{response}->header(
-type => $contentType || "text/html",
-content_disposition => "attachment; filename=\"$fileName\"",
);
}
$this->{session}->writeCompletePage($result, undef, $contentType);

return;
Expand All @@ -205,6 +219,13 @@ sub restExpand {
my $result = Foswiki::Func::expandCommonVariables($theText, $topic, $web) || ' ';

my $contentType = $query->param("contenttype");
my $fileName = $query->param("filename");
if ($fileName) {
$this->{session}{response}->header(
-type => $contentType || "text/html",
-content_disposition => "attachment; filename=\"$fileName\"",
);
}
$this->{session}->writeCompletePage($result, undef, $contentType);

return;
Expand Down Expand Up @@ -242,6 +263,13 @@ sub restTemplate {
}

my $contentType = $query->param("contenttype");
my $fileName = $query->param("filename");
if ($fileName) {
$this->{session}{response}->header(
-type => $contentType || "text/html",
-content_disposition => "attachment; filename=\"$fileName\"",
);
}
$this->{session}->writeCompletePage($result, undef, $contentType);

return;
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/RenderPlugin/build.pl
@@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
BEGIN {
unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} );
}
Expand Down

0 comments on commit 45222bf

Please sign in to comment.