From 70b274b2c0693df73b42707a6b36b8bbcfc32bd4 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 2 Feb 2015 17:29:45 +0100 Subject: [PATCH] Implemented insertion of link to full-size image when DnD is used in the editor window --- Makefile | 2 +- scripts/ckeditor/plugins/dndfiles/plugin.js | 8 +++++--- src/elogd.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 96200f62..bc61b3fd 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ elog: src/elog.c crypt.o $(OBJS) $(CC) $(CFLAGS) -o elog src/elog.c crypt.o $(OBJS) $(LIBS) debug: src/elogd.c regex.o crypt.o auth.o mxml.o - $(CC) -g $(CFLAGS) -o elogd src/elogd.c crypt.o auth.o regex.o mxml.o $(OBJS) $(LIBS) + $(CC) -g $(CFLAGS) -O0 -o elogd src/elogd.c crypt.o auth.o regex.o mxml.o $(OBJS) $(LIBS) %: src/%.c $(CC) $(CFLAGS) -o $@ $< $(LIBS) diff --git a/scripts/ckeditor/plugins/dndfiles/plugin.js b/scripts/ckeditor/plugins/dndfiles/plugin.js index 7a6080a0..459a8b7c 100755 --- a/scripts/ckeditor/plugins/dndfiles/plugin.js +++ b/scripts/ckeditor/plugins/dndfiles/plugin.js @@ -134,14 +134,16 @@ CKEDITOR.plugins.add( 'dndfiles', { $("input", attch).each(function() { // Extract the url of the file - var src = $(this)[0].defaultValue; + var src = $(this)[0].defaultValue; + var thumb = $(this)[0].alt; // Ignore inputs that have this value as it is not needed if(src === "Delete") return; - if(src.indexOf(".png") >= 0 || src.indexOf(".jpg") >= 0 || src.indexOf(".jpeg") >= 0) { // This is an image - html += '' + ''; + if(src.indexOf(".png") >= 0 || src.indexOf(".jpg") >= 0 || src.indexOf(".jpeg") >= 0 + || src.indexOf(".gif") >= 0 || src.indexOf(".svg") >= 0) { // This is an image + html += '' + ''; } else { // this is not an image // Server appends 14 characters in front of the name so we should remove them var server_suffix = 14; diff --git a/src/elogd.c b/src/elogd.c index 9d69c27e..ed634510 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -9414,8 +9414,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL svalue[MAX_N_ATTR + 10][NAME_LENGTH], owner[256], locked_by[256], class_value[80], class_name[80], ua[NAME_LENGTH], mid[80], title[256], login_name[256], full_name[256], cookie[256], orig_author[256], attr_moptions[MAX_N_LIST][NAME_LENGTH], ref[256], file_enc[256], tooltip[10000], - enc_attr[NAME_LENGTH], user_email[256], cmd[256], thumb_name[256], **user_list, fid[20], upwd[80], - subdir[256]; + enc_attr[NAME_LENGTH], user_email[256], cmd[256], thumb_name[256], thumb_ref[256], **user_list, fid[20], + upwd[80], subdir[256]; time_t now, ltime; char fl[8][NAME_LENGTH]; struct tm *pts; @@ -11597,7 +11597,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("%s %d:\n", loc("Attachment"), index + 1); sprintf(str, "attachment%d", index); rsprintf("\n"); - rsprintf("\n", str, att[index]); + thumb_ref[0] = 0; if (strlen(att[index]) < 14 || att[index][6] != '_' || att[index][13] != '_') { rsprintf("Error: Invalid attachment \"%s\"
", att); @@ -11691,6 +11691,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\"%s\"\n", ref, att[index] + 14, att[index] + 14, index); + strlcpy(thumb_ref, ref, sizeof(thumb_ref)); } else if (thumb_status == 2) { for (i = 0;; i++) { get_thumb_name(file_name, thumb_name, sizeof(thumb_name), i); @@ -11707,6 +11708,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\"%s\"\n", ref, att[index] + 14, att[index] + 14, index, i); + strlcpy(thumb_ref, ref, sizeof(thumb_ref)); } else break; } @@ -11720,6 +11722,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\"%s\"\n", ref, att[index] + 14, att[index] + 14, index); + strlcpy(thumb_ref, ref, sizeof(thumb_ref)); } } else { if (is_ascii(file_name)) { @@ -11764,6 +11767,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\n"); } + if (thumb_ref[0]) + rsprintf("\n", index, thumb_ref, att[index]); + else + rsprintf("\n", index, att[index]); + rsprintf("\n"); } else break;