Skip to content

Commit

Permalink
#588 Set file type icon
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Jan 20, 2017
1 parent 3895091 commit de7b383
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
8 changes: 7 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gulp.task('min', function() {
});

gulp.task('copy', ['copy:bootswatch', 'copy:highlightjs', 'copy:font-awesome', 'copy:flag-icon-css',
'copy:html5shiv', 'copy:respond', 'copy:MathJax', 'copy:emoji-parser']);
'copy:html5shiv', 'copy:respond', 'copy:MathJax', 'copy:emoji-parser', 'copy:free-file-icons']);
gulp.task('copy:bootswatch', function() {
return gulp.src([
'src/main/webapp/bower/bootswatch/**/*'
Expand Down Expand Up @@ -72,6 +72,12 @@ gulp.task('copy:emoji-parser', function() {
])
.pipe(gulp.dest('target/knowledge/bower/emoji-parser'));
});
gulp.task('copy:free-file-icons', function() {
return gulp.src([
'src/main/webapp/bower/teambox.free-file-icons/**/*'
])
.pipe(gulp.dest('target/knowledge/bower/teambox.free-file-icons'));
});


gulp.task('default', ['min', 'copy']);
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ public class UploadedFileLogic {
public static UploadedFileLogic get() {
return Container.getComp(UploadedFileLogic.class);
}


/** アイコン画像の種類 */
public static final String[] ICONS = { "_blank", "_page", "aac", "ai", "aiff", "avi", "bmp", "c", "cpp",
"css", "dat", "dmg", "doc", "dotx", "dwg", "dxf", "eps", "exe", "flv", "gif", "h",
"hpp", "html", "ics", "iso", "java", "jpg", "js", "key", "less", "mid", "mp3", "mp4",
"mpg", "odf", "ods", "odt", "otp", "ots", "ott", "pdf", "php", "png", "ppt", "psd",
"py", "qt", "rar", "rb", "rtf", "sass", "scss", "sql", "tga", "tgz", "tiff", "txt",
"wav", "xls", "xlsx", "xml", "yml", "zip" };



/**
* ファイルを保存する
*
Expand Down Expand Up @@ -70,19 +80,24 @@ public UploadFile convUploadFile(String context, KnowledgeFilesEntity entity) {
UploadFile file = new UploadFile();
file.setFileNo(entity.getFileNo());
file.setUrl(context + "/open.file/download?fileNo=" + entity.getFileNo());
// file.setThumbnailUrl(context + "/open.file/thumbnai?fileNo=" + entity.getFileNo());
file.setThumbnailUrl(context + "/bower/teambox.free-file-icons/32px/_blank.png");
file.setName(entity.getFileName());

//file.setType("-");
String thumbnai = context + "/bower/teambox.free-file-icons/16px/_blank.png";
String extention = StringUtils.getExtension(entity.getFileName());
if (StringUtils.contains(extention, ".png", ".jpg", ".jpeg", ".gif", ".bmp")) {
file.setType("image");
} else if (StringUtils.contains(extention, ".pdf", ".pptx")) {
file.setType("slide");
} else {
file.setType("file");
if (StringUtils.isNotEmpty(extention)) {
extention = extention.substring(1); // 先頭の「.」を削除
if (StringUtils.contains(extention, "png", "jpg", "jpeg", "gif", "bmp")) {
file.setType("image");
} else if (StringUtils.contains(extention, "pdf", "pptx")) {
file.setType("slide");
} else {
file.setType("file");
}
if (StringUtils.contains(extention, ICONS)) {
thumbnai = context + "/bower/teambox.free-file-icons/16px/" + extention + ".png";
}
}
file.setThumbnailUrl(thumbnai);

file.setSize(entity.getFileSize());
file.setDeleteUrl(context + "/protect.file/delete?fileNo=" + entity.getFileNo());
Expand Down

0 comments on commit de7b383

Please sign in to comment.