Item13218: PUBURLPATH macro needs to support topic="web.topic"

pencil
Priority: Enhancement
Current State: Closed
Released In: 1.2.0
Target Release: minor
Applies To: Engine
Component: FoswikiStore, PUBURLPATH
Branches: master
Reported By: GeorgeClark
Waiting For:
Last Change By: CrawfordCurrie
Trying to modify the InstantEnhancements document and ran into troubles using the new format of PUBURLPATH.

The example "DOWN" macro uses concatenation for attachment. I was trying to change references to SitePreferences to the %LOCALSITEPREFS% macro, which expands to Web.Topic. Because the macro already includes the web name, it can't easily be passed to the PUBURLPATH as it is currently implemented.

-   * Set DOWN = <img src="%PUBURL%/%USERSWEB%/SitePreferences/my_image.gif" border="0" alt="DOWN" width="16" height="16" />
+   * Set DOWN = <img src="%PUBURLPATH{topic="%LOCALSITEPREFS%" attachment="my_image.gif"}%" border="0" alt="DOWN" width="16" height="16" />

It was generating src="/bin/../pub?topic=Usersweb.SitePreferences;attachment=my_image.gif"

The following change corrects the issue, but since it changes the documented behaviour it's really an enhancement.

diff --git a/core/lib/Foswiki/Store.pm b/core/lib/Foswiki/Store.pm
index 664ac98..902bb2b 100644
--- a/core/lib/Foswiki/Store.pm
+++ b/core/lib/Foswiki/Store.pm
@@ -203,6 +203,12 @@ sub getAttachmentURL {
     my $url = $Foswiki::cfg{PubUrlPath} || '';
     my @params;
 
+    if ( $options{topic} ) {
+        ( $options{web}, $options{topic} ) =
+          Foswiki::Func::normalizeWebTopicName( $options{web},
+            $options{topic} );
+    }
+
     if ( $options{web} ) {
         $url .= '/' . Foswiki::urlEncode( $options{web} );
         delete $options{web};
-- GeorgeClark - 18 Jan 2015

(LOCALSITEPREFS Can't be used in concatenation mode either, since it expands to web.topic, so the URL becomes "/pub/Main.SitePreferences/my_image.gif"

-- GeorgeClark - 18 Jan 2015

No, it's a bugfix. My fault.

-- CrawfordCurrie - 20 Jan 2015

 

ItemTemplate edit

Summary PUBURLPATH macro needs to support topic="web.topic"
ReportedBy GeorgeClark
Codebase
SVN Range
AppliesTo Engine
Component FoswikiStore, PUBURLPATH
Priority Enhancement
CurrentState Closed
WaitingFor
Checkins distro:c634ad1032cd
TargetRelease minor
ReleasedIn 1.2.0
CheckinsOnBranches master
trunkCheckins
masterCheckins distro:c634ad1032cd
ItemBranchCheckins
Release01x01Checkins
Topic revision: r4 - 21 Jan 2015, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy