-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML UI for API and some fixes for HTML pages links in proxied servers
- Loading branch information
Showing
16 changed files
with
395 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/community/wfs3/src/main/java/org/geoserver/wfs3/response/OpenAPIHTMLResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved | ||
* This code is licensed under the GPL 2.0 license, available at the root | ||
* application directory. | ||
*/ | ||
package org.geoserver.wfs3.response; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import org.geoserver.catalog.ResourceInfo; | ||
import org.geoserver.config.GeoServer; | ||
import org.geoserver.platform.GeoServerResourceLoader; | ||
|
||
/** Returns a swagger-UI HTML wrapper for the JSON response */ | ||
public class OpenAPIHTMLResponse extends AbstractHTMLResponse { | ||
|
||
public OpenAPIHTMLResponse(GeoServerResourceLoader loader, GeoServer geoServer) { | ||
super(OpenAPI.class, loader, geoServer); | ||
} | ||
|
||
@Override | ||
protected String getTemplateName(Object value) { | ||
return "api.ftl"; | ||
} | ||
|
||
@Override | ||
protected ResourceInfo getResource(Object value) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/community/wfs3/src/main/resources/org/geoserver/wfs3/response/api.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!-- HTML for static distribution bundle build --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Swagger UI</title> | ||
<link rel="stylesheet" type="text/css" href="${resourceLink('swagger-ui/swagger-ui.css')}" > | ||
<link rel="icon" type="image/png" href="${resourceLink('swagger-ui/favicon-32x32.png')}" sizes="32x32" /> | ||
<link rel="icon" type="image/png" href="${resourceLink('swagger-ui/favicon-16x16.png')}" sizes="16x16" /> | ||
<style> | ||
html | ||
{ | ||
box-sizing: border-box; | ||
overflow: -moz-scrollbars-vertical; | ||
overflow-y: scroll; | ||
} | ||
*, | ||
*:before, | ||
*:after | ||
{ | ||
box-sizing: inherit; | ||
} | ||
body | ||
{ | ||
margin:0; | ||
background: #fafafa; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="swagger-ui"></div> | ||
|
||
<script src="${resourceLink('swagger-ui/swagger-ui-bundle.js')}"> </script> | ||
<script src="${resourceLink('swagger-ui/swagger-ui-standalone-preset.js')}"> </script> | ||
<script> | ||
window.onload = function() { | ||
// Build a system | ||
const ui = SwaggerUIBundle({ | ||
url: "${serviceLink('wfs3/api?f=json')}", | ||
dom_id: '#swagger-ui', | ||
deepLinking: true, | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
plugins: [ | ||
SwaggerUIBundle.plugins.DownloadUrl | ||
], | ||
layout: "StandaloneLayout" | ||
}) | ||
window.ui = ui | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/community/wfs3/src/main/resources/org/geoserver/wfs3/response/common-header.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<#setting locale="en_US"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="${baseURL}wfs3css/blueprint/screen.css" type="text/css" media="screen, projection" /> | ||
<link rel="stylesheet" href="${baseURL}wfs3css/blueprint/print.css" type="text/css" media="print" /> | ||
<link rel="stylesheet" href="${baseURL}wfs3css/geoserver.css" type="text/css" media="screen, projection" /> | ||
<link rel="stylesheet" href="${baseURL}wfs3css/blueprint/ie.css" type="text/css" media="screen, projection" /> | ||
<link rel="stylesheet" href="${resourceLink("wfs3css/blueprint/screen.css")}" type="text/css" media="screen, projection" /> | ||
<link rel="stylesheet" href="${resourceLink("wfs3css/blueprint/print.css")}" type="text/css" media="print" /> | ||
<link rel="stylesheet" href="${resourceLink("wfs3css/geoserver.css")}" type="text/css" media="screen, projection" /> | ||
<link rel="stylesheet" href="${resourceLink("wfs3css/blueprint/ie.css")}" type="text/css" media="screen, projection" /> | ||
</head> | ||
<body> | ||
<div id="header"> | ||
<a href="${baseURL}wfs3"></a> | ||
<a href="${serviceLink("wfs3")}"></a> | ||
</div> | ||
<div id="content"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/community/wfs3/src/main/resources/swagger-ui/oauth2-redirect.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<body onload="run()"> | ||
</body> | ||
</html> | ||
<script> | ||
'use strict'; | ||
function run () { | ||
var oauth2 = window.opener.swaggerUIRedirectOauth2; | ||
var sentState = oauth2.state; | ||
var redirectUrl = oauth2.redirectUrl; | ||
var isValid, qp, arr; | ||
|
||
if (/code|token|error/.test(window.location.hash)) { | ||
qp = window.location.hash.substring(1); | ||
} else { | ||
qp = location.search.substring(1); | ||
} | ||
|
||
arr = qp.split("&") | ||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';}) | ||
qp = qp ? JSON.parse('{' + arr.join() + '}', | ||
function (key, value) { | ||
return key === "" ? value : decodeURIComponent(value) | ||
} | ||
) : {} | ||
|
||
isValid = qp.state === sentState | ||
|
||
if (( | ||
oauth2.auth.schema.get("flow") === "accessCode"|| | ||
oauth2.auth.schema.get("flow") === "authorizationCode" | ||
) && !oauth2.auth.code) { | ||
if (!isValid) { | ||
oauth2.errCb({ | ||
authId: oauth2.auth.name, | ||
source: "auth", | ||
level: "warning", | ||
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server" | ||
}); | ||
} | ||
|
||
if (qp.code) { | ||
delete oauth2.state; | ||
oauth2.auth.code = qp.code; | ||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl}); | ||
} else { | ||
let oauthErrorMsg | ||
if (qp.error) { | ||
oauthErrorMsg = "["+qp.error+"]: " + | ||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") + | ||
(qp.error_uri ? "More info: "+qp.error_uri : ""); | ||
} | ||
|
||
oauth2.errCb({ | ||
authId: oauth2.auth.name, | ||
source: "auth", | ||
level: "error", | ||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server" | ||
}); | ||
} | ||
} else { | ||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl}); | ||
} | ||
window.close(); | ||
} | ||
</script> |
93 changes: 93 additions & 0 deletions
93
src/community/wfs3/src/main/resources/swagger-ui/swagger-ui-bundle.js
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.