Sfoglia il codice sorgente

grafica per api

master
Mattia Gosetto 3 anni fa
parent
commit
1761ec106f
  1. 3
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/.settings/org.eclipse.wst.common.component
  2. 148
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java
  3. 31
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/api/v1/api.css
  4. 10300
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/bootstrap.css

3
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/.settings/org.eclipse.wst.common.component

@ -6,6 +6,9 @@
<dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar"> <dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="sicilia-sue-connector-portlet"/> <property name="context-root" value="sicilia-sue-connector-portlet"/>
<property name="java-output-path" value="/sicilia-sue-connector-portlet/docroot/WEB-INF/classes"/> <property name="java-output-path" value="/sicilia-sue-connector-portlet/docroot/WEB-INF/classes"/>
</wb-module> </wb-module>

148
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java

@ -35,64 +35,126 @@ public class ManualHtml extends Manual {
public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { public void run(HttpServletRequest request, HttpServletResponse response) throws Exception {
String cssFile = "/css/api/v1/api.css"; String cssFile = "/css/api/v1/api.css";
String bootstrapFile = "/css/bootstrap.css";
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
result.append("<!doctype html>").append("<meta charset=\"utf-8\">") result.append("<!doctype html>").append("<meta charset=\"utf-8\">")
.append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">") .append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">")
.append("<head><title>Manual</title>").append("<link rel=\"stylesheet\" href=\"") .append("<head><title>Manual</title>").append("<link rel=\"stylesheet\" href=\"")
.append(request.getContextPath()).append(cssFile).append("?v=") .append(request.getContextPath()).append(cssFile).append("?v=")
.append(new File(request.getServletContext().getRealPath(cssFile)).lastModified()).append("\">") .append(new File(request.getServletContext().getRealPath(cssFile)).lastModified()).append("\">")
.append("</head><body>"); .append("<link rel=\"stylesheet\" href=\"").append(request.getContextPath())
for (Command command : CommandList.getList()) { .append(bootstrapFile).append("\">")
result.append("<div class=\"command\">Comando: <b>/").append(command.getVerb()).append("</b>"); .append("</head><body class=''>");
if (command.isSecure()) { result.append("<div class='container'>");
result.append(" [T]"); result.append("<div class='row'>");
} result.append("<div class='col-12 pt-4'>");
result.append("<div class=\"description\">").append(command.getDescription()).append(".</div>"); result.append("<h1>Sicilia SUE API v1</h1>");
result.append("<div class=\"methods\">Metodi: ")
.append(StringUtils.join(command.getMethods(), StringPool.COMMA_AND_SPACE)).append("</div>");
result.append("<div class=\"parameters\">Parametri:");
List<Parameter> parameters = command.getInputParameters();
if (parameters.isEmpty()) {
result.append(" Nessuno</div>");
} else {
for (Parameter parameter : parameters) {
result.append("<div class=\"parameter\">").append(parameter.getName());
if (parameter.isRequired()) {
result.append(StringPool.STAR);
}
result.append(" (").append(parameter.getType().toString()).append(") - ")
.append(parameter.getDescription()).append("</div>");
}
result.append("</div>"); result.append("</div>");
} result.append("</div>");
parameters = command.getOutputParameters(); for (Command command : CommandList.getList()) {
if (!parameters.isEmpty()) { result.append("<div class='row'>");
result.append("<div class=\"returns\">Restituisce:"); result.append("<div class='col-12 mb-5'>");
for (Parameter parameter : parameters) { result.append("<h2 class='mb-3 mt-2'>/").append(command.getVerb());
result.append("<div class=\"parameter\">").append(parameter.getName()).append(" (") if (command.isSecure())
.append(parameter.getType().toString()).append(") - ").append(parameter.getDescription()); result.append(" <small>[T]</small>");
if (parameter.getType().equals(TYPES.ARRAY)) { result.append("</h2>");
for (Parameter subParameter : parameter.getSubParameters()) {
result.append("<div class=\"parameter\">").append(subParameter.getName()).append(" (") result.append("<p class='description text-secondary mb-3'>").append(command.getDescription()).append(".</p>");
.append(subParameter.getType().toString()).append(") - ")
.append(subParameter.getDescription()).append("</div>"); result.append("<div class='w-100 mb-2'>");
for(String cmd : command.getMethods() ){
result.append("<span class='badge badge-success mr-2 py-1 px-2' data-type='" + cmd.toLowerCase() + "'>"+cmd+"</span>");
} }
} result.append("</div>");
result.append("<div class='d-flex w-100 mb-3'><kbd class='container-fluid py-2'>");
result.append(getCurlExample(command, getBaseUrl(request)));
result.append("</kbd></div>");
List<Parameter> parameters = command.getInputParameters();
result.append("<div class='w-100 mb-3 mt-4'>");
result.append("<h4 class='w-100'>Parametri</h4>");
if (parameters.isEmpty()) {
result.append("<p>Nessuno</p>");
} else {
result.append("<table class='table table-sm table-bordered'>");
result.append("<thead class='thead-light font-weight-bold'>");
result.append("<tr>");
result.append("<th>Campo</th>");
result.append("<th>Obbligatorio</th>");
result.append("<th>Tipo</th>");
result.append("<th>Descrizione</th>");
result.append("</tr>");
result.append("</thead>");
result.append("<tbody>");
result.append(printTableParameters(parameters, 1));
result.append("</tbody>");
result.append("</table>");
}
result.append("</div>");
parameters = command.getOutputParameters();
result.append("<div class='w-100 mb-3 mt-4'>");
result.append("<h4 clsas='w-100'>Risposta</h4>");
if (parameters.isEmpty()) {
result.append("<p>Nessuno</p>");
} else {
result.append("<table class='table table-sm table-bordered'>");
result.append("<thead class='thead-light font-weight-bold'>");
result.append("<tr>");
result.append("<th>Campo</th>");
result.append("<th>Obbligatorio</th>");
result.append("<th>Tipo</th>");
result.append("<th>Descrizione</th>");
result.append("</tr>");
result.append("</thead>");
result.append("<tbody>");
result.append(printTableParameters(parameters, 1));
result.append("</tbody>");
result.append("</table>");
}
result.append("</div>");
result.append("</div>"); result.append("</div>");
}
result.append("</div>"); result.append("</div>");
} }
result.append("<div class=\"example\">Esempio:<pre>").append(getCurlExample(command, getBaseUrl(request))) result.append("<div class='row'>");
.append("</pre></div>"); result.append("<div class='col-12 pt-4'>");
result.append("</div>"); // class="command" result.append("<p>");
} result.append("<b>Note</b><br>[T] = Richiede token di autenticazione: header di richiesta \"");
result.append("<div class=\"notes\">Note:<br>[T] = Richiede token di autenticazione: header di richiesta \"") result.append(Parameters.X_AUTH_TOKEN).append("\" oppure parametro \"").append(Parameters.TOKEN);
.append(Parameters.X_AUTH_TOKEN).append("\" oppure parametro \"").append(Parameters.TOKEN) result.append("\"</p>");
.append("\"<br>* = Parametro obbligatorio</div>"); result.append("</div>");
result.append("</div>");
result.append("</div>");
result.append("</body></html>"); result.append("</body></html>");
setTextHtml(response); setTextHtml(response);
ServletResponseUtil.write(response, result.toString()); ServletResponseUtil.write(response, result.toString());
} }
private String printTableParameters(List<Parameter> parameters, int level){
StringBuilder result = new StringBuilder();
for (Parameter parameter : parameters) {
result.append("<tr>");
result.append("<td style='padding-left:" + (0.75 * level) + "rem'>" + parameter.getName() + "</td>");
result.append("<td>");
if (parameter.isRequired())
result.append("Sì");
else
result.append("No");
result.append("</td>");
result.append("<td>" + parameter.getType().toString() + "</td>");
result.append("<td>" + parameter.getDescription() + "</td>");
result.append("</tr>");
if (parameter.getType().equals(TYPES.ARRAY)) {
printTableParameters(parameter.getSubParameters(), level++);
}
}
return result.toString();
}
@Override @Override
public List<Parameter> getOutputParameters() { public List<Parameter> getOutputParameters() {

31
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/api/v1/api.css

@ -1,7 +1,7 @@
/* http://meyerweb.com/eric/tools/css/reset/ /* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126 v2.0 | 20110126
License: none (public domain) */ License: none (public domain) */
html, body, div, span, applet, object, iframe, /*html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code, a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp, del, dfn, em, img, ins, kbd, q, s, samp,
@ -21,7 +21,6 @@ time, mark, audio, video {
font: inherit; font: inherit;
vertical-align: baseline; vertical-align: baseline;
} }
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section { footer, header, hgroup, menu, nav, section {
display: block; display: block;
@ -43,28 +42,10 @@ q:before, q:after {
table { table {
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
} }*/
/* End reset.css */ /* End reset.css */
body {
margin: 10px; .badge.badge-success[data-type="post"] {
font-family: sans-serif; background-color: #007bff;
}
div {
margin-bottom: 5px;
}
b {
font-weight: bold;
}
pre {
background-color: #ccc;
width: fit-content;
padding: 10px;
border: 1px solid #999;
}
.command {
border-bottom: 1px solid #999;
padding: 10px 0;
}
.parameter {
margin-left: 40px;
} }

10300
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/bootstrap.css vendored

File diff soppresso perché troppo grande Load Diff
Caricamento…
Annulla
Salva