From a3df7a5aad99a047973f1002aa75d8ea1be3ef57 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 30 Jul 2015 12:15:13 +0200 Subject: [PATCH 1/4] Remove html comments also. --- .../javascripts/app/lib/app_post/utils.js.coffee | 13 +++++++++++++ public/assets/tests/html-utils.js | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.js.coffee b/app/assets/javascripts/app/lib/app_post/utils.js.coffee index f008f1e90..a3096c1bc 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.js.coffee @@ -114,6 +114,9 @@ class App.Utils # htmlOnlyWithRichtext = App.Utils.htmlRemoveRichtext( html ) @htmlRemoveRichtext: (html) -> + # remove comments + @_removeComments( html ) + # remove style and class @_removeAttributes( html ) @@ -130,6 +133,9 @@ class App.Utils # cleanHtmlWithRichText = App.Utils.htmlCleanup( html ) @htmlCleanup: (html) -> + # remove comments + @_removeComments( html ) + # remove style and class @_removeAttributes( html ) @@ -169,6 +175,13 @@ class App.Utils .removeAttr( 'title' ) html + @_removeComments: (html) -> + html.contents().each( -> + if @nodeType == 8 + $(@).remove() + ) + html + # signatureNeeded = App.Utils.signatureCheck( message, signature ) @signatureCheck: (message, signature) -> messageText = $( '
' + message + '
' ).text().trim() diff --git a/public/assets/tests/html-utils.js b/public/assets/tests/html-utils.js index 1e8ea4640..18e42afc1 100644 --- a/public/assets/tests/html-utils.js +++ b/public/assets/tests/html-utils.js @@ -256,7 +256,7 @@ test( "htmlRemoveTags", function() { // htmlRemoveRichtext test( "htmlRemoveRichtext", function() { - var source = "
test
" + var source = "
test
" var should = "test" var result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) @@ -330,7 +330,7 @@ test( "htmlRemoveRichtext", function() { // htmlCleanup test( "htmlCleanup", function() { - var source = "
test
" + var source = "
test
" var should = "test" var result = App.Utils.htmlCleanup( $(source) ) equal( result.html(), should, source ) From 074e90d4712f45126c3f86dc0e83177818155a31 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 31 Jul 2015 11:03:56 +0200 Subject: [PATCH 2/4] Fixed bug: Options of searchable_-/multi-/select field get sorted even if disabled via configuration. --- .../app/controllers/_application_controller_form.js.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index ba0bd079d..66e3b2c00 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -2093,6 +2093,9 @@ class App.ControllerForm extends App.Controller # sort attribute.options _sortOptions: (attribute) -> + # skip sorting if it is disabled by config + return if attribute.sortBy == null + return if !attribute.options if _.isArray( attribute.options ) From 01298449cc1a132b3008691f569001ba53a45452 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 3 Aug 2015 11:30:45 +0200 Subject: [PATCH 3/4] Find organization image suggestion and store it as app logo, sync it to assets folder. --- lib/service/image.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/service/image.rb b/lib/service/image.rb index 0d3b87c7c..4dd1fb78b 100644 --- a/lib/service/image.rb +++ b/lib/service/image.rb @@ -56,7 +56,7 @@ returns =begin -find organization image suggestion +find organization image suggestion and store it as app logo result = Service::Image.organization_suggest('edenhofer.de') @@ -72,7 +72,14 @@ returns backend = load_adapter_by_setting( 'image_backend' ) return if !backend - backend.organization_suggest(domain) + result = backend.organization_suggest(domain) + + # sync logo to assets folder + if result + StaticAssets.sync + end + + result end end From 3491dcf043ece266fbc6425d228357e67a6b54a5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 4 Aug 2015 12:41:36 +0200 Subject: [PATCH 4/4] Import translations by each locale, not at once (document size issue). --- app/models/translation.rb | 62 ++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/app/models/translation.rb b/app/models/translation.rb index dbd4dce86..2f4d9cb58 100644 --- a/app/models/translation.rb +++ b/app/models/translation.rb @@ -15,40 +15,42 @@ load translations from online =end def self.load - url = 'https://i18n.zammad.com/api/v1/translations' - if !UserInfo.current_user_id - UserInfo.current_user_id = 1 - end - result = UserAgent.get( - url, - {}, - { - json: true, - } - ) - fail "Can't load translations from #{url}: #{result.error}" if !result.success? + Locale.where(active: true).each {|locale| + url = "https://i18n.zammad.com/api/v1/translations/#{locale.locale}" + if !UserInfo.current_user_id + UserInfo.current_user_id = 1 + end + result = UserAgent.get( + url, + {}, + { + json: true, + } + ) + fail "Can't load translations from #{url}: #{result.error}" if !result.success? - ActiveRecord::Base.transaction do - result.data.each {|translation| + ActiveRecord::Base.transaction do + result.data.each {|translation| - # handle case insensitive sql - exists = Translation.where(locale: translation['locale'], format: translation['format'], source: translation['source']) - translaten = nil - exists.each {|item| - if item.source == translation['source'] - translaten = item + # handle case insensitive sql + exists = Translation.where(locale: translation['locale'], format: translation['format'], source: translation['source']) + translaten = nil + exists.each {|item| + if item.source == translation['source'] + translaten = item + end + } + if translaten + + # verify if update is needed + translaten.update_attributes(translation.symbolize_keys!) + translaten.save + else + Translation.create(translation.symbolize_keys!) end } - if translaten - - # verify if update is needed - translaten.update_attributes(translation.symbolize_keys!) - translaten.save - else - Translation.create(translation.symbolize_keys!) - end - } - end + end + } true end