Skip to content

The Unified and Autonomous Development Platform

Add file upload support

stevefb55e99f7b39
diff --git a/gitop.web/pom.xml b/gitop.web/pom.xml
index a7d23166ac..31b60f1ae7 100644
--- a/gitop.web/pom.xml
+++ b/gitop.web/pom.xml
@@ -35,8 +35,13 @@
<artifactId>commons.wicket</artifactId>
<version>1.0.29</version>
</dependency>
-
-
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.jersey</artifactId>
+ <version>1.0.30</version>
+ </dependency>
+
+
<!-- WICKET -->
<dependency>
<groupId>com.vaynberg.wicket.select2</groupId>
@@ -54,7 +59,31 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-multipart</artifactId>
+ <version>1.17</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.imgscalr</groupId>
+ <artifactId>imgscalr-lib</artifactId>
+ <version>4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.codahale.dropwizard</groupId>
+ <artifactId>dropwizard-jackson</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </dependency>
+
</dependencies>
<repositories>
@@ -73,6 +102,18 @@
</snapshots>
<url>http://artifact.pmease.com/</url>
</repository>
+
+ <repository>
+ <id>sonatype-nexus-snapshots</id>
+ <name>Sonatype Nexus Snapshots</name>
+ <url>http://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
</repositories>
<properties>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/GitopWebApp.java b/gitop.web/src/main/java/com/pmease/gitop/web/GitopWebApp.java
index 7b3b118d47..2ddc7708f4 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/GitopWebApp.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/GitopWebApp.java
@@ -1,6 +1,5 @@
package com.pmease.gitop.web;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
@@ -17,13 +16,9 @@ import org.apache.wicket.request.Response;
import org.apache.wicket.util.time.Duration;
import org.apache.wicket.util.time.Time;
-import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.io.ByteStreams;
-import com.pmease.commons.loader.AppLoader;
import com.pmease.commons.wicket.AbstractWicketConfig;
-import com.pmease.gitop.core.manager.ConfigManager;
-import com.pmease.gitop.core.model.User;
import com.pmease.gitop.web.assets.AssetLocator;
import com.pmease.gitop.web.common.component.avatar.AvatarImageResource;
import com.pmease.gitop.web.common.component.avatar.AvatarImageResourceReference;
@@ -135,8 +130,8 @@ public class GitopWebApp extends AbstractWicketConfig {
getSharedResources().add(AvatarImageResourceReference.AVATAR_RESOURCE, new AvatarImageResource());
mountResource("avatars/${type}/${id}", new AvatarImageResourceReference());
- mountResource("fileManager", new FileManagerResourceReference(getUploadsDir().getAbsolutePath()));
- mountResource("fileUpload", new FileUploadResourceReference(getUploadsDir().getAbsolutePath()));
+ mountResource("fileManager", new FileManagerResourceReference(SitePaths.get().uploadsDir().getAbsolutePath()));
+ mountResource("fileUpload", new FileUploadResourceReference(SitePaths.get().uploadsDir().getAbsolutePath()));
}
public boolean isGravatarEnabled() {
@@ -146,27 +141,4 @@ public class GitopWebApp extends AbstractWicketConfig {
public boolean isPublicSignupEnabled() {
return true;
}
-
- public File getDataDir() {
- String str = AppLoader.getInstance(ConfigManager.class).getStorageSetting().getRepoStorageDir();
- return new File(str);
- }
-
- public File getSystemAvatarDir() {
- return new File(getDataDir(), "avatars");
- }
-
- public File getUserAvatarDir(Long id) {
- Preconditions.checkNotNull(id, "user id");
- return new File(getSystemAvatarDir(), "users/" + id.toString());
- }
-
- public File getUserAvatarDir(User user) {
- return getUserAvatarDir(user.getId());
- }
-
- public File getUploadsDir() {
- return new File(getDataDir(), "uploads");
- }
-
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/SitePaths.java b/gitop.web/src/main/java/com/pmease/gitop/web/SitePaths.java
new file mode 100644
index 0000000000..5698cdf4b6
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/SitePaths.java
@@ -0,0 +1,56 @@
+package com.pmease.gitop.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.File;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.pmease.commons.bootstrap.Bootstrap;
+import com.pmease.commons.loader.AppLoader;
+import com.pmease.gitop.core.manager.ConfigManager;
+import com.pmease.gitop.core.model.User;
+
+@Singleton
+public class SitePaths {
+ private final ConfigManager configManager;
+
+ public static SitePaths get() {
+ return AppLoader.getInstance(SitePaths.class);
+ }
+
+ @Inject
+ SitePaths(ConfigManager configManager) {
+ this.configManager = configManager;
+ }
+
+ public File installDir() {
+ return Bootstrap.installDir;
+ }
+
+ public File dataDir() {
+ // TODO: this is not correct, should change repo storage dir to data dir
+ return new File(configManager.getStorageSetting().getRepoStorageDir());
+ }
+
+ public File avatarsDir() {
+ return new File(dataDir(), "avatars");
+ }
+
+ public File userAvatarDir(Long id) {
+ return new File(avatarsDir(), "users/" + checkNotNull(id));
+ }
+
+ public File userAvatarDir(User user) {
+ return userAvatarDir(checkNotNull(user));
+ }
+
+ public File tempDir() {
+ return new File(installDir(), "temp");
+ }
+
+ public File uploadsDir() {
+ return new File(dataDir(), "uploads");
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java b/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java
index a748b96f45..21be234317 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java
@@ -1,5 +1,6 @@
package com.pmease.gitop.web;
+import javax.inject.Singleton;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
@@ -11,6 +12,8 @@ import com.pmease.commons.jetty.ServletContextConfigurator;
import com.pmease.commons.loader.AbstractPluginModule;
import com.pmease.commons.wicket.AbstractWicketConfig;
import com.pmease.gitop.web.assets.AssetLocator;
+import com.pmease.gitop.web.common.component.fileupload.FileUploadServlet;
+import com.pmease.gitop.web.resource.RestResourceModule;
/**
* NOTE: Do not forget to rename moduleClass property defined in the pom if you've renamed this class.
@@ -24,6 +27,7 @@ public class WebModule extends AbstractPluginModule {
// put your guice bindings here
bind(AbstractWicketConfig.class).to(GitopWebApp.class);
+ bind(SitePaths.class).in(Singleton.class);
contribute(ServletContextConfigurator.class, new ServletContextConfigurator() {
@@ -35,10 +39,13 @@ public class WebModule extends AbstractPluginModule {
ErrorPageErrorHandler errorHandler = (ErrorPageErrorHandler) context.getErrorHandler();
errorHandler.addErrorPage(HttpServletResponse.SC_NOT_FOUND, "/assets/404.html");
+
+ servletHolder = context.addServlet(FileUploadServlet.class, "/uploads/*");
}
});
+ install(new RestResourceModule());
}
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/avatar/AvatarImageResource.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/avatar/AvatarImageResource.java
index 150d01b4ee..39a8328b37 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/avatar/AvatarImageResource.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/avatar/AvatarImageResource.java
@@ -13,6 +13,7 @@ import com.pmease.commons.loader.AppLoader;
import com.pmease.gitop.core.manager.UserManager;
import com.pmease.gitop.core.model.User;
import com.pmease.gitop.web.GitopWebApp;
+import com.pmease.gitop.web.SitePaths;
import com.pmease.gitop.web.common.component.avatar.AvatarImage.AvatarImageType;
public class AvatarImageResource extends DynamicImageResource {
@@ -30,7 +31,7 @@ public class AvatarImageResource extends DynamicImageResource {
User user = AppLoader.getInstance(UserManager.class).get(id);
if (!Strings.isNullOrEmpty(user.getAvatarUrl())) {
- avatarFile = new File(GitopWebApp.get().getUserAvatarDir(id), user.getAvatarUrl());
+ avatarFile = new File(SitePaths.get().userAvatarDir(id), user.getAvatarUrl());
}
} else {
// Repository project = AppLoader.getInstance(RepositoryManager.class).get(id);
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.html b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.html
index 5269003398..36fb6c24c5 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.html
@@ -1,43 +1,125 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
- <wicket:panel>
- <div class="row fileupload-buttonbar">
- <div class="span7">
- <!-- The fileinput-button span is used to style the file input field as button -->
- <span class="btn btn-success fileinput-button">
- <i class="icon-plus icon-white"></i>
- <span>Add files...</span>
- <input type="file" multiple="true"/>
- </span>
- <button type="submit" class="btn btn-primary start">
- <i class="icon-upload icon-white"></i>
- <span>Start upload</span>
+<wicket:panel>
+ <form wicket:id="form" action="/rest/file/upload" method="POST" enctype="multipart/form-data">
+ <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
+ <div class="row fileupload-buttonbar">
+ <div class="col-lg-7">
+ <!-- The fileinput-button span is used to style the file input field as button -->
+ <span class="btn btn-success fileinput-button"> <i
+ class="glyphicon glyphicon-plus"></i> <span>Add files...</span> <input
+ type="file" name="files" />
+ </span>
+ <button type="submit" class="btn btn-primary start">
+ <i class="glyphicon glyphicon-upload"></i> <span>Start
+ upload</span>
+ </button>
+ <button type="reset" class="btn btn-warning cancel">
+ <i class="glyphicon glyphicon-ban-circle"></i> <span>Cancel
+ upload</span>
+ </button>
+ <button type="button" class="btn btn-danger delete">
+ <i class="glyphicon glyphicon-trash"></i> <span>Delete</span>
+ </button>
+ <input type="checkbox" class="toggle">
+ <!-- The loading indicator is shown during file processing -->
+ <span class="fileupload-loading"></span>
+ </div>
+ <!-- The global progress information -->
+ <div class="col-lg-5 fileupload-progress fade">
+ <!-- The global progress bar -->
+ <div class="progress progress-striped active" role="progressbar"
+ aria-valuemin="0" aria-valuemax="100">
+ <div class="progress-bar progress-bar-success" style="width: 0%;"></div>
+ </div>
+ <!-- The extended global progress information -->
+ <div class="progress-extended">&nbsp;</div>
+ </div>
+ </div>
+ <!-- The table listing the files available for upload/download -->
+ <table role="presentation" class="table table-striped">
+ <tbody class="files"></tbody>
+ </table>
+ </form>
+
+<!-- The template to display files available for upload -->
+<script id="template-upload" type="text/x-tmpl">
+{% for (var i=0, file; file=o.files[i]; i++) { %}
+ <tr class="template-upload fade">
+ <td>
+ <span class="preview"></span>
+ </td>
+ <td>
+ <p class="name">{%=file.name%}</p>
+ {% if (file.error) { %}
+ <div><span class="label label-danger">Error</span> {%=file.error%}</div>
+ {% } %}
+ </td>
+ <td>
+ <p class="size">{%=o.formatFileSize(file.size)%}</p>
+ {% if (!o.files.error) { %}
+ <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
+ {% } %}
+ </td>
+ <td>
+ {% if (!o.files.error && !i && !o.options.autoUpload) { %}
+ <button class="btn btn-primary start">
+ <i class="glyphicon glyphicon-upload"></i>
+ <span>Start</span>
</button>
- <button type="reset" class="btn btn-warning cancel">
- <i class="icon-ban-circle icon-white"></i>
- <span>Cancel upload</span>
+ {% } %}
+ {% if (!i) { %}
+ <button class="btn btn-warning cancel">
+ <i class="glyphicon glyphicon-ban-circle"></i>
+ <span>Cancel</span>
</button>
- <button type="button" class="btn btn-danger delete">
- <i class="icon-trash icon-white"></i>
+ {% } %}
+ </td>
+ </tr>
+{% } %}
+</script>
+<!-- The template to display files available for download -->
+<script id="template-download" type="text/x-tmpl">
+{% for (var i=0, file; file=o.files[i]; i++) { %}
+ <tr class="template-download fade">
+ <td>
+ <span class="preview">
+ {% if (file.thumbnailUrl) { %}
+ <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
+ {% } %}
+ </span>
+ </td>
+ <td>
+ <p class="name">
+ {% if (file.url) { %}
+ <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
+ {% } else { %}
+ <span>{%=file.name%}</span>
+ {% } %}
+ </p>
+ {% if (file.error) { %}
+ <div><span class="label label-danger">Error</span> {%=file.error%}</div>
+ {% } %}
+ </td>
+ <td>
+ <span class="size">{%=o.formatFileSize(file.size)%}</span>
+ </td>
+ <td>
+ {% if (file.deleteUrl) { %}
+ <button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
+ <i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
- <input type="checkbox" class="toggle"/>
- </div>
- <!-- The global progress information -->
- <div class="span5 fileupload-progress fade">
- <!-- The global progress bar -->
- <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
- <div class="bar" style="width:0%;"></div>
- </div>
- <!-- The extended global progress information -->
- <div class="progress-extended">&#169;</div>
- </div>
- </div>
- <!-- The loading indicator is shown during file processing -->
- <div class="fileupload-loading"></div>
- <br/>
- <!-- The table listing the files available for upload/download -->
- <table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
-
- </wicket:panel>
+ <input type="checkbox" name="delete" value="1" class="toggle">
+ {% } else { %}
+ <button class="btn btn-warning cancel">
+ <i class="glyphicon glyphicon-ban-circle"></i>
+ <span>Cancel</span>
+ </button>
+ {% } %}
+ </td>
+ </tr>
+{% } %}
+</script>
+</wicket:panel>
</html>
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.java
index 8271a50a61..67b3333b05 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadBar.java
@@ -1,5 +1,6 @@
package com.pmease.gitop.web.common.component.fileupload;
+import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Panel;
/**
@@ -13,6 +14,8 @@ public class FileUploadBar extends Panel {
public FileUploadBar(String id) {
super(id);
- add(new FileUploadResourceBehavior());
+ WebMarkupContainer form = new WebMarkupContainer("form");
+ add(form);
+ form.add(new FileUploadResourceBehavior());
}
}
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceBehavior.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceBehavior.java
index 256b42ffbe..7f72902dd0 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceBehavior.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceBehavior.java
@@ -5,14 +5,15 @@ import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
+import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.util.io.IOUtils;
import org.apache.wicket.util.template.PackageTextTemplate;
-import com.pmease.gitop.web.GitopWebApp;
import com.pmease.gitop.web.assets.AssetLocator;
@SuppressWarnings("serial")
@@ -20,17 +21,17 @@ public class FileUploadResourceBehavior extends Behavior {
private static final ResourceReference FILEUPLOAD_JS =
new JavaScriptResourceReference(
- AssetLocator.class,
- "res/js/jquery.file.upload.js");
+ FileUploadResourceBehavior.class,
+ "res/js/jquery.fileupload.js");
private static final ResourceReference IFRAME_TRANSPORT_JS =
new JavaScriptResourceReference(
- AssetLocator.class,
+ FileUploadResourceBehavior.class,
"res/js/jquery.iframe-transport.js");
private static final ResourceReference FILEUPLOAD_UI_JS =
new JavaScriptResourceReference(
- AssetLocator.class,
+ FileUploadResourceBehavior.class,
"res/js/jquery.fileupload-ui.js");
/**
@@ -55,17 +56,31 @@ public class FileUploadResourceBehavior extends Behavior {
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
+ response.render(CssHeaderItem.forReference(new CssResourceReference(FileUploadResourceBehavior.class, "res/css/jquery.fileupload-ui.css")));
+
response.render(JavaScriptHeaderItem.forReference(AssetLocator.JQUERY_UI_WIDGET_JS));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/tmpl.min.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/load-image.min.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/jquery.blueimp-gallery.min.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/canvas-to-blob.min.js")));
+
response.render(JavaScriptHeaderItem.forReference(IFRAME_TRANSPORT_JS));
response.render(JavaScriptHeaderItem.forReference(FILEUPLOAD_JS));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/jquery.fileupload-process.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/jquery.fileupload-audio.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/jquery.fileupload-video.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/jquery.fileupload-image.js")));
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileUploadResourceBehavior.class, "res/js/jquery.fileupload-validate.js")));
response.render(JavaScriptHeaderItem.forReference(FILEUPLOAD_UI_JS));
- PackageTextTemplate jsTmpl = new PackageTextTemplate(AssetLocator.class, "js/vendor/jquery-file-upload/main.js");
+
+ PackageTextTemplate jsTmpl = new PackageTextTemplate(FileUploadResourceBehavior.class,
+ "res/js/main.js");
try {
Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("componentMarkupId", component.getMarkupId());
- variables.put("url", component.urlFor(new FileUploadResourceReference(GitopWebApp.get().getUploadsDir().getAbsolutePath()), null));
+ variables.put("componentId", component.getMarkupId());
+ variables.put("url", "/rest/file/upload");
variables.put("paramName", PARAM_NAME);
String s = jsTmpl.asString(variables);
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceReference.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceReference.java
index 58083db5e0..a265f8b7f0 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceReference.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadResourceReference.java
@@ -13,7 +13,7 @@ import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.util.upload.FileItem;
-import com.pmease.gitop.web.GitopWebApp;
+import com.pmease.gitop.web.SitePaths;
/**
* A resource reference provides default implementation of
@@ -81,7 +81,7 @@ public class FileUploadResourceReference extends ResourceReference {
PageParameters params = new PageParameters();
params.set("filename", fileItem.getName());
CharSequence url = RequestCycle.get().urlFor(
- new FileManagerResourceReference(GitopWebApp.get().getUploadsDir().getAbsolutePath()),
+ new FileManagerResourceReference(SitePaths.get().uploadsDir().getAbsolutePath()),
params);
return url;
}
@@ -91,7 +91,7 @@ public class FileUploadResourceReference extends ResourceReference {
params.set("filename", fileItem.getName());
params.set("delete", true);
CharSequence url = RequestCycle.get().urlFor(
- new FileManagerResourceReference(GitopWebApp.get().getUploadsDir().getAbsolutePath()),
+ new FileManagerResourceReference(SitePaths.get().uploadsDir().getAbsolutePath()),
params);
return url;
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadServlet.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadServlet.java
new file mode 100644
index 0000000000..814b76d417
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/FileUploadServlet.java
@@ -0,0 +1,182 @@
+package com.pmease.gitop.web.common.component.fileupload;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.imgscalr.Scalr;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+@SuppressWarnings("serial")
+public class FileUploadServlet extends HttpServlet {
+ static File imgDir = new File("/Users/zhenyu/temp/");
+
+ @Override
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ if (request.getParameter("getfile") != null
+ && !request.getParameter("getfile").isEmpty()) {
+ File file = new File(imgDir, request.getParameter("getfile"));
+ if (file.exists()) {
+ int bytes = 0;
+ ServletOutputStream op = response.getOutputStream();
+
+ response.setContentType(getMimeType(file));
+ response.setContentLength((int) file.length());
+ response.setHeader("Content-Disposition", "inline; filename=\""
+ + file.getName() + "\"");
+
+ byte[] bbuf = new byte[1024];
+ DataInputStream in = new DataInputStream(new FileInputStream(
+ file));
+
+ while ((in != null) && ((bytes = in.read(bbuf)) != -1)) {
+ op.write(bbuf, 0, bytes);
+ }
+
+ in.close();
+ op.flush();
+ op.close();
+ }
+ } else if (request.getParameter("delfile") != null
+ && !request.getParameter("delfile").isEmpty()) {
+ File file = new File(imgDir, request.getParameter("delfile"));
+ if (file.exists()) {
+ file.delete(); // TODO:check and report success
+ }
+ } else if (request.getParameter("getthumb") != null
+ && !request.getParameter("getthumb").isEmpty()) {
+ File file = new File(imgDir, request.getParameter("getthumb"));
+ if (file.exists()) {
+ System.out.println(file.getAbsolutePath());
+ String mimetype = getMimeType(file);
+ if (mimetype.endsWith("png") || mimetype.endsWith("jpeg")
+ || mimetype.endsWith("jpg") || mimetype.endsWith("gif")) {
+ BufferedImage im = ImageIO.read(file);
+ if (im != null) {
+ BufferedImage thumb = Scalr.resize(im, 75);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ if (mimetype.endsWith("png")) {
+ ImageIO.write(thumb, "PNG", os);
+ response.setContentType("image/png");
+ } else if (mimetype.endsWith("jpeg")) {
+ ImageIO.write(thumb, "jpg", os);
+ response.setContentType("image/jpeg");
+ } else if (mimetype.endsWith("jpg")) {
+ ImageIO.write(thumb, "jpg", os);
+ response.setContentType("image/jpeg");
+ } else {
+ ImageIO.write(thumb, "GIF", os);
+ response.setContentType("image/gif");
+ }
+ ServletOutputStream srvos = response.getOutputStream();
+ response.setContentLength(os.size());
+ response.setHeader("Content-Disposition",
+ "inline; filename=\"" + file.getName() + "\"");
+ os.writeTo(srvos);
+ srvos.flush();
+ srvos.close();
+ }
+ }
+ } // TODO: check and report success
+ } else {
+ PrintWriter writer = response.getWriter();
+ writer.write("call POST with multipart form data");
+ }
+ }
+
+ /**
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
+ * response)
+ *
+ */
+ @Override
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ if (!ServletFileUpload.isMultipartContent(request)) {
+ throw new IllegalArgumentException(
+ "Request is not multipart, please 'multipart/form-data' enctype for your form.");
+ }
+
+ ServletFileUpload uploadHandler = new ServletFileUpload(new DiskFileItemFactory());
+
+ PrintWriter writer = response.getWriter();
+ response.setContentType("application/json");
+ JSONArray json = new JSONArray();
+ try {
+ List<FileItem> items = uploadHandler.parseRequest(request);
+ for (FileItem item : items) {
+ if (!item.isFormField()) {
+ File file = new File(imgDir, item.getName());
+ item.write(file);
+ JSONObject jsono = new JSONObject();
+ jsono.put("name", item.getName());
+ jsono.put("size", item.getSize());
+ jsono.put("url", "UploadServlet?getfile=" + item.getName());
+ jsono.put("thumbnail_url",
+ "UploadServlet?getthumb=" + item.getName());
+ jsono.put("delete_url",
+ "UploadServlet?delfile=" + item.getName());
+ jsono.put("delete_type", "GET");
+ json.put(jsono);
+ System.out.println(json.toString());
+ }
+ }
+ } catch (FileUploadException e) {
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ writer.write(json.toString());
+ writer.close();
+ }
+
+ }
+
+ private String getMimeType(File file) {
+ String mimetype = "";
+ if (file.exists()) {
+ if (getSuffix(file.getName()).equalsIgnoreCase("png")) {
+ mimetype = "image/png";
+ } else if (getSuffix(file.getName()).equalsIgnoreCase("jpg")) {
+ mimetype = "image/jpg";
+ } else if (getSuffix(file.getName()).equalsIgnoreCase("jpeg")) {
+ mimetype = "image/jpeg";
+ } else if (getSuffix(file.getName()).equalsIgnoreCase("gif")) {
+ mimetype = "image/gif";
+ } else {
+ javax.activation.MimetypesFileTypeMap mtMap = new javax.activation.MimetypesFileTypeMap();
+ mimetype = mtMap.getContentType(file);
+ }
+ }
+ return mimetype;
+ }
+
+ private String getSuffix(String filename) {
+ String suffix = "";
+ int pos = filename.lastIndexOf('.');
+ if (pos > 0 && pos < filename.length() - 1) {
+ suffix = filename.substring(pos + 1);
+ }
+ return suffix;
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/css/gallery.min.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/css/gallery.min.js
new file mode 100644
index 0000000000..c7a7f07461
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/css/gallery.min.js
@@ -0,0 +1 @@
+@charset 'UTF-8';.blueimp-gallery,.blueimp-gallery>.slides>.slide>.slide-content{position:absolute;top:0;right:0;bottom:0;left:0;-moz-backface-visibility:hidden}.blueimp-gallery>.slides>.slide>.slide-content{margin:auto;max-width:100%;max-height:100%;opacity:1}.blueimp-gallery{position:fixed;z-index:9999;overflow:hidden;background:#000;background:rgba(0,0,0,.9);opacity:0;display:none;direction:ltr;-ms-touch-action:none}.blueimp-gallery-carousel{position:relative;z-index:auto;height:432px;max-width:768px;margin:1em auto;box-shadow:0 0 10px #000}.blueimp-gallery-display{display:block;opacity:1}.blueimp-gallery>.slides{position:relative;height:100%;overflow:hidden}.blueimp-gallery>.slides>.slide{position:relative;float:left;height:100%;text-align:center;-webkit-transition-timing-function:cubic-bezier(0.645,.045,.355,1);-moz-transition-timing-function:cubic-bezier(0.645,.045,.355,1);-ms-transition-timing-function:cubic-bezier(0.645,.045,.355,1);-o-transition-timing-function:cubic-bezier(0.645,.045,.355,1);transition-timing-function:cubic-bezier(0.645,.045,.355,1)}.blueimp-gallery,.blueimp-gallery>.slides>.slide>.slide-content{-webkit-transition:opacity .5s linear;-moz-transition:opacity .5s linear;-ms-transition:opacity .5s linear;-o-transition:opacity .5s linear;transition:opacity .5s linear}.blueimp-gallery>.slides>.slide-loading{background:url(../img/loading.gif) center no-repeat;background-size:64px 64px}.blueimp-gallery>.slides>.slide-loading>.slide-content{opacity:0}.blueimp-gallery>.slides>.slide-error{background:url(../img/error.png) center no-repeat}.blueimp-gallery>.slides>.slide-error>.slide-content{display:none}.blueimp-gallery>.prev,.blueimp-gallery>.next{position:absolute;top:50%;left:15px;width:40px;height:40px;margin-top:-23px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-decoration:none;text-shadow:0 0 2px #000;text-align:center;background:#222;background:rgba(0,0,0,.5);-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;cursor:pointer;display:none}.blueimp-gallery>.next{left:auto;right:15px}.blueimp-gallery>.close,.blueimp-gallery>.title{position:absolute;top:15px;left:15px;margin:0 40px 0 0;font-size:20px;line-height:30px;color:#fff;text-shadow:0 0 2px #000;opacity:.8;display:none}.blueimp-gallery>.close{padding:15px;right:15px;left:auto;margin:-15px;font-size:30px;text-decoration:none;cursor:pointer}.blueimp-gallery>.play-pause{position:absolute;right:15px;bottom:15px;width:15px;height:15px;background:url(../img/play-pause.png) 0 0 no-repeat;cursor:pointer;opacity:.5;display:none}.blueimp-gallery-playing>.play-pause{background-position:-15px 0}.blueimp-gallery-controls>.prev,.blueimp-gallery-controls>.next,.blueimp-gallery-controls>.close,.blueimp-gallery-controls>.title,.blueimp-gallery-controls>.play-pause{display:block;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-ms-transform:translateZ(0);-o-transform:translateZ(0);transform:translateZ(0)}.blueimp-gallery-single>.prev,.blueimp-gallery-left>.prev,.blueimp-gallery-single>.next,.blueimp-gallery-right>.next,.blueimp-gallery-single>.play-pause{display:none}.blueimp-gallery>.slides>.slide>.slide-content,.blueimp-gallery>.prev,.blueimp-gallery>.next,.blueimp-gallery>.close,.blueimp-gallery>.play-pause{-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body:last-child .blueimp-gallery>.slides>.slide-error{background-image:url(../img/error.svg)}body:last-child .blueimp-gallery>.play-pause{width:20px;height:20px;background-size:40px 20px;background-image:url(../img/play-pause.svg)}body:last-child .blueimp-gallery-playing>.play-pause{background-position:-20px 0}@media (max-width:767px){.blueimp-gallery-carousel{height:270px;max-width:480px}}*+html .blueimp-gallery>.slides>.slide{min-height:300px}*+html .blueimp-gallery>.slides>.slide>.slide-content{position:relative}.blueimp-gallery>.indicator{position:absolute;top:auto;right:15px;bottom:15px;left:15px;margin:0 40px;padding:0;list-style:none;text-align:center;line-height:10px;display:none}.blueimp-gallery>.indicator>li{display:inline-block;width:9px;height:9px;margin:6px 3px 0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;border:1px solid transparent;background:#ccc;background:rgba(255,255,255,.25) center no-repeat;border-radius:5px;box-shadow:0 0 2px #000;opacity:.5;cursor:pointer}.blueimp-gallery>.indicator>.active{background-color:#fff;border-color:#fff;opacity:.8}.blueimp-gallery-controls>.indicator{display:block;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-ms-transform:translateZ(0);-o-transform:translateZ(0);transform:translateZ(0)}.blueimp-gallery-single>.indicator{display:none}.blueimp-gallery>.indicator{-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}*+html .blueimp-gallery>.indicator>li{display:inline}.blueimp-gallery>.slides>.slide>.video-content>video,.blueimp-gallery>.slides>.slide>.video-content>img{position:absolute;top:0;right:0;bottom:0;left:0;-moz-backface-visibility:hidden}.blueimp-gallery>.slides>.slide>.video-content>video,.blueimp-gallery>.slides>.slide>.video-content>img{margin:auto;max-width:100%;max-height:100%;opacity:1}.blueimp-gallery>.slides>.slide>.video-content>a{position:absolute;top:50%;right:0;left:0;margin:-64px auto 0;width:128px;height:128px;background:url(../img/video-play.png) center no-repeat;opacity:.8;cursor:pointer}.blueimp-gallery>.slides>.slide>.video-playing>a,.blueimp-gallery>.slides>.slide>.video-playing>img{display:none}.blueimp-gallery>.slides>.slide>.video-content>video{display:none}.blueimp-gallery>.slides>.slide>.video-playing>video{display:block}.blueimp-gallery>.slides>.slide>.video-loading>a{background:url(../img/loading.gif) center no-repeat;background-size:64px 64px}body:last-child .blueimp-gallery>.slides>.slide>.video-content>a{background-image:url(../img/video-play.svg)}*+html .blueimp-gallery>.slides>.slide>.video-content{height:100%}*+html .blueimp-gallery>.slides>.slide>.video-content>a{left:50%;margin-left:-64px}
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/css/jquery.fileupload-ui.css b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/css/jquery.fileupload-ui.css
new file mode 100644
index 0000000000..f81b34c7b0
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/css/jquery.fileupload-ui.css
@@ -0,0 +1,68 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload UI Plugin CSS 8.8.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+.fileinput-button {
+ position: relative;
+ overflow: hidden;
+}
+.fileinput-button input {
+ position: absolute;
+ top: 0;
+ right: 0;
+ margin: 0;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ transform: translate(-300px, 0) scale(4);
+ font-size: 23px;
+ direction: ltr;
+ cursor: pointer;
+}
+.fileupload-buttonbar .btn,
+.fileupload-buttonbar .toggle {
+ margin-bottom: 5px;
+}
+.progress-animated .progress-bar,
+.progress-animated .bar {
+ background: url(../img/progressbar.gif) !important;
+ filter: none;
+}
+.fileupload-loading {
+ float: right;
+ width: 32px;
+ height: 32px;
+ background: url(../img/loading.gif) center no-repeat;
+ background-size: contain;
+ display: none;
+}
+.fileupload-processing .fileupload-loading {
+ display: block;
+}
+.files audio,
+.files video {
+ max-width: 300px;
+}
+
+@media (max-width: 767px) {
+ .fileupload-buttonbar .toggle,
+ .files .toggle,
+ .files .btn span {
+ display: none;
+ }
+ .files .name {
+ width: 80px;
+ word-wrap: break-word;
+ }
+ .files audio,
+ .files video {
+ max-width: 80px;
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/canvas-to-blob.min.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/canvas-to-blob.min.js
new file mode 100644
index 0000000000..7ee3553a06
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/canvas-to-blob.min.js
@@ -0,0 +1 @@
+!function(t){"use strict";var e=t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype,n=t.Blob&&function(){try{return Boolean(new Blob)}catch(t){return!1}}(),o=n&&t.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(t){return!1}}(),r=t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,i=(n||r)&&t.atob&&t.ArrayBuffer&&t.Uint8Array&&function(t){var e,i,a,l,u,B;for(e=t.split(",")[0].indexOf("base64")>=0?atob(t.split(",")[1]):decodeURIComponent(t.split(",")[1]),i=new ArrayBuffer(e.length),a=new Uint8Array(i),l=0;l<e.length;l+=1)a[l]=e.charCodeAt(l);return u=t.split(",")[0].split(":")[1].split(";")[0],n?new Blob([o?a:i],{type:u}):(B=new r,B.append(i),B.getBlob(u))};t.HTMLCanvasElement&&!e.toBlob&&(e.mozGetAsFile?e.toBlob=function(t,n,o){o&&e.toDataURL&&i?t(i(this.toDataURL(n,o))):t(this.mozGetAsFile("blob",n))}:e.toDataURL&&i&&(e.toBlob=function(t,e,n){t(i(this.toDataURL(e,n)))})),"function"==typeof define&&define.amd?define(function(){return i}):t.dataURLtoBlob=i}(this);
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/jquery.blueimp-gallery.min.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/jquery.blueimp-gallery.min.js
new file mode 100644
index 0000000000..0de6b4a53d
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/jquery.blueimp-gallery.min.js
@@ -0,0 +1 @@
+!function(t){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper"],t):(window.blueimp=window.blueimp||{},window.blueimp.Gallery=t(window.blueimp.helper||window.jQuery))}(function(t){"use strict";function e(t,i){return t&&t.length&&void 0!==document.body.style.maxHeight?this&&this.options===e.prototype.options?(this.list=t,this.num=t.length,this.initOptions(i),this.initialize(),void 0):new e(t,i):!1}return t.extend(e.prototype,{options:{container:"#blueimp-gallery",slidesContainer:"div",titleElement:"h3",displayClass:"blueimp-gallery-display",controlsClass:"blueimp-gallery-controls",singleClass:"blueimp-gallery-single",leftEdgeClass:"blueimp-gallery-left",rightEdgeClass:"blueimp-gallery-right",playingClass:"blueimp-gallery-playing",slideClass:"slide",slideLoadingClass:"slide-loading",slideErrorClass:"slide-error",slideContentClass:"slide-content",toggleClass:"toggle",prevClass:"prev",nextClass:"next",closeClass:"close",playPauseClass:"play-pause",typeProperty:"type",titleProperty:"title",urlProperty:"href",displayTransition:!0,clearSlides:!0,stretchImages:!1,toggleControlsOnReturn:!0,toggleSlideshowOnSpace:!0,enableKeyboardNavigation:!0,closeOnEscape:!0,closeOnSlideClick:!0,closeOnSwipeUpOrDown:!0,emulateTouchEvents:!0,hidePageScrollbars:!0,disableScroll:!0,carousel:!1,continuous:!0,unloadElements:!0,startSlideshow:!1,slideshowInterval:5e3,index:0,preloadRange:2,transitionSpeed:400,slideshowTransitionSpeed:void 0,event:void 0,onopen:void 0,onopened:void 0,onslide:void 0,onslideend:void 0,onslidecomplete:void 0,onclose:void 0,onclosed:void 0},carouselOptions:{hidePageScrollbars:!1,toggleControlsOnReturn:!1,toggleSlideshowOnSpace:!1,enableKeyboardNavigation:!1,closeOnEscape:!1,closeOnSlideClick:!1,closeOnSwipeUpOrDown:!1,disableScroll:!1,startSlideshow:!0},support:function(e){var i,s,n,o={touch:void 0!==window.ontouchstart||window.DocumentTouch&&document instanceof DocumentTouch},l={webkitTransition:{end:"webkitTransitionEnd",prefix:"-webkit-"},MozTransition:{end:"transitionend",prefix:"-moz-"},OTransition:{end:"otransitionend",prefix:"-o-"},transition:{end:"transitionend",prefix:""}},r=function(){document.body.appendChild(e),s&&(i=s.name.slice(0,-9)+"ransform",void 0!==e.style[i]&&(e.style[i]="translateZ(0)",n=window.getComputedStyle(e).getPropertyValue(s.prefix+"transform"),o.transform={prefix:s.prefix,name:i,translate:!0,translateZ:!!n&&"none"!==n})),void 0!==e.style.backgroundSize&&(e.style.backgroundSize="contain",o.backgroundSize={contain:"contain"===window.getComputedStyle(e).getPropertyValue("background-size")}),document.body.removeChild(e)};for(i in l)if(l.hasOwnProperty(i)&&void 0!==e.style[i]){s=l[i],s.name=i,o.transition=s;break}return document.body?r():t(document).on("DOMContentLoaded",r),o}(document.createElement("div")),requestAnimationFrame:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,initialize:function(){return this.initStartIndex(),this.initWidget()===!1?!1:(this.initEventListeners(),this.onslide(this.index),this.ontransitionend(),this.options.startSlideshow&&this.play(),void 0)},slide:function(t,e){window.clearTimeout(this.timeout);var i,s,n,o=this.index;if(o!==t&&1!==this.num){if(e||(e=this.options.transitionSpeed),this.support.transition){for(this.options.continuous||(t=this.circle(t)),i=Math.abs(o-t)/(o-t),this.options.continuous&&(s=i,i=-this.positions[this.circle(t)]/this.slideWidth,i!==s&&(t=-i*this.num+t)),n=Math.abs(o-t)-1;n;)n-=1,this.move(this.circle((t>o?t:o)-n-1),this.slideWidth*i,0);t=this.circle(t),this.move(o,this.slideWidth*i,e),this.move(t,0,e),this.options.continuous&&this.move(this.circle(t-i),-(this.slideWidth*i),0)}else t=this.circle(t),this.animate(o*-this.slideWidth,t*-this.slideWidth,e);this.onslide(t)}},getIndex:function(){return this.index},getNumber:function(){return this.num},prev:function(){(this.options.continuous||this.index)&&this.slide(this.index-1)},next:function(){(this.options.continuous||this.index<this.num-1)&&this.slide(this.index+1)},play:function(t){var e=this;window.clearTimeout(this.timeout),this.interval=t||this.options.slideshowInterval,this.elements[this.index]>1&&(this.timeout=this.setTimeout(!this.requestAnimationFrame&&this.slide||function(t,i){e.animationFrameId=e.requestAnimationFrame.call(window,function(){e.slide(t,i)})},[this.index+1,this.options.slideshowTransitionSpeed],this.interval)),this.container.addClass(this.options.playingClass)},pause:function(){window.clearTimeout(this.timeout),this.interval=null,this.container.removeClass(this.options.playingClass)},add:function(t){var e;for(this.list=this.list.concat(t),this.num=this.list.length,this.num>2&&null===this.options.continuous&&(this.options.continuous=!0,this.container.removeClass(this.options.leftEdgeClass)),this.container.removeClass(this.options.rightEdgeClass).removeClass(this.options.singleClass),e=this.num-t.length;e<this.num;e+=1)this.addSlide(e),this.positionSlide(e);this.positions.length=this.num,this.initSlides(!0)},resetSlides:function(){this.slidesContainer.empty(),this.slides=[]},handleClose:function(){var t=this.options;this.destroyEventListeners(),this.pause(),this.container[0].style.display="none",this.container.removeClass(t.displayClass).removeClass(t.singleClass).removeClass(t.leftEdgeClass).removeClass(t.rightEdgeClass),t.hidePageScrollbars&&(document.body.style.overflow=this.bodyOverflowStyle),this.options.clearSlides&&this.resetSlides(),this.options.onclosed&&this.options.onclosed.call(this)},close:function(){var t=this,e=function(i){i.target===t.container[0]&&(t.container.off(t.support.transition.end,e),t.handleClose())};this.options.onclose&&this.options.onclose.call(this),this.support.transition&&this.options.displayTransition?(this.container.on(this.support.transition.end,e),this.container.removeClass(this.options.displayClass)):this.handleClose()},circle:function(t){return(this.num+t%this.num)%this.num},move:function(t,e,i){this.translateX(t,e,i),this.positions[t]=e},translate:function(t,e,i,s){var n=this.slides[t].style,o=this.support.transition,l=this.support.transform;n[o.name+"Duration"]=s+"ms",n[l.name]="translate("+e+"px, "+i+"px)"+(l.translateZ?" translateZ(0)":"")},translateX:function(t,e,i){this.translate(t,e,0,i)},translateY:function(t,e,i){this.translate(t,0,e,i)},animate:function(t,e,i){if(!i)return this.slidesContainer[0].style.left=e+"px",void 0;var s=this,n=(new Date).getTime(),o=window.setInterval(function(){var l=(new Date).getTime()-n;return l>i?(s.slidesContainer[0].style.left=e+"px",s.ontransitionend(),window.clearInterval(o),void 0):(s.slidesContainer[0].style.left=(e-t)*(Math.floor(100*(l/i))/100)+t+"px",void 0)},4)},preventDefault:function(t){t.preventDefault?t.preventDefault():t.returnValue=!1},onresize:function(){this.initSlides(!0)},onmousedown:function(t){t.which&&1===t.which&&(t.preventDefault(),(t.originalEvent||t).touches=[{pageX:t.pageX,pageY:t.pageY}],this.ontouchstart(t))},onmousemove:function(t){this.touchStart&&((t.originalEvent||t).touches=[{pageX:t.pageX,pageY:t.pageY}],this.ontouchmove(t))},onmouseup:function(t){this.touchStart&&(this.ontouchend(t),delete this.touchStart)},onmouseout:function(e){if(this.touchStart){var i=e.target,s=e.relatedTarget;(!s||s!==i&&!t.contains(i,s))&&this.onmouseup(e)}},ontouchstart:function(t){var e=(t.originalEvent||t).touches[0];this.touchStart={x:e.pageX,y:e.pageY,time:Date.now()},this.isScrolling=void 0,this.touchDelta={}},ontouchmove:function(t){var e,i,s=(t.originalEvent||t).touches[0],n=(t.originalEvent||t).scale,o=this.index;if(!(s.length>1||n&&1!==n))if(this.options.disableScroll&&t.preventDefault(),this.touchDelta={x:s.pageX-this.touchStart.x,y:s.pageY-this.touchStart.y},e=this.touchDelta.x,void 0===this.isScrolling&&(this.isScrolling=this.isScrolling||Math.abs(e)<Math.abs(this.touchDelta.y)),this.isScrolling)this.options.closeOnSwipeUpOrDown&&this.translateY(o,this.touchDelta.y+this.positions[o],0);else for(t.preventDefault(),window.clearTimeout(this.timeout),this.options.continuous?i=[this.circle(o+1),o,this.circle(o-1)]:(this.touchDelta.x=e/=!o&&e>0||o===this.num-1&&0>e?Math.abs(e)/this.slideWidth+1:1,i=[o],o&&i.push(o-1),o<this.num-1&&i.unshift(o+1));i.length;)o=i.pop(),this.translateX(o,e+this.positions[o],0)},ontouchend:function(){var t,e,i,s,n,o=this.index,l=this.options.transitionSpeed,r=this.slideWidth,a=Number(Date.now()-this.touchStart.time)<250,h=a&&Math.abs(this.touchDelta.x)>20||Math.abs(this.touchDelta.x)>r/2,d=!o&&this.touchDelta.x>0||o===this.num-1&&this.touchDelta.x<0,c=!h&&this.options.closeOnSwipeUpOrDown&&(a&&Math.abs(this.touchDelta.y)>20||Math.abs(this.touchDelta.y)>this.slideHeight/2);this.options.continuous&&(d=!1),t=this.touchDelta.x<0?-1:1,this.isScrolling?c?this.close():this.translateY(o,0,l):h&&!d?(e=o+t,i=o-t,s=r*t,n=-r*t,this.options.continuous?(this.move(this.circle(e),s,0),this.move(this.circle(o-2*t),n,0)):e>=0&&e<this.num&&this.move(e,s,0),this.move(o,this.positions[o]+s,l),this.move(this.circle(i),this.positions[this.circle(i)]+s,l),o=this.circle(i),this.onslide(o)):this.options.continuous?(this.move(this.circle(o-1),-r,l),this.move(o,0,l),this.move(this.circle(o+1),r,l)):(o&&this.move(o-1,-r,l),this.move(o,0,l),o<this.num-1&&this.move(o+1,r,l))},ontransitionend:function(t){var e=this.slides[this.index];t&&e!==t.target||(this.interval&&this.play(),this.setTimeout(this.options.onslideend,[this.index,e]))},oncomplete:function(e){var i,s=e.target||e.srcElement,n=s&&s.parentNode;s&&n&&(i=this.getNodeIndex(n),t(n).removeClass(this.options.slideLoadingClass),"error"===e.type?(t(n).addClass(this.options.slideErrorClass),this.elements[i]=3):this.elements[i]=2,s.clientHeight>this.container[0].clientHeight&&(s.style.maxHeight=this.container[0].clientHeight),this.interval&&this.slides[this.index]===n&&this.play(),this.setTimeout(this.options.onslidecomplete,[i,n]))},onload:function(t){this.oncomplete(t)},onerror:function(t){this.oncomplete(t)},onkeydown:function(t){switch(t.which||t.keyCode){case 13:this.options.toggleControlsOnReturn&&(this.preventDefault(t),this.toggleControls());break;case 27:this.options.closeOnEscape&&this.close();break;case 32:this.options.toggleSlideshowOnSpace&&(this.preventDefault(t),this.toggleSlideshow());break;case 37:this.options.enableKeyboardNavigation&&(this.preventDefault(t),this.prev());break;case 39:this.options.enableKeyboardNavigation&&(this.preventDefault(t),this.next())}},handleClick:function(e){var i=this.options,s=e.target||e.srcElement,n=s.parentNode,o=function(e){return t(s).hasClass(e)||t(n).hasClass(e)};n===this.slidesContainer[0]?(this.preventDefault(e),i.closeOnSlideClick?this.close():this.toggleControls()):n.parentNode&&n.parentNode===this.slidesContainer[0]?(this.preventDefault(e),this.toggleControls()):o(i.toggleClass)?(this.preventDefault(e),this.toggleControls()):o(i.prevClass)?(this.preventDefault(e),this.prev()):o(i.nextClass)?(this.preventDefault(e),this.next()):o(i.closeClass)?(this.preventDefault(e),this.close()):o(i.playPauseClass)&&(this.preventDefault(e),this.toggleSlideshow())},onclick:function(t){return this.options.emulateTouchEvents&&this.touchDelta&&(Math.abs(this.touchDelta.x)>20||Math.abs(this.touchDelta.y)>20)?(delete this.touchDelta,void 0):this.handleClick(t)},updateEdgeClasses:function(t){t?this.container.removeClass(this.options.leftEdgeClass):this.container.addClass(this.options.leftEdgeClass),t===this.num-1?this.container.addClass(this.options.rightEdgeClass):this.container.removeClass(this.options.rightEdgeClass)},handleSlide:function(t){this.options.continuous||this.updateEdgeClasses(t),this.loadElements(t),this.options.unloadElements&&this.unloadElements(t),this.setTitle(t)},onslide:function(t){this.index=t,this.handleSlide(t),this.setTimeout(this.options.onslide,[t,this.slides[t]])},setTitle:function(t){var e=this.slides[t].firstChild.title,i=this.titleElement;i.length&&(this.titleElement.empty(),e&&i[0].appendChild(document.createTextNode(e)))},setTimeout:function(t,e,i){var s=this;return t&&window.setTimeout(function(){t.apply(s,e||[])},i||0)},imageFactory:function(e,i){var s,n,o,l=this,r=this.imagePrototype.cloneNode(!1),a=e,h=this.options.stretchImages&&this.support.backgroundSize&&this.support.backgroundSize.contain,d=function(e){if(!s){if(e={type:e.type,target:n},!n.parentNode)return l.setTimeout(d,[e]);s=!0,t(r).off("load error",d),h&&"load"===e.type&&(n.style.background='url("'+a+'") center no-repeat',n.style.backgroundSize="contain"),i(e)}};return"string"!=typeof a&&(a=this.getItemProperty(e,this.options.urlProperty),o=this.getItemProperty(e,this.options.titleProperty)),h?n=this.elementPrototype.cloneNode(!1):(n=r,r.draggable=!1),o&&(n.title=o),t(r).on("load error",d),r.src=a,n},createElement:function(e,i){var s=e&&this.getItemProperty(e,this.options.typeProperty),n=s&&this[s.split("/")[0]+"Factory"]||this.imageFactory,o=e&&n.call(this,e,i);return o||(o=this.elementPrototype.cloneNode(!1),this.setTimeout(i,[{type:"error",target:o}])),t(o).addClass(this.options.slideContentClass),o},loadElement:function(e){this.elements[e]||(this.slides[e].firstChild?this.elements[e]=t(this.slides[e]).hasClass(this.options.slideErrorClass)?3:2:(this.elements[e]=1,t(this.slides[e]).addClass(this.options.slideLoadingClass),this.slides[e].appendChild(this.createElement(this.list[e],this.proxyListener))))},loadElements:function(t){var e,i=Math.min(this.num,2*this.options.preloadRange+1),s=t;for(e=0;i>e;e+=1)s+=e*(0===e%2?-1:1),s=this.circle(s),this.loadElement(s)},unloadElements:function(t){var e,i,s;for(e in this.elements)this.elements.hasOwnProperty(e)&&(s=Math.abs(t-e),s>this.options.preloadRange&&s+this.options.preloadRange<this.num&&(i=this.slides[e],i.removeChild(i.firstChild),delete this.elements[e]))},addSlide:function(t){var e=this.slidePrototype.cloneNode(!1);e.setAttribute("data-index",t),this.slidesContainer[0].appendChild(e),this.slides.push(e)},positionSlide:function(t){var e=this.slides[t];e.style.width=this.slideWidth+"px",this.support.transition&&(e.style.left=t*-this.slideWidth+"px",this.move(t,this.index>t?-this.slideWidth:this.index<t?this.slideWidth:0,0))},initSlides:function(e){var i,s;for(e||(this.positions=[],this.positions.length=this.num,this.elements={},this.imagePrototype=document.createElement("img"),this.elementPrototype=document.createElement("div"),this.slidePrototype=document.createElement("div"),t(this.slidePrototype).addClass(this.options.slideClass),this.slides=this.slidesContainer[0].children,i=this.options.clearSlides||this.slides.length!==this.num),this.slideWidth=this.container[0].offsetWidth,this.slideHeight=this.container[0].offsetHeight,this.slidesContainer[0].style.width=this.num*this.slideWidth+"px",i&&this.resetSlides(),s=0;s<this.num;s+=1)i&&this.addSlide(s),this.positionSlide(s);this.options.continuous&&this.support.transition&&(this.move(this.circle(this.index-1),-this.slideWidth,0),this.move(this.circle(this.index+1),this.slideWidth,0)),this.support.transition||(this.slidesContainer[0].style.left=this.index*-this.slideWidth+"px")},toggleControls:function(){var t=this.options.controlsClass;this.container.hasClass(t)?this.container.removeClass(t):this.container.addClass(t)},toggleSlideshow:function(){this.interval?this.pause():this.play()},getNodeIndex:function(t){return parseInt(t.getAttribute("data-index"),10)},getNestedProperty:function(t,e){return e.replace(/\[(?:'([^']+)'|"([^"]+)"|(\d+))\]|(?:(?:^|\.)([^\.\[]+))/g,function(e,i,s,n,o){var l=o||i||s||n&&parseInt(n,10);e&&t&&(t=t[l])}),t},getItemProperty:function(t,e){return t[e]||t.getAttribute&&t.getAttribute("data-"+e)||this.getNestedProperty(t,e)},initStartIndex:function(){var t,e=this.options.index,i=this.options.urlProperty;if(e&&"number"!=typeof e)for(t=0;t<this.num;t+=1)if(this.list[t]===e||this.getItemProperty(this.list[t],i)===this.getItemProperty(e,i)){e=t;break}this.index=this.circle(parseInt(e,10)||0)},initEventListeners:function(){var e=this,i=this.slidesContainer,s=function(t){var i=e.support.transition&&e.support.transition.end===t.type?"transitionend":t.type;e["on"+i](t)};t(window).on("resize",s),t(document.body).on("keydown",s),this.container.on("click",s),this.support.touch?i.on("touchstart touchmove touchend",s):this.options.emulateTouchEvents&&this.support.transition&&i.on("mousedown mousemove mouseup mouseout",s),this.support.transition&&i.on(this.support.transition.end,s),this.proxyListener=s},destroyEventListeners:function(){var e=this.slidesContainer,i=this.proxyListener;t(window).off("resize",i),t(document.body).off("keydown",i),this.container.off("click",i),this.support.touch?e.off("touchstart touchmove touchend",i):this.options.emulateTouchEvents&&this.support.transition&&e.off("mousedown mousemove mouseup mouseout",i),this.support.transition&&e.off(this.support.transition.end,i)},handleOpen:function(){this.options.onopened&&this.options.onopened.call(this)},initWidget:function(){var e=this,i=function(t){t.target===e.container[0]&&(e.container.off(e.support.transition.end,i),e.handleOpen())};return this.container=t(this.options.container),this.container.length?(this.slidesContainer=this.container.find(this.options.slidesContainer),this.slidesContainer.length?(this.titleElement=this.container.find(this.options.titleElement),1===this.num&&this.container.addClass(this.options.singleClass),this.options.onopen&&this.options.onopen.call(this),this.support.transition&&this.options.displayTransition?this.container.on(this.support.transition.end,i):this.handleOpen(),this.options.hidePageScrollbars&&(this.bodyOverflowStyle=document.body.style.overflow,document.body.style.overflow="hidden"),this.container[0].style.display="block",this.initSlides(),this.container.addClass(this.options.displayClass),void 0):!1):!1},initOptions:function(e){this.options=t.extend({},this.options),(e&&e.carousel||this.options.carousel&&(!e||e.carousel!==!1))&&t.extend(this.options,this.carouselOptions),t.extend(this.options,e),this.num<3&&(this.options.continuous=this.options.continuous?null:!1),this.support.transition||(this.options.emulateTouchEvents=!1),this.options.event&&this.preventDefault(this.options.event)}}),e}),function(t){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery"],t):t(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(t,e){"use strict";t.extend(e.prototype.options,{fullScreen:!1});var i=e.prototype.initialize,s=e.prototype.handleClose;return t.extend(e.prototype,{getFullScreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement},requestFullScreen:function(t){t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen&&t.mozRequestFullScreen()},exitFullScreen:function(){document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.mozCancelFullScreen&&document.mozCancelFullScreen()},initialize:function(){i.call(this),this.options.fullScreen&&!this.getFullScreenElement()&&this.requestFullScreen(this.container[0])},handleClose:function(){this.getFullScreenElement()===this.container[0]&&this.exitFullScreen(),s.call(this)}}),e}),function(t){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery"],t):t(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(t,e){"use strict";t.extend(e.prototype.options,{indicatorContainer:"ol",activeIndicatorClass:"active",thumbnailProperty:"thumbnail",thumbnailIndicators:!0});var i=e.prototype.initSlides,s=e.prototype.addSlide,n=e.prototype.resetSlides,o=e.prototype.handleClick,l=e.prototype.handleSlide,r=e.prototype.handleClose;return t.extend(e.prototype,{createIndicator:function(e){var i,s,n=this.indicatorPrototype.cloneNode(!1),o=this.getItemProperty(e,this.options.titleProperty),l=this.options.thumbnailProperty;return this.options.thumbnailIndicators&&(s=e.getElementsByTagName&&t(e).find("img")[0],s?i=s.src:l&&(i=this.getItemProperty(e,l)),i&&(n.style.backgroundImage='url("'+i+'")')),o&&(n.title=o),n},addIndicator:function(t){if(this.indicatorContainer.length){var e=this.createIndicator(this.list[t]);e.setAttribute("data-index",t),this.indicatorContainer[0].appendChild(e),this.indicators.push(e)}},setActiveIndicator:function(e){this.indicators&&(this.activeIndicator&&this.activeIndicator.removeClass(this.options.activeIndicatorClass),this.activeIndicator=t(this.indicators[e]),this.activeIndicator.addClass(this.options.activeIndicatorClass))},initSlides:function(t){t||(this.indicatorContainer=this.container.find(this.options.indicatorContainer),this.indicatorContainer.length&&(this.indicatorPrototype=document.createElement("li"),this.indicators=this.indicatorContainer[0].children)),i.call(this,t)},addSlide:function(t){s.call(this,t),this.addIndicator(t)},resetSlides:function(){n.call(this),this.indicatorContainer.empty(),this.indicators=[]},handleClick:function(t){var e=t.target||t.srcElement,i=e.parentNode;if(i===this.indicatorContainer[0])this.preventDefault(t),this.slide(this.getNodeIndex(e));else{if(i.parentNode!==this.indicatorContainer[0])return o.call(this,t);this.preventDefault(t),this.slide(this.getNodeIndex(i))}},handleSlide:function(t){l.call(this,t),this.setActiveIndicator(t)},handleClose:function(){this.activeIndicator&&this.activeIndicator.removeClass(this.options.activeIndicatorClass),r.call(this)}}),e}),function(t){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery"],t):t(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(t,e){"use strict";return t.extend(e.prototype.options,{videoContentClass:"video-content",videoLoadingClass:"video-loading",videoPlayingClass:"video-playing",videoPosterProperty:"poster",videoSourcesProperty:"sources"}),e.prototype.videoFactory=function(e,i){var s,n,o,l,r,a=this,h=this.options,d=this.elementPrototype.cloneNode(!1),c=t(d),u=[{type:"error",target:d}],p=document.createElement("video"),m=this.getItemProperty(e,h.urlProperty),f=this.getItemProperty(e,h.typeProperty),g=this.getItemProperty(e,h.titleProperty),y=this.getItemProperty(e,h.videoPosterProperty),v=this.getItemProperty(e,h.videoSourcesProperty);if(c.addClass(h.videoContentClass),g&&(d.title=g),p.canPlayType)if(m&&f&&p.canPlayType(f))p.src=m;else if(v)for("string"==typeof v&&(v=t.parseJSON(v));v&&v.length;)if(n=v.shift(),m=this.getItemProperty(n,h.urlProperty),f=this.getItemProperty(n,h.typeProperty),m&&f&&p.canPlayType(f)){p.src=m;break}return y&&(p.setAttribute("poster",y),s=this.imagePrototype.cloneNode(!1),t(s).addClass(h.toggleClass),s.src=y,s.draggable=!1,d.appendChild(s)),o=document.createElement("a"),o.setAttribute("target","_blank"),o.setAttribute("download",g),o.href=m,p.src&&(p.controls=!0,t(p).on("error",function(){a.setTimeout(i,u)}).on("pause",function(){l=!1,c.removeClass(a.options.videoLoadingClass).removeClass(a.options.videoPlayingClass),r&&a.container.addClass(a.options.controlsClass),a.interval&&a.play()}).on("playing",function(){l=!1,c.removeClass(a.options.videoLoadingClass).addClass(a.options.videoPlayingClass),a.container.hasClass(a.options.controlsClass)?(r=!0,a.container.removeClass(a.options.controlsClass)):r=!1}).on("play",function(){window.clearTimeout(a.timeout),l=!0,c.addClass(a.options.videoLoadingClass)}),t(o).on("click",function(t){t.preventDefault(),l?p.pause():p.play()}),d.appendChild(p)),d.appendChild(o),this.setTimeout(i,[{type:"load",target:d}]),d},e}),function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery","./blueimp-gallery.js"],t):t(window.jQuery,window.blueimp.Gallery)}(function(t,e){"use strict";t(document).on("click","[data-gallery]",function(i){var s=t(this).data("gallery"),n=t(s),o=n.length&&n||t(e.prototype.options.container),l=t.extend(o.data(),{container:o[0],index:this,event:i,onopen:function(){o.data("gallery",this).trigger("open")},onopened:function(){o.trigger("opened")},onslide:function(){o.trigger("slide",arguments)},onslideend:function(){o.trigger("slideend",arguments)},onslidecomplete:function(){o.trigger("slidecomplete",arguments)},onclose:function(){o.trigger("close")},onclosed:function(){o.trigger("closed").removeData("gallery")}}),r=t('[data-gallery="'+s+'"]');return l.filter&&(r=r.filter(l.filter)),new e(r,l)})});
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/load-image.min.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/load-image.min.js
new file mode 100644
index 0000000000..8f04e85144
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/load-image.min.js
@@ -0,0 +1 @@
+(function(e){"use strict";var t=function(e,i,a){var n,r,o=document.createElement("img");if(o.onerror=i,o.onload=function(){!r||a&&a.noRevoke||t.revokeObjectURL(r),i&&i(t.scale(o,a))},t.isInstanceOf("Blob",e)||t.isInstanceOf("File",e))n=r=t.createObjectURL(e),o._type=e.type;else{if("string"!=typeof e)return!1;n=e,a&&a.crossOrigin&&(o.crossOrigin=a.crossOrigin)}return n?(o.src=n,o):t.readFile(e,function(e){var t=e.target;t&&t.result?o.src=t.result:i&&i(e)})},i=window.createObjectURL&&window||window.URL&&URL.revokeObjectURL&&URL||window.webkitURL&&webkitURL;t.isInstanceOf=function(e,t){return Object.prototype.toString.call(t)==="[object "+e+"]"},t.transformCoordinates=function(){},t.getTransformedOptions=function(e){return e},t.renderImageToCanvas=function(e,t,i,a,n,r,o,s,d,l){return e.getContext("2d").drawImage(t,i,a,n,r,o,s,d,l),e},t.hasCanvasOption=function(e){return e.canvas||e.crop},t.scale=function(e,i){i=i||{};var a,n,r,o,s,d,l,c,u,g=document.createElement("canvas"),f=e.getContext||t.hasCanvasOption(i)&&g.getContext,h=e.naturalWidth||e.width,m=e.naturalHeight||e.height,p=h,S=m,b=function(){var e=Math.max((r||p)/p,(o||S)/S);e>1&&(p=Math.ceil(p*e),S=Math.ceil(S*e))},v=function(){var e=Math.min((a||p)/p,(n||S)/S);1>e&&(p=Math.ceil(p*e),S=Math.ceil(S*e))};return f&&(i=t.getTransformedOptions(i),l=i.left||0,c=i.top||0,i.sourceWidth?(s=i.sourceWidth,void 0!==i.right&&void 0===i.left&&(l=h-s-i.right)):s=h-l-(i.right||0),i.sourceHeight?(d=i.sourceHeight,void 0!==i.bottom&&void 0===i.top&&(c=m-d-i.bottom)):d=m-c-(i.bottom||0),p=s,S=d),a=i.maxWidth,n=i.maxHeight,r=i.minWidth,o=i.minHeight,f&&a&&n&&i.crop?(p=a,S=n,u=s/d-a/n,0>u?(d=n*s/a,void 0===i.top&&void 0===i.bottom&&(c=(m-d)/2)):u>0&&(s=a*d/n,void 0===i.left&&void 0===i.right&&(l=(h-s)/2))):((i.contain||i.cover)&&(r=a=a||r,o=n=n||o),i.cover?(v(),b()):(b(),v())),f?(g.width=p,g.height=S,t.transformCoordinates(g,i),t.renderImageToCanvas(g,e,l,c,s,d,0,0,p,S)):(e.width=p,e.height=S,e)},t.createObjectURL=function(e){return i?i.createObjectURL(e):!1},t.revokeObjectURL=function(e){return i?i.revokeObjectURL(e):!1},t.readFile=function(e,t,i){if(window.FileReader){var a=new FileReader;if(a.onload=a.onerror=t,i=i||"readAsDataURL",a[i])return a[i](e),a}return!1},"function"==typeof define&&define.amd?define(function(){return t}):e.loadImage=t})(this),function(e){"use strict";"function"==typeof define&&define.amd?define(["load-image"],e):e(window.loadImage)}(function(e){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var t=e.renderImageToCanvas;e.detectSubsampling=function(e){var t,i;return e.width*e.height>1048576?(t=document.createElement("canvas"),t.width=t.height=1,i=t.getContext("2d"),i.drawImage(e,-e.width+1,0),0===i.getImageData(0,0,1,1).data[3]):!1},e.detectVerticalSquash=function(e,t){var i,a,n,r,o,s=e.naturalHeight||e.height,d=document.createElement("canvas"),l=d.getContext("2d");for(t&&(s/=2),d.width=1,d.height=s,l.drawImage(e,0,0),i=l.getImageData(0,0,1,s).data,a=0,n=s,r=s;r>a;)o=i[4*(r-1)+3],0===o?n=r:a=r,r=n+a>>1;return r/s||1},e.renderImageToCanvas=function(i,a,n,r,o,s,d,l,c,u){if("image/jpeg"===a._type){var g,f,h,m,p=i.getContext("2d"),S=document.createElement("canvas"),b=1024,v=S.getContext("2d");if(S.width=b,S.height=b,p.save(),g=e.detectSubsampling(a),g&&(n/=2,r/=2,o/=2,s/=2),f=e.detectVerticalSquash(a,g),g||1!==f){for(r*=f,c=Math.ceil(b*c/o),u=Math.ceil(b*u/s/f),l=0,m=0;s>m;){for(d=0,h=0;o>h;)v.clearRect(0,0,b,b),v.drawImage(a,n,r,o,s,-h,-m,o,s),p.drawImage(S,0,0,b,b,d,l,c,u),h+=b,d+=c;m+=b,l+=u}return p.restore(),i}}return t(i,a,n,r,o,s,d,l,c,u)}}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["load-image"],e):e(window.loadImage)}(function(e){"use strict";var t=e.hasCanvasOption;e.hasCanvasOption=function(e){return t(e)||e.orientation},e.transformCoordinates=function(e,t){var i=e.getContext("2d"),a=e.width,n=e.height,r=t.orientation;if(r)switch(r>4&&(e.width=n,e.height=a),r){case 2:i.translate(a,0),i.scale(-1,1);break;case 3:i.translate(a,n),i.rotate(Math.PI);break;case 4:i.translate(0,n),i.scale(1,-1);break;case 5:i.rotate(.5*Math.PI),i.scale(1,-1);break;case 6:i.rotate(.5*Math.PI),i.translate(0,-n);break;case 7:i.rotate(.5*Math.PI),i.translate(a,-n),i.scale(-1,1);break;case 8:i.rotate(-.5*Math.PI),i.translate(-a,0)}},e.getTransformedOptions=function(e){if(!e.orientation||1===e.orientation)return e;var t,i={};for(t in e)e.hasOwnProperty(t)&&(i[t]=e[t]);switch(e.orientation){case 2:i.left=e.right,i.right=e.left;break;case 3:i.left=e.right,i.top=e.bottom,i.right=e.left,i.bottom=e.top;break;case 4:i.top=e.bottom,i.bottom=e.top;break;case 5:i.left=e.top,i.top=e.left,i.right=e.bottom,i.bottom=e.right;break;case 6:i.left=e.top,i.top=e.right,i.right=e.bottom,i.bottom=e.left;break;case 7:i.left=e.bottom,i.top=e.right,i.right=e.top,i.bottom=e.left;break;case 8:i.left=e.bottom,i.top=e.left,i.right=e.top,i.bottom=e.right}return e.orientation>4&&(i.maxWidth=e.maxHeight,i.maxHeight=e.maxWidth,i.minWidth=e.minHeight,i.minHeight=e.minWidth,i.sourceWidth=e.sourceHeight,i.sourceHeight=e.sourceWidth),i}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["load-image"],e):e(window.loadImage)}(function(e){"use strict";var t=window.Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice);e.blobSlice=t&&function(){var e=this.slice||this.webkitSlice||this.mozSlice;return e.apply(this,arguments)},e.metaDataParsers={jpeg:{65505:[]}},e.parseMetaData=function(t,i,a){a=a||{};var n=this,r=a.maxMetaDataSize||262144,o={},s=!(window.DataView&&t&&t.size>=12&&"image/jpeg"===t.type&&e.blobSlice);(s||!e.readFile(e.blobSlice.call(t,0,r),function(t){var r,s,d,l,c=t.target.result,u=new DataView(c),g=2,f=u.byteLength-4,h=g;if(65496===u.getUint16(0)){for(;f>g&&(r=u.getUint16(g),r>=65504&&65519>=r||65534===r);){if(s=u.getUint16(g+2)+2,g+s>u.byteLength){console.log("Invalid meta data: Invalid segment size.");break}if(d=e.metaDataParsers.jpeg[r])for(l=0;d.length>l;l+=1)d[l].call(n,u,g,s,o,a);g+=s,h=g}!a.disableImageHead&&h>6&&(o.imageHead=c.slice?c.slice(0,h):new Uint8Array(c).subarray(0,h))}else console.log("Invalid JPEG file: Missing JPEG marker.");i(o)},"readAsArrayBuffer"))&&i(o)}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["load-image","load-image-meta"],e):e(window.loadImage)}(function(e){"use strict";e.ExifMap=function(){return this},e.ExifMap.prototype.map={Orientation:274},e.ExifMap.prototype.get=function(e){return this[e]||this[this.map[e]]},e.getExifThumbnail=function(e,t,i){var a,n,r;if(!i||t+i>e.byteLength)return console.log("Invalid Exif data: Invalid thumbnail data."),void 0;for(a=[],n=0;i>n;n+=1)r=e.getUint8(t+n),a.push((16>r?"0":"")+r.toString(16));return"data:image/jpeg,%"+a.join("%")},e.exifTagTypes={1:{getValue:function(e,t){return e.getUint8(t)},size:1},2:{getValue:function(e,t){return String.fromCharCode(e.getUint8(t))},size:1,ascii:!0},3:{getValue:function(e,t,i){return e.getUint16(t,i)},size:2},4:{getValue:function(e,t,i){return e.getUint32(t,i)},size:4},5:{getValue:function(e,t,i){return e.getUint32(t,i)/e.getUint32(t+4,i)},size:8},9:{getValue:function(e,t,i){return e.getInt32(t,i)},size:4},10:{getValue:function(e,t,i){return e.getInt32(t,i)/e.getInt32(t+4,i)},size:8}},e.exifTagTypes[7]=e.exifTagTypes[1],e.getExifValue=function(t,i,a,n,r,o){var s,d,l,c,u,g,f=e.exifTagTypes[n];if(!f)return console.log("Invalid Exif data: Invalid tag type."),void 0;if(s=f.size*r,d=s>4?i+t.getUint32(a+8,o):a+8,d+s>t.byteLength)return console.log("Invalid Exif data: Invalid data offset."),void 0;if(1===r)return f.getValue(t,d,o);for(l=[],c=0;r>c;c+=1)l[c]=f.getValue(t,d+c*f.size,o);if(f.ascii){for(u="",c=0;l.length>c&&(g=l[c],"\0"!==g);c+=1)u+=g;return u}return l},e.parseExifTag=function(t,i,a,n,r){var o=t.getUint16(a,n);r.exif[o]=e.getExifValue(t,i,a,t.getUint16(a+2,n),t.getUint32(a+4,n),n)},e.parseExifTags=function(e,t,i,a,n){var r,o,s;if(i+6>e.byteLength)return console.log("Invalid Exif data: Invalid directory offset."),void 0;if(r=e.getUint16(i,a),o=i+2+12*r,o+4>e.byteLength)return console.log("Invalid Exif data: Invalid directory size."),void 0;for(s=0;r>s;s+=1)this.parseExifTag(e,t,i+2+12*s,a,n);return e.getUint32(o,a)},e.parseExifData=function(t,i,a,n,r){if(!r.disableExif){var o,s,d,l=i+10;if(1165519206===t.getUint32(i+4)){if(l+8>t.byteLength)return console.log("Invalid Exif data: Invalid segment size."),void 0;if(0!==t.getUint16(i+8))return console.log("Invalid Exif data: Missing byte alignment offset."),void 0;switch(t.getUint16(l)){case 18761:o=!0;break;case 19789:o=!1;break;default:return console.log("Invalid Exif data: Invalid byte alignment marker."),void 0}if(42!==t.getUint16(l+2,o))return console.log("Invalid Exif data: Missing TIFF marker."),void 0;s=t.getUint32(l+4,o),n.exif=new e.ExifMap,s=e.parseExifTags(t,l,l+s,o,n),s&&!r.disableExifThumbnail&&(d={exif:{}},s=e.parseExifTags(t,l,l+s,o,d),d.exif[513]&&(n.exif.Thumbnail=e.getExifThumbnail(t,l+d.exif[513],d.exif[514]))),n.exif[34665]&&!r.disableExifSub&&e.parseExifTags(t,l,l+n.exif[34665],o,n),n.exif[34853]&&!r.disableExifGps&&e.parseExifTags(t,l,l+n.exif[34853],o,n)}}},e.metaDataParsers.jpeg[65505].push(e.parseExifData)}),function(e){"use strict";"function"==typeof define&&define.amd?define(["load-image","load-image-exif"],e):e(window.loadImage)}(function(e){"use strict";var t,i,a;e.ExifMap.prototype.tags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright",36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",42240:"Gamma",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"PhotographicSensitivity",34856:"OECF",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"CameraOwnerName",42033:"BodySerialNumber",42034:"LensSpecification",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber",0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"},e.ExifMap.prototype.stringValues={ExposureProgram:{0:"Undefined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Undefined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},ComponentsConfiguration:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"},Orientation:{1:"top-left",2:"top-right",3:"bottom-right",4:"bottom-left",5:"left-top",6:"right-top",7:"right-bottom",8:"left-bottom"}},e.ExifMap.prototype.getText=function(e){var t=this.get(e);switch(e){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":case"Orientation":return this.stringValues[e][t];case"ExifVersion":case"FlashpixVersion":return String.fromCharCode(t[0],t[1],t[2],t[3]);case"ComponentsConfiguration":return this.stringValues[e][t[0]]+this.stringValues[e][t[1]]+this.stringValues[e][t[2]]+this.stringValues[e][t[3]];case"GPSVersionID":return t[0]+"."+t[1]+"."+t[2]+"."+t[3]}return t+""},t=e.ExifMap.prototype.tags,i=e.ExifMap.prototype.map;for(a in t)t.hasOwnProperty(a)&&(i[t[a]]=a);e.ExifMap.prototype.getAll=function(){var e,i,a={};for(e in this)this.hasOwnProperty(e)&&(i=t[e],i&&(a[i]=this.getText(i)));return a}});
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/main.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/main.js
index f003dcf047..7bdf6d9016 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/main.js
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/main.js
@@ -1,26 +1,41 @@
+/*
+ * jQuery File Upload Plugin JS Example 8.8.2
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint nomen: true, regexp: true */
+/*global $, window, blueimp */
+
$(function () {
'use strict';
- $('#${componentMarkupId}').fileupload({
- url: '${url}',
- paramName: '${paramName}',
- singleFileUploads: true,
- maxFileSize: 5000000,
- acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
- process: [
- {
- action: 'load',
- fileTypes: /^image\/(gif|jpeg|png)$/,
- maxFileSize: 20000000 // 20MB
- },
- {
- action: 'resize',
- maxWidth: 1440,
- maxHeight: 900
- },
- {
- action: 'save'
- }
- ]
+ // Initialize the jQuery File Upload widget:
+ $('#${componentId}').fileupload({
+ // Uncomment the following to send cross-domain cookies:
+ //xhrFields: {withCredentials: true},
+ url: '${url}'
});
-});
\ No newline at end of file
+
+ // Load existing files:
+ $('#${componentId}').addClass('fileupload-processing');
+ $.ajax({
+ // Uncomment the following to send cross-domain cookies:
+ //xhrFields: {withCredentials: true},
+ url: $('#${componentId}').fileupload('option', 'url'),
+ dataType: 'json',
+ context: $('#${componentId}')[0]
+ }).always(function () {
+ $(this).removeClass('fileupload-processing');
+ }).done(function (result) {
+ console.log('done');
+ $(this).fileupload('option', 'done')
+ .call(this, null, {result: result});
+ });
+
+});
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/tmpl.min.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/tmpl.min.js
index 065532e7ca..bd82354436 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/tmpl.min.js
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/fileupload/res/js/tmpl.min.js
@@ -1 +1 @@
-(function(a){"use strict";var b=function(a,c){var d=/[^\w\-\.:]/.test(a)?new Function(b.arg+",tmpl","var _e=tmpl.encode"+b.helper+",_s='"+a.replace(b.regexp,b.func)+"';return _s;"):b.cache[a]=b.cache[a]||b(b.load(a));return c?d(c,b):function(a){return d(a,b)}};b.cache={},b.load=function(a){return document.getElementById(a).innerHTML},b.regexp=/([\s'\\])(?![^%]*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,b.func=function(a,b,c,d,e,f){if(b)return{"\n":"\\n","\r":"\\r","\t":"\\t"," ":" "}[a]||"\\"+a;if(c)return c==="="?"'+_e("+d+")+'":"'+("+d+"||'')+'";if(e)return"';";if(f)return"_s+='"},b.encReg=/[<>&"'\x00]/g,b.encMap={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#39;"},b.encode=function(a){return String(a||"").replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e&&(s||'')||_e(s);},include=function(s,d){_s+=tmpl(s,d);}",typeof define=="function"&&define.amd?define(function(){return b}):a.tmpl=b})(this);
\ No newline at end of file
+!function(e){"use strict";var n=function(e,t){var c=/[^\w\-\.:]/.test(e)?new Function(n.arg+",tmpl","var _e=tmpl.encode"+n.helper+",_s='"+e.replace(n.regexp,n.func)+"';return _s;"):n.cache[e]=n.cache[e]||n(n.load(e));return t?c(t,n):function(e){return c(e,n)}};n.cache={},n.load=function(e){return document.getElementById(e).innerHTML},n.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,n.func=function(e,n,t,c,r,u){return n?{"\n":"\\n","\r":"\\r"," ":"\\t"," ":" "}[n]||"\\"+n:t?"="===t?"'+_e("+c+")+'":"'+("+c+"==null?'':"+c+")+'":r?"';":u?"_s+='":void 0},n.encReg=/[<>&"'\x00]/g,n.encMap={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#39;"},n.encode=function(e){return(null==e?"":""+e).replace(n.encReg,function(e){return n.encMap[e]||""})},n.arg="o",n.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return n}):e.tmpl=n}(this);
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html
index fa926ceba3..f0be37e899 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html
@@ -2,7 +2,6 @@
<wicket:extend>
<div class="container">
<h1>Hello, Gitop!</h1>
-
<h3>Upload Test</h3>
<div wicket:id="upload"></div>
</div>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/resource/RestResourceModule.java b/gitop.web/src/main/java/com/pmease/gitop/web/resource/RestResourceModule.java
new file mode 100644
index 0000000000..eda7be9fe3
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/resource/RestResourceModule.java
@@ -0,0 +1,12 @@
+package com.pmease.gitop.web.resource;
+
+import com.google.inject.AbstractModule;
+
+public class RestResourceModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(TestResource.class);
+ }
+
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java b/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java
new file mode 100644
index 0000000000..3a3dbd3418
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java
@@ -0,0 +1,108 @@
+package com.pmease.gitop.web.resource;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+
+import com.codahale.dropwizard.jackson.Jackson;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import com.pmease.gitop.web.SitePaths;
+
+@Path("/file")
+public class TestResource {
+
+ private static final String SUCCESS_RESPONSE = "Successful";
+ private static final String FAILED_RESPONSE = "Failed";
+
+ @POST
+ @Path("/upload")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ public Response uploadFile(@Context HttpServletRequest request) throws JsonProcessingException {
+ String candidateName = null;
+ File uploadDir = SitePaths.get().uploadsDir();
+
+ Result result = new Result();
+
+ // checks whether there is a file upload request or not
+ if (ServletFileUpload.isMultipartContent(request)) {
+ final FileItemFactory factory = new DiskFileItemFactory();
+ final ServletFileUpload fileUpload = new ServletFileUpload(factory);
+
+ try {
+ /*
+ * parseRequest returns a list of FileItem but in old
+ * (pre-java5) style
+ */
+ final List<FileItem> items = fileUpload.parseRequest(request);
+
+ if (items != null) {
+ final Iterator<FileItem> iter = items.iterator();
+ while (iter.hasNext()) {
+ final FileItem item = iter.next();
+ final String itemName = item.getName();
+ final String fieldName = item.getFieldName();
+ final String fieldValue = item.getString();
+
+ if (item.isFormField()) {
+ candidateName = fieldValue;
+ System.out.println("Field Name: " + fieldName
+ + ", Field Value: " + fieldValue);
+ System.out.println("Candidate Name: "
+ + candidateName);
+ } else {
+ final File savedFile = new File(uploadDir, itemName);
+ System.out.println("Saving the file: "
+ + savedFile.getName());
+ item.write(savedFile);
+
+ UploadFile f = new UploadFile();
+ f.name = savedFile.getName();
+ f.size = savedFile.length();
+ result.files.add(f);
+ }
+
+ }
+ }
+ } catch (FileUploadException fue) {
+ fue.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ ObjectMapper mapper = Jackson.newObjectMapper();
+ String str = mapper.writeValueAsString(result);
+
+ System.out.println("Returned Response Status: " + str);
+ return Response.ok().entity(str).build();
+ }
+
+ static class Result {
+ @JsonProperty
+ List<UploadFile> files = Lists.newArrayList();
+ }
+
+ static class UploadFile {
+ @JsonProperty
+ String name;
+ @JsonProperty
+ long size;
+ }
+}