Changeset 8289


Ignore:
Timestamp:
07/24/10 08:11:38 (22 months ago)
Author:
CrawfordCurrie
Message:

Item9317: added a bunch more doc on how to use head and body zones, and corrected the sense of the doc describing OptimizePageLayout - it doesn't optimise when set, it de-optimises when not set, and that's an important difference.

Location:
trunk/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/data/System/CommandAndCGIScripts.txt

    r7932 r8289  
    255255| =attachment= | Attachment to move | =none= | 
    256256| =currentwebonly= | if defined, searches current web only for links to this topic | | 
    257 | =newattachment= | (Optional) new name for attachment | =none= | 
     257| =newattachment= | New name for attachment | =attachment=, if given | 
    258258| =newtopic= | new topic name | | 
    259259| =newweb= | new web name | | 
  • trunk/core/data/System/JavascriptFiles.txt

    r7989 r8289  
    66user experience is significantly improved if it is enabled. 
    77 
    8 Foswiki Javascript support comprises a number of base Javascript files, 
     8Foswiki Javascript support includes a number of base Javascript files, 
    99attached to this topic, that provide support for features in the basic screens, 
    1010and are used by most skins. These files are automatically included as required 
     
    1515user interface components. 
    1616 
    17 *Related Topics:* SkinTemplates, [[Skins]] 
     17You can use Javascript in the body of topics, but you are highly recommended 
     18to use the [[VarADDTOZONE][%<nop>ADDTOZONE{"body" ...}%]] macro if you do so. 
     19Bear in mind that inline Javascript represents a significant security risk to 
     20Foswiki sites, and sites vulnerable to hackers should seriously consider 
     21installing the =SafeWikiPlugin= to control it. 
     22 
     23*Related Topics:* SkinTemplates, [[Skins]], [[VarADDTOZONE][ADDTOZONE]] 
    1824<!-- 
    1925   * Set ALLOWTOPICCHANGE = %USERSWEB%.AdminGroup 
  • trunk/core/data/System/VarADDTOZONE.txt

    r8211 r8289  
    1111</verbatim> 
    1212 
    13 _Zones_ are specific places in the output HTML that are marked in the source templates using the [[VarRENDERZONE][RENDERZONE]] macro. Zones are used to collect various materials together, such as Javascript and CSS, that must be included in the output HTML in a specific order, and in a specific place. By default, skins define two zones, =head= and =body= which are in the HEAD tag and at the end of the BODY tag respectively. 
     13_Zones_ are specific places in the output HTML that are marked in the source templates using the [[VarRENDERZONE][RENDERZONE]] macro. Zones are used to collect various materials together, such as Javascript and CSS, that must be included in the output HTML in a specific order, and in a specific place. Each =ADDTOZONE= call can be identified by a _unique identifier_, and you can state dependencies on other identifiers. In this way you can constrain the order in which they are expanded in the output. 
    1414 
    15 Each =ADDTOZONE= call can be identified by a _unique identifier_, and you can state dependencies on other identifiers. In this way you can constraint the order in which the text added by each call is expanded in the output. 
     15There are always at least two zones, =head= and =body= - see [[#HeadAndBody][below]] for more information on how to use these standard zones. You can create as many additional zones as you like. Interesting use cases in wiki applications: 
     16   * create a =sidebar= zone to add widgets 
     17   * create a =toolbar= zone to add buttons icons 
    1618 
    1719Parameters: 
     
    2628     STOPINCLUDE 
    2729 
    28 Note that using =topic= and =section= is actually a short form of  
     30Using =topic= and =section= is actually a short form of  
    2931<verbatim class="tml"> 
    3032%ADDTOZONE{ 
     
    3436</verbatim> 
    3537 
     38#HeadAndBody 
     39*How to use the =head= and =body= zones* 
     40 
     41Notionally the =head= and =body= zones correspond to the end of the HTML =&lt;HEAD&gt; tag and the end of the BODY tag respectively. Normally you should add CSS (and other HTML =&lt;HEAD&gt; content, such as =meta=) to the =head= zone, and Javascript to the =body= zone. There is a setting in =configure=, ={OptimizePageLayout}=, that controls what happens next. First, dependencies between the individual =ADDTOZONE= statements are resolved *within each zone*. Then, if ={OptimizePageLayout}= is enabled, the =head= content is added to the =&lt;HEAD&gt;, and the =body= content is added to the BODY. However, if ={OptimizePageLayout}= is _disabled_ (the default), both the =head= and =body= zones will be added to the HTML =&lt;HEAD&gt;. 
     42 
     43For this reason you must be careful to: 
     44   1 Only add HTML to the body zone _that is also legal in the =&lt;HEAD&gt;_ 
     45   1 Ensure that no =head= content (and no inline Javascript) depends on =body= content. Any such dependency will be _silently ignored_. 
     46   1 Make sure that all inline JavaScript code in the topic (if it is allowed) 
     47     is added to the page using 
     48     =%<nop>ADDTOZONE{"body"...requires="library-tag"}%= 
     49     with the appropriate library-tag to guarantee a correct load order. 
     50 
    3651See also [[VarRENDERZONE][RENDERZONE]] 
  • trunk/core/data/System/VarRENDERZONE.txt

    r8211 r8289  
    2525required in the templates. 
    2626 
    27 Note that you can create as many zones as you like. You are not restricted 
    28 to just =body= and =head=. Interesting use cases in wiki applications: 
    29  
    30    * create a =sidebar= zone to add widgets 
    31    * create a =toolbar= zone to add buttons icons 
    32  
    33 See also [[VarADDTOZONE][ADDTOZONE]] 
     27See also [[VarADDTOZONE][ADDTOZONE]] for more information on zones. 
  • trunk/core/lib/Foswiki.spec

    r8198 r8289  
    565565# Used to disallow the use of SCRIPT and LITERAL tags in topics by removing 
    566566# them from the body of topics during rendering. 
    567 # <font color="red">This setting is now DEPRECATED</font> - use SafeWikiPlugin 
    568 # instead. 
     567# <font color="red">This setting is fundamentally unsafe and is now 
     568# DEPRECATED</font> - use SafeWikiPlugin instead. 
    569569$Foswiki::cfg{AllowInlineScript} = $TRUE; 
    570570 
     
    10661066#---++ HTML Page Layout 
    10671067# **BOOLEAN EXPERT** 
    1068 # Enable heuristics to optimize the HTML layout by placing all JavaScript files 
    1069 # at the bottom of the page, while leaving all CSS files at the top. Note, that 
    1070 # you will need to load JavaScript files using <code>%ADDTOZONE{"body" ...}%</code> 
    1071 # for content that should participate in this optimization step. Similarly, all 
    1072 # CSS files should be added to the page using <code>%ADDTOZONE{"head" ...}%</code>. 
    1073 # Note also, that placing JavaScript library files at the bottom of the page, JavaScript 
    1074 # code within the topic content area might potentially break when it relys on those libraries 
    1075 # being loaded before. So please make sure all JavaScript code is added to the page 
    1076 # using <code>%ADDTOZONE{"body"...requires="library-tag"}%</code> with the appropriate library tag 
    1077 # to guarantee a correct linear order of the files being loaded by the browser. 
     1068# If this option is disabled then Foswiki will move all 
     1069# <code>%ADDTOZONE{"body"...}%</code> statements to the end of the 
     1070# HTML &lt;HEAD&gt; tag (immediately after the content added by 
     1071# <code>%ADDTOZONE{"head"...}%</code>). If the option is enabled, then 
     1072# <code>%ADDTOZONE{"body"...}%</code> statements are added to the end of 
     1073# the &lt;BODY&gt; tag instead. This optimises the performance of browsers. 
     1074# <strong>Warning</strong> enabling the optimisation might 
     1075# <u>break</u> topics if Javascript code within the topic content has 
     1076# a dependency on other code being loaded in the body zone. See 
     1077# System.VarADDTOZONE for more information. There may also 
     1078# be problems with plugins which post-process body content, such as 
     1079# SafeWikiPlugin.  
    10781080$Foswiki::cfg{OptimizePageLayout} = $FALSE; 
    10791081 
Note: See TracChangeset for help on using the changeset viewer.