Add Macro to support SWF (Flash) within APT -------------------------------------------
Key: DOXIA-109 URL: http://jira.codehaus.org/browse/DOXIA-109 Project: doxia Issue Type: Improvement Components: Core Affects Versions: 1.0-alpha-8 Environment: Java code. Reporter: Steve Motola Priority: Trivial Created SwfMacro to support SWF files within APT documentation. Needs some refinement but functional. Below is rough code to go in: /doxia-1.0-alpha-8/doxia-core/src/main/java/org/apache/maven/doxia/macro (or more recent builds, i only found access to alpha-8) package org.apache.maven.doxia.macro; /* * Copyright 2004-2006 The Apache Software Foundation. * * Licensed 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 java.util.Iterator; /** * Macro for embedding Flash (SWF) within Maven documentation. * * @plexus.component role="org.apache.maven.doxia.macro.Macro" * role-hint="swf" */ public class SwfMacro extends AbstractMacro { private static final String EOL = System.getProperty( "line.separator" ); public void execute( Sink sink, MacroRequest request ) { // TODO: at what point to throw exceptions if some required information // is not provided? // 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(str != "") { src = str; } } if(key.equals("id")) { str = (String) request.getParameter(key); if(str != "") { id = str; } } if(key.equals("width")) { width = (String) request.getParameter(key); if(str != "") { width = str; } } if(key.equals("height")) { str = (String) request.getParameter(key); if(str != "") { height = str; } } if(key.equals("quality")) { str = (String) request.getParameter(key); if(str != "") { quality = str; } } if(key.equals("menu")) { str = (String) request.getParameter(key); if(str != "") { menu = str; } } if(key.equals("loop")) { str = (String) request.getParameter(key); if(str != "") { loop = str; } } if(key.equals("play")) { str = (String) request.getParameter(key); if(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(str != "") { version = str; } } } } if(key.equals("allowScript")) { str = (String) request.getParameter(key); if(str != "") { allowScript = str; } } } String content = "<center>" + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version + "' width='" + width + "' height='" + height + "' id='" + id + "'>" + "<param name='movie' value='" + src + ".swf'>" + "<param name='quality' value='" + quality + "'>" + "<param name='menu' value='" + menu + "'>" + "<param name='loop' value='" + loop + "'>" + "<param name='play' value='" + play + "'>" + "<param name='allowScriptAccess' value='" + allowScript + "'>" + "<embed src='" + src + ".swf' width='" + width + "' height='" + height + "' loop='" + loop + "' play='" + play + "' quality='" + quality + "' allowScriptAccess='" + allowScript + "' " + "pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='" + menu + "'></embed>" + "</object>" + "</center>"; sink.rawText(content); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira