Skip to content

Commit

Permalink
Item14339: Canonical SCRIPTURL macros
Browse files Browse the repository at this point in the history
Change all SCRIPTURL and SCRIPTURLPATH macros to the canonical form
where possible.   This is only the core topics and templates. As these
changes are not backwards compatible, plugins are not included.

There is still more work to support Anchors and the jsonrpc and rest
scripts.
  • Loading branch information
gac410 committed Mar 11, 2017
1 parent 7a6f2e7 commit 5d2a11f
Show file tree
Hide file tree
Showing 27 changed files with 154 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,17 @@ sub std_tests {

#TODO: redo this with custom tmpl and check each username
my $output;
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
if ( $this->check_dependency('Foswiki,>=,2.1.999') ) {
$output = <<'THIS';
%TMPL:P{"settmltablesummary"
SUMMARY="%MAKETEXT{"Attachments"}%"
}%<div class="foswikiAttachments">
| *I* | *%MAKETEXT{"Attachment"}%* | *%MAKETEXT{"Action"}%* | *%MAKETEXT{"Size"}%* | *%MAKETEXT{"Date"}%* | *%MAKETEXT{"Who"}%* | *%MAKETEXT{"Comment"}%* |
| %ICON{"home.org.au.png" default="else"}%<span class="foswikiHidden">png</span> | <a href="%ATTACHURLPATH%/%ENCODE{home.org.au.png}%"><noautolink>home.org.au.png</noautolink></a> | <a href='%SCRIPTURLPATH{"attach" topic="%WEB%.%TOPIC%" filename="home.org.au.png" revInfo="1"}%' title="%MAKETEXT{"change, update, previous revisions, move, delete..."}%" rel="nofollow">%MAKETEXT{"manage"}%</a> | 4 K|<span class="foswikiNoBreak">31 May 2007 - 21:58</span> |TemporaryTopicUserMappingContribTestsUsersWeb.JoeDoe | |
</div>
THIS
}
elsif ( $this->check_dependency('Foswiki,>=,1.2') ) {
$output = <<'THIS';
%TMPL:P{"settmltablesummary"
SUMMARY="%MAKETEXT{"Attachments"}%"
Expand Down
6 changes: 3 additions & 3 deletions core/data/Main/AdminUserLeftBar.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1421599902" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="AdminUser"}%
%ADDTOZONE{
"head"
Expand All @@ -16,7 +16,7 @@ Customise this topic; samples and ideas available at
%SYSTEMWEB%.WebLeftBarCookbook.
--> *My links:*
* [[%USERSWEB%.AdminUser][My home page]]
* [[%SCRIPTURL{search}%/%BASEWEB%/%HOMETOPIC%?search=AdminUser;type=word;scope=text;reverse=on;casesensitive=on;order=modified;limit=50;zeroresults=on][AdminUser %BASEWEB% activities]]
* [[%SCRIPTURLPATH{"search" topic="%BASEWEB%.WebSearch" search="AdminUser" type="word" scope="text" reverse="on" casesensitive="on" order="modified" limit="50" zeroresults="on"}%][AdminUser %BASEWEB% activities]]
* [[%LOGOUTURL%][Logout]]
<a class="foswikiSmallish" href="%SCRIPTURLPATH{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%">edit</a>
<a class='foswikiSmallish' href='%SCRIPTURLPATH{"edit" topic="%WEB%.%TOPIC%" t="%GMTIME{"$epoch"}%"}%'>edit</a>

4 changes: 2 additions & 2 deletions core/data/Main/WikiGroups.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1300572565" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%
---+ Wiki groups dashboard
Showing all known groups that can be used to define [[%SYSTEMWEB%.AccessControl][access controls]] in <nop>%WIKITOOLNAME%.
Expand All @@ -20,7 +20,7 @@ With this enabled, adding and removing members and also topic upgrades for each
}%

<sticky>
<form action="%SCRIPTURLPATH{"manage"}%/%WEB%/%TOPIC%" method="post">
<form action='%SCRIPTURLPATH{"manage" topic="%WEB%.%TOPIC%"}%' method='post'>
<input type="hidden" name="action" value="addUserToGroup"/>
<input type="hidden" name="create" value="1"/>
<div class="foswikiFormSteps">
Expand Down
6 changes: 3 additions & 3 deletions core/data/System/AccessControl.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1457197356" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="UserDocumentationCategory"}%
%STARTINCLUDE%
---+ Access Control
Expand Down Expand Up @@ -304,7 +304,7 @@ If needed, you can further restrict access to selected webs with ALLOWWEBVIEW an
---++++ When using Template Login

[[UserAuthentication#TemplateLogin][User authentication with TemplateLogin]] is enabled on your site. To require login for *all* scripts:
* Add all scripts in the =foswiki/bin= directory (except for =login=, =logon=) to the list of ={AuthScripts}= in [[%SCRIPTURL{"configure"}%][configure]], =Security And Authentication= tab, =Login= sub-tab, For a default Foswiki installation:
* Add all scripts in the =foswiki/bin= directory (except for =jsonrpc=, =login= and =logon=) to the list of ={AuthScripts}= in [[%SCRIPTURLPATH{"configure"}%][configure]], =Security And Authentication= tab, =Login= sub-tab, For a default Foswiki installation:

* Default (open) site:
<verbatim>
Expand Down Expand Up @@ -350,7 +350,7 @@ Use the following setup is used to "lock down" the Wiki to logged in users, whil
---+++ Control access to topic History and Raw text.

Foswiki 2.0 now restricts the guest user from access to topic history and raw topic text. This is configurable. See:
[[%SCRIPTURLPATH{configure}][configure]] =Security and Authentication > Access Control > {FeatureAccess}{AllowRaw}= and ={FeatureAccess}{AllowHistory}= (They are expert level settings, so the "Show expert options" button in the lower left corner must be pressed.)
[[%SCRIPTURLPATH{"configure"}][configure]] =Security and Authentication > Access Control > {FeatureAccess}{AllowRaw}= and ={FeatureAccess}{AllowHistory}= (They are expert level settings, so the "Show expert options" button in the lower left corner must be pressed.)

Each of these setting has 3 choices:
* =authenticated= - This is the default. Anyone who is logged in has access
Expand Down
4 changes: 2 additions & 2 deletions core/data/System/AppendixCascadingStyleSheets.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1437331638" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="DeveloperDocumentationCategory"}%
%STARTINCLUDE%
---+ Appendix C: CSS
Expand Down Expand Up @@ -214,7 +214,7 @@ Markers to invoke behaviour with unobtrusive !JavaScript.
#TestFoswikiFocus
---++++ Troubleshooting foswikiFocus
* Test for loading error of focus plugin (no message means ok): %JQREQUIRE{"focus"}%
* [[%SCRIPTURL{view}%/%WEB%/%TOPIC%?testfocus=1#TestFoswikiFocus][Test foswikiFocus]]
* [[%SCRIPTURLPATH{"view" topic="%WEB%.%TOPIC%" testfocus="1"}%#TestFoswikiFocus][Test foswikiFocus]]

%IF{"$'URLPARAM{testfocus}'='1'" then="
$percntJQREQUIRE{$quotfocus$quot}$percnt
Expand Down
12 changes: 7 additions & 5 deletions core/data/System/CommandAndCGIScripts.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1484612966" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="DeveloperDocumentationCategory"}%
%STARTINCLUDE%
---+ CGI and Command Line Scripts
Expand Down Expand Up @@ -162,7 +162,7 @@ __New topic creation %ICON{"wip"}%:__
The string AUTOINC followed by one or more digits anywhere in the topic name will be converted to a number such that the resulting topic name is unique in the target web. However this doesn't happen until the topic is saved.

When a new topic is created using edit, the topic isn't actually created until the edit is saved. The content of the new topic is initialised according to the parameters you pass.
* =templatetopic= - defines the full name (web.topic) of a topic to use as a template for the new topic. The template topic is copied and, unless =notemplateexpansion= is set, the following macros are expanded in the topic text: =URLPARAM=, =DATE=, =SERVERTIME=, =GMTIME=, =USERNAME=, =WIKINAME=, =WIKIUSERNAME=, =USERINFO=. (see %SYSTEMWEB%.TopicTemplates)
* =templatetopic= - defines the full name (web.topic) of a topic to use as a template for the new topic. The template topic is copied and, unless =notemplateexpansion= is set, the following macros are expanded in the topic text: =URLPARAM=, =DATE=, =SERVERTIME=, =GMTIME=, =USERNAME=, =WIKINAME=, =WIKIUSERNAME=, =USERINFO=. (see %SYSTEMWEB%.TemplateTopics)
* =text= - use this as the text of the topic. Macros are *not* expanded in this text. Overrides any text set in the =templatetopic=.
* =formtemplate= - Overrides any form set in the =templatetopic=.
* =notemplateexpansion= - given by =templatetopic=. Use this when you want a verbatim copy of a topic.
Expand Down Expand Up @@ -544,7 +544,7 @@ Form field values are passed in parameters named 'field' - for example, if I hav
*%X% Note:* The =save= script can only be called via HTTP POST method. Make sure you specify =method="post"= if you call the =save= script via a form action. Example:

<verbatim class="html">
<form name="new" action="%SCRIPTURLPATH{save}%/Sandbox/" method="post">
<form name='new' action='%SCRIPTURLPATH{"save" topic="%SANDBOXWEB%.SomeTopic"}%' method='post'>
...
</form>
</verbatim>
Expand Down Expand Up @@ -624,7 +624,7 @@ Used for viewing topics.
| =rev= | Revision to view (e.g. =rev=45=) | _latest_ |
| =SEARCH&lt;hex number&gt;= | Identifies a result set that is being paged through | |
| =section= | Allows to view only a part of the topic delimited by a named section (see %SYSTEMWEB%.VarSTARTSECTION). If the given section is not present, no topic content is displayed. | |
| =template= | Allows you to specify a different skin template, overriding the 'view' template the view script would normally use. The default template is =view=. For example, you could specify [[%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=edit][%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=edit]]. This is mainly useful when you have specialised templates for a Wiki Application. | |
| =template= | Allows you to specify a different skin template, overriding the 'view' template the view script would normally use. The default template is =view=. For example, you could specify [[%SCRIPTURLPATH{"view" topic="%WEB%.%TOPIC%" template="edit"}%][%SCRIPTURLPATH{"view" topic="%WEB%.%TOPIC%" template="edit"}%]]. This is mainly useful when you have specialised templates for a Wiki Application. | |
| _&lt;any name&gt;_ | It can be expanded in the topic text during rendering and referenced in IF statements - See the %SYSTEMWEB%.VarURLPARAM macro and %SYSTEMWEB%.IfStatements | |

<div class="foswikiHelp">
Expand All @@ -636,10 +636,12 @@ Used for viewing attachments. Normally, a site will publish the attachments (=pu

| *Parameter* | *Description* | *Default* |
| =filename= | name of attachment | _required_ |
| =topic= | Name of the Web.Topc | _optional_ |
| =rev= | Revision to view | _latest_ |

Instead of using the =filename= parameter, you can append the attachment name
to the end of the URL path (after the topic) e.g. =%SCRIPTURL{viewfile}%/Webname/TopicName/Attachment.gif=
to the end of the URL path (after the topic) e.g. =%SCRIPTURL{viewfile}%/Webname/TopicName/Attachment.gif=. However, when writing a link to an attachment
it's recommended to use the fully canonical form: =%<nop>SCRIPTURLPATH{"viewfile" topic="Webname.Topicname" filename="Attachment.gif"}%.

---++ Tool Scripts
Details on command line scripts located in the =tools= directory.
Expand Down
4 changes: 2 additions & 2 deletions core/data/System/CompleteDocumentation.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1488593563" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
---+!! Reference Manual (%WIKIVERSION%)

This page contains all documentation topics as one long, complete reference sheet.
Expand All @@ -8,7 +8,7 @@ This page contains all documentation topics as one long, complete reference shee
%BUTTON{
"%MAKETEXT{"Load content"}%"
icon="book"
onclick="window.location.href='%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?section=content';"
onclick="window.location.href='%SCRIPTURLPATH{\"view\" topic=\"%WEB%.%TOPIC%\" section=\"content\"}%';"
}% %MAKETEXT{"Use this button to load the content.%BR% *Caution* the content is very large and loading it will put a high load on your browser. Only load the content if you are going to print it - otherwise use the [[ReferenceManual][online reference manual]]."}%

<verbatim class="foswikiHidden">
Expand Down
39 changes: 21 additions & 18 deletions core/data/System/DataForms.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1478801122" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="UserDocumentationCategory"}%
%STARTINCLUDE%
---+!! Data Forms
Expand Down Expand Up @@ -357,7 +357,7 @@ Initial values can then be provided in the URLs or as form values.

For example:
<verbatim>
%SCRIPTURL{edit}%/%WEB%/KnowledgeTopicAUTOINC00001?formtemplate=MyForm;Subject=FAQWhatIsWikiWiki;Category=One;Category=Two;action=form
%SCRIPTURL{"edit" topic="%WEB%.KnowledgeTopicAUTOINC00001" formtemplate="MyForm" Subject="FAQWhatIsWikiWiki" Category="One" Category="Two" action="form"}%
</verbatim>

* =XxxYyyAUTOINC00001=: creates a new auto-numbered topic name with base "XxxYyy" - see [[%SYSTEMWEB%.TemplateTopics#AutomaticallyGeneratedTopicname][automatically generate unique topic names]]
Expand All @@ -371,25 +371,28 @@ If you want to create+save a topic instead of bringing up the edit screen, you m

The same parameters as above can be set in HTML (hidden) form fields:
<verbatim class='tml'>
<form name="newtopic" action="%SCRIPTURLPATH{"save"}%/Sandbox/" method="post">
<input type="hidden" name="formtemplate" value="SimpleForm" />
<input type="hidden" name="topic" value="KnowledgeTopicAUTOINC00001" />
<input type="hidden" name="Subject" value="FAQWhatIsWikiWiki" />
<input type="hidden" name="Category" value="One" />
<input type="hidden" name="Category" value="Two" />
<input type="submit" class="foswikiSubmit" value="Create topic" />
<form name='newtopic' action='%SCRIPTURLPATH{"save" web="%SANDBOXWEB%"}%' method='post'>
<input type='hidden' name='formtemplate' value='SimpleForm' />
<input type='hidden' name='topic' value='KnowledgeTopicAUTOINC00001' />
<input type='hidden' name='Subject' value='FAQWhatIsWikiWiki' />
<input type='hidden' name='Category' value='One' />
<input type='hidden' name='Category' value='Two' />
<input type='submit' class='foswikiSubmit' value='Create topic' />
</form>
</verbatim>

Creates:
<form name="newtopic" action="%SCRIPTURLPATH{"save"}%/Sandbox/" method="post">
<input type="hidden" name="formtemplate" value="SimpleForm" />
<input type="hidden" name="topic" value="KnowledgeTopicAUTOINC00001" />
<input type="hidden" name="Subject" value="FAQWhatIsWikiWiki" />
<input type="hidden" name="Category" value="One" />
<input type="hidden" name="Category" value="Two" />
<input type="submit" class="foswikiSubmit" value="Create topic" />
</form>
%IF{"istopic '%SANDBOXWEB%.SimpleForm'" then="
<form name='newtopic' action='%SCRIPTURLPATH{"save" web="%SANDBOXWEB%"}%' method='post'>
<input type='hidden' name='formtemplate' value='SimpleForm' />
<input type='hidden' name='topic' value='KnowledgeTopicAUTOINC00001' />
<input type='hidden' name='Subject' value='FAQWhatIsWikiWiki' />
<input type='hidden' name='Category' value='One' />
<input type='hidden' name='Category' value='Two' />
<input type='submit' class='foswikiSubmit' value='Create topic' />
</form>
" else="This demo is not functional because %SANDBOXWEB%.SimpleForm does not exist. Create a simple data form
with the fields Subject and Category. Return here, and a Create button will be shown."}%

For an overview of web form parameters, see [[%SYSTEMWEB%.CommandAndCGIScripts][CGI and Command Line Scripts]].


Expand Down
14 changes: 7 additions & 7 deletions core/data/System/DefaultPreferences.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1457496285" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICPARENT{name="AdminToolsCategory"}%
---+!! <nop>%WIKITOOLNAME% Site-Level Preferences

Expand Down Expand Up @@ -132,7 +132,7 @@ been removed from Foswiki 2.0.

* Image, URL and alternate tooltip text of the logo *for this installation*: you should change these settings for your site, or they can be overwridden in <nop>%WEBPREFSTOPIC% for individual webs by defining these settings there.
* Set WIKILOGOIMG = %PUBURL%/%SYSTEMWEB%/ProjectLogos/foswiki-logo.png
* Set WIKILOGOURL = %SCRIPTURL{"view"}%/%USERSWEB%/%HOMETOPIC%
* Set WIKILOGOURL = %SCRIPTURL{"view" topic="%USERSWEB%.%HOMETOPIC%"}%
* Set WIKILOGOALT = Powered by Foswiki, The Free and Open Source Wiki

* Home page of this site
Expand Down Expand Up @@ -177,7 +177,7 @@ been removed from Foswiki 2.0.

* URL for current topic
* Shortcut TOPICURL -- absolute URL for the current topic
* Set TOPICURL = %SCRIPTURL{"view"}%/%BASEWEB%/%BASETOPIC%
* Set TOPICURL = %SCRIPTURL{"view" topic="%BASEWEB%.%BASETOPIC%"}%

#RegistrationOptions
---+++ Registration configuration options
Expand Down Expand Up @@ -211,7 +211,7 @@ Note, this feature also must be enabled on the UserRegistration page by adding

* ==http-equiv== meta tags for ==view==, ==rdiff==, ==attach==, ==search*== scripts:
* #Set HTTP_EQUIV_ON_VIEW =
* Set HTTP_EQUIV_ON_VIEW = <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="%SCRIPTURLPATH{"view"}%/%WEB%/WebRss" />
* Set HTTP_EQUIV_ON_VIEW = <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="%SCRIPTURLPATH{"view" topic="%WEB%.WebRss"}%" />

* ==http-equiv== meta tags for ==edit== script:
* Set HTTP_EQUIV_ON_EDIT =
Expand Down Expand Up @@ -285,7 +285,7 @@ Note, this feature also must be enabled on the UserRegistration page by adding

---+++ Legacy support
* Support for legacy "EDITTOPIC", used to be hard-coded, now replaced by TMPL:P conditional instantiation
* Set EDITURL = %SCRIPTURLPATH{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%
* Set EDITURL = %SCRIPTURLPATH{"edit" topic="%WEB%.%TOPIC%" t="%GMTIME{"$epoch"}%"}%
* Set EDITTOPIC = <a href="%EDITURL%" title="Edit Topic - deprecated usage - please see release notes">Edit</a>
* Support for MAINWEB which is often used in older legacy webs that have been upgraded to Foswiki
* Set MAINWEB = %USERSWEB%
Expand Down Expand Up @@ -405,7 +405,7 @@ Note, this feature also must be enabled on the UserRegistration page by adding
* Format of a NewWikiWord link:
* Note that =$text= is the topic link text, =$topic= is the name of the new topic, and =$web= is the name of the web for the new topic. Values for the 3 are taken from the link syntax =[<nop>[$web.$topic][$text]]=. For normal plain !WikiWord links =$text= and =$topic= are the same. The value of =$web= is the current web unless the link is in the format =$web.$topic=.
* Default setting:
* Set NEWLINKFORMAT = <a class="foswikiNewLink" href="%SCRIPTURLPATH{"edit"}%/$web/$topic?topicparent=%ENCODE{"%WEB%.%TOPIC%"}%" rel="nofollow" title="%MAKETEXT{"Create this topic"}%">$text</a>
* Set NEWLINKFORMAT = <a class="foswikiNewLink" href="%SCRIPTURLPATH{"edit" topic="$web.$topic" topicparent="%WEB%.%TOPIC%"}%" rel="nofollow" title="%MAKETEXT{"Create this topic"}%">$text</a>

* %SYSTEMWEB%.PreviewBackground image:
* Set PREVIEWBGIMAGE = %PUBURLPATH%/%SYSTEMWEB%/PreviewBackground/preview2bg.gif
Expand All @@ -416,7 +416,7 @@ Note, this feature also must be enabled on the UserRegistration page by adding
* Show extra help for !ApacheLogin users for %USERSWEB%.AdminUser login
* Set ADMINLOGIN = %IF{"{LoginManager} = 'Foswiki::LoginManager::ApacheLogin' AND NOT context authenticated"
then="Foswiki is configured using <nop>ApacheLogin, please [[%LOGINURL%][login]] as a normal user first. Then the Admin Login will replace this text"
else="[[%SCRIPTURL{login}%/%BASEWEB%/%BASETOPIC%?sudo=sudo][internal admin login]] (use the password set in [[%SCRIPTURLPATH{"configure"}%][configure]])."}%
else="[[%SCRIPTURLPATH{"login" topic="%BASEWEB%.%BASETOPIC%" sudo="sudo"}%][internal admin login]] (use the password set in [[%SCRIPTURLPATH{"configure"}%][configure]])."}%

* Formatting of revision comparison: =sequential=, =sidebyside= or =debug=
* Set DIFFRENDERSTYLE = sequential
Expand Down
Loading

0 comments on commit 5d2a11f

Please sign in to comment.