From 941833e4d29e58713c1151ab5484aba8d46cb031 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Fri, 14 Mar 2014 10:10:05 +0800 Subject: [PATCH] Downloaded Modules now use tags. mobile/app always active --- app/controllers/admin/module_store_controller.rb | 10 +++++----- app/controllers/application_controller.rb | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/module_store_controller.rb b/app/controllers/admin/module_store_controller.rb index b53b8f8..f431d37 100644 --- a/app/controllers/admin/module_store_controller.rb +++ b/app/controllers/admin/module_store_controller.rb @@ -26,11 +26,11 @@ class Admin::ModuleStoreController < OrbitBackendController extension = get_extension(params[:id]) rescue nil extension_name = extension["key"].to_s git_repository_url = extension["git_url"] - version = extension["version"] + tag = extension["tag"] module_installed = File.read("downloaded_extensions.rb").include?(extension["key"]) if module_installed.eql?(false) - @download_link = "gem '#{extension_name}', '#{version}', :git => '#{git_repository_url}'" + @download_link = "gem '#{extension_name}', :git => '#{git_repository_url}', :tag => '#{tag}'" File.open("downloaded_extensions.rb", 'a') do |file| file.puts @download_link end @@ -107,8 +107,8 @@ class Admin::ModuleStoreController < OrbitBackendController if !extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}.blank? extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['installed']=true extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['enabled']=status - extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['installed_version']=exist_ext[1].split(/[\'\"]/)[1] - if extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['version'] != exist_ext[1].split(/[\'\"]/)[1] + extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['installed_version']=exist_ext[2].split(/[\'\"]/)[1] + if extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['tag'] != exist_ext[2].split(/[\'\"]/)[1] extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['updated'] = false else extensions.select{|ext| ext['key']==exist_ext[0].split(/[\'\"]/)[1]}[0]['updated'] = true @@ -134,7 +134,7 @@ class Admin::ModuleStoreController < OrbitBackendController status = !extension.start_with?("# ") extension = extension.split(',') - downloaded_extensions << {'name' => extension[0].split(/[\'\"]/)[1], 'version' => extension[1].split(/[\'\"]/)[1], 'repo' => extension[2].split(/[\'\"]/)[1], 'status' => status} + downloaded_extensions << {'name' => extension[0].split(/[\'\"]/)[1], 'repo' => extension[1].split(/[\'\"]/)[1], 'tag' => extension[2].split(/[\'\"]/)[1], 'status' => status} end extensions.close diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2f9882a..5393f68 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -476,6 +476,15 @@ class ApplicationController < ActionController::Base session[:mobile_param] end request.format = :mobile if mobile_device? + else + session[:mobile_param] = if request.path =~ /app/ + '1' + elsif params[:mobile] + params[:mobile] + else + session[:mobile_param] + end + request.format = :mobile if mobile_device? end end