Fix url for static

This commit is contained in:
Paulo Gustavo Veiga 2022-01-14 16:39:20 -08:00
parent 202b3dd285
commit 4668cba3bf
12 changed files with 14 additions and 219 deletions

View File

@ -101,8 +101,7 @@ admin.user = admin@wisemapping.org
# Base URL where WiseMapping is deployed. By default, It will be automatically inferred. # Base URL where WiseMapping is deployed. By default, It will be automatically inferred.
# If you are planning to put wisemapping behind an Apache using an Apache Proxy setup, you must enable this property. # If you are planning to put wisemapping behind an Apache using an Apache Proxy setup, you must enable this property.
#site.baseurl = http://example.com:8080/wisemapping site.static.js.url = /static
# Site Homepage URL. This will be used as URL for homepage location. # Site Homepage URL. This will be used as URL for homepage location.
site.homepage = c/home site.homepage = c/home

View File

@ -1,41 +0,0 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* 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.
*/
package com.wisemapping.exceptions;
import org.jetbrains.annotations.NotNull;
public class ImportUnexpectedException
extends WiseMappingException {
private byte[] freemindXml;
public ImportUnexpectedException(@NotNull Throwable e, @NotNull byte[] map) {
super("Unexpected expected error importing freemind. Please, try latter.", e);
this.freemindXml = map;
}
public ImportUnexpectedException(String str, Exception e) {
super(str);
initCause(e);
}
public byte[] getFreemindXml() {
return freemindXml;
}
}

View File

