Graph Magic Includes

Here is the place that the deep magic occurs. The includable page sections (ie, INCLUDEs) below make the actual TWiki pages featureful, yet keep them short and tidy. Some of the INCLUDEs, for example:

  • pick up local information from the including page, go off and search for pages in the same view, then come back and present the results with a disclosure triangle, link, and descriptive text

  • package up a set of TWiki markup for a particular type of page.

Vicki Brown did all the heavy lifting here, but Rich Morin also wrote and/or tweaked a few things, kibitzed, etc.

These INCLUDEs are used by individual edge, node, or view pages.

Nodes of a View (nodes_of_view)

Screenshot:

nodes_of_view.jpg

Description:

Used in all View pages (V_ prefix); for examples, see ViewIndex.

For each name in a view's Node Names form field:
  1. Convert from node name to TWiki topic (look up the page that describes that node)
  2. Set variable MYPAGE to that topic (for convenience)
  3. Show a link to that page, using the page title as the link text
  4. Set a twisty
    • twisty follows the link
    • "exec summary" of node topic is used as Twisty "suffix"
    • precis info from the page goes inside the Twisty (indented)

Code:

%STARTSECTION{"nodes_of_view"}%
%FOREACH{"name" in="%FORMFIELD{"NodeNames" topic="%INCLUDINGTOPIC%"}%"}%

<!-- A couple of the following lines won't work when folded. We tried.  -->
   $percntCALC{ $SET(MYPAGE, $percntSEARCH{"META:FIELD.*NodeNames.*value=.$name\"" topic="N_*" type="regex" nonoise="on" format="$topic" }% ) }%

$percntIFDEFINEDTHEN{"$percntCALC{$GET(MYPAGE)}%"}% 

    [[$percntCALC{$GET(MYPAGE)}%]
*~~  [$percntFORMFIELD{"NodeTitle" topic="$percntCALC{$GET(MYPAGE)}%" }% ]] 
    $percntTWISTY{
       showlink=" "
       hidelink=" "
       suffix="&nbsp;&nbsp; $percntFORMFIELD{"NodeSummary" topic="$percntCALC{$GET(MYPAGE)}%" }% "
       showimgright="%ICONURLPATH{toggleopen-small}%"
       hideimgright="%ICONURLPATH{toggleclose-small}%"
    }% 
    <ul>
    <p>
    $percntFORMFIELD{"NodePrecis" topic="$percntCALC{$GET(MYPAGE)}%"}% 
    </ul> $percntENDTWISTY%

$percntELSEDEFINED% 
  %RED% Egad! %ENDCOLOR% No pages match `$name'. (This can't be good.)
$percntFIDEFINED%

%NEXT{"name"}%
%ENDSECTION{"nodes_of_view"}%

Test Code

%FOREACH{"name" in="%FORMFIELD{"NodeNames" topic="%INCLUDINGTOPIC%"}%"}%
   $percntSEARCH{"META:FIELD.*NodeNames.*value=.$name\"" topic="N_*" type="regex" format="$topic $n $n" }%
%NEXT{"name"}%

Views of an Edge (views_of_edge)

Screenshot:

views_of_edge.png

Description:

Used in all Edge pages (E_ prefix); for examples, see EdgeIndex.

For each name in an edge's View Names form field:
  1. Convert from view name to TWiki topic (look up the page that describes that view)
  2. Set variable MYPAGE to that topic (for convenience)
  3. Show a link to that page, using the page title as the link text
  4. Set a twisty
    • twisty follows the link
    • "exec summary" of view topic is used as Twisty "suffix"
    • precis info from the page goes inside the Twisty (indented)

Code:

%STARTSECTION{"views_of_edge"}%
%FOREACH{"name" in="%FORMFIELD{"ViewNames" topic="%INCLUDINGTOPIC%"}%"}%

<!-- A couple of the following lines won't work when folded. We tried.  -->
   $percntCALC{ $SET(MYPAGE, $percntSEARCH{"META:FIELD.*ViewName.*value=.$name\"" topic="V_*" type="regex" nonoise="on" format="$topic" }% ) }%

$percntIFDEFINEDTHEN{"$percntCALC{$GET(MYPAGE)}%"}% 
 
    [[$percntCALC{$GET(MYPAGE)}%]
*~~  [$percntFORMFIELD{"ViewTitle" topic="$percntCALC{$GET(MYPAGE)}%" }% ]] 
    $percntTWISTY{
       showlink=" "
       hidelink=" "
       suffix="&nbsp;&nbsp; $percntFORMFIELD{"ViewSummary" topic="$percntCALC{$GET(MYPAGE)}%" }% "
       showimgright="%ICONURLPATH{toggleopen-small}%"
       hideimgright="%ICONURLPATH{toggleclose-small}%"
    }% 
    <ul>
    <p>
    $percntFORMFIELD{"ViewPrecis" topic="$percntCALC{$GET(MYPAGE)}%"}% 
    </ul> $percntENDTWISTY%

$percntELSEDEFINED% 
  %RED% Egad! %ENDCOLOR% No pages match `$name'. (This can't be good.)
