]> source.dussan.org Git - archiva.git/commitdiff
add rest doc for ui services
authorOlivier Lamy <olamy@apache.org>
Fri, 5 Oct 2012 15:48:08 +0000 (15:48 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 5 Oct 2012 15:48:08 +0000 (15:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1394607 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/docs/RestDocsServlet.java [deleted file]
archiva-modules/archiva-web/archiva-webapp-js/pom.xml
archiva-modules/archiva-web/archiva-webapp-js/src/enunciate/enunciate.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/docs/RestDocsServlet.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/WEB-INF/web.xml
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/docs.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/docs.html

diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/docs/RestDocsServlet.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/docs/RestDocsServlet.java
deleted file mode 100644 (file)
index 993adbe..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-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 );
-    }
-}
index 529764f877c998cff9e206d370d4b1ad2627cb8c..8c0eb6f3bac2f379767b40ccd96a850a586ed51a 100644 (file)
@@ -40,6 +40,8 @@
     <archiva.baseRestUrl />
     <rest.admin.pwd />
     <test.useTomcat>false</test.useTomcat>
+    <enunciate.docsDir>${project.build.outputDirectory}/rest-docs-archiva-ui</enunciate.docsDir>
+
   </properties>
 
   <dependencies>
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/enunciate/enunciate.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/enunciate/enunciate.xml
new file mode 100644 (file)
index 0000000..b76ab51
--- /dev/null
@@ -0,0 +1,43 @@
+<?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
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/docs/RestDocsServlet.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/docs/RestDocsServlet.java
new file mode 100644 (file)
index 0000000..020f171
--- /dev/null
@@ -0,0 +1,91 @@
+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 );
+    }
+}
index 7f5c8acb047629d0e80cc01fa2a9d8c7e688ab0e..eb89242f2e7d9d214713d355e37a97027e16f219 100644 (file)
@@ -81,7 +81,7 @@
 
   <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>
 
index 518e5fb9914fb944c2e1f1241e14acb303770a70..4dcd8e8a297c5826f9de4f6bfb9f36d68e2560b0 100644 (file)
@@ -38,6 +38,25 @@ define("archiva.docs",["jquery","i18n","jquery.tmpl","bootstrap"], function() {
     });
   }
 
+  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");
   }
index 9685961c51468fe83e8a1f396a62d69d394ef36c..712f6ce7df0f1cb24a2c91c233ee6bfa9c86de35 100644 (file)
@@ -637,6 +637,12 @@ function(jquery,ui,sammy,tmpl) {
           goToArchivaRestDoc(target);
         });
 
+        this.get("#rest-docs-archiva-ui/:target",function(){
+          var target=this.params.target;
+          $.log("archiva-rest-docs-ui, target:"+target);
+          goToArchivaRestUiDoc(target);
+        });
+
       });
   };
 
index c1e1a9f28d59228346b16e995c5305ce529a024c..b03cb0b30591bec57a35f432cd91d7c2b116884c 100644 (file)
@@ -25,6 +25,7 @@
       <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>
@@ -33,5 +34,4 @@
 </script>
 
 <script id="users_docs" type="text/html">
-         rest docs
 </script>
\ No newline at end of file