diff options
Diffstat (limited to 'archiva-web')
4 files changed, 48 insertions, 7 deletions
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java index 987a72bcf..2e62b86ad 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippet.java @@ -39,10 +39,16 @@ import java.io.IOException; public class CopyPasteSnippet extends AbstractLogEnabled { - public void write( Object o, PageContext pageContext ) + public static final String PRE = "pre"; + + public static final String TOGGLE = "toggle"; + + public void write( String wrapper, Object o, PageContext pageContext ) throws JspException { + StringBuffer prefix = new StringBuffer(); StringBuffer buf = new StringBuffer(); + StringBuffer suffix = new StringBuffer(); if ( o == null ) { @@ -51,7 +57,24 @@ public class CopyPasteSnippet } else if ( o instanceof ManagedRepositoryConfiguration ) { - createSnippet( buf, (ManagedRepositoryConfiguration) o, pageContext ); + ManagedRepositoryConfiguration repo = (ManagedRepositoryConfiguration) o; + + if ( TOGGLE.equals( wrapper ) ) + { + prefix.append( "<a href=\"#\" onclick=\"Effect.toggle('repoPom" ); + prefix.append( repo.getId() ).append( "','slide'); return false;\">Show POM Snippet</a><br/>" ); + prefix.append( "<pre class=\"pom\" style=\"display: none;\" id=\"repoPom" ).append( repo.getId() ); + prefix.append( "\"><code>" ); + + suffix.append( "</code></pre>" ); + } + else if ( PRE.equals( wrapper ) ) + { + prefix.append( "<pre>" ); + suffix.append( "</pre>" ); + } + + createSnippet( buf, repo, pageContext ); } else { @@ -61,7 +84,11 @@ public class CopyPasteSnippet try { JspWriter out = pageContext.getOut(); + + out.write( prefix.toString() ); out.write( StringEscapeUtils.escapeXml( buf.toString() ) ); + out.write( suffix.toString() ); + out.flush(); } catch ( IOException e ) @@ -84,6 +111,8 @@ public class CopyPasteSnippet snippet.append( " <" ).append( distRepoName ).append( ">\n" ); snippet.append( " <id>" ).append( repo.getId() ).append( "</id>\n" ); + snippet.append( " <url>dav:" ).append( ContextUtils.getBaseURL( pageContext, "repository" ) ); + snippet.append( "/" ).append( repo.getId() ).append( "/" ).append( "</url>\n" ); if ( !"default".equals( repo.getLayout() ) ) { diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java index 237c5ea55..47054e82f 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/CopyPasteSnippetTag.java @@ -34,6 +34,8 @@ public class CopyPasteSnippetTag extends TagSupport { private Object object; + + private String wrapper = CopyPasteSnippet.PRE; public void release() { @@ -59,7 +61,7 @@ public class CopyPasteSnippetTag throw new JspException( "Unable to process snippet. Component not found." ); } - snippet.write( object, pageContext ); + snippet.write( wrapper, object, pageContext ); return super.doEndTag(); } @@ -68,4 +70,9 @@ public class CopyPasteSnippetTag { this.object = object; } + + public void setWrapper( String wrapper ) + { + this.wrapper = wrapper; + } } diff --git a/archiva-web/archiva-webapp/src/main/resources/META-INF/taglib.tld b/archiva-web/archiva-webapp/src/main/resources/META-INF/taglib.tld index 43473f122..492e3c995 100644 --- a/archiva-web/archiva-webapp/src/main/resources/META-INF/taglib.tld +++ b/archiva-web/archiva-webapp/src/main/resources/META-INF/taglib.tld @@ -93,6 +93,13 @@ <description><![CDATA[The Object to Render]]></description> </attribute> + <attribute> + <name>wrapper</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + + <description><![CDATA[The wrapper type to use, can be 'pre' or 'toggle']]></description> + </attribute> </tag> <tag> diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp index 778257c3c..0ba26bce2 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp @@ -214,10 +214,8 @@ </c:if> <tr> <th>POM Snippet</th> - <td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/> - <pre class="pom" style="display: none;" id="repoPom${repository.id}"><code> - <archiva:copy-paste-snippet object="${repository}"/> - </code></pre> + <td> + <archiva:copy-paste-snippet object="${repository}" wrapper="toggle" /> </td> </tr> </table> |