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

Last change on this file since 22703 was 22703, checked in by GarthBraithwaite_STG, 10 months ago

view - removed the "RENAME" type jars as these should be implemented and fully documented according to each specific adopter's enviro/install. Minor popup tweaks.

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" select="HTML_CONTENT/HTML_CLASS"
60                ibis:doc="ability to specify the main html css class."
61        />
62
63
64        <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
65        <xsl:template name="Page.specificHeadContent" 
66                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.">
67                <xsl:apply-templates select="HTML_CONTENT/OTHER_HEAD_CONTENT" mode="ibis.copyOnlyChildren"/>
68        </xsl:template>
69
70
71
72        <xsl:template name="Page.contentBody" ibis:doc="HTML API template implementation
73                that provides main HTML body content for the page.  Defaults to copying
74                all elements and attributes of the the 'HTML_CONTENT/CONTENT' element."
75        >
76                <!-- used an apply templates so that the ibis: elements are processed -->
77                <xsl:apply-templates select="HTML_CONTENT/CONTENT" mode="ibis.copyOnlyChildren"/>
78        </xsl:template>
79
80
81        <xsl:template match="ibis:ContentBlock" mode="ibis.copy"
82                ibis:doc="Provides ability to more easily embed a fixed content block   
83                        into the page's content.
84                "
85        >
86                <xsl:call-template name="ContentContainer.contentBlock">
87                        <xsl:with-param name="containerID" select="if(0 != string-length(@id)) then @id else NAME"/>
88                        <xsl:with-param name="contentContainerClass" select="@contentContainerClass"/>
89                        <xsl:with-param name="additionalClasses"     select="@additionalClasses"/>
90                        <xsl:with-param name="title"       select="TITLE"/>
91                        <xsl:with-param name="headingLevel"  select="if(exists(@headingLevel)) then @headingLevel else 3"/>     
92                        <xsl:with-param name="description" select="DESCRIPTION"/>
93                        <xsl:with-param name="help"        select="HELP"/>
94                        <xsl:with-param name="content">
95                                <xsl:apply-templates select="CONTENT" mode="ibis.copyOnlyChildren"/>
96                        </xsl:with-param>
97                </xsl:call-template>
98        </xsl:template>
99
100
101
102        <xsl:template match="ibis:ExpandableContent" mode="ibis.copy"
103                ibis:doc="Provides ability to more easily embed an expandable content block
104                        into the page's content.  Note that the approp CSS will need to be included.
105                        The control and container require an 'id' attribute.  This ID uses the
106                        optional NAME sub element.  If NAME doesn't exist then postion() is used. 
107                        This will create unique ID's in most cases.  The CONTENT text() and
108                        sub elements will be ibis:copied into the assoc content container DIV.
109
110                        Dropdown content are is just as easily coded directly in the CONTENT
111                        so no template call/special processing is implemented as it just gets
112                        in the way.
113                "
114        >
115                <xsl:call-template name="ContentContainer.expandable">
116                        <xsl:with-param name="controlID"   select="@id"/>
117                        <xsl:with-param name="controlType" select="@controlType"/>
118                        <xsl:with-param name="additionalClasses" select="@additionalClasses"/>
119                        <xsl:with-param name="controlName" select="
120                                if(not(@controlName)) then NAME
121                                else @controlName
122                        "/>
123                        <xsl:with-param name="title"        select="TITLE"/>
124                        <xsl:with-param name="headingLevel" select="if(exists(@headingLevel)) then @headingLevel else 2"/>     
125                        <xsl:with-param name="description"  select="DESCRIPTION"/>
126                        <xsl:with-param name="help"         select="HELP"/>
127                        <xsl:with-param name="content">
128                                <xsl:apply-templates select="CONTENT" mode="ibis.copyOnlyChildren"/>
129                        </xsl:with-param>
130                        <xsl:with-param name="show"         select="exists(SHOW) or (string-length(@show) != 0)"/>
131                </xsl:call-template>
132        </xsl:template>
133
134
135
136        <xsl:template match="ibis:SelectionsList" mode="ibis.copy"
137                ibis:doc="Provides ability to more easily create a list structure based
138                        on the standard SELECTIONS/SELECTION structure.  The controlType and
139                        class controls indentured/expandable behavior.  Note that the approp
140                        CSS will need to be included.  This code handles sub ibis:includes
141                        so that a MENU structure can be included.  If the container element
142                        does NOT have a direct child element named SELECTIONS then the optional
143                        SELECTIONS_CONTAINER_ELEMENT_NAME can be used.  If the INCLUDE_SUB_LISTS
144                        element is present then the list will be processed for sub lists.
145                "
146        >
147                <!-- variable is needed to process any ibis:include statements -->
148                <xsl:param name="ibisIncludeProcessedContent">
149                        <xsl:apply-templates select="*" mode="ibis.copy"/>
150                </xsl:param>
151                <xsl:param name="selections"
152                        select="
153                                if(exists(SELECTIONS_CONTAINER_ELEMENT_NAME))
154                                        then $ibisIncludeProcessedContent//*[name()=$ibisIncludeProcessedContent/SELECTIONS_CONTAINER_ELEMENT_NAME]/*
155                                        else $ibisIncludeProcessedContent
156                        "
157                />
158<xsl:message select="'=========HTML CONTENT PAGE. ibis:selectionslist'"/>
159<xsl:message select="*"/>
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
168                        <xsl:with-param name="showSelectionsTitle" select="true()"/>
169                        <xsl:with-param name="headingLevel"   select="if(0 != string-length(@headingLevel)) then @headingLevel else 0"/>
170                        <xsl:with-param name="selections"     select="$selections"/>
171                </xsl:call-template>
172        </xsl:template>
173
174
175
176        <xsl:template match="ibis:ContiditionalSection" mode="ibis.copy"
177                ibis:doc="Provides ability include/exclude certain sections of HTML
178                        CONTENT.  For this to work, an overriden callback type template
179                        is used.  This template is passed the section's ID.  The template
180                        must then determine if the section should be included.  The template
181                        determines this by XML, the passed in ID, and any other parameters
182                        that have been passed into the transformer process. 
183
184                        For working examples see repository for the user related XSLT and
185                        HTML_CONTENT ~May 2013.
186                "
187        >
188                <xsl:param name="test">
189                        <xsl:call-template name="HTMLContent.includeConditionalSection">
190                                <xsl:with-param name="sectionID" select="@id"/>
191                        </xsl:call-template>
192                </xsl:param>
193
194                <xsl:if test="ibis:isFirstLetter_T_or_Y_or_X($test)">
195                        <xsl:apply-templates select="(text() | *)" mode="ibis.copy"/>
196                </xsl:if>
197        </xsl:template>
198
199
200
201        <xsl:template name="HTMLContent.includeConditionalSection"
202                ibis:doc="Callback type template that controls if the section should be
203                        processed.  If the template returns 'T', 'X', or 'Y' then that
204                        content will be included.  If nothing or 'F', 'N' then that cotent
205                        will be omitted.  Default is to omit everything.  Sub XSLTs must
206                        override this template and determine if the content should be shown
207                        based on the XML, params passed in, and the section's ID attribute.
208                "
209        >
210                <xsl:param name="sectionID"/>
211        </xsl:template>
212
213
214        <xsl:template match="ibis:help" mode="ibis.copy"
215                ibis:doc="Provides a help button/popup.  1/2021 tried moving this to the
216                        help/include xslt.  Had to implement as a ibis:help element to more
217                        easily pick it up.  Doing so then keeps the ibis namespace which
218                        causes other issues even if matching and creating a new element name.
219                        If the ibis namespace is excluded then other ibis elements are
220                        skipped (like include and app prefix etc.).  As such decided to keep
221                        the processing clean and deal with specific elements CONTENT and
222                        HELP (which also has an optional CONTENT element to process).
223                "
224        >
225                <xsl:call-template name="Help.content">
226                        <xsl:with-param name="help" select="."/>
227                </xsl:call-template>
228        </xsl:template>
229
230
231        <xsl:template match="ibis:baseRequestPath" mode="ibis.copy"
232                ibis:doc="Provides access to the base req path for things like js ajax reqs."
233        ><xsl:value-of select="$ibis.baseRequestPath"/></xsl:template>
234
235
236        <xsl:template match="ibis:Popup" mode="#all">
237                <div id="{@id}" class="Popup {@additionalClasses}"> 
238                        <xsl:call-template name="SelectionsList.inputControl">
239                                <xsl:with-param name="inputID"    select="@controlID"/>
240                                <xsl:with-param name="inputName"  select="@controlName"/>
241                                <xsl:with-param name="inputType"  select="@controlType"/>
242                                <xsl:with-param name="labelClass" select="@controlClass"/>
243                                <xsl:with-param name="title"      select="@controlTitle"/>
244                                <xsl:with-param name="show"       select="'true' = @show"/>
245                                <xsl:with-param name="toggleRadioOnClick" select="'radio' = @controlType"/>
246                                <xsl:with-param name="headingLevel" select="@headingLevel"/>
247                                <xsl:with-param name="description" select="@description"/>
248                        </xsl:call-template>
249<!--
250                        <input id="{$controlName}" type="checkbox" checked="checked"
251                                name="{$controlName}" class="Control"
252                        />
253                        <label for="{$controlName}" title="Show/hide alerts"
254                                class="FontIcon" font-icon="{$fontIcon} &#xe403;"
255                        />
256                       
257                        id="{@containerID}"
258-->
259                        <div class="Container">
260                                <div class="Content">
261                                        <xsl:apply-templates select="* | text()" mode="ibis.copy"/>
262                                </div>
263                        </div>
264                </div>
265        </xsl:template>
266
267
268        <xsl:template match="ibis:SelectionsToJSONArray" mode="#all">
269
270                <xsl:variable name="selections">
271                        <xsl:apply-templates select="*" mode="ibis.copy"/>
272                </xsl:variable>
273
274                <script>
275var <xsl:value-of select="@variableName"/> = [
276                <xsl:for-each select="$selections//SELECTION[not(SELECTIONS)]">
277                        <xsl:sort select="TITLE"/>
278                        <xsl:if test="1 != position()">,</xsl:if>
279{
280        "name":            "<xsl:value-of select="if(0 != string-length(NAME)) then NAME else position()"/>"
281        ,"title":      "<xsl:value-of select="TITLE"/>"
282        ,"href" :      "<xsl:value-of select="ibis:getRequestURL(LOCAL_URL)"/>"
283        ,"group":      "<xsl:value-of select="substring(TITLE,1,1)"/>"
284}
285                </xsl:for-each>
286];
287                </script>
288        </xsl:template>
289
290<!--
291GARTH TODO: saxon 10.x has support for XSLT xpath evaluate
292        <xsl:template match="ibis:xsltParamContent" mode="ibis.copy"
293                ibis:doc="Provides access to XSLT param content."
294        ><xsl:value-of select="@content"/></xsl:template>
295       
296       
297                <script type="text/javascript" ibis:src="js/leaflet-src.js"/>
298                <script type="text/javascript" ibis:src="js/geostats.js"/>
299                <script type="text/javascript" ibis:src="js/jquery.leaflet.js"/>
300
301                <script type="text/javascript" ibis:src="js/L.GeoJSON.Interactive.js"/>
302                <script type="text/javascript" ibis:src="js/L.GeoJSON.Interactive.Choropleth.js"/>
303                <script type="text/javascript" ibis:src="js/L.LayerSets.js"/>
304                <script type="text/javascript" ibis:src="js/L.Control.LayerSets.js"/>
305                <script type="text/javascript" ibis:src="js/L.Control.Choropleth.js"/>
306                <script type="text/javascript" ibis:src="js/L.Control.Zoom.Min.js"/>
307                <script type="text/javascript" ibis:src="js/L.Map.ContextMenu.js"/>
308
309       
310                        $.ajax({
311                                type: "GET"
312                                ,url: "/nmibis-view/query/definition/contentblocks/covid/COVIDRateCounty.html?DataVizContainerIDPrefix=sq1003"
313//                              ,url: "/nm/query/definition/contentblocks/covid/COVIDRateCounty.html?DataVizContainerIDPrefix=sq1003"
314                                ,timeout: 1000*60*20    // in milli secs.
315                                ,success:
316                                        function(data)
317                                        {
318                                                $("#sq1003_script").html(  $(data).filter("#dataVizJavascript").html()  );
319                                                $("#sq1003_dataSources").html(  $(data).filter("#dataSources").html()  );
320                                                $("#sq1003_datasetModifiedDate").html(  $(data).filter("#datasetModifiedDate").html()  );
321                                        }
322                                ,error:
323                                        function(jqXHR, status, errorThrown)
324                                        {
325                                                console.warn("IBIS-PH Covid Ajax Query Request Error: " + status);
326                                                console.warn(errorThrown);
327                                                $("#sq1003_map").html("Sorry, content not available (" + status + ").");
328                                        }
329                        });
330       
331       
332-->
333</xsl:stylesheet>
334<!-- ============================= End of File ============================= -->
335
Note: See TracBrowser for help on using the repository browser.