You are here: Foswiki>Tasks Web>Item14225 (20 Jan 2017, GeorgeClark)Edit Attach

Item14225: EXPORTEDPREFERENCES has not kept up with changes to FOSWIKI.pm

pencil
Priority: Low
Current State: Confirmed
Released In: 2.2.0
Target Release: minor
Applies To: Engine
Component: Documentation, JQueryPlugin
Branches: Item14225
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
The setting for EXPORTEDPREFERENCES in DefaultPreferences does not match what is actually in the inline script tag.

  • ATTACHMENTNAMEFILTER is missing
  • URLHOST is missing
  • SCRIPTURLPATHS is missing.

This might make it confusing for a plugin that uses EXPORTEDPREFERENCES as the authority for extending the list (as documented).

The %URLHOST% doesn't have equivalent Wiki variable. The documented way to get the hostname is to use the ENV variable HTTP_HOST (foswiki.org) however in a proxy environment, that will most likely be incorrect. URLHOST however is taken from the configuration and would be accurate.

The NAMEFILTER and ATTACHMENTNAMEFILTER are initialized in the JQueryPlugin/FOSWIKI.pm. They should probably be added to Foswiki.pm too. (NAMEFILTER is also initialized in DefaultPreferences, using a %QUERY macro against the configuration.)

We need a comment in JQueryPlugin/FOSWIKI.pm stating that this module be kept in sync with the EXPORTEDPREFERENCES default setting.

Suggested fix:
  • Add missing settings from DefaultPreferences EXPORTEDPREFERENCES
  • Update FOSWIKI.pm to add an exception in processing SCRIPTURLPATHS.
  • Add ATTACHMENTNAMEFILTER, NAMEFILTER and URLHOST to Foswiki.pm default macros.
  • Remove the initialization from DefaultPreferences.

Conditional initializations in JQueryPlugin/FOSWIKI.pm need to be retained for backwards compatibility.

-- GeorgeClark - 19 Nov 2016

URLHOST and SCRIPTURLPATHS are always there. They don't need to be listed in EXPORTEDPREFERENCES. They are required for the foswiki.getScriptUrl() javascript api to work correctly. Any plugin that want's to propagate additional - maybe non-standard - preferences from perl to javascript should do this:

%ADDTOZONE{
   "script" 
   id="MyPluginSettins" 
   text="<script class='foswikiPreferences' type='text/json'>
      \"MyPluginSettings\": {
         \"foo\": \"bar\",
         \"baz\": \"%MAKRO{...}%\"
      }
      </script>"
}%

And then access it in javascript using the foswiki.getPreference() api.

var val = foswiki.getPreference("MyPluginSettings").foo;

SCRIPTURLPATHS should not be used directly. Instead use foswiki.getScriptUrl(script, web, topic, params), foswiki.getrScriptUrlPath(script, web, topic, params).

-- MichaelDaum - 22 Nov 2016

Marking this for 2.2, and for now leaving it in the item branch, unmerged.

-- GeorgeClark - 05 Dec 2016
 
Topic revision: r5 - 20 Jan 2017, GeorgeClark
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