Add zoom support for embedded maps.

Add new url to embedded maps
This commit is contained in:
Paulo Gustavo Veiga 2012-06-03 20:23:31 -03:00
parent 3907e04ff6
commit 88b0efa859
20 changed files with 134 additions and 277 deletions

View File

@ -40,12 +40,11 @@ div#zoomIn {
}
#zoomOut {
background: url(../images/zoom-out.png) no-repeat left top;;
background: url(../images/zoom-out.png) no-repeat left top;
margin-top: 10px;
margin-left: 5px;
}
.button {
width: 20px;
height: 20px;

View File

@ -1,78 +0,0 @@
/*
* Copyright [2011] [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.controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wisemapping.model.MindMap;
import com.wisemapping.filter.UserAgent;
import java.lang.reflect.UndeclaredThrowableException;
public class EmbeddedViewController extends BaseMultiActionController {
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView view;
try {
final MindMap mindmap = this.getMindmapFromRequest(httpServletRequest);
if (mindmap == null) {
throw new IllegalStateException("Map could not be found");
}
final String fullViewStr = httpServletRequest.getParameter("fullView");
final boolean fullView = Boolean.parseBoolean(fullViewStr);
final UserAgent userAgent = UserAgent.create(httpServletRequest);
if (userAgent.isBrowserSupported()) {
view = new ModelAndView("embeddedView");
view.addObject("mindmap", mindmap);
final String xmlMap = mindmap.getXmlAsJsLiteral();
view.addObject("mapXml", xmlMap);
final String zoomStr = httpServletRequest.getParameter("zoom");
float zoom = 1;
if(zoomStr!=null)
{
try {
zoom = Float.parseFloat(zoomStr);
} catch (NumberFormatException e) {
}
}
view.addObject("zoom",zoom);
} else {
view = new ModelAndView("embeddedViewNotSupported");
}
view.addObject("fullView", fullView);
} catch (UndeclaredThrowableException e) {
// Security exception ....
view = new ModelAndView("embeddedViewError");
}
return view;
}
}

View File

@ -55,7 +55,6 @@ public class UserAgent implements Serializable {
firefox = UserAgent.create("Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.12) Gecko/20080129 Iceweasel/2.0.0.12 (Debian-2.0.0.12-0etch1)");
assert firefox.isBrowserSupported();
}
@ -323,10 +322,10 @@ public class UserAgent implements Serializable {
public boolean isBrowserSupported() {
// Is it a supported browser ?.
final UserAgent.Product product = this.getProduct();
boolean result = product == UserAgent.Product.FIREFOX && this.isVersionGreatedOrEqualThan(3, 0);
boolean result = product == UserAgent.Product.FIREFOX && this.isVersionGreatedOrEqualThan(10, 0);
result = result || product == UserAgent.Product.EXPLORER && this.isVersionGreatedOrEqualThan(7, 0) && this.getOs() == UserAgent.OS.WINDOWS;
result = result || product == UserAgent.Product.OPERA && this.isVersionGreatedOrEqualThan(9, 0);
result = result || product == UserAgent.Product.CHROME && this.isVersionGreatedOrEqualThan(8, 0);
result = result || product == UserAgent.Product.OPERA && this.isVersionGreatedOrEqualThan(11, 0);
result = result || product == UserAgent.Product.CHROME && this.isVersionGreatedOrEqualThan(19, 0);
result = result || product == UserAgent.Product.SAFARI && this.isVersionGreatedOrEqualThan(5, 0);
return result;
}

View File

@ -23,6 +23,13 @@ import java.util.List;
@Controller
public class MindmapController {
private String baseUrl;
MindmapController() {
}
@Autowired
private MindmapService mindmapService;
@ -100,6 +107,17 @@ public class MindmapController {
return view;
}
@RequestMapping(value = "maps/{id}/embed")
public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom, @NotNull HttpServletRequest request) {
ModelAndView view;
final UserAgent userAgent = UserAgent.create(request);
final MindMap mindmap = mindmapService.getMindmapById(id);
view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap);
view.addObject("user", Utils.getUser());
view.addObject("zoom", zoom == null ? 1 : zoom);
return view;
}
@RequestMapping(value = "collaborator")
public ModelAndView showCollaborator(@RequestParam(required = true) long mapId) {
final MindMapBean modelObject = findMindmapBean(mapId);

View File

@ -20,7 +20,6 @@ package com.wisemapping.rest;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.exporter.ExportFormat;
import com.wisemapping.importer.ImportFormat;
import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException;
@ -33,10 +32,8 @@ import com.wisemapping.rest.model.RestMindmapInfo;
import com.wisemapping.rest.model.RestMindmapList;
import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService;
import com.wisemapping.service.UserService;
import com.wisemapping.validator.MapInfoValidator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
@ -45,7 +42,6 @@ import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;

View File

@ -80,3 +80,6 @@ registration.recaptcha.publicKey =
# Site administration user. This user will have special permissions for operations such as removing users, set password
# etc.
admin.user = admin@wisemapping.org
# Site URL. This url will be used during sharing emails and public views.
site.baseurl = http://localhost:8080

View File

@ -309,4 +309,5 @@ NO_PRODUCTION_DATABASE_CONFIGURED=Note: Although HSQLDB is bundled with WiseMapp
IMPORT=Import
EMBEDDED_MAP_SIZE=* Note: You can change embedded map size modifying 'height' and 'width' style properties. You can also adjust the zoom factor modifying 'zoom' parameter from the URL.
EXPORT_FORMAT_RESTRICTIONS=Important: Exporting to Image, PDF or SVG is available only in the editor toolbar only.\
EXPORT_FORMAT_RESTRICTIONS=Important: Exporting to Image, PDF or SVG is available only in the editor toolbar only.
STARRED=Starred

View File

@ -239,7 +239,6 @@ NEWS_DESC_FREEMIND=Ahora, puede importar y exportar sus mapas con formato de Fre
NEWS_TITLE_KEYBOARD_NAVIGATION=La creacion de mapas mentales es mas facil que nunca!
NEWS_DESC_KEYBOARD_NAVIGATION=WiseMapping lo deja crear sus mapas mentales utilzando solo el teclado.
MOST_POPULAR_MAPS=Los mapas mas populares
JOIN_WISEMAPPING=Utilice WiseMapping
IT_IS_FREE=Es gratis!
CREATE_EDIT_ACCESS_FROM_ANYWHERE=Crear, editar y acceder a sus mapas mentales desde cualquier lugar de Internet
@ -258,4 +257,5 @@ SEARCH_PUBLIC=Buscar mapas públicos
UNDO_EDITION=Undo Edition
REDO_EDITION=Redo Edition
REVERT=revert
EXPORT_FORMAT_RESTRICTIONS=Important: Exporting to Image, PDF or SVG is available only in the editor toolbar only.\
EXPORT_FORMAT_RESTRICTIONS=Important: Exporting to Image, PDF or SVG is available only in the editor toolbar.
STARRED=Starred

View File

@ -248,3 +248,4 @@ EMBEDDED_MAP_SIZE=* Note
EDITOR_LINKS=Mind Map feature
NEWS_ADD_ICON=Mind Map feature
EXPORT_FORMAT_RESTRICTIONS=Important: Exporting to Image, PDF or SVG is available only in the editor toolbar only.\
STARRED=Starred

View File

@ -8,11 +8,9 @@
<definition name="homepage" page="/jsp/homepage.jsp"/>
<definition name="mindmapList" page="/jsp/mindmapList.jsp"/>
<definition name="embeddedView" page="/jsp/embeddedView.jsp"/>
<definition name="embeddedViewNotSupported" page="/jsp/embeddedViewNotSupported.jsp"/>
<definition name="mindmapEmbedded" page="/jsp/mindmapEmbed.jsp"/>
<definition name="mindmapEditor" page="/jsp/mindmapEditor.jsp"/>
<definition name="mindmapCooker" page="/jsp/mindmapCooker.jsp"/>
<definition name="embeddedViewError" page="/jsp/embeddedViewError.jsp"/>
<definition name="mindmapPrint" page="/jsp/mindmapPrint.jsp"/>
<!-- Template Declaration -->

View File

@ -24,15 +24,15 @@
<sec:http pattern="/c/login" security="none"/>
<sec:http pattern="/c/userregistration" security="none"/>
<sec:http pattern="/c/activation" security="none"/>
<sec:http pattern="/c/forgotpassword" security="none"/>
<sec:http pattern="/c/home" security="none"/>
<sec:http pattern="/c/maps/*/embed" security="none"/>
<sec:http pattern="/c/activation" security="none"/>
<sec:http pattern="/c/try" security="none"/>
<sec:http pattern="/c/search" security="none"/>
<sec:http pattern="/c/keyboard" security="none"/>
<sec:http pattern="/c/embeddedview" security="none"/>
<sec:http pattern="/c/publicview" security="none"/>
<sec:http pattern="/c/termsOfUse" security="none"/>
<sec:http pattern="/c/keyboard" security="none"/>
<sec:http use-expressions="true" create-session="never" pattern="/service/**">
<sec:intercept-url pattern="/service/admin/users/**" access="isAuthenticated() and hasRole('ROLE_ADMIN')"/>

View File

@ -136,11 +136,6 @@
<property name="mindmapService" ref="mindmapService"/>
</bean>
<bean id="embeddedView" class="com.wisemapping.controller.EmbeddedViewController">
<property name="methodNameResolver" ref="paramResolverByAction"/>
<property name="mindmapService" ref="mindmapService"/>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
@ -152,7 +147,6 @@
<props>
<!-- Review -->
<prop key="publicView">publicView</prop>
<prop key="embeddedView">embeddedView</prop>
<!-- Forms based -->
<prop key="userRegistration">userController</prop>

View File

@ -1,106 +0,0 @@
<!DOCTYPE HTML>
<%@ include file="/jsp/init.jsp" %>
<html>
<head>
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="../css/embedded.css"/>
<script type='text/javascript' src='../js/mootools-core.js'></script>
<script type='text/javascript' src='../js/mootools-more.js'></script>
<script type='text/javascript' src='../js/core.js'></script>
<script type="text/javascript">
var mapId = '${mindmap.id}';
var mapXml = '${mapXml}';
var mindReady = false;
$(document).addEvent('loadcomplete', function(resource) {
mindReady = resource == 'mind' ? true : mindReady;
if (mindReady) {
var editorProperties = {zoom:${zoom},saveOnLoad:true,collab:'standalone',readOnly:true};
designer = buildDesigner(editorProperties);
var parser = new DOMParser();
var domDocument = parser.parseFromString(mapXml, "text/xml");
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(domDocument);
var mindmap = serializer.loadFromDom(domDocument, mapId);
// Now, load the map ...
designer.loadMap(mindmap);
// If not problem has arisen, close the dialog ...
if (!window.hasUnexpectedErrors) {
waitDialog.deactivate();
}
$('zoomIn').addEvent('click', function() {
designer.zoomIn();
});
$('zoomOut').addEvent('click', function() {
designer.zoomOut();
});
}
});
</script>
</head>
<body>
<div id="waitDialog" style="display:none">
<div id="waitingContainer">
<div class="loadingIcon"></div>
<div class="loadingText">
Loading ...
</div>
</div>
</div>
<div id="errorDialog" style="display:none">
<div id="errorContainer">
<div class="loadingIcon"></div>
<div class="loadingText">
Unexpected error loading your map :(
</div>
</div>
</div>
<script type="text/javascript">
var waitDialog = new core.WaitDialog();
waitDialog.activate(true, $("waitDialog"));
$(window).addEvent("error", function(event) {
// Show error dialog ...
waitDialog.changeContent($("errorDialog"), false);
return false;
});
</script>
<div id="mapContainer">
<div id="mindplot"></div>
<div id="embFooter">
<a href="${pageContext.request.contextPath}/c/home" target="new">
<div id="logo"></div>
</a>
<div id="zoomIn" class="button"></div>
<div id="zoomOut" class="button"></div>
<div id="mapDetails">
<%--<span class="title"><spring:message code="CREATOR"/>:</span><span>${mindmap.creator}</span>--%>
<span class="title"><spring:message code="DESCRIPTION"/>:</span><span>${mindmap.title}</span>
</div>
</div>
</div>
<script type="text/javascript" src="../js/editor.js"></script>
</body>
</html>

View File

@ -1,35 +0,0 @@
<!DOCTYPE HTML>
<%@ include file="/jsp/init.jsp" %>
<html>
<head>
<title>
<spring:message code="NO_ENOUGH_PERMISSIONS"/>
</title>
<meta http-equiv="Content-type" value="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../css/embedded.css">
<link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon">
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="../css/wisehomeOldIE.css"/>
<![endif]-->
</head>
<body>
<div class="pageBodyContent" style="padding:40px;padding-top:100px;">
<h1>
<spring:message code="NO_ENOUGH_PERMISSIONS"/>
</h1>
<p>
<spring:message code="NO_ENOUGH_PERMISSIONS_DETAILS"/>
</p>
</div>
<div id="embFooter">
<a href="${pageContext.request.contextPath}/c/home" target="new">
<div id="logo"></div>
</a>
</div>
</body>
</html>

View File

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<%@ include file="/jsp/init.jsp" %>
<html>
<head>
<meta http-equiv="Content-type" value="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../css/embedded.css">
</head>
<body>
<div id="mapContainer">
<spring:message code="BROWSER_NOT_SUPPOERTED"/>
<spring:message code="CHECK_BROWSERS"/><a href="www.wisemapping.com">www.wisemapping.com</a>
</div>
</body>
</html>

View File

@ -17,7 +17,7 @@
<li><strong><spring:message code="CREATION_TIME"/>:</strong> ${wisemapDetail.creationTime}</li>
<li><strong><spring:message code="LAST_UPDATE"/>:</strong> ${wisemapDetail.lastEditTime}</li>
<li><strong><spring:message code="LAST_UPDATE_BY"/>:</strong> ${wisemapDetail.lastEditor}</li>
<li><strong> <spring:message code="TAGS"/>:</strong> ${wisemapDetail.tags}</li>
<li><strong> <spring:message code="STARRED"/>:</strong> ${wisemapDetail.starred}</li>
</ul>
</div>
<div class="tab-pane fade" id="collaborators">

View File

@ -6,10 +6,6 @@
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>
<%@ include file="/jsp/init.jsp" %>
<c:url value="maps/" var="shareMap">
<c:param name="action" value="collaborator"/>
<c:param name="userEmail" value="${pageContext.request.userPrincipal.name}"/>
</c:url>
<html>
<head>
<base href="../../../"/>
@ -60,12 +56,6 @@
<body>
<div id="actionsContainer"></div>
<div>
<c:url value="maps/" var="shareMap">
<c:param name="action" value="collaborator"/>
<c:param name="userEmail" value="${pageContext.request.userPrincipal.name}"/>
</c:url>
</div>
<div id="header">
<div id="headerInfo">

View File

@ -0,0 +1,93 @@
<!DOCTYPE HTML>
<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%>
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
<%--@elvariable id="editorTryMode" type="java.lang.String"--%>
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %>
<%@ include file="/jsp/init.jsp" %>
<html>
<head>
<base href="${pageContext.request.contextPath}/"/>
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
<link rel="stylesheet/less" type="text/css" href="css/embedded.less"/>
<script type='text/javascript' src='js/mootools-core.js'></script>
<script type='text/javascript' src='js/mootools-more.js'></script>
<script type='text/javascript' src='js/core.js'></script>
<script type='text/javascript' src='js/less.js'></script>
<script type="text/javascript">
var mapId = '${mindmap.id}';
var mapXml = '${mindmap.xmlAsJsLiteral}';
$(document).addEvent('loadcomplete', function(resource) {
// Configure designer options ...
var options = loadDesignerOptions();
options.size.height = options.size.height + 50;
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/");
var userOptions = ${mindmap.properties};
options.zoom = ${zoom};
// Set map id ...
options.mapId = mapId;
// Print is read only ...
options.readOnly = true;
// Build designer ...
var designer = buildDesigner(options);
// Load map from XML ...
var parser = new DOMParser();
var domDocument = parser.parseFromString(mapXml, "text/xml");
var persistence = mindplot.PersistenceManager.getInstance();
var mindmap = persistence.loadFromDom(mapId, domDocument);
designer.loadMap(mindmap);
$('zoomIn').addEvent('click', function() {
designer.zoomIn();
});
$('zoomOut').addEvent('click', function() {
designer.zoomOut();
});
});
</script>
</head>
<body>
<div id="mapContainer">
<div id="mindplot"></div>
<div id="embFooter">
<a href="${pageContext.request.contextPath}/c/home" target="new">
<div id="footerLogo"></div>
</a>
<div id="zoomIn" class="button"></div>
<div id="zoomOut" class="button"></div>
<div id="mapDetails">
<span class="title"><spring:message code="CREATOR"/>:</span><span>${mindmap.creator}</span>
<span class="title"><spring:message code="DESCRIPTION"/>:</span><span>${mindmap.title}</span>
</div>
</div>
</div>
<script type="text/javascript" src="../js/editor.js"></script>
</body>
</html>

View File

@ -22,7 +22,8 @@
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
<link rel="stylesheet" type="text/css" href="css/embedded.less"/>
<link rel="stylesheet/less" type="text/css" href="css/embedded.less"/>
<style type="text/css" media="print">
@page {
size: A4 landscape;
@ -59,6 +60,7 @@
<script type='text/javascript' src='js/mootools-core.js'></script>
<script type='text/javascript' src='js/mootools-more.js'></script>
<script type='text/javascript' src='js/core.js'></script>
<script type='text/javascript' src='js/less.js'></script>
<link rel="icon" href="images/favicon.ico" type="image/x-icon">

View File

@ -45,12 +45,12 @@
</div>
<label><spring:message code="BLOG_SNIPPET"/></label>
<pre id="embedCode">&lt;iframe style="width:600px;height:400px;border: 1px
solid black" src="http://www.wisemapping.com/c/embeddedView?mapId=${mindmap.id}&zoom=1"&gt; &lt;/iframe&gt;</pre>
solid black" src="http://www.wisemapping.com/c/maps/${mindmap.id}/embed?zoom=1"&gt; &lt;/iframe&gt;</pre>
</div>
<div class="tab-pane fade" id="publicUrlTab">
<spring:message code="URL"/>:
<input name="url" value="http://www.wisemapping.com/c/publicView?mapId=${mindmap.id}"
<input name="url" value="???"
style="width:400px"
readonly="readonly"/>
</div>