Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -r32d1d2ae1e17adb6839a95ecd2331a08168d11a8 -r4e48bcd112ec0b3f9ff808e3c9378a6d556f693e
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 32d1d2ae1e17adb6839a95ecd2331a08168d11a8)
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4e48bcd112ec0b3f9ff808e3c9378a6d556f693e)
@@ -725,5 +725,7 @@
label.save.as.course.grouping.hint =You can save the groups as "Course groupings" so it can be used in other lessons as well. If the groups are just specifically for this lesson, you might not want to do this. Otherwise, click the button to give them a name and reuse them later.
label.advanced.settings =Advanced settings
+label.video.stream.not.available =Video stream not available.
+label.screen.capture.will.appear.in.this.box =The screen capture will appear in this box.
#======= End labels: Exported 718 labels for en AU =====
Index: lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java
===================================================================
diff -u -rfebc5ec394566f98439ce776a0be320b34310b0a -r4e48bcd112ec0b3f9ff808e3c9378a6d556f693e
--- lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java (.../PortraitSaveAction.java) (revision febc5ec394566f98439ce776a0be320b34310b0a)
+++ lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java (.../PortraitSaveAction.java) (revision 4e48bcd112ec0b3f9ff808e3c9378a6d556f693e)
@@ -21,7 +21,6 @@
* ****************************************************************
*/
-
package org.lamsfoundation.lams.web;
import java.io.InputStream;
@@ -61,7 +60,10 @@
private static Logger log = Logger.getLogger(PortraitSaveAction.class);
private static IUserManagementService service;
private static CentralToolContentHandler centralToolContentHandler;
- private static int LARGEST_DIMENSION = 120;
+ private static int LARGEST_DIMENSION_ORIGINAL = 400;
+ private static int LARGEST_DIMENSION_LARGE = 200;
+ private static int LARGEST_DIMENSION_MEDIUM = 80;
+ private static int LARGEST_DIMENSION_SMALL = 29;
/**
* Upload portrait image.
@@ -79,8 +81,7 @@
PortraitActionForm portraitForm = (PortraitActionForm) form;
FormFile file = portraitForm.getFile();
String fileName = file.getFileName();
- PortraitSaveAction.log.debug(
- "got file: " + fileName + " of type: " + file.getContentType() + " with size: " + file.getFileSize());
+ log.debug("got file: " + fileName + " of type: " + file.getContentType() + " with size: " + file.getFileSize());
User user = getService().getUserByLogin(request.getRemoteUser());
@@ -92,82 +93,76 @@
return mapping.findForward("errors");
}
- // resize picture
- InputStream is = PortraitUtils.resizePicture(file.getInputStream(), PortraitSaveAction.LARGEST_DIMENSION);
+ // check file exists
+ InputStream is = file.getInputStream();
if (is == null) {
errors.add("file", new ActionMessage("error.general.1"));
saveErrors(request, errors);
return mapping.findForward("errors");
}
// write to content repository
- NodeKey node = null;
+ NodeKey originalFileNode = null;
if ((file != null) && !StringUtils.isEmpty(fileName)) {
+
+ //Create nice file name. If file name equals to "blob" - it means it was uploaded using webcam
+ String fileNameWithoutExt;
+ boolean isUploadedFromWebcam = false;
+ if (fileName.equals("blob")) {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO userDTO = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ fileNameWithoutExt = userDTO.getLogin() + "_portrait";
+ isUploadedFromWebcam = true;
+
+ } else {
+ fileNameWithoutExt = fileName.substring(0, fileName.indexOf('.'));
+ }
+
+ // upload to the content repository
try {
- fileName = fileName.substring(0, fileName.indexOf('.')) + ".jpg";
- node = getCentralToolContentHandler().uploadFile(is, fileName, file.getContentType());
+ if (!isUploadedFromWebcam) {
+ //resize
+ is = PortraitUtils.resizePicture(file.getInputStream(), LARGEST_DIMENSION_ORIGINAL);
+ }
+ originalFileNode = getCentralToolContentHandler().uploadFile(is, fileNameWithoutExt + "_original.jpg", file.getContentType());
is.close();
+ log.debug("saved file with uuid: " + originalFileNode.getUuid() + " and version: " + originalFileNode.getVersion());
+
+ //resize to the large size
+ is = PortraitUtils.resizePicture(file.getInputStream(), LARGEST_DIMENSION_LARGE);
+ NodeKey node = getCentralToolContentHandler().updateFile(originalFileNode.getUuid(), is, fileNameWithoutExt + "_large.jpg", file.getContentType());
+ is.close();
+ log.debug("saved file with uuid: " + node.getUuid() + " and version: " + node.getVersion());
+
+ //resize to the medium size
+ is = PortraitUtils.resizePicture(file.getInputStream(), LARGEST_DIMENSION_MEDIUM);
+ node = getCentralToolContentHandler().updateFile(node.getUuid(), is, fileNameWithoutExt + "_medium.jpg", file.getContentType());
+ is.close();
+ log.debug("saved file with uuid: " + node.getUuid() + " and version: " + node.getVersion());
+
+ //resize to the small size
+ is = PortraitUtils.resizePicture(file.getInputStream(), LARGEST_DIMENSION_SMALL);
+ node = getCentralToolContentHandler().updateFile(node.getUuid(), is, fileNameWithoutExt + "_small.jpg", file.getContentType());
+ is.close();
+ log.debug("saved file with uuid: " + node.getUuid() + " and version: " + node.getVersion());
+
} catch (Exception e) {
request.setAttribute("errorMessage", e.getMessage());
return mapping.findForward("error.system");
}
+
}
- PortraitSaveAction.log.debug("saved file with uuid: " + node.getUuid() + " and version: " + node.getVersion());
-
// delete old portrait file (we only want to keep the user's current portrait)
if (user.getPortraitUuid() != null) {
getCentralToolContentHandler().deleteFile(user.getPortraitUuid());
}
- user.setPortraitUuid(node.getUuid());
+ user.setPortraitUuid(originalFileNode.getUuid());
getService().saveUser(user);
return mapping.findForward("profile");
}
- /**
- * Save portrait taken from web camera.
- */
- public ActionForward saveWebcamPortrait(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- // check if there is a session with logged in user
- HttpSession ss = SessionManager.getSession();
- UserDTO userDTO = (UserDTO) ss.getAttribute(AttributeNames.USER);
- User user = getService().getUserByLogin(request.getRemoteUser());
- if ((userDTO == null) || (user == null)) {
- throw new UserAccessDeniedException("User hasn't been logged in");
- }
-
- // check if the file is an image using the MIME content type
- String mediaType = request.getContentType().split("/", 2)[0];
- if (!mediaType.equals("image")) {
- throw new FileUtilException("The file is not an image.");
- }
-
- // check if there is an input stream
- InputStream is = request.getInputStream();
- if (is == null) {
- throw new FileUtilException("Sorry, there has been an error.");
- }
-
- // write to content repository
- String fileName = user.getFullName() + " portrait.jpg";
- NodeKey node = getCentralToolContentHandler().uploadFile(is, fileName, "image/jpeg");
- is.close();
-
- log.debug("saved file with uuid: " + node.getUuid() + " and version: " + node.getVersion());
-
- // delete old portrait file (we only want to keep the user's current portrait)
- if (user.getPortraitUuid() != null) {
- getCentralToolContentHandler().deleteFile(user.getPortraitUuid());
- }
- user.setPortraitUuid(node.getUuid());
- getService().saveUser(user);
-
- return null;
- }
-
private CentralToolContentHandler getCentralToolContentHandler() {
if (centralToolContentHandler == null) {
WebApplicationContext wac = WebApplicationContextUtils
@@ -178,10 +173,10 @@
}
private IUserManagementService getService() {
- if (PortraitSaveAction.service == null) {
+ if (service == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
- PortraitSaveAction.service = (IUserManagementService) ctx.getBean("userManagementService");
+ service = (IUserManagementService) ctx.getBean("userManagementService");
}
return service;
}
Index: lams_central/web/includes/flash/webcam.swf
===================================================================
diff -u -rb0e43d3189749133af52bc2e225ce1533a33a11a -r4e48bcd112ec0b3f9ff808e3c9378a6d556f693e
Binary files differ
Fisheye: Tag 4e48bcd112ec0b3f9ff808e3c9378a6d556f693e refers to a dead (removed) revision in file `lams_central/web/includes/javascript/webcam.js'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_central/web/includes/javascript/webrtc-capturestill.js
===================================================================
diff -u
--- lams_central/web/includes/javascript/webrtc-capturestill.js (revision 0)
+++ lams_central/web/includes/javascript/webrtc-capturestill.js (revision 4e48bcd112ec0b3f9ff808e3c9378a6d556f693e)
@@ -0,0 +1,135 @@
+//Script taken from https://github.com/mdn/samples-server/blob/master/s/webrtc-capturestill/capture.js
+//Last commit date - Mar 11, 2015.
+
+(function() {
+ // The width and height of the captured photo. We will set the
+ // width to the value defined here, but the height will be
+ // calculated based on the aspect ratio of the input stream.
+
+ var width = 460; // We will scale the photo width to this
+ var height = 0; // This will be computed based on the input stream
+
+ // |streaming| indicates whether or not we're currently streaming
+ // video from the camera. Obviously, we start at false.
+
+ var streaming = false;
+
+ // The various HTML elements we need to configure or control. These
+ // will be set by the startup() function.
+
+ var video = null;
+ var canvas = null;
+ var photo = null;
+ var startbutton = null;
+ //*LAMS* var added by LAMS. It will hold a URL representing the webcamera picture. It get created by URL.createObjectURL() method.
+ var objectURL;
+
+ function startup() {
+ video = document.getElementById('video');
+ canvas = document.getElementById('canvas');
+ photo = document.getElementById('photo');
+ startbutton = document.getElementById('startbutton');
+
+ //*LAMS* onload event added by LAMS
+ photo.onload = function() {
+ if (typeof objectURL !== 'undefined') {
+ // no longer need to read the blob so it's revoked
+ URL.revokeObjectURL(objectURL);
+ }
+ };
+
+ navigator.getMedia = ( navigator.getUserMedia ||
+ navigator.webkitGetUserMedia ||
+ navigator.mozGetUserMedia ||
+ navigator.msGetUserMedia);
+
+ navigator.getMedia(
+ {
+ video: true,
+ audio: false
+ },
+ function(stream) {
+ if (navigator.mozGetUserMedia) {
+ video.mozSrcObject = stream;
+ } else {
+ var vendorURL = window.URL || window.webkitURL;
+ video.src = vendorURL.createObjectURL(stream);
+ }
+ video.play();
+ },
+ function(err) {
+ console.log("An error occured! " + err);
+ }
+ );
+
+ video.addEventListener('canplay', function(ev){
+ if (!streaming) {
+ height = video.videoHeight / (video.videoWidth/width);
+
+ // Firefox currently has a bug where the height can't be read from
+ // the video, so we will make assumptions if this happens.
+
+ if (isNaN(height)) {
+ height = width / (4/3);
+ }
+
+ video.setAttribute('width', width);
+ video.setAttribute('height', height);
+ canvas.setAttribute('width', width);
+ canvas.setAttribute('height', height);
+ streaming = true;
+ }
+ }, false);
+
+ startbutton.addEventListener('click', function(ev){
+ takepicture();
+ ev.preventDefault();
+ }, false);
+
+ clearphoto();
+ }
+
+ // Fill the photo with an indication that none has been
+ // captured.
+
+ function clearphoto() {
+ //*LAMS* reimplemented this method
+ $("#still-portrait").hide();
+ }
+
+ // Capture a photo by fetching the current contents of the video
+ // and drawing it into a canvas, then converting that to a PNG
+ // format data URL. By drawing it on an offscreen canvas and then
+ // drawing that to the screen, we can change its size and/or apply
+ // other changes before drawing it.
+
+ function takepicture() {
+ var context = canvas.getContext('2d');
+ if (width && height) {
+ canvas.width = width;
+ canvas.height = height;
+ context.drawImage(video, 0, 0, width, height);
+
+ //*LAMS* added by LAMS. Creates a Blob object representing the image contained in the canvas. Which we then display in photo img.
+ canvas.toBlob(function(blob) {
+ $("#still-portrait").show();
+ $('html, body').animate({
+ scrollTop: $("#still-portrait").offset().top
+ }, 2000);
+
+ objectURL = URL.createObjectURL(blob);
+ photo.src = objectURL;
+ });
+
+ //*LAMS* commented out by LAMS
+ //var data = canvas.toDataURL('image/png');
+ //photo.setAttribute('src', data);
+ } else {
+ clearphoto();
+ }
+ }
+
+ // Set up our event listener to run the startup process
+ // once loading is complete.
+ window.addEventListener('load', startup, false);
+})();
\ No newline at end of file
Index: lams_central/web/includes/sounds/shutter.mp3
===================================================================
diff -u -rb0e43d3189749133af52bc2e225ce1533a33a11a -r4e48bcd112ec0b3f9ff808e3c9378a6d556f693e
Binary files differ
Index: lams_central/web/portrait.jsp
===================================================================
diff -u -ra83b0eec89979dce7415b02afdda324b14018dbb -r4e48bcd112ec0b3f9ff808e3c9378a6d556f693e
--- lams_central/web/portrait.jsp (.../portrait.jsp) (revision a83b0eec89979dce7415b02afdda324b14018dbb)
+++ lams_central/web/portrait.jsp (.../portrait.jsp) (revision 4e48bcd112ec0b3f9ff808e3c9378a6d556f693e)
@@ -26,80 +26,45 @@
margin-bottom: 0xp;
}
- #webcam {
- padding-bottom: 17px;
+ #canvas, #still-portrait {
+ display:none;
}
-
+
-
+
-