r2 - 11 Apr 2007 - 09:46:19 - DickFurnasYou are here: TWiki >  Sandbox Web > EarnTips

LEarn Tips and how they work

Figure out how Tips of the Day works as model for grabbing problems for a random problem set.

Table of Contents

Tip of Day snippet from TWikiTipsOfTheDayInclude:

tip TWiki Tip of the Day
File attachments
One can attach files to any topic. The action of attaching a file to a topic is similar to attaching ... Read on Read more

Two tips at once, longer summary:

  • Two tips at once: second copy of
  • Longer summary: s/100/500/g

tip TWiki Tip of the Day
TWiki Skins
Skins overlay regular templates with alternate header/footer layouts. You can use Skins to change the look of a TWiki topic, for example, the layout of the header and footer. Rendered text between header and footer does not change. You can also use Skins to define an alternate view, like a view optimized for printing. To see the installed TWikiSkins, see TWikiSkinBrowser. See More Tips... TWiki:Main.PaulineCheung 30 Jan 2005 Read on Read more

tip TWiki Tip of the Day
TWiki Skins
Skins overlay regular templates with alternate header/footer layouts. You can use Skins to change the look of a TWiki topic, for example, the layout of the header and footer. Rendered text between header and footer does not change. You can also use Skins to define an alternate view, like a view optimized for printing. To see the installed TWikiSkins, see TWikiSkinBrowser. See More Tips... TWiki:Main.PaulineCheung 30 Jan 2005 Read on Read more

Parse the guts:

  • The original code:

<div class="tipsOfTheDay"><div class="tipsOfTheDayContents">
<strong class="tipsOfTheDayHeader">%ICON{tip}% TWiki Tip of the Day</strong>
<div class="tipsOfTheDayText">%CALC{$SET(webtopic, $LISTRAND(%SEARCH{ "^TWiki[Custom]*Tip[0-9A-Z]" web="%TWIKIWEB%, %MAINWEB%" topic="TWiki*Tip*" scope="topic" type="regex" casesensitive="on" nosearch="on" nototal="on" separator=", " format="$web.$topic" noheader="on" }%))$SET(pos, $FIND(., $GET(webtopic)))$SET(web, $REPLACE($GET(webtopic), $GET(pos), 100))$SET(topic, $REPLACE($GET(webtopic), 1, $GET(pos)))}%
%CALC{$NOP(%)SEARCH{ \"^$GET(topic)$\" web=\"$GET(web)\" scope="topic" regex="on" nosearch=\"on\" noheader=\"on\" nototal=\"on\" limit=\"1\" format=\"<span class=\\"tipsOfTheDayTitle\\">[[%SCRIPTURL{view}%/$web/$topic][$pattern(.*?\-\-\-\+([^\n\r]+).*)]]</span><br /> $summary(100, noheader) [[%SCRIPTURL{view}%/$web/$topic][%MAKETEXT{"Read on"}% <img src=\\"%ICONURL{more-small}%\\" alt=\\"Read more\\" title=\\"Read on\\" width=\\"13\\" height=\\"13\\" border=\\"0\\" />]]\"}$NOP(%)}%
</div>
</div>
</div>

  • Indented for comprehension.
    • Does not function with all the spaces shown here for parsing.


<div class="tipsOfTheDay">

<div class="tipsOfTheDayContents">
<strong class="tipsOfTheDayHeader">%ICON{tip}% TWiki Tip of the Day</strong>

<div class="tipsOfTheDayText">
%CALC{
    $SET(webtopic, 
        $LISTRAND(
            %SEARCH{ "^TWiki[Custom]*Tip[0-9A-Z]"
                web="%TWIKIWEB%, %MAINWEB%"
                topic="TWiki*Tip*" 
                scope="topic" 
                type="regex" 
                casesensitive="on" 
                nosearch="on" 
                nototal="on" 
                separator=", " 
                format="$web.$topic" 
                noheader="on" 
            }%
        )
    )
    $SET(pos,$FIND(.,$GET(webtopic)))
    $SET(web, $REPLACE($GET(webtopic), $GET(pos), 500))
    $SET(topic, $REPLACE($GET(webtopic), 1, $GET(pos)))
}%

%CALC{
    $NOP(%)SEARCH{ \"^$GET(topic)$\" 
        web=\"$GET(web)\" 
        scope="topic" 
        regex="on" 
        nosearch=\"on\" 
        noheader=\"on\" 
        nototal=\"on\" 
        limit=\"1\" 
        format=\"<span class=\\"tipsOfTheDayTitle\\">
            [[%SCRIPTURL{view}%/$web/$topic][$pattern(.*?\-\-\-\+([^\n\r]+).*)]]
            </span>
            <br />
            $summary(500, noheader) 
            [[%SCRIPTURL{view}%/$web/$topic][%MAKETEXT{"Read on"}% <img src=\\"%ICONURL{more-small}%\\" alt=\\"Read more\\" title=\\"Read on\\" width=\\"13\\" height=\\"13\\" border=\\"0\\" />]]
         \"}
    $NOP(%)}
%
</div>
</div>
</div>

-- DickFurnas - 10 Apr 2007

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions

tip TWiki Tip of the Day
Raw Text link
At the bottom of the page next to Edit and Attach , there is a Raw Text link that allows one to ... Read on Read more

 
Cornell Math Department
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback