source: main/trunk/greenstone3/web/interfaces/default/transform/pages/webswing-gli.xsl@ 37327

Last change on this file since 37327 was 37327, checked in by davidb, 14 months ago

Introducing an embeded version of webswing-gli so there can be Javascript handler that the Java can call via the webswing-api

File size: 5.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util">
10
11 <!-- This page, structurally speaking, is a hybrid of home.xsl and about.xsl -->
12 <!-- If no collection argument is explicitly given, then produces a general
13 embedded GLI, however if a collection is specified, then it produced
14 a page with a navigation area akin to an about this page, only with
15 GLI embedd in it, rather than about this collection txt -->
16
17 <!-- use the 'main' layout -->
18 <xsl:import href="layouts/main.xsl"/>
19
20 <!-- what is this used for??? Can it be deleted? -->
21 <xsl:variable name="groupPath"><xsl:value-of select="/page/pageRequest/paramList/param[@name='group']/@value"/></xsl:variable>
22
23 <!-- set page title -->
24
25 <xsl:template name="pageTitle">
26 <!-- if no collection specified -->
27 <xsl:choose>
28 <xsl:when test="$groupPath != ''">
29 <gslib:groupName path="{$groupPath}"/>
30 </xsl:when>
31 <xsl:otherwise>
32 <gslib:siteName/>
33 </xsl:otherwise>
34 </xsl:choose>
35 <!-- otherwise -->
36 <!--
37 <xsl:template name="pageTitle"><gslib:collectionName/></xsl:template>
38 -->
39 </xsl:template>
40
41
42
43 <!-- set page breadcrumbs -->
44 <xsl:template name="breadcrumbs">
45 <!-- if no collection specified -->
46 <xsl:if test="$groupPath != ''">
47 <gslib:siteLink/>
48 <xsl:for-each select="/page/pageResponse/pathList/group">
49 <xsl:sort data-type="number" select="@position"/>
50 <gslib:rightArrow/>
51 <xsl:if test="position() != last()">
52 <!-- don't want the current group in the breadcrumbs -->
53 <a>
54 <xsl:attribute name="href"><gslib:groupHref path="{@path}"/></xsl:attribute>
55 <xsl:attribute name="title"><gslib:groupName path="{@path}"/></xsl:attribute>
56 <gslib:groupName path="{@path}"/>
57 </a>
58 </xsl:if>
59 </xsl:for-each>
60 </xsl:if>
61 <!-- else -->
62 <!--
63 <gslib:siteLink/>
64 <gslib:rightArrow/>
65 <gslib:groupLinks/>
66 -->
67
68 </xsl:template>
69
70
71 <!-- the page content -->
72 <xsl:template match="/page">
73
74 <xsl:choose>
75 <xsl:when test="$this-element/displayItemList/displayItem[@name='icon']">
76 <img border="0">
77 <xsl:attribute name="src"><xsl:value-of select="$this-element/metadataList/metadata[@name='httpPath']"/>/images/<xsl:value-of select="$this-element/displayItemList/displayItem[@name='icon']"/></xsl:attribute>
78 <xsl:attribute name="alt">
79 <xsl:value-of select="$this-element/displayItemList/displayItem[@name='name']"/>
80 </xsl:attribute>
81 <xsl:attribute name="title">
82 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'webswing_glipage')"/>
83 </xsl:attribute>
84 </img>
85 </xsl:when>
86 </xsl:choose>
87
88 <!--Display the description text of the current collection,
89 and if some services are available then create a list
90 of links for each service within a <ul id="servicelist"> element.-->
91 <xsl:call-template name="webswing-embed-gli"/>
92 </xsl:template>
93
94 <xsl:template name="webswing-embed-gli">
95 <link rel="stylesheet" href="/webswing-server/css/style.css" />
96
97
98 <div class="webswing-element" data-webswing-instance="webswingInstance0" style="height: 600px;">
99 <div id="loading" class="ws-modal-container">
100 <div class="ws-login">
101 <div class="ws-login-content">
102 <div class="ws-spinner">
103 <div class="ws-spinner-dot-1"><xsl:comment>filler</xsl:comment></div>
104 <div class="ws-spinner-dot-2"><xsl:comment>filler</xsl:comment></div>
105 </div>
106 </div>
107 </div>
108 </div>
109 </div>
110
111 <gsf:script>
112 var webswingInstance0 = {
113 options: {
114 autoStart: true,
115 args: 'foo',
116 recording: getParam('recording'),
117 debugPort: getParam('debugPort'),
118 connectionUrl:'/webswing-server/gli',
119
120
121 customization: function(injector) {
122 injector.services.base.handleActionEvent = function(actionName, data, binaryData) {
123 console.log("WebSwing actionEvent callback handler: called with actionName = " + actionName);
124 if (actionName == "previewURL") {
125 var url = data;
126 window.open(url, '_blank');
127 }
128 }
129 }
130
131
132 }
133 }
134
135 function getParam(name) {
136 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
137 var results = new RegExp("[\\?&amp;]" + name + "=([^&amp;#]*)").exec(location.href);
138 return results == null ? null : decodeURIComponent(results[1]);
139 }
140 </gsf:script>
141
142
143 <script data-webswing-global-var="webswing">
144 <xsl:text disable-output-escaping="yes">
145 (function (window, document) {
146 var loader = function () {
147 var baseUrl = '/webswing-server/gli';
148 baseUrl = baseUrl.indexOf("/", baseUrl.length - 1) !== -1 ? baseUrl : (baseUrl + "/");
149 var xmlhttp = new XMLHttpRequest();
150 xmlhttp.onreadystatechange = function () {
151 if (xmlhttp.readyState == XMLHttpRequest.DONE) {
152 var version = xmlhttp.status == 200 ? xmlhttp.responseText : "undefined";
153 var script = document.createElement("script"),
154 tag = document.getElementsByTagName("script")[0];
155 script.src = baseUrl + "javascript/webswing-embed.js?version=" + version;
156 tag.parentNode.insertBefore(script, tag);
157 }
158 };
159 xmlhttp.open("GET", baseUrl + "rest/version", true);
160 xmlhttp.send();
161 };
162 window.addEventListener ? window.addEventListener("load", loader, false) : window.attachEvent("onload", loader);
163 })(window, document);
164 </xsl:text>
165 </script>
166
167
168
169 </xsl:template>
170
171</xsl:stylesheet>
172
Note: See TracBrowser for help on using the repository browser.