@ -20,13 +20,13 @@ package com.wisemapping.filter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter { public class RequestPropertiesInterceptor implements HandlerInterceptor {
@Value("${google.analytics.enabled}") @Value("${google.analytics.enabled}")
private Boolean analyticsEnabled; private Boolean analyticsEnabled;
@ -54,6 +54,7 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
@Value("${security.type}") @Value("${security.type}")
private String securityType; private String securityType;
@Override
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
request.setAttribute("google.analytics.enabled", analyticsEnabled); request.setAttribute("google.analytics.enabled", analyticsEnabled);

View File

@ -18,72 +18,6 @@
package com.wisemapping.filter; package com.wisemapping.filter;
import com.wisemapping.util.Browser; public interface SupportedUserAgent{
import com.wisemapping.util.UserAgent; String USER_AGENT_HEADER = "User-Agent";
import com.wisemapping.util.Version;
import org.jetbrains.annotations.NotNull;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
public class SupportedUserAgent implements Serializable {
public static final String USER_AGENT_HEADER = "User-Agent";
transient private UserAgent userAgent;
private final String header;
private SupportedUserAgent(@NotNull final String header) {
this.header = header;
}
public static SupportedUserAgent create(@NotNull final HttpServletRequest request) {
return new SupportedUserAgent(request.getHeader(USER_AGENT_HEADER));
}
public boolean isBrowserSupported() {
// final UserAgent userAgent = this.getUserAgent();
// final Browser browser = userAgent.getBrowser();
// final OperatingSystem os = userAgent.getOperatingSystem();
// final Version version = userAgent.getBrowserVersion();
// final int majorVersion = version != null ? Integer.parseInt(version.getMajorVersion()) : -1;
//
// boolean result = browser == Browser.FIREFOX && majorVersion >= 10;
// result = result || browser == Browser.FIREFOX2 && majorVersion >= 17;
// result = result || browser == Browser.FIREFOX3 && majorVersion >= 29;
// result = result || browser == Browser.FIREFOX4 && majorVersion >= 40;
// result = result || browser == Browser.IE8 || browser == Browser.IE9 || browser == Browser.IE11 ;
// result = result || browser == Browser.IE && majorVersion >= 8;
// result = result || browser == Browser.OPERA10 && majorVersion >= 11;
// result = result || browser == Browser.CHROME && majorVersion >= 18;
// result = result || browser == Browser.SAFARI5;
// result = result || browser == Browser.SAFARI && majorVersion >= 5;
// result = result || browser == Browser.MOBILE_SAFARI;
// result = result || os.isMobileDevice() && (os == OperatingSystem.ANDROID || os == OperatingSystem.iOS4_IPHONE);
// result = result || browser.getBrowserType() == BrowserType.ROBOT;
return true;
}
@NotNull
synchronized
private UserAgent getUserAgent() {
if (userAgent == null) {
userAgent = new UserAgent(header);
}
return userAgent;
}
public boolean needsGCF() {
final UserAgent userAgent = this.getUserAgent();
final Browser browser = userAgent.getBrowser();
final Version version = userAgent.getBrowserVersion();
return (browser == Browser.IE8 || browser == Browser.IE && Integer.parseInt(version.getMajorVersion()) == 8) && !header.contains("chromeframe");
}
public static SupportedUserAgent create(@NotNull final String userAgent) {
return new SupportedUserAgent(userAgent);
}
} }

View File

@ -21,6 +21,7 @@ package com.wisemapping.filter;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.i18n.SessionLocaleResolver; import org.springframework.web.servlet.i18n.SessionLocaleResolver;
@ -29,8 +30,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.util.Locale; import java.util.Locale;
public class UserLocaleInterceptor extends HandlerInterceptorAdapter { public class UserLocaleInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
final HttpSession session = request.getSession(false); final HttpSession session = request.getSession(false);

View File

@ -19,7 +19,6 @@
package com.wisemapping.rest; package com.wisemapping.rest;
import com.wisemapping.exceptions.ClientException; import com.wisemapping.exceptions.ClientException;
import com.wisemapping.exceptions.ImportUnexpectedException;
import com.wisemapping.exceptions.Severity; import com.wisemapping.exceptions.Severity;
import com.wisemapping.mail.NotificationService; import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.User; import com.wisemapping.model.User;
@ -64,15 +63,6 @@ public class BaseController {
return new RestErrors(ex.getMessage(), Severity.WARNING); return new RestErrors(ex.getMessage(), Severity.WARNING);
} }
@ExceptionHandler(ImportUnexpectedException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public RestErrors handleImportErrors(@NotNull ImportUnexpectedException ex, @NotNull HttpServletRequest request) {
final User user = Utils.getUser();
notificationService.reportJavaException(ex, user, new String(ex.getFreemindXml()), request);
return new RestErrors(ex.getMessage(), Severity.SEVERE);
}
@ExceptionHandler(ValidationException.class) @ExceptionHandler(ValidationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
public RestErrors handleValidationErrors(@NotNull ValidationException ex) { public RestErrors handleValidationErrors(@NotNull ValidationException ex) {

View File

@ -60,19 +60,6 @@ public class MindmapController {
return "mindmapPrint"; return "mindmapPrint";
} }
@RequestMapping(value = "maps/{id}/share")
public String showSharePage(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException {
final Mindmap mindmap = findMindmap(id);
model.addAttribute("mindmap", mindmap);
return "mindmapShare";
}
@RequestMapping(value = "maps/{id}/sharef")
public String showSharePageFull(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException {
showSharePage(id, model);
return "mindmapShareFull";
}
@RequestMapping(value = "maps/") @RequestMapping(value = "maps/")
public String showListPage(@NotNull Model model) { public String showListPage(@NotNull Model model) {
return "mindmapList"; return "mindmapList";

View File

@ -99,7 +99,7 @@ admin.user = admin@wisemapping.org
site.homepage = c/home site.homepage = c/home
# Font end static content can be deployed externally to the web app. Uncomment here and specify the url base location. # Font end static content can be deployed externally to the web app. Uncomment here and specify the url base location.
# site.static.js.url = http://www.example.com/ site.static.js.url = /static
################################################################################## ##################################################################################
# Google Analytics Settings # Google Analytics Settings

View File

@ -72,7 +72,7 @@
</div> </div>
</c:if> </c:if>
<script type="text/javascript" src="<c:out value="${requestScope['site.static.js.url']}"/>loader.js"></script> <script type="text/javascript" src="${requestScope['site.static.js.url']}/mindplot/loader.js"></script>
</body> </body>

View File

@ -34,7 +34,7 @@
<span class="title"><spring:message code="DESCRIPTION"/>:</span><span><c:out value="${mindmap.title}"/></span> <span class="title"><spring:message code="DESCRIPTION"/>:</span><span><c:out value="${mindmap.title}"/></span>
</div> </div>
<script type="text/javascript" src="<c:out value="${requestScope['site.static.js.url']}"/>loader.js"></script> <script type="text/javascript" src="${requestScope['site.static.js.url']}/mindplot/loader.js"></script>
<div id="floating-panel"> <div id="floating-panel">
<div id="zoom-button"> <div id="zoom-button">

View File

@ -35,8 +35,8 @@
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div> <div id="root"></div>
<script type="text/javascript" src="<c:out value="${requestScope['site.static.js.url']}"/>vendors.bundle.js"></script> <script type="text/javascript" src="${requestScope['site.static.js.url']}/webapp/vendors.bundle.js"></script>
<script type="text/javascript" src="<c:out value="${requestScope['site.static.js.url']}"/>app.bundle.js"></script> <script type="text/javascript" src="${requestScope['site.static.js.url']}/webapp/app.bundle.js"></script>
</body> </body>
</html> </html>

View File

@ -1,77 +0,0 @@
package com.wisemapping.test.model;
import com.wisemapping.filter.SupportedUserAgent;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test(enabled=false)
public class UserAgentTest {
public void isBrowserSupported() {
final SupportedUserAgent firefox15 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15");
Assert.assertEquals(firefox15.isBrowserSupported(), true);
final SupportedUserAgent firefox9 = SupportedUserAgent.create("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a2) Gecko/20111101 Firefox/9.0a2");
Assert.assertEquals(firefox9.isBrowserSupported(), false);
final SupportedUserAgent chrome18 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0");
Assert.assertEquals(chrome18.isBrowserSupported(), true);
final SupportedUserAgent chrome21 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1");
Assert.assertEquals(chrome21.isBrowserSupported(), true);
final SupportedUserAgent ie10 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)");
Assert.assertEquals(ie10.isBrowserSupported(), true);
final SupportedUserAgent ie10_6 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0");
Assert.assertEquals(ie10_6.isBrowserSupported(), true);
final SupportedUserAgent ie9 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; Tablet PC 2.0)");
Assert.assertEquals(ie9.isBrowserSupported(), true);
final SupportedUserAgent ie8 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)");
Assert.assertEquals(ie8.isBrowserSupported(), true);
final SupportedUserAgent safari = SupportedUserAgent.create("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; da-dk) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1");
Assert.assertEquals(safari.isBrowserSupported(), true);
final SupportedUserAgent safari6 = SupportedUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");
Assert.assertEquals(safari6.isBrowserSupported(), true);
final SupportedUserAgent safariIpad = SupportedUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");
Assert.assertEquals(safariIpad.isBrowserSupported(), true);
final SupportedUserAgent googlebot = SupportedUserAgent.create("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
Assert.assertEquals(googlebot.isBrowserSupported(), true);
final SupportedUserAgent mediapartners = SupportedUserAgent.create("Mediapartners-Google/2.1");
Assert.assertEquals(mediapartners.isBrowserSupported(), true);
final SupportedUserAgent ie11 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko");
Assert.assertEquals(ie11.isBrowserSupported(), true);
final SupportedUserAgent firefox20 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20121215 Firefox/20.0 AppEngine-Google; (+http://code.google.com/appengine; appid: slubuntuk)");
Assert.assertEquals(firefox20.isBrowserSupported(), true);
final SupportedUserAgent firefox30 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0");
Assert.assertEquals(firefox30.isBrowserSupported(), true);
}
public void isGCFRequired() {
final SupportedUserAgent ie10 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)");
Assert.assertEquals(ie10.needsGCF(), false);
final SupportedUserAgent ie8 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)");
Assert.assertEquals(ie8.needsGCF(), true);
final SupportedUserAgent ie8WithGCF = SupportedUserAgent.create("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; SV1) chromeframe/11.0.660.0");
Assert.assertEquals(ie8WithGCF.needsGCF(), false);
}
}