+++ /dev/null
-package org.apache.archiva.rest.docs;
-/*
- * 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.commons.lang.StringUtils;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-
-/**
- * @author Olivier Lamy
- * @since 1.4-M4
- */
-public class RestDocsServlet
- extends HttpServlet
-{
- private Logger logger = LoggerFactory.getLogger( getClass() );
-
- @Override
- protected void doGet( HttpServletRequest req, HttpServletResponse resp )
- throws ServletException, IOException
- {
-
- logger.debug( "docs request to path: {}", req.getPathInfo() );
-
- String path = StringUtils.removeStart( req.getPathInfo(), "/" );
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( path );
-
- String startPath = StringUtils.substringBefore( path, "/" );
-
- // replace all links !!
- Document document = Jsoup.parse( is, "UTF-8", "" );
-
- Element body = document.body().child( 0 );
-
- Elements links = body.select( "a[href]" );
-
- for ( Iterator<Element> elementIterator = links.iterator(); elementIterator.hasNext(); )
- {
- Element link = elementIterator.next();
- //link.attr( "onclick", "loadRestDocs('" + startPath + "\',\'"+ "rest-docs/" + startPath + "/" + link.attr( "href" ) + "\');" );
- link.attr( "href", "#" + startPath + "/" + link.attr( "href" ) );
-
- }
-
- Elements codes = body.select( "code" );
-
- for ( Iterator<Element> elementIterator = codes.iterator(); elementIterator.hasNext(); )
- {
- Element code = elementIterator.next();
- code.attr( "class", code.attr( "class" ) + " nice-code" );
- }
-
- //res.appendChild( body.child( 1 ) );
-
- Document res = new Document( "" );
- res.appendChild( body.select( "div[id=main]" ).first() );
-
- resp.getOutputStream().write( res.outerHtml().getBytes() );
-
- //IOUtils.copy( is, resp.getOutputStream() );
- //super.doGet( req, resp );
- }
-}
<archiva.baseRestUrl />
<rest.admin.pwd />
<test.useTomcat>false</test.useTomcat>
+ <enunciate.docsDir>${project.build.outputDirectory}/rest-docs-archiva-ui</enunciate.docsDir>
+
</properties>
<dependencies>
--- /dev/null
+<?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.
+ -->
+<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
+
+ <services>
+ <rest defaultRestSubcontext="archivaUiServices"/>
+ </services>
+
+ <modules>
+
+ <cxf disabled="false"/>
+ <jersey disabled="true" />
+ <c disabled="true"/>
+ <csharp disabled="true"/>
+ <obj-c disabled="true"/>
+ <jaxws-ri disabled="true"/>
+ <jaxws-support disabled="true"/>
+
+ <docs disabled="false" title="Apache Archiva UI REST API" includeExampleXml="true" includeExampleJson="true"
+ includeDefaultDownloads="false">
+ <war docsDir="apidocs" />
+ </docs>
+
+ </modules>
+
+</enunciate>
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.webapp.ui.services.docs;
+/*
+ * 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.commons.lang.StringUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M4
+ */
+public class RestDocsServlet
+ extends HttpServlet
+{
+ private Logger logger = LoggerFactory.getLogger( getClass() );
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+
+ logger.debug( "docs request to path: {}", req.getPathInfo() );
+
+ String path = StringUtils.removeStart( req.getPathInfo(), "/" );
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( path );
+
+ String startPath = StringUtils.substringBefore( path, "/" );
+
+ // replace all links !!
+ Document document = Jsoup.parse( is, "UTF-8", "" );
+
+ Element body = document.body().child( 0 );
+
+ Elements links = body.select( "a[href]" );
+
+ for ( Iterator<Element> elementIterator = links.iterator(); elementIterator.hasNext(); )
+ {
+ Element link = elementIterator.next();
+ //link.attr( "onclick", "loadRestDocs('" + startPath + "\',\'"+ "rest-docs/" + startPath + "/" + link.attr( "href" ) + "\');" );
+ link.attr( "href", "#" + startPath + "/" + link.attr( "href" ) );
+
+ }
+
+ Elements codes = body.select( "code" );
+
+ for ( Iterator<Element> elementIterator = codes.iterator(); elementIterator.hasNext(); )
+ {
+ Element code = elementIterator.next();
+ code.attr( "class", code.attr( "class" ) + " nice-code" );
+ }
+
+ //res.appendChild( body.child( 1 ) );
+
+ Document res = new Document( "" );
+ res.appendChild( body.select( "div[id=main]" ).first() );
+
+ resp.getOutputStream().write( res.outerHtml().getBytes() );
+
+ //IOUtils.copy( is, resp.getOutputStream() );
+ //super.doGet( req, resp );
+ }
+}
<servlet>
<servlet-name>RestDocumentation</servlet-name>
- <servlet-class>org.apache.archiva.rest.docs.RestDocsServlet</servlet-class>
+ <servlet-class>org.apache.archiva.webapp.ui.services.docs.RestDocsServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
});
}
+ goToArchivaRestUiDoc=function(target){
+ $("#main-content" ).html(mediumSpinnerImg());
+ $.ajax({
+ url:"rest-docs/rest-docs-archiva-ui/"+target,
+ type:"get",
+ dataType: "html",
+ success: function(data){
+ $("#main-content" ).html($("#rest_docs").tmpl());
+ $("#main-content" ).find("#rest_docs_content" ).html(data);
+ prettyPrint();
+ }
+ });
+ }
+
+
+ displayArchivaRestUIDocs=function(){
+ window.sammyArchivaApplication.setLocation("#rest-docs-archiva-ui/index.html");
+ }
+
displayArchivaRestDocs=function(){
window.sammyArchivaApplication.setLocation("#rest-docs-archiva-rest-api/index.html");
}
goToArchivaRestDoc(target);
});
+ this.get("#rest-docs-archiva-ui/:target",function(){
+ var target=this.params.target;
+ $.log("archiva-rest-docs-ui, target:"+target);
+ goToArchivaRestUiDoc(target);
+ });
+
});
};
<div id="docs_rest_choice">
<ul>
<li><a onclick="displayArchivaRestDocs();">Archiva Rest Api Docs</a></li>
+ <li><a onclick="displayArchivaRestUIDocs();">Archiva Rest Api UI Docs</a></li>
</ul>
</div>
</div>
</script>
<script id="users_docs" type="text/html">
- rest docs
</script>
\ No newline at end of file