maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r539770 - in /maven/doxia: doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java site/src/site/apt/guide-doxia-macros.apt site/src/site/apt/swf-macro.apt
Date Sat, 19 May 2007 15:49:12 GMT
Author: vsiveton
Date: Sat May 19 08:49:11 2007
New Revision: 539770

URL: http://svn.apache.org/viewvc?view=rev&rev=539770
Log:
DOXIA-109: Add Macro to support SWF (Flash) within APT
DOXIA-110: Add APT site documentation for SWF Maceo
Submitted by: Steve Motola
Reviewed by: Vincent Siveton

o applied patches with some modifications: code format, using StringUtils.isNotEmpty() and
StringBuffer
o updated documentation to link to the swf macro page

Added:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java
  (with props)
    maven/doxia/site/src/site/apt/swf-macro.apt   (with props)
Modified:
    maven/doxia/site/src/site/apt/guide-doxia-macros.apt

Added: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java?view=auto&rev=539770
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java
(added)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java
Sat May 19 08:49:11 2007
@@ -0,0 +1,186 @@
+package org.apache.maven.doxia.macro;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.Iterator;
+
+/**
+ * Macro for embedding Flash (SWF) within Maven documentation.
+ *
+ * @plexus.component role="org.apache.maven.doxia.macro.Macro"
+ * role-hint="swf"
+ *
+ * @author <a href="mailto:steve.motola@gmail.com">Steve Motola</a>
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class SwfMacro
+    extends AbstractMacro
+{
+    private static final String EOL = System.getProperty( "line.separator" );
+
+    /**
+     * @see org.apache.maven.doxia.macro.Macro#execute(org.apache.maven.doxia.sink.Sink,
org.apache.maven.doxia.macro.MacroRequest)
+     */
+    public void execute( Sink sink, MacroRequest request )
+        throws MacroExecutionException
+    {
+        // parameter defaults
+        String src = "";
+        String id = "swf";
+        String width = "400";
+        String height = "400";
+        String quality = "high";
+        String menu = "false";
+        String loop = "0";
+        String play = "true";
+        String version = "9,0,45,0";
+        String allowScript = "sameDomain";
+
+        // assign parameters
+        for ( Iterator i = request.getParameters().keySet().iterator(); i.hasNext(); )
+        {
+            String str = "";
+            String key = (String) i.next();
+            if ( key.equals( "src" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    src = str;
+                }
+            }
+            if ( key.equals( "id" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    id = str;
+                }
+            }
+            if ( key.equals( "width" ) )
+            {
+                width = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    width = str;
+                }
+            }
+            if ( key.equals( "height" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    height = str;
+                }
+            }
+            if ( key.equals( "quality" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    quality = str;
+                }
+            }
+            if ( key.equals( "menu" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    menu = str;
+                }
+            }
+            if ( key.equals( "loop" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    loop = str;
+                }
+            }
+            if ( key.equals( "play" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    play = str;
+                }
+            }
+            if ( key.equals( "version" ) )
+            {
+                str = (String) request.getParameter( key );
+                // enable version shorthand
+                // TODO: put in other shorthand versions
+                if ( str.equals( "6" ) )
+                {
+                    version = "6,0,29,0";
+                }
+                else
+                {
+                    if ( str.equals( "9" ) )
+                    {
+                        version = "9,0,45,0";
+                    }
+                    else
+                    {
+                        if ( StringUtils.isNotEmpty( str ) )
+                        {
+                            version = str;
+                        }
+                    }
+                }
+            }
+            if ( key.equals( "allowScript" ) )
+            {
+                str = (String) request.getParameter( key );
+                if ( StringUtils.isNotEmpty( str ) )
+                {
+                    allowScript = str;
+                }
+            }
+        }
+
+        StringBuffer content = new StringBuffer();
+        content.append( "<center>" ).append( EOL );
+        content.append( "<object classid=\"clsid27CDB6E-AE6D-11cf-96B8-444553540000\"
" )
+            .append( "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="
)
+            .append( version ).append( "\" width=\"" ).append( width ).append( "\" height=\""
).append( height )
+            .append( "\" id=\"" ).append( id ).append( "\">" ).append( EOL );
+        content.append( "<param name=\"movie\" value=\"" ).append( src ).append( ".swf\">"
).append( EOL );
+        content.append( "<param name=\"quality\" value=\"" ).append( quality ).append(
"\">" ).append( EOL );
+        content.append( "<param name=\"menu\" value=\"" ).append( menu ).append( "\">"
).append( EOL );
+        content.append( "<param name=\"loop\" value=\"" ).append( loop ).append( "\">"
).append( EOL );
+        content.append( "<param name=\"play\" value=\"" ).append( play ).append( "\">"
).append( EOL );
+        content.append( "<param name=\"allowScriptAccess\" value=\"" ).append( allowScript
).append( "\">" );
+        content.append( "<embed src=\"" ).append( src ).append( "\" width=\"" ).append(
width ).append( "\" height=\"" )
+            .append( height ).append( "\" loop=\"" ).append( loop ).append( "\" play=\""
).append( play )
+            .append( "\" quality=\"" ).append( quality ).append( "\" allowScriptAccess=\""
).append( allowScript )
+            .append( "\" " ).append( "pluginspage=\"http://www.macromedia.com/go/getflashplayer\"
" )
+            .append( "type=\"application/x-shockwave-flash\" menu=\"" ).append( menu ).append(
"\">" ).append( EOL );
+        content.append( "</embed>" ).append( EOL );
+        content.append( "</object>" ).append( EOL );
+        content.append( "</center>" ).append( EOL );
+
+        sink.rawText( content.toString() );
+    }
+}
\ No newline at end of file

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/SwfMacro.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/doxia/site/src/site/apt/guide-doxia-macros.apt
URL: http://svn.apache.org/viewvc/maven/doxia/site/src/site/apt/guide-doxia-macros.apt?view=diff&rev=539770&r1=539769&r2=539770
==============================================================================
--- maven/doxia/site/src/site/apt/guide-doxia-macros.apt (original)
+++ maven/doxia/site/src/site/apt/guide-doxia-macros.apt Sat May 19 08:49:11 2007
@@ -1,10 +1,10 @@
  ------
  Guide to Doxia Macros
  ------
