create new tag
, view all tags

Proposed: Used Conditional text to speed up Pattern Skin

To speed up PatternSkin, you could set the USERLAYOUTURL and USERSTYLEURL to an empty value in TWikiPreferences and output the @imports conditionally. There are two imports, and they are very slow, also if a user has no customized CSS. This is because three topics are fetched instead of one: The actual page and two CSS. (If not set in user home page, the @import url("../Codev/?skin=text&contenttype=text/css"); points to a topic)

One simple solution is to use the SpreadSheetPlugin to output the @import text conditionally. The CALCs are very speedy. The only drawback is that there will be some gibberish text in the HTML header if the Plugin is disabled.

See Sandbox.TestConditionalOutput for an actual example.

Actual code for twiki/templates/twiki.pattern.tmpl:

%CALC{$IF($EXACT(%USERLAYOUTURL%,),<nop>,@import url("%USERLAYOUTURL%");)}%
%CALC{$IF($EXACT(%USERSTYLEURL%,),<nop>,@import url("%USERSTYLEURL%");)}%

The <nop> trick makes the whole line go away if the setting is empty.

-- PeterThoeny - 03 Sep 2004

an aternative is to add a conditional syntax into the templating system. or to move to useing a real templating system.

-- SvenDowideit - 04 Sep 2004

Couldn't you just create an empty.css file with nothing in it that would get cached and set the variables to point to in by default in TWikiPreferences?

-- SamHasler - 04 Sep 2004

I have another use for either a conditional or a local variable. Some wish to have the breadcrumb at the top, others at the bottom of the page. I wouldn't want to retrieve the total breadcrumb text twice - this is an expensive operation. So I could either

  • store the retrieved text in a variable and put that text in 2 divs, one at the top and one at the bottom, and hide one by css (is this possible using the SpreadSheetPlugin?)
    • Could the parent finding code be changed to find all variables in a template and then only do the searching once? -- SamHasler - 05 Sep 2004
  • use a conditional to either display it at the top or the bottom - this is more complex because yet another variable should be set by the user
  • a templating system?

-- ArthurClemens - 04 Sep 2004

Immediate actions I recommend:

  • As Sam suggests, change TWiki.org's Pattern Skin to use an empty.css file and point to it in the TWikiPreferences (an alternative is to use the conditional CALC, which is probably slightly faster since no extra file needs to be fetched)
    • This will speed up TWiki.org considerably
  • Create a patch with this and list it in KnownIssuesOfTWiki01Sep2004
    • This will speed up installations using the PatternSkin

We can look into improving the templating system. If we accept the SpreadSheetPlugin as a default we could simply use it for conditional code.

In regards to breadcrumb, simply %CALC{$SET(breadcrumb, ...)}% variable on top, then conditionaly show it on top or bottom based on a pref setting, e.g. %CALC{$IF($EXACT(%BREADCRUMBLOCATION%,top),$GET(breadcrumb),<nop>)}%

A word on sidebar usability:

At my workplace we have a skin in our own branding that has a conditional sidebar. Free form collaboration works best if there is no sidebar (less issues with wide images, tables and preformatted text), more official content works best if there is a sidebar (more content above the fold). So, in the same web we have have a mix of pages that have a sidebar and pages that don't. Webs that are mainly used for documentation have the sidebar enabled by default; it can be switched off for special pages that need more horizontal space. Webs that are mainly used for collaboration have the sidebar turned off by default; it can be enabled for pages where needed.

Technically, we set a SIDEBAR pref setting pointing to the sidebar topic. Collaboration webs have an empty SIDEBAR setting in the WebPreferences. Each pages that needs a sidebar has a * Set SIDEBAR = MyTeamSidebar page setting. The skin uses the CALC to show or not show the sidebar based on the setting. Since it is a pref setting it is fairly speedy.

-- PeterThoeny - 04 Sep 2004

I you have no sidebar, wouldn't you prefer to use the full width of the page? Some When using PatternSkin also some css settings would also need to change to reclaim the space. See PatternSkinCustomization.

-- ArthurClemens - 04 Sep 2004

I've added PatternSkin/empty.css to TWiki.TWikiPreferences.

I am also testing the SpreadSheet solution, but this doesn't change the output as I always get a value from USERLAYOUTURL, in my case ../Sandbox/?skin=text&contenttype=text/css.

-- ArthurClemens - 04 Sep 2004

This happened because of the other Set TWIKILAYOUTURL etc. settings in TWikiPreferences. If I remove them, I now get @import url("%USERLAYOUTURL%"); as a result.

-- ArthurClemens - 05 Sep 2004

TopicClassification FeatureRequest
TopicSummary Add conditional output of imports in pattern skin
CurrentState UnderInvestigation
OutstandingIssues There is no point in assigning this to a release until it has a CoreTeam priority and someone is working on it.

InterestedParties PeterThoeny


Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2005-02-15 - SamHasler
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.