From 4d6e68f9b10514f98b526df4284941754c9e0942 Mon Sep 17 00:00:00 2001 From: Dario Milicic Date: Tue, 30 Sep 2014 12:55:07 +0200 Subject: [PATCH] All new strings should now be localized. There is a new function called localize in the scripts/load-ckeditor.js that translates any given string to the server's language (This function is SYNCHRONOUS). The editor area should make use of more room on bigger screens. The make install command should now behave correctly. --- Makefile | 18 ++++++-------- elogd.cfg | 2 +- .../ckeditor/plugins/image2/dialogs/image2.js | 4 +++- scripts/ckeditor/plugins/save/plugin.js | 3 ++- scripts/load-ckeditor.js | 24 +++++++++++++++++-- src/elogd.c | 2 +- src/git-revision.h | 2 +- 7 files changed, 37 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 19d55be9..75f8be6d 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ ifeq ($(OSTYPE),Linux) CC = gcc endif -CFLAGS += -I$(MXMLDIR) +CFLAGS += -I$(MXMLDIR) ifdef USE_SSL ifneq ($(USE_SSL),0) @@ -157,7 +157,7 @@ update: $(EXECS) install: $(EXECS) @$(INSTALL) -m 0755 -d $(DESTDIR) $(SDESTDIR) $(MANDIR)/man1/ $(MANDIR)/man8/ - @$(INSTALL) -m 0755 -d $(ELOGDIR)/scripts/ $(ELOGDIR)/resources/ $(ELOGDIR)/ssl/ $(ELOGDIR)/themes/default/icons + @$(INSTALL) -m 0755 -d $(ELOGDIR)/scripts/ $(ELOGDIR)/resources/ $(ELOGDIR)/ssl/ $(ELOGDIR)/themes/default/icons @$(INSTALL) -m 0755 -d $(ELOGDIR)/logbooks/demo @$(INSTALL) -v -m 0755 ${BINFLAGS} elog elconv $(DESTDIR) @$(INSTALL) -v -m 0755 ${BINFLAGS} elogd $(SDESTDIR) @@ -165,25 +165,21 @@ install: $(EXECS) @$(INSTALL) -v -m 0644 man/elogd.8 $(MANDIR)/man8/ @$(INSTALL) -v -m 0644 scripts/*.js $(ELOGDIR)/scripts/ - # @echo "Installing CKeditor to $(ELOGDIR)/scripts/ckeditor" - # @unzip -q -o scripts/fckeditor.zip -d $(ELOGDIR)/scripts/ - # @$(INSTALL) -v -m 0644 scripts/fckeditor/fckelog.js $(ELOGDIR)/scripts/fckeditor/fckelog.js - # @mkdir -p -m 0755 $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog - # @$(INSTALL) -v -m 0644 scripts/fckeditor/editor/plugins/elog/fckplugin.js $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog/fckplugin.js - # @$(INSTALL) -v -m 0644 scripts/fckeditor/editor/plugins/elog/inserttime.gif $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog/inserttime.gif + @echo "Installing CKeditor to $(ELOGDIR)/scripts/ckeditor" + cp -r scripts/ $(ELOGDIR)/scripts - @echo "Installing resources to $(ELOGDIR)/resources" + @echo "Installing resources to $(ELOGDIR)/resources" @$(INSTALL) -m 0644 resources/* $(ELOGDIR)/resources/ @$(INSTALL) -m 0644 ssl/* $(ELOGDIR)/ssl/ - @echo "Installing themes to $(ELOGDIR)/themes" + @echo "Installing themes to $(ELOGDIR)/themes" @$(INSTALL) -m 0644 themes/default/icons/* $(ELOGDIR)/themes/default/icons/ @for file in `find themes/default -type f | grep -v .svn` ; \ do \ $(INSTALL) -m 0644 $$file $(ELOGDIR)/themes/default/`basename $$file` ;\ done - @echo "Installing example logbook to $(ELOGDIR)/logbooks/demo" + @echo "Installing example logbook to $(ELOGDIR)/logbooks/demo" @if [ ! -f $(ELOGDIR)/logbooks/demo ]; then \ $(INSTALL) -v -m 0644 logbooks/demo/* $(ELOGDIR)/logbooks/demo ; \ fi diff --git a/elogd.cfg b/elogd.cfg index a00baab8..5b8292b6 100755 --- a/elogd.cfg +++ b/elogd.cfg @@ -3,7 +3,7 @@ port = 8080 [demo] Theme = default -Comment = General linux tips & tricks +Comment = SwissFEL DEMO Attributes = Author, Type, Category, Subject Options Type = Routine, Software Installation, Problem Fixed, Configuration, Other Options Category = General, Hardware, Software, Network, Other diff --git a/scripts/ckeditor/plugins/image2/dialogs/image2.js b/scripts/ckeditor/plugins/image2/dialogs/image2.js index a2ba2af4..cb832aae 100755 --- a/scripts/ckeditor/plugins/image2/dialogs/image2.js +++ b/scripts/ckeditor/plugins/image2/dialogs/image2.js @@ -546,9 +546,11 @@ CKEDITOR.dialog.add( 'image2', function( editor ) { var dialog = this.getDialog(); var files = dialog.getContentElement("Upload", "upload").getInputElement().$.files; + var file_missing_msg = localize("Please select a fileadaw!"); + // no files were selected if(files.length == 0) { - alert("Please select a file!"); + alert(file_missing_msg); return false; } diff --git a/scripts/ckeditor/plugins/save/plugin.js b/scripts/ckeditor/plugins/save/plugin.js index 930dae7e..72bc57b4 100755 --- a/scripts/ckeditor/plugins/save/plugin.js +++ b/scripts/ckeditor/plugins/save/plugin.js @@ -46,7 +46,8 @@ command.modes = { wysiwyg: !!( editor.element.$.form ) }; editor.ui.addButton && editor.ui.addButton( 'Save', { - label: editor.lang.save.toolbar, + label: localize("Submit"), + // label: editor.lang.save.toolbar, command: pluginName, toolbar: 'document,10' } ); diff --git a/scripts/load-ckeditor.js b/scripts/load-ckeditor.js index 5338c785..3cc2d834 100755 --- a/scripts/load-ckeditor.js +++ b/scripts/load-ckeditor.js @@ -1,3 +1,21 @@ +// This function takes a string that should be translated +// and asks the server for the translation to the server's locale. +// Translation of the string is returned. +// +// NOTE: This function works SYNCRHONOUSLY +function localize(str) { + var URL = '/' + parent.logbook + "/?cmd=loc&value=" + str; + + return $.ajax({ + type: "GET", + url: URL, + async: false + }).responseText; +} + +console.log(localize("Submit")); + +// After the page has loaded, load the Ckeditor and the attachment dropbox $(document).ready(function() { $('textarea').addClass("ckeditor"); @@ -9,8 +27,10 @@ $(document).ready(function() { var editor = ev.editor; - // Make the editor bigger - editor.resize("100%", "500"); + // Make the editor bigger (at least 500px high and 80% of the viewport otherwise) + var width = Math.max(500, 0.8 * $(window).height() ); + console.log(width); + editor.resize("100%", new String(width)); // Create a new command with the desired exec function var overridecmd = new CKEDITOR.command(editor, { diff --git a/src/elogd.c b/src/elogd.c index 4780191c..3928d5ba 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -11520,7 +11520,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\n"); rsprintf("\n"); rsprintf("
"); - rsprintf("

Drop attachments here...

"); + rsprintf("

%s

", loc("Drop attachments here...")); rsprintf(""); } } diff --git a/src/git-revision.h b/src/git-revision.h index 7a78de05..1d2d9d1a 100644 --- a/src/git-revision.h +++ b/src/git-revision.h @@ -1 +1 @@ -#define GIT_REVISION "Tue Sep 23 17:21:20 2014 +0200 - 6a67f99" +#define GIT_REVISION "Tue Sep 23 17:31:26 2014 +0200 - 5e1898f"