This question about Topic Markup Language and applications: Answered

Slash in tmpl include

There is a problem using skin templates in topics in nested webs.

TMPL:INCLUDE{"Applications/WebApp.TopicView"} gets mangled by the regex{filenameInvalidCharRegex} in Template.pm line 387:
387    $name =~ s/$Foswiki::regex{filenameInvalidCharRegex}//g;

Before line 387 name = Applications/WebApp.TopicView
After line 387 name = ApplicationsWebApp.TopicView

The slash (/) is stripped. The work around is to use a dot (.) instead of a slash to separate the webs.

Question Is this intended behaviour?

Detail

The System.SkinTemplates documentation states:
"Also the qualification needs to be given in the form Web/SubWeb.TopicTemplate as in the example; Web/SubWeb/TopicTemplate does not work."

In fact, this construct does not work. It should be: " ... needs to be given in the form Web.SubWeb.TopicTemplate ..."

I have not found a statement specific to TMPL:INCLUDE.

Checking Foswiki.pm line 584 compiles the regex as:
     $regex{filenameInvalidCharRegex} = qr/$Foswiki::cfg{AttachmentNameFilter}/o;

And my default configuration has AttachmentNameFilter as
[\\*?~^$@%`"'&|<>/\[\]#\x00-\x1f]
. The documentation states that this is a filter-out regex, removing the slash (/) and not the full stop (.).

This makes sense for Attachmants, because they are files, not directories.

But is there a reason why there is an inconsistency in the reference to sub-webs?

If so, the documentation should be updated.

If not, can the filenameInvalidCharRegex allow the slash (/)?

Or should there be an entirely separate regex for template directives?

Kind regards,

-- BramVanOosterhout - 12 Aug 2020

The slash is not supposed to work. Actually I never use it at all.

-- MichaelDaum - 12 Aug 2020

OK. In that case the documentation (SkinTemplates) needs to be updated. Here is a patch:
diff --git a/core/data/System/SkinTemplates.txt b/core/data/System/SkinTemplates.txt
index 3e5335557..6b481e904 100644
--- a/core/data/System/SkinTemplates.txt
+++ b/core/data/System/SkinTemplates.txt
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="ProjectContributor" comment="" date="1506603718" format="1.1" version="1"}%
+%META:TOPICINFO{author="BaseUserMapping_333" comment="" date="1597293348" format="1.1" reprev="3" version="3"}%
 %META:TOPICPARENT{name="Skins"}%
 
 ---+ Skin Templates
@@ -238,6 +238,8 @@ For example, let's say we are viewing a topic in web =Sandbox= and are sear
 
 When a skin name or template name is used to build a topic name, the first character is automatically capitalised.
 
+When a !SubWeb is used, the $web reference  must be qualified with a dot (.), not slash (/). For instance: If SANDBOXWEB above is a !SubWeb, then the reference must be SANDBOXWEB= Sandbox.SubWeb. =Sandbox/SubWeb= does not work.
+
 The _skin path_ is set as described in [[Skins]].
 
 #TemplatePreferences
@@ -253,9 +255,9 @@ then the indicated templates will be chosen for =view= and =edit= respectively.
 
 Note that the topic name specified as a template may need to be fully qualified with Web and !SubWeb. E.g.
 
-   * Set VIEW_TEMPLATE = Web/SubWeb.SpecificViewTemplate
+   * Set VIEW_TEMPLATE = Web.SubWeb.SpecificViewTemplate
 
-Also the qualification needs to be given in the form !Web/SubWeb.TopicTemplate as in the example; !Web/SubWeb/TopicTemplate does not work. +Also the qualification needs to be given in the form !Web.SubWeb.TopicTemplate as in the example; !Web/SubWeb.TopicTemplate or !Web/SubWeb/TopicTemplate does not work. #TemplateSecurity ---+++ Security and usability

-- BramVanOosterhout - 13 Aug 2020

Awesome! Feel free to check it in to git. Thanks.

Btw do you have checkin rights? You should though I can't fid you on github. What's your user profile there?

-- MichaelDaum - 13 Aug 2020

On github I am BramVan-Oosterhout

I don't believe I have checkin rights on github.

If I work out how to do it, do I need to create a task and push?

-- BramVanOosterhout - 14 Aug 2020

Welcome on board (again) big grin . You've got write access to the foswiki repos now which means you can clone them directly and check in your changes right away. No need to fork and create pull requests.

The basic workflow goes like this:

  1. create an issue in the Tasks web describing what you are working on; mark it being-worked-on and the name of the person working on it in the related fields
  2. clone the related git if you haven't already
  3. check in your changes with a checkin message refering back to the task item you create: first line starts with "ItemXXX: short summary" and presumably more infos as you like; this makes sure the webhooks of github will add an entry to the Task web automatically listing the changeset there
  4. create as many checkins on the task item as you need to finish the piece of work
  5. either close the task or - if it is a core change - mark it waiting-for-release

More info can be found at DevelopersBible.

-- MichaelDaum - 14 Aug 2020

OK, I created a task: Item14930 and I pushed it.

It is now at: https://github.com/foswiki/distro/commit/58f39f9ed8b965950686409d295f7c8760dc3b07

Do I need to do anything more?

Hmm, looking at what is on github I should have done
TOPICINFO metadata is set to author="ProjectContributor" and version="1"
by editing the SkinTemplates.txt file directy?

-- BramVanOosterhout - 29 Aug 2020
 

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version Foswiki 2.1.6
Status Answered
Related Topics
Topic revision: r7 - 29 Aug 2020, BramVanOosterhout
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