Merge branch 'master' of gitlab.tp.rulingcom.com:saurabh/orbit4-5 into nccu

This commit is contained in:
Harry Bomrah 2015-04-27 21:41:27 +08:00
commit ccb9a24861
8 changed files with 42 additions and 30 deletions

View File

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

View File

@ -106,9 +106,6 @@ class Admin::SitesController < OrbitAdminController
else else
result = "success" result = "success"
# Bundler.with_clean_env { `cd #{Rails.root} && bundle update` } # Bundler.with_clean_env { `cd #{Rails.root} && bundle update` }
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=built_in_extensions.rb bundle update && bundle` }
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` }
end end
render :text => result render :text => result

View File

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

View File

@ -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();
} }
}) })
} }

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
<li title="<%= t('site_info') %>"><%= link_to admin_site_site_info_path(current_site), :class => active_for_action('sites', 'site_info') do %><span><i class="icons-browser"></i></span><%end%></li> <li title="<%= t('site_info') %>"><%= link_to admin_site_site_info_path(current_site), :class => active_for_action('sites', 'site_info') do %><span><i class="icons-browser"></i></span><%end%></li>
<li title="<%= t('mobile_settings') %>"><%= link_to admin_site_responsive_setting_path(current_site), :class => active_for_action('sites', 'responsive_setting') do %><span><i class="icons-mobile"></i></span><%end%></li> <!-- <li title="<%#= t('mobile_settings') %>"><%#= link_to admin_site_responsive_setting_path(current_site), :class => active_for_action('sites', 'responsive_setting') do %><span><i class="icons-mobile"></i></span><%#end%></li> -->
<li title="<%= t('search_engine') %>"><%= link_to admin_site_search_engine_path(current_site), :class => active_for_action('sites', 'search_engine') do %><span><i class="icons-search"></i></span><%end%></li> <li title="<%= t('search_engine') %>"><%= link_to admin_site_search_engine_path(current_site), :class => active_for_action('sites', 'search_engine') do %><span><i class="icons-search"></i></span><%end%></li>