source: main/trunk/ibisph-view/src/main/webapp/xslt/html/HTMLContentPage.xslt @ 22751

Last change on this file since 22751 was 22751, checked in by GarthBraithwaite_STG, 6 months ago

view - fixed topic IP list button. Added default StaticContent? to html class for html_content pages.

File size: 14.5 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet version="3.0" 
4        xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" 
5        xmlns:ibis="http://www.ibisph.org"
6
7        exclude-result-prefixes="ibis"
8>
9        <xsl:import href="Page.xslt"/>
10        <xsl:import href="SiteSpecific.xslt"/>
11
12
13        <ibis:doc>
14                <name>html/HTMLContentPage</name>
15                <summary>Core templates that handle the 'HTML_CONTENT' XML elements to
16                        produce an IBIS-PH HTML page.
17                </summary>
18                <description>
19                        Base XSLT that provides the templates to transform 'HTML_CONTENT' type
20                        XML content to IBISPH-View HTML pages.  This template and the 'HTML_CONTENT'
21                        XML data files form a simple mechanism to help keep all static type pages
22                        more easily maintained and consistent.  This framework provides the
23                        advantages of server side includes (SSI) while providing some extra
24                        value like being able to reference resources using a relative path.
25
26                        URL NOTE: This template contains a special way to handle IBIS type URLs.
27                        Instead of hard coding the link to include the application context and
28                        path, a relative type path can be used with an "ibis:" namespace.  This
29                        causes the web app context prefix to be added to the resource path so
30                        that the path is free of context deployment paths.  If the link is within
31                        the same 'folder' (as defined in with the resource mapping), then the
32                        'ibis:' is not needed.  However, if it is NOT, then it should be used.
33                        An example is the 'about/content_usage.html' page referencing a graphic
34                        image 'image/OH.gif'.  If the link is coded using relative addressing
35                        and the system is deployed to the webapp context of 'ibisph-view' then
36                        this link will not work because the server will look for the image with
37                        a path of: 'ibisph-view/about/image/DOH.gif'.  To work, the link would
38                        have to be coded as '/ibisph-view/image/DOH.gif' but what happens if this
39                        save system is deployed as the root application.  Then the link would
40                        have to be coded as '/image/DOH.gif' etc.  The processing of the link
41                        by this template automatically adds the appropriate webapp content prefix
42                        so that the resources can be relatively addressed.  Of couse if a relative
43                        address is really wanted then simply skip placing the 'ibis:' namespace
44                        prefix to the link's attribute.
45                </description>
46        </ibis:doc>
47
48
49        <!-- ~~~~~~~~~~~~~~~~~~~~~~~ PARAMS / VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~ -->
50        <xsl:param name="Page.pageTitle" select="HTML_CONTENT/TITLE"
51                ibis:doc="HTML API template implementation that provides the HTML page's title text."
52        />
53        <xsl:param name="Page.metaDescription" select="HTML_CONTENT/DESCRIPTION"
54                ibis:doc="HTML API template implementation that provides the HTML page's 'description' meta tag text.  Defaults to the 'HTML_CONTENT/DESCRIPTION' element."
55        />
56        <xsl:param name="Page.metaKeywords" select="HTML_CONTENT/KEYWORDS"
57                ibis:doc="HTML API template implementation that provides the HTML page's 'keyword' meta tag text.  Defaults to the 'HTML_CONTENT/KEYWORDS' element."
58        />
59        <xsl:param name="Page.htmlClass" 
60                select="if(0 != string-length(HTML_CONTENT/HTML_CLASS)) then HTML_CONTENT/HTML_CLASS else 'StaticContent'"
61                ibis:doc="ability to specify the main html css class."
62        />
63
64
65        <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
66        <xsl:template name="Page.specificHeadContent" 
67                ibis:doc="HTML API template implementation that provides the ability to specify other HTML HEAD tag content.  Defaults to the 'HTML_CONTENT/OTHER_HEAD_CONTENT' element.">
68                <xsl:apply-templates select="HTML_CONTENT/OTHER_HEAD_CONTENT" mode="ibis.copyOnlyChildren"/>
69        </xsl:template>
70
71
72
73        <xsl:template name="Page.contentBody" ibis:doc="HTML API template implementation
74                that provides main HTML body content for the page.  Defaults to copying
75                all elements and attributes of the the 'HTML_CONTENT/CONTENT' element."
76        >
77                <!-- used an apply templates so that the ibis: elements are processed -->
78                <xsl:apply-templates select="HTML_CONTENT/CONTENT" mode="ibis.copyOnlyChildren"/>
79        </xsl:template>
80
81
82        <xsl:template match="ibis:ContentBlock" mode="ibis.copy"
83                ibis:doc="Provides ability to more easily embed a fixed content block   
84                        into the page's content.
85                "
86        >
87                <xsl:call-template name="ContentContainer.contentBlock">
88                        <xsl:with-param name="containerID" select="if(0 != string-length(@id)) then @id else NAME"/>
89                        <xsl:with-param name="contentContainerClass" select="@contentContainerClass"/>
90                        <xsl:with-param name="additionalClasses"     select="@additionalClasses"/>
91                        <xsl:with-param name="title"       select="TITLE"/>
92                        <xsl:with-param name="headingLevel"  select="if(exists(@headingLevel)) then @headingLevel else 3"/>     
93                        <xsl:with-param name="description" select="DESCRIPTION"/>
94                        <xsl:with-param name="help"        select="HELP"/>
95                        <xsl:with-param name="content">
96                                <xsl:apply-templates select="CONTENT" mode="ibis.copyOnlyChildren"/>
97                        </xsl:with-param>
98                </xsl:call-template>
99        </xsl:template>
100
101
102
103        <xsl:template match="ibis:ExpandableContent" mode="ibis.copy"
104                ibis:doc="Provides ability to more easily embed an expandable content block
105                        into the page's content.  Note that the approp CSS will need to be included.
106                        The control and container require an 'id' attribute.  This ID uses the
107                        optional NAME sub element.  If NAME doesn't exist then postion() is used. 
108                        This will create unique ID's in most cases.  The CONTENT text() and
109                        sub elements will be ibis:copied into the assoc content container DIV.
110
111                        Dropdown content are is just as easily coded directly in the CONTENT
112                        so no template call/special processing is implemented as it just gets
113                        in the way.
114                "
115        >
116                <xsl:call-template name="ContentContainer.expandable">
117                        <xsl:with-param name="controlID"   select="@id"/>
118                        <xsl:with-param name="controlType" select="@controlType"/>
119                        <xsl:with-param name="additionalClasses" select="@additionalClasses"/>
120                        <xsl:with-param name="controlName" select="
121                                if(not(@controlName)) then NAME
122                                else @controlName
123                        "/>
124                        <xsl:with-param name="title"        select="TITLE"/>
125                        <xsl:with-param name="headingLevel" select="if(exists(@headingLevel)) then @headingLevel else 2"/>     
126                        <xsl:with-param name="description"  select="DESCRIPTION"/>
127                        <xsl:with-param name="help"         select="HELP"/>
128                        <xsl:with-param name="content">
129                                <xsl:apply-templates select="CONTENT" mode="ibis.copyOnlyChildren"/>
130                        </xsl:with-param>
131                        <xsl:with-param name="show"         select="exists(SHOW) or (string-length(@show) != 0)"/>
132                </xsl:call-template>
133        </xsl:template>
134
135
136
137        <xsl:template match="ibis:SelectionsList" mode="ibis.copy"
138                ibis:doc="Provides ability to more easily create a list structure based
139                        on the standard SELECTIONS/SELECTION structure.  The controlType and
140                        class controls indentured/expandable behavior.  Note that the approp
141                        CSS will need to be included.  This code handles sub ibis:includes
142                        so that a MENU structure can be included.  If the container element
143                        does NOT have a direct child element named SELECTIONS then the optional
144                        SELECTIONS_CONTAINER_ELEMENT_NAME can be used.  If the INCLUDE_SUB_LISTS
145                        element is present then the list will be processed for sub lists.
146                "
147        >
148                <!-- variable is needed to process any ibis:include statements -->
149                <xsl:param name="applyTemplatesContent">
150                        <xsl:apply-templates select="*" mode="ibis.copy"/>
151                </xsl:param>
152                <xsl:param name="selections"
153                        select="
154                                if(exists(SELECTIONS_CONTAINER_ELEMENT_NAME))
155                                        then $applyTemplatesContent//*[name()=$applyTemplatesContent/SELECTIONS_CONTAINER_ELEMENT_NAME]/*
156                                        else $applyTemplatesContent
157                        "
158                />
159
160                <xsl:call-template name="SelectionsList.processSelections">
161                        <xsl:with-param name="containerID"    select="@id"/>
162                        <xsl:with-param name="containerClass" select="concat('Selections ', @additionalClasses)"/>
163                        <xsl:with-param name="controlType"    select="@controlType"/>
164<!--
165                        <xsl:with-param name="headingLevel"   select="@headingLevel"/>
166-->
167                        <xsl:with-param name="showSelectionsTitle" select="true()"/>
168                        <xsl:with-param name="headingLevel"   select="if(0 != string-length(@headingLevel)) then @headingLevel else 0"/>
169                        <xsl:with-param name="selections"     select="$selections"/>
170                </xsl:call-template>
171        </xsl:template>
172
173
174
175        <xsl:template match="ibis:ContiditionalSection" mode="ibis.copy"
176                ibis:doc="Provides ability include/exclude certain sections of HTML
177                        CONTENT.  For this to work, an overriden callback type template
178                        is used.  This template is passed the section's ID.  The template
179                        must then determine if the section should be included.  The template
180                        determines this by XML, the passed in ID, and any other parameters
181                        that have been passed into the transformer process. 
182
183                        For working examples see repository for the user related XSLT and
184                        HTML_CONTENT ~May 2013.
185                "
186        >
187                <xsl:param name="test">
188                        <xsl:call-template name="HTMLContent.includeConditionalSection">
189                                <xsl:with-param name="sectionID" select="@id"/>
190                        </xsl:call-template>
191                </xsl:param>
192
193                <xsl:if test="ibis:isFirstLetter_T_or_Y_or_X($test)">
194                        <xsl:apply-templates select="(text() | *)" mode="ibis.copy"/>
195                </xsl:if>
196        </xsl:template>
197
198
199
200        <xsl:template name="HTMLContent.includeConditionalSection"
201                ibis:doc="Callback type template that controls if the section should be
202                        processed.  If the template returns 'T', 'X', or 'Y' then that
203                        content will be included.  If nothing or 'F', 'N' then that cotent
204                        will be omitted.  Default is to omit everything.  Sub XSLTs must
205                        override this template and determine if the content should be shown
206                        based on the XML, params passed in, and the section's ID attribute.
207                "
208        >
209                <xsl:param name="sectionID"/>
210        </xsl:template>
211
212
213        <xsl:template match="ibis:help" mode="ibis.copy"
214                ibis:doc="Provides a help button/popup.  1/2021 tried moving this to the
215                        help/include xslt.  Had to implement as a ibis:help element to more
216                        easily pick it up.  Doing so then keeps the ibis namespace which
217                        causes other issues even if matching and creating a new element name.
218                        If the ibis namespace is excluded then other ibis elements are
219                        skipped (like include and app prefix etc.).  As such decided to keep
220                        the processing clean and deal with specific elements CONTENT and
221                        HELP (which also has an optional CONTENT element to process).
222                "
223        >
224                <xsl:call-template name="Help.content">
225                        <xsl:with-param name="help" select="."/>
226                </xsl:call-template>
227        </xsl:template>
228
229
230        <xsl:template match="ibis:baseRequestPath" mode="ibis.copy"
231                ibis:doc="Provides access to the base req path for things like js ajax reqs."
232        ><xsl:value-of select="$ibis.baseRequestPath"/></xsl:template>
233
234
235        <xsl:template match="ibis:Popup" mode="#all">
236                <div id="{@id}" class="Popup {@additionalClasses}"> 
237                        <xsl:call-template name="SelectionsList.inputControl">
238                                <xsl:with-param name="inputID"    select="@controlID"/>
239                                <xsl:with-param name="inputName"  select="@controlName"/>
240                                <xsl:with-param name="inputType"  select="@controlType"/>
241                                <xsl:with-param name="labelClass" select="@controlClass"/>
242                                <xsl:with-param name="title"      select="@controlTitle"/>
243                                <xsl:with-param name="show"       select="'true' = @show"/>
244                                <xsl:with-param name="toggleRadioOnClick" select="'radio' = @controlType"/>
245                                <xsl:with-param name="headingLevel" select="@headingLevel"/>
246                                <xsl:with-param name="description" select="@description"/>
247                        </xsl:call-template>
248<!--
249                        <input id="{$controlName}" type="checkbox" checked="checked"
250                                name="{$controlName}" class="Control"
251                        />
252                        <label for="{$controlName}" title="Show/hide alerts"
253                                class="FontIcon" font-icon="{$fontIcon} &#xe403;"
254                        />
255                       
256                        id="{@containerID}"
257-->
258                        <div class="Container">
259                                <div class="Content">
260                                        <xsl:apply-templates select="* | text()" mode="ibis.copy"/>
261                                </div>
262                        </div>
263                </div>
264        </xsl:template>
265
266
267        <xsl:template match="ibis:SelectionsToJSONArray" mode="#all">
268
269                <xsl:variable name="selections">
270                        <xsl:apply-templates select="*" mode="ibis.copy"/>
271                </xsl:variable>
272
273                <script>
274var <xsl:value-of select="@variableName"/> = [
275                <xsl:for-each select="$selections//SELECTION[not(SELECTIONS)]">
276                        <xsl:sort select="TITLE"/>
277                        <xsl:if test="1 != position()">,</xsl:if>
278{
279        "name":            "<xsl:value-of select="if(0 != string-length(NAME)) then NAME else position()"/>"
280        ,"title":      "<xsl:value-of select="TITLE"/>"
281        ,"href" :      "<xsl:value-of select="ibis:getRequestURL(LOCAL_URL)"/>"
282        ,"group":      "<xsl:value-of select="substring(TITLE,1,1)"/>"
283}
284                </xsl:for-each>
285];
286                </script>
287        </xsl:template>
288
289<!--
290GARTH TODO: saxon 10.x has support for XSLT xpath evaluate
291        <xsl:template match="ibis:xsltParamContent" mode="ibis.copy"
292                ibis:doc="Provides access to XSLT param content."
293        ><xsl:value-of select="@content"/></xsl:template>
294       
295       
296                <script type="text/javascript" ibis:src="js/leaflet-src.js"/>
297                <script type="text/javascript" ibis:src="js/geostats.js"/>
298                <script type="text/javascript" ibis:src="js/jquery.leaflet.js"/>
299
300                <script type="text/javascript" ibis:src="js/L.GeoJSON.Interactive.js"/>
301                <script type="text/javascript" ibis:src="js/L.GeoJSON.Interactive.Choropleth.js"/>
302                <script type="text/javascript" ibis:src="js/L.LayerSets.js"/>
303                <script type="text/javascript" ibis:src="js/L.Control.LayerSets.js"/>
304                <script type="text/javascript" ibis:src="js/L.Control.Choropleth.js"/>
305                <script type="text/javascript" ibis:src="js/L.Control.Zoom.Min.js"/>
306                <script type="text/javascript" ibis:src="js/L.Map.ContextMenu.js"/>
307
308       
309                        $.ajax({
310                                type: "GET"
311                                ,url: "/nmibis-view/query/definition/contentblocks/covid/COVIDRateCounty.html?DataVizContainerIDPrefix=sq1003"
312//                              ,url: "/nm/query/definition/contentblocks/covid/COVIDRateCounty.html?DataVizContainerIDPrefix=sq1003"
313                                ,timeout: 1000*60*20    // in milli secs.
314                                ,success:
315                                        function(data)
316                                        {
317                                                $("#sq1003_script").html(  $(data).filter("#dataVizJavascript").html()  );
318                                                $("#sq1003_dataSources").html(  $(data).filter("#dataSources").html()  );
319                                                $("#sq1003_datasetModifiedDate").html(  $(data).filter("#datasetModifiedDate").html()  );
320                                        }
321                                ,error:
322                                        function(jqXHR, status, errorThrown)
323                                        {
324                                                console.warn("IBIS-PH Covid Ajax Query Request Error: " + status);
325                                                console.warn(errorThrown);
326                                                $("#sq1003_map").html("Sorry, content not available (" + status + ").");
327                                        }
328                        });
329       
330       
331-->
332</xsl:stylesheet>
333<!-- ============================= End of File ============================= -->
334
Note: See TracBrowser for help on using the repository browser.