- The Maven Team 
+ The Maven Team
  ------
  25 November 2006
- ------      
+ ------
 
 ~~ Licensed to the Apache Software Foundation (ASF) under one
 ~~ or more contributor license agreements.  See the NOTICE file
@@ -27,12 +27,12 @@
 
  The Doxia Core module includes the Echo and Snippet macros, and you can create
  your own.
- 
+
  Macros are Plexus components with a role of org.apache.macro.doxia.macro.Macro.
  The role-hint is the macro name.
- 
+
  For example:
- 
+
 -----
 /**
  * @plexus.component role="org.apache.maven.doxia.macro.Macro"
@@ -45,13 +45,13 @@
 -----
 
   is called with
-  
+
 -----
 %{echo|param=value|param2=value2}
 -----
 
   and will output
-  
+
 -----
   param ---> value
   param2 ---> value2
@@ -59,11 +59,11 @@
 
   (The echo macro simply prints out the key and value of any parameters that you
   supply.)
-  
+
   Note that macros <<must not>> be indented in your apt source document.
-  
-~~ In the execute method, [TODO] 
-  
+
+~~ In the execute method, [TODO]
+
   The following plugin config can be used to generate the Plexus component.xml
   file for the module containing your macro:
 
@@ -87,3 +87,11 @@
         ...
         </build>
 -----
+
+*Out-of-box Doxia Macros
+
+  * TOC Macro
+
+  * Snippet Macro
+
+  * {{{swf-macro.html}SWF Macro}}

Added: maven/doxia/site/src/site/apt/swf-macro.apt
URL: http://svn.apache.org/viewvc/maven/doxia/site/src/site/apt/swf-macro.apt?view=auto&rev=539770
==============================================================================
--- maven/doxia/site/src/site/apt/swf-macro.apt (added)
+++ maven/doxia/site/src/site/apt/swf-macro.apt Sat May 19 08:49:11 2007
@@ -0,0 +1,94 @@
+ ------
+ Doxia - SWF Macro
+ ------
+ The Maven Team
+ ------
+ 17 May 2007
+ ------
+
+~~ 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.
+
+SWF Macro
+
+ The SWF macro enables users of APT to put SWF (Flash) assets in their documentation.
+
+ Flash assets typically need to be wrappered in <<<object>>> and <<<embed>>>
tags and can have
+ a variety of parameters.  Below is a typical example:
+
+-----
+<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
+    codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'
+    width='400' height='400' id='MyMovie'>
+    <param name='movie' value='myfile.swf'>
+    <param name='quality' value='high'>
+    <param name='menu' value='false'>
+    <param name='loop' value='0'>
+    <embed src='myfile.swf' width='400' height='400' loop='0' quality='high'
+    pluginspage='http://www.macromedia.com/go/getflashplayer'
+    type='application/x-shockwave-flash' menu='false'></embed>
+</object>
+-----
+
+  In order to use a *.swf in your APT file, use the basic syntax:
+
+-----
+%{swf|src=swf/myfile.swf|id=MyMovie|width=600|height=200}
+-----
+
+  For which <<<src>>> is the required parameter.  Make sure to put your
*.swf file into
+  the <</resources>> folder so that it will get copied to /target when running
the <<<mvn site>>> task.
+
+  You can use more advanced parameters to control the output, as per below:
+
+-----
+%{swf|src=swf/myfile.swf|id=MyMovie|width=600|height=200|version=9|allowScript=always}
+-----
+
+  For a full listing of parameters and their values see the Adobe knowledge base:
+
+  {{{http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_12701}http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_12701}}
+
+*Parameters and Defaults
+
+  Currently the following parameters are available through the macro.  If no value is placed
within a parameter, the
+  value will default to the following:
+
+  * id = "swf"
+
+  * width = "400"
+
+  * height = "400"
+
+  * quality = "high"
+
+  * menu = "false"
+
+  * loop = "0"
+
+  * play = "true"
+
+  * version = "9,0,45,0"
+
+  * allowScript = "sameDomain"
+
+  []
+
+  Note:  There is some provided shorthand for versions, i.e. - version=6 - becomes version=6,0,29,0.
+
+  <TODO:>  only shorthand for 6 and 9 are functional.  Need to find standard long
+  version for other types.

Propchange: maven/doxia/site/src/site/apt/swf-macro.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/site/src/site/apt/swf-macro.apt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message