forked from saurabh/orbit4-5
page id cannot be chinese and also some module update fixes
This commit is contained in:
parent
0380972e5b
commit
057f689526
|
@ -110,13 +110,13 @@ class Admin::ModuleStoreController < OrbitAdminController
|
||||||
def update_module
|
def update_module
|
||||||
key = params["key"]
|
key = params["key"]
|
||||||
type = params["type"]
|
type = params["type"]
|
||||||
if type == "built_in"
|
# if type == "built_in"
|
||||||
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update #{key}` }
|
# Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update #{key}` }
|
||||||
elsif type == "downloaded"
|
# elsif type == "downloaded"
|
||||||
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update #{key}` }
|
# Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update #{key}` }
|
||||||
end
|
# end
|
||||||
@built_in_extensions = get_built_in_extensions
|
Bundler.with_clean_env { `cd #{Rails.root} && bundle update #{key}` }
|
||||||
render :partial => "modules_to_update"
|
render :nothing => true
|
||||||
%x(kill -s USR2 `cat tmp/pids/unicorn.pid`)
|
%x(kill -s USR2 `cat tmp/pids/unicorn.pid`)
|
||||||
sleep 5
|
sleep 5
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Admin::ModuleStoreHelper
|
||||||
extensions_to_update = get_extensions_to_update
|
extensions_to_update = get_extensions_to_update
|
||||||
@extensions_to_update_count = extensions_to_update.count
|
@extensions_to_update_count = extensions_to_update.count
|
||||||
built_in_extensions = get_extension_from_file("built_in",extensions_to_update)
|
built_in_extensions = get_extension_from_file("built_in",extensions_to_update)
|
||||||
built_in_extensions.concat(get_extension_from_file("downloaded",extensions_to_update))
|
# built_in_extensions.concat(get_extension_from_file("downloaded",extensions_to_update))
|
||||||
return built_in_extensions
|
return built_in_extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,23 +28,25 @@ module Admin::ModuleStoreHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_extensions_to_update
|
def get_extensions_to_update
|
||||||
if !File.exists?("#{Rails.root}/built_in_extensions.rb.lock") || !File.exists?("#{Rails.root}/downloaded_extensions.rb.lock")
|
# if !File.exists?("#{Rails.root}/built_in_extensions.rb.lock") || !File.exists?("#{Rails.root}/downloaded_extensions.rb.lock")
|
||||||
update_extension_file("built_in")
|
# update_extension_file("built_in")
|
||||||
update_extension_file("downloaded")
|
# update_extension_file("downloaded")
|
||||||
return []
|
# return []
|
||||||
else
|
# else
|
||||||
|
# update_extensions = get_update_info_for_extensions("built_in")
|
||||||
|
# update_extensions.concat(get_update_info_for_extensions("downloaded"))
|
||||||
|
# return update_extensions
|
||||||
|
# end
|
||||||
update_extensions = get_update_info_for_extensions("built_in")
|
update_extensions = get_update_info_for_extensions("built_in")
|
||||||
update_extensions.concat(get_update_info_for_extensions("downloaded"))
|
|
||||||
return update_extensions
|
return update_extensions
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def update_extension_file(type)
|
def update_extension_file(type)
|
||||||
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=#{type}_extensions.rb bundle update && bundle` }
|
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=#{type}_extensions.rb bundle update && bundle` }
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_update_info_for_extensions(type)
|
def get_update_info_for_extensions(type)
|
||||||
buffer = Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=#{type}_extensions.rb bundle outdated` }
|
buffer = Bundler.with_clean_env { `cd #{Rails.root} && bundle outdated` }
|
||||||
buffer = buffer.split("\n")
|
buffer = buffer.split("\n")
|
||||||
if buffer.last == "Bundle up to date!"
|
if buffer.last == "Bundle up to date!"
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$("a.update_module").on("click",function(){
|
$("a.update_module").on("click",function(){
|
||||||
if(!$(this).hasClass("disabled")){
|
var el = $(this);
|
||||||
$(this).text("Updating").addClass("disabled");
|
if(!el.hasClass("disabled")){
|
||||||
var key = $(this).data("module-key"),
|
$(".update_module").addClass("disabled");
|
||||||
type = $(this).data("module-type")
|
el.text("Updating, please wait...");
|
||||||
|
var key = el.data("module-key"),
|
||||||
|
type = el.data("module-type")
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "/admin/module_store/update_module",
|
url : "/admin/module_store/update_module",
|
||||||
data : {"key" : key, "type" : type},
|
data : {"key" : key, "type" : type},
|
||||||
|
@ -23,7 +25,8 @@
|
||||||
type : "post"
|
type : "post"
|
||||||
}).always(function(obj){
|
}).always(function(obj){
|
||||||
if(obj.status == 200){
|
if(obj.status == 200){
|
||||||
update_module_table.html(obj.responseText);
|
el.text("Updating gem list.");
|
||||||
|
update_module_tables();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,13 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
|
||||||
var el = $(e.target),
|
var el = $(e.target),
|
||||||
prev_el = $(e.relatedTarget);
|
prev_el = $(e.relatedTarget);
|
||||||
if(el.attr("href") == "#update_module"){
|
if(el.attr("href") == "#update_module"){
|
||||||
|
update_module_tables();
|
||||||
|
}else if(prev_el.attr("href") == "#update_module"){
|
||||||
|
update_module_table.html('<div class="loading-image-wrapper"><img src="/assets/preloader.gif" /><span>Fetching module update info.</span></div>');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
var update_module_tables = function(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "/admin/module_store/modules_to_update",
|
url : "/admin/module_store/modules_to_update",
|
||||||
type : "get",
|
type : "get",
|
||||||
|
@ -185,9 +192,6 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
|
||||||
}).done(function(data){
|
}).done(function(data){
|
||||||
update_module_table.html(data);
|
update_module_table.html(data);
|
||||||
})
|
})
|
||||||
}else if(prev_el.attr("href") == "#update_module"){
|
|
||||||
update_module_table.html('<div class="loading-image-wrapper"><img src="/assets/preloader.gif" /><span>Fetching module update info.</span></div>');
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<% if params[:action] == "new" %>
|
<% if params[:action] == "new" %>
|
||||||
<%= f.label :name, content_tag(:i, nil, :class => "icons-star") + t(:page)+' ID' %>
|
<%= f.label :name, content_tag(:i, nil, :class => "icons-star") + t(:page)+' ID' %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :page_id, class:"input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces.;Page id is already taken.;"} %>
|
<%= f.text_field :page_id, class:"input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;detect_chinese;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces.;Page id is already taken.;Page ID cannot be in chinese.;"} %>
|
||||||
<span class="help-block"><%= t("front_page.name_field_helper") %></span>
|
<span><%= t("front_page.name_field_helper") %></span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,5 +17,11 @@ $(document).ready(function(){
|
||||||
fromvalidator.validate_functions.pageid_validation = function(value){
|
fromvalidator.validate_functions.pageid_validation = function(value){
|
||||||
return (pageids.indexOf(value) == -1 ? true : false);
|
return (pageids.indexOf(value) == -1 ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromvalidator.validate_functions.detect_chinese = function(value){
|
||||||
|
var re1 = new RegExp("^[\u4E00-\uFA29]*$"),
|
||||||
|
re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); //Chinese character range
|
||||||
|
return (!(re1.test(value) && (! re2.test(value))));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue