You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2010/07/21 23:51:27 UTC

svn commit: r966434 - in /lenya/contributions/2_0_X/modules: defaultstyle/xslt/ tagcloud/ tagcloud/config/ tagcloud/resources/ tagcloud/resources/javascript/ tagcloud/resources/javascript/templates/ tagcloud/xslt/

Author: andreas
Date: Wed Jul 21 21:51:26 2010
New Revision: 966434

URL: http://svn.apache.org/viewvc?rev=966434&view=rev
Log:
Migrate tag cloud to Dojo.

Added:
    lenya/contributions/2_0_X/modules/tagcloud/resources/
    lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/
    lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/TagCloud.js
    lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/templates/
    lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/templates/TagCloud.html
    lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2tags.xsl
Modified:
    lenya/contributions/2_0_X/modules/defaultstyle/xslt/page.xsl
    lenya/contributions/2_0_X/modules/tagcloud/config/module.xml
    lenya/contributions/2_0_X/modules/tagcloud/sitemap.xmap
    lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2xhtml.xsl

Modified: lenya/contributions/2_0_X/modules/defaultstyle/xslt/page.xsl
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/defaultstyle/xslt/page.xsl?rev=966434&r1=966433&r2=966434&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/defaultstyle/xslt/page.xsl (original)
+++ lenya/contributions/2_0_X/modules/defaultstyle/xslt/page.xsl Wed Jul 21 21:51:26 2010
@@ -15,8 +15,6 @@
   limitations under the License.
 -->
 
-<!-- $Id: page2xhtml.xsl 439367 2006-09-01 16:15:28Z andreas $ -->
-
 <xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns="http://www.w3.org/1999/xhtml"
@@ -69,6 +67,9 @@
           <i:include src="cocoon://modules/atom/serviceLinks" strip-root="true"/>
           <script type="text/javascript" src="/modules/firedocs/javascript/firedocs.js"/>
         </xsl:if>
+        <script type="text/javascript" src="/modules/dojo/dojo/dojo.js"
+          djConfig="parseOnLoad: true, bindEncoding: 'utf-8', locale: '{$language}'"/>
+        <script type="text/javascript" src="/modules/tagcloud/javascript/TagCloud.js"/>
       </head>
       <body>
         <div id="page">
@@ -96,17 +97,8 @@
                   <xsl:call-template name="searchForm"/>
                   
                   <div id="content">
-                    <i:include src="cocoon://modules/tagcloud/{$pub}/{$area}/{$language}/tagcloud.xml"/>
+                    <div dojoType="lenya.tagcloud.TagCloud" pub="'{$pub}'" area="'{$area}'" lang="'{$language}'"><xsl:comment/></div>
                     <xi:include href="#" xmlns:xi="http://www.w3.org/2001/XInclude"/>
-                    <!--
-                    <i:include src="cocoon:/{$pub}/{$area}/{$uuid}/{$language}.content">
-                      <i:fallback>
-                        <p>
-                          This document doesn't exist.
-                        </p>
-                      </i:fallback>
-                    </i:include>
-                    -->
                   </div>
                   
                   <xsl:call-template name="footer"/>

Modified: lenya/contributions/2_0_X/modules/tagcloud/config/module.xml
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/tagcloud/config/module.xml?rev=966434&r1=966433&r2=966434&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/tagcloud/config/module.xml (original)
+++ lenya/contributions/2_0_X/modules/tagcloud/config/module.xml Wed Jul 21 21:51:26 2010
@@ -19,6 +19,7 @@
 <module xmlns="http://apache.org/lenya/module/1.0">
   <id>org.apache.lenya.modules.tagcloud</id>
   <depends module="org.apache.lenya.modules.lucene"/>
+  <depends module="org.apache.lenya.modules.dojo"/>
   <package>org.apache.lenya.modules</package>
   <version>0.1-dev</version>
   <name>Tag Cloud</name>

Added: lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/TagCloud.js
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/TagCloud.js?rev=966434&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/TagCloud.js (added)
+++ lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/TagCloud.js Wed Jul 21 21:51:26 2010
@@ -0,0 +1,65 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+dojo.require('dijit._Widget');
+dojo.require('dijit._Templated');
+dojo.provide("lenya.tagcloud.TagCloud");
+
+dojo.declare(
+  'lenya.tagcloud.TagCloud',
+  [dijit._Widget, dijit._Templated],
+  {
+    templatePath : new dojo._Url('', '/modules/tagcloud/javascript/templates/TagCloud.html'),
+    
+    pub: undefined,
+    area: undefined,
+    lang: undefined,
+    
+    postCreate: function() {
+      this.inherited(arguments);
+    
+      var that = this;
+    
+      dojo.xhrGet({
+        url: "/modules/tagcloud/" + this.pub + "/" + this.area + "/" + this.lang + "/tagcloud.xml",
+        handleAs: "xml",
+        
+        load: function(response, ioArgs) {
+          var container = that._container;
+          var i;
+          var tags = response.getElementsByTagName("*")[0].getElementsByTagName("*");
+          for (i = 0; i < tags.length; i++) {
+            var tag = tags[i];
+            var link = document.createElement("a");
+            link.appendChild(document.createTextNode(tag.textContent));
+            link.href = tag.getAttribute("href");
+            link.style.fontSize = (parseInt(tag.getAttribute("priority")) + 11) + "px";
+            container.appendChild(link);
+            container.appendChild(document.createTextNode(" "));
+          }
+          return true;
+        },
+    
+        error: function(response, ioArgs) {
+          alert("Could not load tag cloud, HTTP status code: " + ioArgs.xhr.status);
+          return response;
+        }
+        
+      });
+    
+    }
+  }
+);