$percntFIDEFINED%

%NEXT{"name"}%
%ENDSECTION{"views_of_edge"}%

Views of a Node (views_of_node)

Screenshot:

views_of_node.jpg

Description:

Used in all Node pages (N_ prefix); for examples, see NodeIndex.

  1. Search across all View pages (V_ prefix)
  2. If page lists this Node in its NodeNames form field,
    print the result as
    • link to topic, using the View title as the link text
    • Precis (inside Twisty)
    • list of all nodes in this view (inside Twisty)

Wish List:
  • Link Node Names in "Includes" section to their pages. Foreach??

Code:

Below, don't break the FORMFIELD{"NodeNames"... line and don't escape the quotes.

To Do: Consider turning the second SEARCH into a FOREACH across RESULTS

%STARTSECTION{"views_of_node"}%

   %CALC{ $SET(RESULTS, %SEARCH{"META:FIELD.*name=.NodeNames.*value=.*%FORMFIELD{"NodeNames" topic="%INCLUDINGTOPIC%"}%" topic="V_*" type="regex" nonoise="on" separator=", " format="$topic" }% ) }%

%IFDEFINEDTHEN{"%CALC{$GET(RESULTS)}%"}% 

%~~ SEARCH{
~~~ search="
*~~   META:FIELD.*name=.NodeNames.*value=.*%FORMFIELD{"NodeNames" topic="%INCLUDINGTOPIC%"}%
*~~ "
~~~ topic="V_.*" type="regex" zeroresults="on" nosearch="on"  nototal="off"
~~~ order="formfield(ViewTitle)"
~~~ format="
~~~ [[$topic][$formfield(ViewTitle)]] $n
~~~ $percntTWISTY{
~~~     showlink=\" \"
~~~     hidelink=\" \"
~~~     suffix=\"&nbsp;&nbsp;$formfield(ViewSummary)\"
~~~     showimgright=\"%ICONURLPATH{toggleopen-small}%\" 
~~~     hideimgright=\"%ICONURLPATH{toggleclose-small}%\"
~~~     start=\"hide\"
~~~  }$percnt $n 
~~~ <ul>
~~~   <p>$formfield(ViewPrecis)
~~~   <p><b>Includes:</b>
~~~   <ul>
~~~     $percntFORMFIELD{\"NodeNames\" topic=\"$topic\"}$percnt
~~~   </ul>
~~~ </ul> $n 
~~~ $percntENDTWISTY$percnt
~~~ $n $n
~~~ "
~~~ }%

%ELSEDEFINED% 
  %RED% Egad! %ENDCOLOR% No pages match `%FORMFIELD{"NodeNames" topic="%INCLUDINGTOPIC%"}%'. (This can't be good.)
%FIDEFINED%

%ENDSECTION{"views_of_node"}%

List Things (of a particular type) that are present in a Web

These INCLUDEs are used by index pages (eg, EdgeIndex, NodeIndex, ViewIndex).

All Edges in a Web (edges_of_web)

Screenshot:

edges_of_web.png

Description:

Used in the EdgeIndex page. For each Edge page, generate a table row.

Code:

%STARTSECTION{"edges_of_web"}%
%~~ SEARCH{"META:FORM{name=\"EdgeForm"  excludetopic="*Template, *Form"
~~~ noheader="on" nosearch="on"
~~~ order="formfield(EdgeTitle)"
~~~ format="|
~~~ [[$topic][$formfield(EdgeTitle)]] |
~~~ $formfield(EdgeSummary) |
~~~ "
~~~ }%
%ENDSECTION{"edges_of_web"}%

All Nodes in a Web (nodes_of_web)

Screenshot:

nodes_of_web.png

Description:

Used in the NodeIndex page. For each Node page, generate a table row.

Code:

%STARTSECTION{"nodes_of_web"}%
%~~ SEARCH{"META:FORM{name=\"NodeForm"  excludetopic="*Template, *Form"
~~~ noheader="on" nosearch="on"
~~~ order="formfield(NodeTitle)"
~~~ format="|
~~~ [[$topic][$formfield(NodeTitle)]] |
~~~ $formfield(NodeSummary) |
~~~ "
~~~ }%
%ENDSECTION{"nodes_of_web"}%

All Views in a Web (views_of_web)

Screenshot:

views_of_web.png

Description:

Used in the ViewIndex page. For each View page, generate a table row.

Code:

%STARTSECTION{"views_of_web"}%
%~~ SEARCH{"META:FORM{name=\"ViewForm"  excludetopic="*Template, *Form"
~~~ noheader="on" nosearch="on"
~~~ order="formfield(ViewTitle)"
~~~ format="|
~~~ [[$topic][$formfield(ViewTitle)]] |
~~~ $formfield(ViewSummary) |
~~~ "
~~~ }%
%ENDSECTION{"views_of_web"}%

Helpers for pages

Edge Page Header (edge_page_hdr)

Description:

Generate header boilerplate for an Edge page.

Code:

%STARTSECTION{"edge_page_hdr"}%
<noautolink>

---+!!  %FORMFIELD{"EdgeTitle" topic="%INCLUDINGTOPIC%"}%
 
%TOC{depth="3"}%

<b>%FORMFIELD{"EdgeSummary" topic="%INCLUDINGTOPIC%"}%</b>

%FORMFIELD{"EdgePrecis" topic="%INCLUDINGTOPIC%"}%
%ENDSECTION{"edge_page_hdr"}%

Node Page Header (node_page_hdr)

Description:

Generate header boilerplate for a Node page.

Code:

%STARTSECTION{"node_page_hdr"}%
<noautolink>

---+!!  %FORMFIELD{"NodeTitle" topic="%INCLUDINGTOPIC%"}%
 
%TOC{depth="3"}%

<b>%FORMFIELD{"NodeSummary" topic="%INCLUDINGTOPIC%"}%</b>

%FORMFIELD{"NodePrecis" topic="%INCLUDINGTOPIC%"}%
%ENDSECTION{"node_page_hdr"}%

View Page Header (view_page_hdr)

Description:

Generate header boilerplate for a View page.

Code:

%STARTSECTION{"view_page_hdr"}%
<noautolink>

---+!!  %FORMFIELD{"ViewTitle" topic="%INCLUDINGTOPIC%"}%
 
%TOC{depth="3"}%

<b>%FORMFIELD{"ViewSummary" topic="%INCLUDINGTOPIC%"}%</b>

%FORMFIELD{"ViewPrecis" topic="%INCLUDINGTOPIC%"}%
%ENDSECTION{"view_page_hdr"}%


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r22 - 11 Aug 2008, VickiBrown
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email