[kune-commits] r1100 - in trunk: . src/main/java/org/ourproject/kune/app/public/others src/main/java/org/ourproject/kune/platf/client/dto src/main/java/org/ourproject/kune/platf/client/ui/download src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ext src/main/java/org/ourproject/kune/workspace/client/cnt src/main/resources src/test/java/org/ourproject/kune/platf/client/ui/rte src/test/java/org/ourproject/kune/platf/client/ui/rte/insertmedia

vjrj vjrj at ourproject.org
Fri Apr 24 04:28:23 CEST 2009


Author: vjrj
Date: 2009-04-24 04:28:18 +0200 (Fri, 24 Apr 2009)
New Revision: 1100

Added:
   trunk/src/main/java/org/ourproject/kune/app/public/others/cortado.jar
   trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/
   trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptorTest.java
Modified:
   trunk/TODO
   trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/download/FileDownloadUtils.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaRegistry.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/InsertMediaAbstractPanel.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/MediaUtils.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ext/InsertMediaExtPresenter.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
   trunk/src/main/resources/kune.properties
Log:
Incomplete - task Audio/Video contents player. External videos easy embeding support (from youtube, google video, ... entering only the url)

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/TODO	2009-04-24 02:28:18 UTC (rev 1100)
@@ -11,6 +11,11 @@
    Use org-mode in emacs to easy manage this file
 
 * SHORT-TERM (URGENT)
+** maven-gwt problem (using another plugin from codehaus)
+   mvn com.totsp.gwt:maven-googlewebtoolkit2-plugin:compile
+   and so on.
+   More info:
+   http://code.google.com/p/gwt-maven/wiki/M2FAQ
 ** vjrj use xwiki maven repo
    http://maven.xwiki.org/releases/com/xpn/xwiki/platform/xwiki-web-wysiwyg/1.8-rc-2/
 ** vjrj <v> better RTE
@@ -157,8 +162,14 @@
    see:  svn checkout svn://anonsvn.it.su.se/su-smack su-smack
 ** TODO <v> study different embeded video solutions
    - for ogg :: http://www.flumotion.net/cortado/
-   - for mp3+flv :: flowplayer
-   - for avi :: ??
+   http://www.flumotion.net/cortado/
+   https://code.fluendo.com/flumotion/trac/browser/cortado/trunk/README
+   http://en.flossmanuals.net/TheoraCookbook/Cortado		
+   - for mp3+flv :: flowplayer		    
+   - for avi :: some links:
+   http://www.w3schools.com/media/media_browservideos.asp
+   http://www.solitude.dk/archives/embedquicktime/
+   http://www.solitude.dk/archives/embedquicktime/jquery.embedquicktime-source.js
 ** TODO <d> Inform to translators when original content changes
 ** TODO <v> Restarting server don't affect client session
    Now there are problems if client was started before server, when server restart (session persist)

Added: trunk/src/main/java/org/ourproject/kune/app/public/others/cortado.jar
===================================================================
(Binary files differ)


Property changes on: trunk/src/main/java/org/ourproject/kune/app/public/others/cortado.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -57,6 +57,11 @@
         return type;
     }
 
