Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-08-04 12:43:25 +02:00
commit 7b15f669d4
5 changed files with 59 additions and 34 deletions

View file

@ -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 )

View file

@ -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 = $( '<div>' + message + '</div>' ).text().trim()

View file

@ -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

View file

@ -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

View file

@ -256,7 +256,7 @@ test( "htmlRemoveTags", function() {
// htmlRemoveRichtext
test( "htmlRemoveRichtext", function() {
var source = "<div><a href=\"test\">test</a></div>"
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
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 = "<div><a href=\"test\">test</a></div>"
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
var should = "test"
var result = App.Utils.htmlCleanup( $(source) )
equal( result.html(), should, source )