diff --git a/app/controllers/admin/personal_plugin_intros_controller.rb b/app/controllers/admin/personal_plugin_intros_controller.rb index 109eff7..976b83b 100644 --- a/app/controllers/admin/personal_plugin_intros_controller.rb +++ b/app/controllers/admin/personal_plugin_intros_controller.rb @@ -41,7 +41,6 @@ class Admin::PersonalPluginIntrosController < OrbitMemberController end def edit - debugger if !has_access? render_401 end diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index c738759..283085d 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -1,5 +1,7 @@ class Admin::SitesController < OrbitAdminController before_filter :get_site + before_filter :set_git_branch, :only=>[:check_updates, :update_orbit] + layout "structure" def mail_setting @@ -83,7 +85,7 @@ class Admin::SitesController < OrbitAdminController if (@current_tag.eql?(@latest_tag) == false) %x(git fetch origin) end - @new_updates = %x(git log "#{@current_tag}"..."#{@latest_tag}" --pretty=format:"%ad','%s" --date=short).split("\n").map{|log| log.gsub("'","").split(",")}.to_json + @new_updates = %x(git log #{@branch}..origin/#{@branch} --pretty=format:"%ad','%s" --date=short).split("\n").map{|log| log.gsub("'","").split(",")}.to_json render :json => @new_updates end @@ -92,7 +94,7 @@ class Admin::SitesController < OrbitAdminController need_stash = %x(git diff).blank? %x(git stash) unless need_stash %x(git fetch origin) - pull_result = %x(git pull -r --ff-only 2>&1 origin #{@latest_tag}) + pull_result = %x(git pull -r --ff-only 2>&1 origin #{@branch}) %x(git stash pop) unless need_stash if pull_result.include? "fatal: Not possible to fast-forward, aborting." @@ -113,7 +115,7 @@ class Admin::SitesController < OrbitAdminController private def get_site - @site = Site.first + @site = @current_site.nil? ? Site.first : @current_site end def site_params @@ -142,12 +144,7 @@ class Admin::SitesController < OrbitAdminController end - def git_branch + def set_git_branch @branch = %x(git rev-parse --abbrev-ref HEAD).gsub("\n","") end - - def git_tags - @current_tag = %x(git describe --tags).gsub("\n","").split("-").first - @latest_tag = `git ls-remote --tags origin | awk '{print $2}'`.split(/\n/).last.gsub("refs/tags/","") rescue nil - end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6a443d3..1cc8639 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base end def current_site - @current_site = Site.first + @current_site = @current_site.nil? ? Site.first : @current_site end def frontent_allowed @@ -102,9 +102,10 @@ class ApplicationController < ActionController::Base log.request_method = request.request_method log.remote_ip = request.remote_ip log.referer = request.referer - log.save - - current_user.user_actions << log + begin + current_user.user_actions << log if log.save + rescue + end end end @@ -120,7 +121,7 @@ class ApplicationController < ActionController::Base private def current_user - @current_user ||= User.find(session[:user_id]) if session[:user_id] rescue nil + @current_user = @current_user.nil? ? (User.find(session[:user_id]) if session[:user_id] rescue nil) : @current_user end protected diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6ec11e..2b55c4d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -16,7 +16,7 @@ module ApplicationHelper end def render_header - site = Site.first + site = current_site header_file = File.join('../templates', "#{@key}", "/home/header.html.erb") header_file_html = render :file => header_file header = Nokogiri::HTML(header_file_html, nil, "UTF-8") @@ -33,7 +33,7 @@ module ApplicationHelper end def render_site_title - site = Site.first + site = current_site title = site.title rescue "" if site.title_always_on if !params[:slug].nil? @@ -49,11 +49,11 @@ module ApplicationHelper end def render_google_analytics - Site.first.google_analytics.html_safe rescue "" + current_site.google_analytics.html_safe rescue "" end def render_footer - site = Site.first + site = current_site footer_file = File.join('../templates', "#{@key}", "/home/footer.html.erb") footer_file_html = render :file => footer_file footer = Nokogiri::HTML(footer_file_html, nil, "UTF-8") diff --git a/app/views/admin/sites/update_manager.erb b/app/views/admin/sites/update_manager.erb index abd95d1..28434e8 100644 --- a/app/views/admin/sites/update_manager.erb +++ b/app/views/admin/sites/update_manager.erb @@ -1,6 +1,3 @@ -<% content_for :side_bar do %> - <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> -<% end %>