Added: lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/templates/TagCloud.html
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/templates/TagCloud.html?rev=966434&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/templates/TagCloud.html (added)
+++ lenya/contributions/2_0_X/modules/tagcloud/resources/javascript/templates/TagCloud.html Wed Jul 21 21:51:26 2010
@@ -0,0 +1,3 @@
+<div dojoAttachPoint="_container" class="tagCloud">
+  <h3>Tags</h3>
+</div>
\ No newline at end of file

Modified: lenya/contributions/2_0_X/modules/tagcloud/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/tagcloud/sitemap.xmap?rev=966434&r1=966433&r2=966434&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/tagcloud/sitemap.xmap (original)
+++ lenya/contributions/2_0_X/modules/tagcloud/sitemap.xmap Wed Jul 21 21:51:26 2010
@@ -22,6 +22,13 @@
     <map:generators default="file">
       <map:generator name="index-terms" src="org.apache.lenya.modules.tagcloud.IndexTermsGenerator"/>
     </map:generators>
+    <map:transformers default="xslt">
+      <map:transformer name="uuid2url-tags" logger="lenya.sitemap.transformer.uuid2url-tags"
+        src="org.apache.lenya.cms.cocoon.transformation.UuidToUrlTransformer">
+        <transform namespace="http://apache.org/lenya/tagcloud" element="tag" attribute="href"/>
+      </map:transformer>
+      
+    </map:transformers>
   </map:components>
 
   <map:pipelines>
@@ -41,9 +48,13 @@
       <!-- pattern: {1:pub}/{2:area}/{3:lang}/tagcloud.xml -->
       <map:match pattern="*/*/*/tagcloud.xml">
         <map:generate src="cocoon:/{1}/{2}/{3}/terms.xml"/>
-        <map:transform src="xslt/terms2xhtml.xsl">
+        <map:transform src="xslt/terms2tags.xsl">
           <map:parameter name="searchDocUuid" value="{path2uuid:{1}:{2}:/search}"/>
           <map:parameter name="field" value="\\{http\://purl.org/dc/elements/1.1/\}subject"/>
+          <map:parameter name="language" value="{3}"/>
+        </map:transform>
+        <map:transform type="uuid2url-tags">
+          <map:parameter name="url" value="/{1}/{2}"/>
         </map:transform>
         <map:serialize type="xml"/>
       </map:match>

Added: lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2tags.xsl
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2tags.xsl?rev=966434&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2tags.xsl (added)
+++ lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2tags.xsl Wed Jul 21 21:51:26 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+  xmlns:search="http://apache.org/lenya/search"
+  xmlns:tag="http://apache.org/lenya/tagcloud"
+  exclude-result-prefixes="search">
+  
+  
+  <xsl:param name="searchDocUuid"/>
+  <xsl:param name="field"/>
+  <xsl:param name="language"/>
+  
+  
+  <xsl:template match="search:terms">
+    <tag:tags>
+      <xsl:apply-templates/>
+    </tag:tags>
+  </xsl:template>
+  
+  
+  <xsl:template match="search:term">
+    <tag:tag priority="{@relativeHits}" href="lenya-document:{$searchDocUuid},lang={$language}?type=raw&amp;queryString={$field}:{.}">
+      <xsl:value-of select="."/>
+    </tag:tag>
+  </xsl:template>
+  
+  
+</xsl:stylesheet>
\ No newline at end of file

Modified: lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2xhtml.xsl?rev=966434&r1=966433&r2=966434&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2xhtml.xsl (original)
+++ lenya/contributions/2_0_X/modules/tagcloud/xslt/terms2xhtml.xsl Wed Jul 21 21:51:26 2010
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
   xmlns:search="http://apache.org/lenya/search"
   xmlns="http://www.w3.org/1999/xhtml"
@@ -9,7 +25,7 @@
   <xsl:param name="field"/>
   
   <xsl:template match="search:terms">
-    <div class="tagCloud">
+    <div>
       <h3>Tags</h3>
       <xsl:apply-templates/>
     </div>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org