Author: [email protected]
Date: Mon Jan 23 15:30:20 2012
New Revision: 1971
Log:
[AMDATUOPENSOCIAL-181] Fixed setting the proper height for gadgets
Modified:
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/jquery.dashboard.js
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.jsp
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/DashboardWidget.java
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/Widget.java
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/BaseRESTServiceImpl.java
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/DashboardRESTServiceImpl.java
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GadgetSpecProcessorImpl.java
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigOpenSocialContainerImpl.java
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
Modified:
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/jquery.dashboard.js
==============================================================================
---
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/jquery.dashboard.js
(original)
+++
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/jquery.dashboard.js
Mon Jan 23 15:30:20 2012
@@ -258,6 +258,7 @@
url: (typeof obj.url != 'undefined' ? obj.url : null),
editurl: obj.editurl,
title: obj.title,
+ height: obj.height,
open: obj.open,
metadata: obj.metadata
});
@@ -445,7 +446,9 @@
};
widget.serialize = function() {
dashboard.log('entering serialize function',1);
- var r = '{"title" : "' + widget.title + '", "id" : "' + widget.id +
'", "index" : "' + widget.index + '", "column" : "' + widget.column +
'","editurl" : "' + widget.editurl + '","open" : ' + widget.open + ',"url" : "'
+ widget.url + '"';
+ var r = '{"title" : "' + widget.title + '", "id" : "' + widget.id +
'", "index" : "' + widget.index
+ + '", "column" : "' + widget.column + '","editurl" : "' +
widget.editurl + '","open" : ' + widget.open
+ + ',"url" : "' + widget.url + '", "height" : "' + widget.height +
'"';
if (typeof widget.metadata != 'undefined') {
r+= ',"metadata":{'
@@ -989,6 +992,7 @@
open: true,
fullscreen: false,
loaded: false,
+ height: 150,
url: '',
index:0,
metadata: {}
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.jsp
==============================================================================
---
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.jsp
(original)
+++
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.jsp
Mon Jan 23 15:30:20 2012
@@ -35,13 +35,12 @@
</script>
<!-- In debug mode, enable the following two lines and disable the two lines
after that -->
- <!--
+
<script type="text/javascript"
src="${contextPath}/dashboard/static/js/jquery.dashboard.all.js"></script>
<script type="text/javascript"
src="${contextPath}/dashboard/static/js/dashboard.all.js"></script>
- -->
- <script type="text/javascript"
src="${contextPath}/dashboard/static/js/jquery.dashboard.all.min.js"></script>
- <script type="text/javascript"
src="${contextPath}/dashboard/static/js/dashboard.all.min.js"></script>
+
+
<script type="text/javascript"
src="${contextPath}/gadgets/js/shindig-container:pubsub-2.js?c=1&debug=1"></script>
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
==============================================================================
---
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
(original)
+++
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
Mon Jan 23 15:30:20 2012
@@ -142,15 +142,15 @@
shindig.Gadget.call(this, opt_params);
this.serverBase_ = contextPath + '/gadgets/'; // default gadget server
this.queryIfrGadgetType_();
- };
+ };
widget.WidgetIfrGadget.inherits(shindig.BaseIfrGadget);
shindig.IfrContainer.prototype.gadgetClass = widget.WidgetIfrGadget;
-
+
var metadata = widget.metadata;
if (typeof metadata != 'undefined' && typeof metadata.gadgetUrl !=
'undefined') {
var gadget = shindig.container.createGadget(
- {serviceName: widget.id, specUrl: metadata.gadgetUrl, width:
"100%", secureToken: metadata.secureToken, cssClassGadgetContent:"", widget:
widget});
+ {serviceName: widget.id, specUrl: metadata.gadgetUrl, width:
"100%", secureToken: metadata.secureToken, cssClassGadgetContent:"", widget:
widget, height: widget.height});
shindig.container.addGadget(gadget);
shindig.container.renderGadget(gadget);
@@ -218,8 +218,9 @@
if (widget != 'undefined') {
dashboard.addWidget({
"id":wId,
- "dbid": dbId,
+ "dbid":dbId,
"title":widget.title,
+ "height":widget.height,
"column":"first",
"url":widget.url,
"metadata":widget.metadata
@@ -264,6 +265,7 @@
"id":wId,
"dbid": dbId,
"title":widget.title,
+ "height":widget.height,
"column":"first",
"url":widget.url,
"metadata":widget.metadata
Modified:
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/DashboardWidget.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/DashboardWidget.java
(original)
+++
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/DashboardWidget.java
Mon Jan 23 15:30:20 2012
@@ -25,6 +25,7 @@
@SerializedName("editurl") private String m_editUrl;
@SerializedName("open") private Boolean m_open;
@SerializedName("url") private String m_url;
+ @SerializedName("height") private String m_height;
@SerializedName("metadata") private Metadata m_metadata;
public String getTitle() {
@@ -90,5 +91,13 @@
public void setMetadata(Metadata metadata) {
m_metadata = metadata;
}
+
+ public void setHeight(String height) {
+ m_height = height;
+ }
+
+ public String getHeight() {
+ return m_height;
+ }
}
Modified:
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/Widget.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/Widget.java
(original)
+++
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/bean/Widget.java
Mon Jan 23 15:30:20 2012
@@ -25,10 +25,11 @@
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class Widget {
// Default widget elements, these attributes are stored in the AppData of
the user
- @SerializedName("id") private String m_id;
+ @SerializedName("id")
+ private String m_id;
private String m_url;
private String m_column;
-
+
// These elements are added from the gadget spec
private String m_title;
private boolean m_removeAccessGranted;
@@ -38,10 +39,11 @@
private String m_authorEmail;
private String m_authorAffiliation;
private String m_titleUrl;
-
+ private String m_height;
+
// Additional metadata; secure token and, gadget url
private Metadata m_metadata;
-
+
public String getId() {
return m_id;
}
@@ -57,7 +59,7 @@
public void setUrl(String url) {
m_url = url;
}
-
+
public String getColumn() {
return m_column;
}
@@ -121,7 +123,7 @@
public void setAuthorAffiliation(String authorAffiliation) {
m_authorAffiliation = authorAffiliation;
}
-
+
public String getTitle() {
return m_title;
}
@@ -137,6 +139,13 @@
public void setTitleUrl(String titleUrl) {
m_titleUrl = titleUrl;
}
-
-
+
+ public void setHeight(String height) {
+ m_height = height;
+ }
+
+ public String getHeight() {
+ return m_height;
+ }
+
}
Modified:
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/BaseRESTServiceImpl.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/BaseRESTServiceImpl.java
(original)
+++
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/BaseRESTServiceImpl.java
Mon Jan 23 15:30:20 2012
@@ -95,7 +95,7 @@
.setService(TokenProvider.class,
tenantFilter).setRequired(true).setInstanceBound(true));
m_component.add(dependencies);
-
+
m_logService.log(LogService.LOG_INFO, getClass().getName() + " service
initialized");
}
@@ -145,10 +145,14 @@
// Set description
widget.setDescription(getGadgetSpecValue(gadgetSpec,
"description", ""));
+ // Set height
+ widget.setHeight(getGadgetSpecValue(gadgetSpec, "height", "150"));
+
// Set screenshot
String defaultScreenshot =
request.getContextPath() + "/" + Activator.RES_ALIAS +
"/static/images/defaultgadget.png";
widget.setScreenshot(getGadgetSpecValue(gadgetSpec, "screenshot",
defaultScreenshot));
+
}
else {
// Set author
@@ -187,13 +191,14 @@
else if (relUrl.startsWith("https://")) {
relUrl = relUrl.substring("https://".length());
}
- else return relUrl;
-
+ else
+ return relUrl;
+
// Now strip of hostname
relUrl = relUrl.substring(relUrl.indexOf("/"));
return relUrl;
}
-
+
protected String toAbsoluteUrl(final String url, final HttpServletRequest
request) {
if (url.startsWith("/")) {
// This is a relative URL, convert to absolute URL
@@ -253,7 +258,7 @@
userPrefsBytes = (byte[]) user.getProperties().get(APP_DATA +
".userprefs." + widgetId);
if (userPrefsBytes != null) {
Map<String, String> userPrefs =
- (Map<String, String>)
ConversionUtil.byteArrayToObject(userPrefsBytes);
+ (Map<String, String>)
ConversionUtil.byteArrayToObject(userPrefsBytes);
return userPrefs;
}
}
@@ -281,74 +286,75 @@
}
}
- protected boolean canSeeGadgetCategory(User user, GadgetCategory
category) {
- if (user == null) {
- return false;
- }
- Authorization authorization = m_userAdmin.getAuthorization(user);
-
- if
(authorization.hasRole(GadgetCategory.USE_GADGET_CATEGORY_GROUP_ALL) &&
!category.equals(GadgetCategory.AMDATU_PLATFORM)) {
- return true;
- }
-
- return
authorization.hasRole(GadgetCategory.USE_GADGET_CATEGORY_GROUP_PREFIX +
category.getId());
- }
-
- protected User getUserFromRequest(HttpServletRequest request) {
- String username = getUserNameFromRequest(request);
- if (username == null) {
- return null;
- }
- else {
- return (User) m_userAdmin.getRole(username);
- }
- }
-
- String getUserNameFromRequest(HttpServletRequest request) {
- String token = m_tokenProvider.getTokenFromRequest(request);
- if (token != null) {
- try {
- Map<String, String> attributes =
m_tokenProvider.verifyToken(token);
- if (attributes.containsKey(TokenProvider.USERNAME)) {
- return attributes.get(TokenProvider.USERNAME);
- }
- }
- catch (TokenProviderException e) {
- // Ignore invalid tokens
- }
- catch (InvalidTokenException e) {
- // Ignore invalid tokens
- }
- }
- return null;
- }
-
+ protected boolean canSeeGadgetCategory(User user, GadgetCategory category)
{
+ if (user == null) {
+ return false;
+ }
+ Authorization authorization = m_userAdmin.getAuthorization(user);
+
+ if (authorization.hasRole(GadgetCategory.USE_GADGET_CATEGORY_GROUP_ALL)
+ && !category.equals(GadgetCategory.AMDATU_PLATFORM)) {
+ return true;
+ }
+
+ return
authorization.hasRole(GadgetCategory.USE_GADGET_CATEGORY_GROUP_PREFIX +
category.getId());
+ }
+
+ protected User getUserFromRequest(HttpServletRequest request) {
+ String username = getUserNameFromRequest(request);
+ if (username == null) {
+ return null;
+ }
+ else {
+ return (User) m_userAdmin.getRole(username);
+ }
+ }
+
+ String getUserNameFromRequest(HttpServletRequest request) {
+ String token = m_tokenProvider.getTokenFromRequest(request);
+ if (token != null) {
+ try {
+ Map<String, String> attributes =
m_tokenProvider.verifyToken(token);
+ if (attributes.containsKey(TokenProvider.USERNAME)) {
+ return attributes.get(TokenProvider.USERNAME);
+ }
+ }
+ catch (TokenProviderException e) {
+ // Ignore invalid tokens
+ }
+ catch (InvalidTokenException e) {
+ // Ignore invalid tokens
+ }
+ }
+ return null;
+ }
+
// Returns a 200 - OK
- protected Response get200(Object entity) {
+ protected Response get200(Object entity) {
return
Response.status(Status.OK).entity(entity).cacheControl(NO_CACHE_CONTROL).build();
}
-
+
// Returns a 400 - BAD REQUEST
protected Response get400(String msg) {
return
Response.status(Status.BAD_REQUEST).entity(msg).cacheControl(NO_CACHE_CONTROL).build();
}
-
+
// Returns a 401 - UNAUTHORIZED
protected Response get401(String msg) {
return
Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
}
-
+
// Returns a 404 - NOT FOUND
protected Response get404() {
return
Response.status(Response.Status.NOT_FOUND).cacheControl(NO_CACHE_CONTROL).build();
}
-
+
// Returns a 500 - INTERNAL SERVER ERROR
protected Response get500(Exception e, String msg) {
m_logService.log(LogService.LOG_ERROR, msg, e);
return
Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
-
+
protected String getBaseURL(HttpServletRequest request) {
return request.getScheme() + "://" + request.getServerName() + ":" +
request.getServerPort();
}
Modified:
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/DashboardRESTServiceImpl.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/DashboardRESTServiceImpl.java
(original)
+++
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/rest/DashboardRESTServiceImpl.java
Mon Jan 23 15:30:20 2012
@@ -285,11 +285,11 @@
}
Map<String, String> gadgetSpec =
getOpenSocialContainer().getGadgetSpec(request, gadgetUrl, null);
-
// Ignore the widget if its gadgetspec could not be found
if (gadgetSpec != null) {
widget.setTitle(gadgetSpec.get("title"));
-
+ widget.setHeight(gadgetSpec.get("height"));
+
// Generate a security token for the widget and set it in the
metadata field
String st = generateSecurityToken(gadgetUrl, request);
Metadata metadata = new Metadata();
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GadgetSpecProcessorImpl.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GadgetSpecProcessorImpl.java
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GadgetSpecProcessorImpl.java
Mon Jan 23 15:30:20 2012
@@ -60,8 +60,7 @@
public Gadget process(GadgetContext context) {
try {
- Gadget gadget = m_processor.process(context);
- return gadget;
+ return m_processor.process(context);
}
catch (ProcessingException e) {
// We log the error as WARNING but explicitly do NOT provide the
stacktrace, since
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigOpenSocialContainerImpl.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigOpenSocialContainerImpl.java
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigOpenSocialContainerImpl.java
Mon Jan 23 15:30:20 2012
@@ -135,6 +135,7 @@
gadgetSpec.put("description",
spec.getModulePrefs().getDescription());
gadgetSpec.put("author", spec.getModulePrefs().getAuthor());
gadgetSpec.put("title_url",
spec.getModulePrefs().getTitleUrl().toString());
+ gadgetSpec.put("height",
spec.getModulePrefs().getAttribute("height", "150"));
if (spec.getModulePrefs().getScreenshot() != null
&&
!spec.getModulePrefs().getScreenshot().toString().isEmpty()) {
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
Mon Jan 23 15:30:20 2012
@@ -831,7 +831,7 @@
'" style="visibility:hidden;display:none"' +
'" src="about:blank' +
'" frameborder="no" scrolling="auto"' +
- (this.height ? ' height="' + this.height + '"' : '') +
+ (this.height ? ' height="' + (parseInt(this.height) + 5) + '"' : '') +
(this.width ? ' width="' + this.width + '"' : '') +
' onload="' + onload + '"></iframe>' +
'<div id="' + iframeId + '_loading" width="100%" align="center"
class="loading">' +
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits