Refactoring relative paths PR#209.
- use html `base` tag containing the context path once instead inside every single URL/link. - update and enhance `nginx-contextpath` example - export javascript code into separated file - Add TODO note to javascript clipboard check (from PR#250) since Firefox and Safari do not support the current implementation
This commit is contained in:
committed by
PlantUML
parent
1245b15e01
commit
638724925e
@@ -6,8 +6,6 @@
|
||||
// properties
|
||||
boolean showSocialButtons = (boolean)request.getAttribute("showSocialButtons");
|
||||
boolean showGithubRibbon = (boolean)request.getAttribute("showGithubRibbon");
|
||||
// URL base
|
||||
String contextpath = request.getAttribute("contextpath").toString();
|
||||
// image URLs
|
||||
boolean hasImg = (boolean)request.getAttribute("hasImg");
|
||||
String imgurl = request.getAttribute("imgurl").toString();
|
||||
@@ -23,31 +21,17 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<base href="<%= request.getContextPath() %>/" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="expires" content="0" />
|
||||
<meta http-equiv="pragma" content="no-cache" />
|
||||
<meta http-equiv="cache-control" content="no-cache, must-revalidate" />
|
||||
<link rel="icon" href="<%= contextpath %>/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="shortcut icon" href="<%= contextpath %>/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="stylesheet" href="<%= contextpath %>/plantuml.css" />
|
||||
<link rel="stylesheet" href="<%= contextpath %>/webjars/codemirror/5.63.0/lib/codemirror.css" />
|
||||
<script src="<%= contextpath %>/webjars/codemirror/5.63.0/lib/codemirror.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
// load CodeMirror
|
||||
document.myCodeMirror = CodeMirror.fromTextArea(
|
||||
document.getElementById("text"),
|
||||
{ lineNumbers: true,
|
||||
extraKeys: {Tab: false, "Shift-Tab": false}
|
||||
}
|
||||
);
|
||||
// resolve relative path inside url input once
|
||||
const url = document.getElementById("url");
|
||||
if (!url.value.startsWith("http")) {
|
||||
url.value = window.location.origin + url.value;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
|
||||
<link rel="stylesheet" href="plantuml.css" />
|
||||
<link rel="stylesheet" href="webjars/codemirror/5.63.0/lib/codemirror.css" />
|
||||
<script src="plantuml.js"></script>
|
||||
<script src="webjars/codemirror/5.63.0/lib/codemirror.js"></script>
|
||||
<title>PlantUMLServer</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -64,7 +48,7 @@
|
||||
</div>
|
||||
<div id="content">
|
||||
<%-- CONTENT --%>
|
||||
<form method="post" accept-charset="utf-8" action="<%= contextpath %>/form">
|
||||
<form method="post" accept-charset="utf-8" action="form">
|
||||
<p> <label for="text">UML Editor Content</label>
|
||||
<textarea id="text" name="text" cols="120" rows="10"><%= net.sourceforge.plantuml.servlet.PlantUmlServlet.stringToHTMLString(decoded) %></textarea>
|
||||
<input type="submit" value="Submit" title="Submit Code and generate diagram"/>
|
||||
@@ -73,7 +57,7 @@
|
||||
</form>
|
||||
<hr/>
|
||||
<p>You can enter here a previously generated URL:</p>
|
||||
<form method="post" action="<%= contextpath %>/form">
|
||||
<form method="post" action="form">
|
||||
<p> <label for="url">previously generated URL</label>
|
||||
<input id="url" name="url" type="text" size="150" value="<%= imgurl %>" />
|
||||
<br/>
|
||||
@@ -103,33 +87,6 @@
|
||||
</p>
|
||||
<% } %>
|
||||
</div>
|
||||
<script>
|
||||
var clipboard_write=false;
|
||||
var clipboard_read=false;
|
||||
|
||||
if (navigator.permissions){
|
||||
navigator.permissions.query({ name: "clipboard-write" }).then((result) => {
|
||||
if (result.state == "granted" || result.state == "prompt") {
|
||||
clipboard_write = true;
|
||||
}
|
||||
});
|
||||
navigator.permissions.query({ name: "clipboard-read" }).then((result) => {
|
||||
if (result.state == "granted" || result.state == "prompt") {
|
||||
clipboard_read = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function copyToClipboard(fieldid, fielddesc) {
|
||||
if (clipboard_write == true){
|
||||
var copyText = '';
|
||||
copyText = document.getElementById(fieldid).value;
|
||||
navigator.clipboard.writeText(document.getElementById(fieldid).value)
|
||||
alert(fielddesc + " copied to clipboard");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<%-- FOOTER --%>
|
||||
<%@ include file="footer.jspf" %>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user