|
From: <tre...@us...> - 2007-09-02 18:12:42
|
Revision: 335
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=335&view=rev
Author: trevorolio
Date: 2007-09-02 11:12:42 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
Made the whiteboard info panel provide image upload capabilities.
Fixed a bug in which browser form uploads of images resulted in displaying the image file as text (aka horrid text junk).
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-02 18:12:39 UTC (rev 334)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-02 18:12:42 UTC (rev 335)
@@ -31,6 +31,7 @@
import com.ogoglio.appdev.persist.PersistException;
import com.ogoglio.appdev.servlet.SiteResource;
+import com.ogoglio.client.DecoratedInputStream;
import com.ogoglio.media.MediaService;
import com.ogoglio.persist.AccountRecord;
import com.ogoglio.persist.SimPersistTasks;
@@ -502,8 +503,10 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
+ String pageContentType = null;
if (request.getContentType() != null && request.getContentType().startsWith("multipart/form-data")) {
- InputStream fileInput = getFirstFile(request, Sim.MAX_PAGE_SIZE);
+ DecoratedInputStream fileInput = getFirstFile(request, Sim.MAX_PAGE_SIZE);
+ pageContentType = fileInput.getMimeType();
if (fileInput == null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
@@ -518,6 +521,7 @@
if (newValue == null) {
getMediaService().delete(MediaService.getPageContentName(spaceID, thingID, pageID));
} else {
+ pageContentType = "text/plain";
getMediaService().write(MediaService.getPageContentName(spaceID, thingID, pageID), newValue);
}
break;
@@ -526,7 +530,7 @@
} else {
getMediaService().write(MediaService.getPageContentName(spaceID, thingID, pageID), request.getInputStream(), Sim.MAX_PAGE_SIZE);
}
- simulator.pageContentsChanged(thingID, pageID, request.getContentType());
+ simulator.pageContentsChanged(thingID, pageID, pageContentType);
response.setStatus(HttpServletResponse.SC_OK);
return;
} catch (PersistException e) {
Modified: maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js 2007-09-02 18:12:39 UTC (rev 334)
+++ maven/trunk/ogoglio-server/src/main/resources/populate/template-28/WhiteBoard.js 2007-09-02 18:12:42 UTC (rev 335)
@@ -15,8 +15,8 @@
function formatBoardText(text){
var result = '';
- for(var i=0; i < text.length - 2; i++){
- if((text[i] == '\n' || text[i] == '\r') && (text[i + 1] == '\n' || text[i + 1] == '\r')){
+ for(var i=0; i < text.length; i++){
+ if(i != text.length - 1 && (text[i] == '\n' || text[i] == '\r') && (text[i + 1] == '\n' || text[i + 1] == '\r')){
result += '<br>';
} else {
result += text[i];
@@ -88,8 +88,9 @@
html += '<input type="submit" value="update whiteboard" />';
html += '</form>';
html += '<hr>';
- html += '<form action="service?nonce=clear" method="post">';
- html += '<input type="submit" value="clear whiteboard" />';
+ html += '<form action="/og/space/' + space.id + '/thing/' + thingID + '/page/' + pageID + '/content" enctype="multipart/form-data" method="post">';
+ html += '<input type="file" name="pageFile" />';
+ html += '<input type="submit" value="update page directly" />';
html += '</form>';
html += htmlSuffix;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|