+    public boolean isAvi() {
+        return type != null && subtype != null && type.equals("video")
+                && (subtype.equals("x-msvideo") || subtype.equals("msvideo"));
+    }
+
     public boolean isFlv() {
         return type != null && subtype != null && type.equals("video")
                 && (subtype.equals("flv") || subtype.equals("x-flv"));

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/download/FileDownloadUtils.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/download/FileDownloadUtils.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/download/FileDownloadUtils.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -80,7 +80,10 @@
             url.add(new UrlParam(FileConstants.DOWNLOAD, download));
         }
         if (useHash) {
-            url.add(new UrlParam(FileConstants.HASH, session.getUserHash()));
+            String hash = session.getUserHash();
+            if (hash != null) {
+                url.add(new UrlParam(FileConstants.HASH, hash));
+            }
         }
         return url.toString();
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptor.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptor.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -2,30 +2,46 @@
 
 public class ExternalMediaDescriptor {
 
+    public static final String URL = "###URL###";
+    public static final String HEIGHT = "###HEIGHT###";
+    public static final String WIDTH = "###WIDTH###";
+
     private final String name;
     private final String siteurl;
     private final String detectRegex;
     private final String idRegex;
     private final String embedTemplate;
+    private int width;
+    private int height;
 
     public ExternalMediaDescriptor(final String name, final String siteurl, final String detectRegex,
-            final String idRegex, final String embedTemplate) {
+            final String idRegex, final String embedTemplate, final int defWidth, final int defHeight) {
         this.name = name;
         this.siteurl = siteurl;
         this.detectRegex = detectRegex;
         this.idRegex = idRegex;
         this.embedTemplate = embedTemplate;
+        width = defWidth;
+        height = defHeight;
     }
 
     public String getEmbed(final String url) {
-        String id = url.replaceFirst(idRegex, "kk");
-        return embedTemplate.replaceFirst("\\[%d\\]", id);
+        String id = getId(url);
+        String result = embedTemplate.replaceAll(URL, id);
+        result = result.replaceAll(HEIGHT, "" + height);
+        result = result.replaceAll(WIDTH, "" + width);
+        return result;
     }
 
-    public boolean is(final String url) {
-        return url.matches(detectRegex);
+    public int getHeight() {
+        return height;
     }
 
+    public String getId(final String url) {
+        String id = url.replaceFirst(idRegex, "$1");
+        return id;
+    }
+
     public String getName() {
         return name;
     }
@@ -33,4 +49,20 @@
     public String getSiteurl() {
         return siteurl;
     }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public boolean is(final String url) {
+        return url.matches(detectRegex);
+    }
+
+    public void setHeight(final int height) {
+        this.height = height;
+    }
+
+    public void setWidth(final int width) {
+        this.width = width;
+    }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaRegistry.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaRegistry.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -7,7 +7,8 @@
 
     private static final long serialVersionUID = 1L;
 
-    public static final ExternalMediaDescriptor NO_MEDIA = new ExternalMediaDescriptor(null, null, null, null, null);
+    public static final ExternalMediaDescriptor NO_MEDIA = new ExternalMediaDescriptor(null, null, null, null, null, 0,
+            0);
 
     public ExternalMediaDescriptor get(final String url) {
         for (ExternalMediaDescriptor media : this) {

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/InsertMediaAbstractPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/InsertMediaAbstractPanel.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/InsertMediaAbstractPanel.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -52,6 +52,6 @@
     }
 
     public void setIntro(final String text) {
-        intro.setHtml(text);
+        intro.setHtml(text + "<br/>");
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/MediaUtils.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/MediaUtils.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/abstractmedia/MediaUtils.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -17,6 +17,11 @@
         this.downloadUtils = downloadUtils;
     }
 
+    public String getAviEmbed(final StateToken token) {
+        return session.getInitData().getAviEmbedObject().replace(DOC_URL_TAG,
+                session.getSiteUrl() + downloadUtils.getUrl(token));
+    }
+
     public String getFlvEmbed(final StateToken token) {
         return session.getInitData().getFlvEmbedObject().replace(DOC_URL_TAG,
                 session.getSiteUrl() + downloadUtils.getUrl(token));

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ext/InsertMediaExtPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ext/InsertMediaExtPresenter.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ext/InsertMediaExtPresenter.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -17,8 +17,27 @@
         super(insertMediaDialog);
         this.externalMediaRegistry = externalMediaRegistry;
 
-        externalMediaRegistry.add(new ExternalMediaDescriptor("youtube", "http://youtube.com",
-                "http://[a-z]*.youtube.com/watch?v=.*", "FIXME", "<embed [%d]>"));
+        externalMediaRegistry.add(new ExternalMediaDescriptor(
+                "youtube",
+                "http://youtube.com",
+                ".*youtube.*",
+                ".*youtube.com/watch.*[\\?&]v=(.*)",
+                "<object width=\"###WIDTH###\" height=\"###HEIGHT###\"><param name=\"movie\" value=\"http://youtube.com/v/###URL###\" /><param name=\"wmode\" value=\"opaque\" /><embed src=\"http://youtube.com/v/###URL###\" type=\"application/x-shockwave-flash\" width=\"###WIDTH###\" height=\"###HEIGHT###\" wmode=\"opaque\"></embed></object>",
+                480, 385));
+        externalMediaRegistry.add(new ExternalMediaDescriptor(
+                "blip.tv",
+                "http://blip.tv",
+                ".*blip\\.tv.*",
+                ".*blip.tv/file/([0-9]+).*",
+                "<embed src=\"http://blip.tv/play/###URL###\" type=\"application/x-shockwave-flash\" width=\"###WIDTH###\" height=\"###HEIGHT###\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" ></embed>",
+                480, 385));
+        externalMediaRegistry.add(new ExternalMediaDescriptor(
+                "google video",
+                "http://video.google.com/",
+                ".*video\\.google.*",
+                ".*video\\.google\\.com/videoplay.*docid=([0-9]+).*",
+                "<embed id=\"VideoPlayback\" src=\"http://video.google.com/googleplayer.swf?docid=###URL###&hl=es&fs=true\" style=\"width:###WIDTH###;height:###HEIGHT###\" allowFullScreen=\"true\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" wmode=\"opaque\" > </embed>",
+                400, 326));
     }
 
     public void init(final InsertMediaExtView view) {

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -94,6 +94,8 @@
                     view.setContent(mediaUtils.get().getOggEmbed(token), false);
                 } else if (mimeType.isFlv()) {
                     view.setContent(mediaUtils.get().getFlvEmbed(token), false);
+                } else if (mimeType.isAvi()) {
+                    view.setContent(mediaUtils.get().getAviEmbed(token), false);
                 } else if (mimeType.isText()) {
                     view.setContent(contentBody, true);
                 } else {

Modified: trunk/src/main/resources/kune.properties
===================================================================
--- trunk/src/main/resources/kune.properties	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/main/resources/kune.properties	2009-04-24 02:28:18 UTC (rev 1100)
@@ -54,7 +54,9 @@
 # The code used to play local embeded videos/audios. Change this with other player/code (include a ###DOC_URL### tag)
 kune.media.flvembededobject = <object width="400" height="300" data="http://flowplayer.org/swf/flowplayer-3.1.0.swf" type="application/x-shockwave-flash"> <param name="movie" value="http://flowplayer.org/swf/flowplayer-3.1.0.swf" /> <param name="allowfullscreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value='config={"clip":{"url":"###DOC_URL###", "autoPlay": false, "autoBuffering": false },"canvas":{"backgroundColor":"#CC6633"},"plugins":{"controls":{"time":true,"volume":false,"fullscreen":true}}}' /> <param name="wmode" value="opaque"> </object>
 kune.media.mp3embededobject = <object width="350" height="24" data="http://flowplayer.org/swf/flowplayer-3.1.0.swf" type="application/x-shockwave-flash"> <param name="movie" value="http://flowplayer.org/swf/flowplayer-3.1.0.swf" /> <param name="allowfullscreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value='config={"clip":{"url":"###DOC_URL###", "autoPlay": false, "autoBuffering": false },"canvas":{"backgroundColor":"#CC6633"},"plugins":{"audio":{"url":"http://flowplayer.org/swf/flowplayer.audio.swf"},"controls":{"time":true,"volume":true,"fullscreen":false}}}' /> <param name="wmode" value="opaque"> </object>
-kune.media.aviembededobject = <object > </object>
-kune.media.oggembededobject = <applet code="com.fluendo.player.Cortado.class" archive="/kune/others/cortado-ovt-debug-0.2.2.jar" width="352" height="288"> <param name="url" value="###DOC_URL###"/> <param name="local" value="false"/> <param name="duration" value="232"/> <param name="keepAspect" value="true"/> <param name="video" value="true"/> <param name="audio" value="true"/> <param name="bufferSize" value="200"/> <param name="userId" value="user"/> <param name="password" value="test"/> </applet>
-# http://www.flumotion.net/cortado/
-# https://code.fluendo.com/flumotion/trac/browser/cortado/trunk/README
+kune.media.oggembededobject = <applet code="com.fluendo.player.Cortado.class" archive="/kune/others/cortado.jar" width="352" height="288"> <param name="url" value="###DOC_URL###"/> <param name="local" value="false"/> <param name="duration" value="232"/> <param name="keepAspect" value="true"/> <param name="video" value="true"/> <param name="audio" value="true"/> <param name="bufferSize" value="200"/> <param name="userId" value="user"/> <param name="password" value="test"/> </applet>
+kune.media.aviembededobject = <object data="###DOC_URL###" type="video/msvideo" />
+
+### More info about properties
+# http://en.wikipedia.org/wiki/.properties
+# http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)

Added: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptorTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptorTest.java	2009-04-22 14:36:46 UTC (rev 1099)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/insertmedia/ExternalMediaDescriptorTest.java	2009-04-24 02:28:18 UTC (rev 1100)
@@ -0,0 +1,83 @@
+package org.ourproject.kune.platf.client.ui.rte.insertmedia;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ExternalMediaDescriptorTest {
+
+    private ExternalMediaDescriptor ytmedia;
+    private ExternalMediaDescriptor btmedia;
+    private ExternalMediaDescriptor gvmedia;
+
+    @Before
+    public void before() {
+        ytmedia = new ExternalMediaDescriptor(
+                "youtube",
+                "http://youtube.com",
+                ".*youtube.*",
+                ".*youtube.com/watch.*[\\?&]v=(.*)",
+                "<object width=\"###WIDTH###\" height=\"###HEIGHT###\"><param name=\"movie\" value=\"http://youtube.com/v/###URL###\" /><param name=\"wmode\" value=\"transparent\" /><embed src=\"http://youtube.com/v/###URL###\" type=\"application/x-shockwave-flash\" width=\"###WIDTH###\" height=\"###HEIGHT###\" wmode=\"transparent\"></embed></object>",
+                480, 385);
+        btmedia = new ExternalMediaDescriptor(
+                "blip.tv",
+                "http://blip.tv",
+                ".*blip\\.tv.*",
+                ".*blip.tv/file/([0-9]+).*",
+                "<embed src=\"http://blip.tv/play/###URL###\" type=\"application/x-shockwave-flash\" width=\"###WIDTH###\" height=\"###HEIGHT###\" allowscriptaccess=\"always\" allowfullscreen=\"true\"></embed>",
+                480, 385);
+        gvmedia = new ExternalMediaDescriptor(
+                "google video",
+                "http://video.google.com/",
+                ".*video\\.google.*",
+                ".*video\\.google\\.com/videoplay.*docid=([0-9]+).*",
+                "<embed id=\"VideoPlayback\" src=\"http://video.google.com/googleplayer.swf?docid=###URL###&hl=es&fs=true\" style=\"width:###WIDTH###;height:###HEIGHT###\" allowFullScreen=\"true\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"> </embed>",
+                400, 326);
+
+    }
+
+    @Test
+    public void getIds() {
+        assertEquals("v2aKo6la7J4", ytmedia.getId("http://www.youtube.com/watch?v=v2aKo6la7J4"));
+        assertEquals("v2aKo6la7J4", ytmedia.getId("http://de.youtube.com/watch?v=v2aKo6la7J4"));
+        assertEquals("v2aKo6la7J4", ytmedia.getId("http://www.youtube.com/watch?gl=ES&hl=es&v=v2aKo6la7J4"));
+        assertEquals("v2aKo6la7J4", ytmedia.getId("http://youtube.com/watch?gl=ES&hl=es&v=v2aKo6la7J4"));
+
+        assertEquals("1646241", btmedia.getId("http://vjrj.blip.tv/file/1646241/"));
+        assertEquals("1646241",
+                btmedia.getId("http://blip.tv/file/1646241?utm_source=featured_ep&utm_medium=featured_ep"));
+        assertEquals("1646241", btmedia.getId("http://blip.tv/file/1646241"));
+
+        assertEquals(
+                "7360794370207355739",
+                gvmedia.getId("http://video.google.com/videoplay?ei=VBPxSbXDLob2-Aabu9B-&q=chomsky&docid=7360794370207355739"));
+        assertEquals(
+                "7360794370207355739",
+                gvmedia.getId("http://video.google.com/videoplay?docid=7360794370207355739&ei=VBPxSbXDLob2-Aabu9B-&q=chomsky"));
+        assertEquals("7360794370207355739",
+                gvmedia.getId("http://video.google.com/videoplay?docid=7360794370207355739"));
+    }
+
+    @Test
+    public void testGeEmb() {
+        String result = ytmedia.getEmbed("http://www.youtube.com/watch?v=v2aKo6la7J4");
+        assertFalse(result.matches(ExternalMediaDescriptor.HEIGHT));
+        assertFalse(result.matches(ExternalMediaDescriptor.WIDTH));
+        assertFalse(result.matches(ExternalMediaDescriptor.URL));
+        assertTrue(result.matches(".*v2aKo6la7J4.*"));
+    }
+
+    @Test
+    public void testMatch() {
+        assertTrue(ytmedia.is("sdfklasdfayoutubekasdf"));
+    }
+
+    @Test
+    public void testNoMatch() {
+        assertFalse(ytmedia.is("sdfklasdfakasdf"));
+    }
+
+}




More information about the kune-commits mailing list