diff --git a/app/assets/images/license-denied.png b/app/assets/images/license-denied.png new file mode 100644 index 0000000..2641519 Binary files /dev/null and b/app/assets/images/license-denied.png differ diff --git a/app/assets/javascripts/frontend.js b/app/assets/javascripts/frontend.js index fa2e95a..c717991 100644 --- a/app/assets/javascripts/frontend.js +++ b/app/assets/javascripts/frontend.js @@ -1,8 +1,16 @@ (function($) { - $("document").ready(function(){ + $("document").ready(function(){ // Get link data-attribute and make the banner clickable - $('.w-ad-banner__slide').not('[data-link=""]').not(".youtube").addClass('cursor').on("click",function(){ - window.open($(this).data("link"),"_blank"); + $('.w-ad-banner__slide') + .not('[data-link=""]') + .not(".youtube") + .addClass('cursor') + .on("click",function(){ + if( $(this).data('target') === '_blank' ) { + window.open($(this).data("link"), "_blank"); + } else { + window.location.href = ($(this).data("link")); + } }) }) }(jQuery)); \ No newline at end of file diff --git a/app/assets/stylesheets/basic/global.css b/app/assets/stylesheets/basic/global.css index 3f05c30..c22a181 100644 --- a/app/assets/stylesheets/basic/global.css +++ b/app/assets/stylesheets/basic/global.css @@ -122,6 +122,20 @@ legend { text-align: center; list-style: none; } +#sidebar .sidebar-nav .license-denied { + cursor: not-allowed; +} +#sidebar .sidebar-nav .license-denied > span { + position: relative; + width: 60px; +} +#sidebar .sidebar-nav .license-denied > span:before { + position: absolute; + top: 10px; + left: 12px; + font-size: 3.1em; + color: rgba(205, 10, 10, 0.46); +} #sidebar > h2.position { margin: 0; width: 61px; @@ -188,6 +202,7 @@ legend { } #sidebar .sidebar-nav > li a { display: block; + text-decoration: none; } #sidebar .sidebar-nav > li i { font-size: 1.6em; diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index eb9c299..acb8485 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -119,6 +119,7 @@ class Admin::SitesController < OrbitAdminController def bundle_install 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` } %x(kill -s USR2 `cat tmp/pids/unicorn.pid`) sleep 5 render :nothing => true diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 5cfca10..7bda6bf 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -75,13 +75,26 @@ class PagesController < ApplicationController end params[:url] = page.url categories = [] - page.categories.each do |c| - category = Category.find(c) rescue nil - if !category.nil? && !category.disable - categories << c + if page.module == "member" + if page.categories.first == "all" + categories = ["all"] + else + page.categories.each do |c| + category = Role.find(c) rescue nil + if !category.nil? && !category.disabled + categories << c + end + end end + else + page.categories.each do |c| + category = Category.find(c) rescue nil + if !category.nil? && !category.disable + categories << c + end + end + categories = ["all"] if categories.blank? end - categories = ["all"] if categories.blank? @manifest = @key OrbitHelper.set_params params,current_user OrbitHelper.set_site_locale locale diff --git a/app/controllers/store_api_controller.rb b/app/controllers/store_api_controller.rb index a5c5d81..4bd74e8 100644 --- a/app/controllers/store_api_controller.rb +++ b/app/controllers/store_api_controller.rb @@ -30,7 +30,10 @@ class StoreApiController < ApplicationController response = {"success" => false} end render :json => response.to_json - bundle_install if response["success"] + if response["success"] + bundle_install + # give_permissions(params[:module_key]) + end end def uninstall_module @@ -43,6 +46,10 @@ class StoreApiController < ApplicationController render :json => {"success" => true}.to_json end + def render_license_denied + render :layout => "back_end" + end + private def bundle_install Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` } @@ -50,6 +57,12 @@ class StoreApiController < ApplicationController sleep 5 end + def restart_server_after_install + %x(kill -s USR2 `cat tmp/pids/unicorn.pid`) + sleep 5 + end + + def download_template(url,name) dir = File.join(Rails.root,"public","template_cache") destination = File.join(Rails.root,"app","templates","#{Site.first.template}","modules") diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index 73734d2..25eb17a 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -172,8 +172,15 @@ module OrbitBackendHelper http = Net::HTTP.new(uri.host,uri.port) request = Net::HTTP::Get.new("/site/permissions") request.body = params_to_send.to_query - response = http.request(request) - data = JSON.parse(response.body) + response = http.request(request) rescue nil + if response.nil? + data = {} + data["message"] = "Could not connect to the store." + data["error"] = "CONNECTION_REFUSED" + data["success"] = false + else + data = JSON.parse(response.body) + end if !data["success"] case data["error"] when "INVALID_SITE_TOKEN" diff --git a/app/models/module_app.rb b/app/models/module_app.rb index cd1d4a1..efee743 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -14,6 +14,7 @@ class ModuleApp field :widget_methods field :desktop_enabled, type: Boolean, default: false field :widget_settings + field :store_permission_granted, type: Boolean, default: false has_many :categories, dependent: :destroy, :autosave => true has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true diff --git a/app/models/orbit_store.rb b/app/models/orbit_store.rb index 9c9b64f..1217dc2 100644 --- a/app/models/orbit_store.rb +++ b/app/models/orbit_store.rb @@ -1,3 +1,4 @@ class OrbitStore URL = "http://store.tp.rulingcom.com" + MODULE_EXCEPTIONS = ["category","tag","authorization"] end \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/assets/javascripts/app.js b/app/templates/orbit_bootstrap/assets/javascripts/app.js index a9dd1ed..276189f 100644 --- a/app/templates/orbit_bootstrap/assets/javascripts/app.js +++ b/app/templates/orbit_bootstrap/assets/javascripts/app.js @@ -1,110 +1,106 @@ (function($) { "use strict" - - // Init functions + function init () { - // Announcement modules - var annc = { - truncation : function (el, maxLength) { + var doc = document; + + var orbit = { + // Cross browser add class function + addClass : function(el, className) { + if( el.classList ) { + el.classList.add(className); + } else { + el.className += ' ' + className; + } + }, + // Cross browser has class function + hasClass : function(el, cls) { + return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1; + }, + // Add class name to the menu item when its children items are more than eight + addMegaDropdownClass : function(el, len) { + for( var i = 0; i < el.length; i++ ) { + if( el[i].children.length > len ) { + orbit.addClass(el[i].parentNode, 'mega-dropdown'); + } + } + }, + // Append caret to menu item if it has dropdown + addCaret : function() { + var list = doc.querySelectorAll('.page_menu.level_2'); + for( var i = 0, len = list.length; i < len; i++ ) { + var node = doc.createElement('span'); + node.className = 'caret'; + list[i].parentNode.appendChild(node); + } + }, + // Add link and cursor class name on element that has data-link attribute + addLinkOnADBanner : function(els) { + $.each(els, function(i) { + if ($(this).data('link') !== "" && !$(this).hasClass('youtube')) { + $(this).on('click', function() { + var target = $(this).data('target'), + link = $(this).data('link'); + if (target === '_blank') { + window.open(link, target); + } else { + window.location.href = link; + } + }).addClass('cursor'); + } + }); + }, + // Announcement text truncation + truncation : function (el, len) { for( var i = 0; i < el.length; i ++ ) { if ( el[i].firstChild !== null ) { - if( el[i].firstChild.length > maxLength ) { - var newTitle = el[i].firstChild.nodeValue; - var newTitle = newTitle.substring(0, maxLength) + '...' + if( el[i].firstChild.length > len ) { + var newStr = el[i].firstChild.nodeValue, + newStr = newStr.substring(0, len) + '...' el .eq(i) - .text(newTitle); + .text(newStr); } } } - } - } + }, + // Sitemenu dropdown + sitemenuDropdown : function() { + var el = doc.querySelectorAll('.sitemenu__list.level-2'); + for( var i = 0, len = el.length; i < len; i++ ) { + if( el[i].hasChildNodes() ) { + var caret = doc.createElement('span'); + caret.className = 'sitemenu___dropdown-toggle fa fa-caret-down'; + caret.setAttribute('data-toggle', 'dropdown'); - function anncFix() { - var w$ = $('.w-announcement-4'); - if( w$.length ) { - annc.truncation(w$.find('.w-annc__subtitle'), 25); - } - } - - // Necessary for Responsive images - function bullEye() { - // $(".bullseye").bullseye({ - // fadeEffect: false - // }); - } - - // Adding class to submenu that has dropdown items - function submenuFix () { - var item$ = $('.submenu__item.level-1'); - var itemLen = item$.length; - var list$ = item$.find('.submenu__list.level-2'); - - for( var i=0; i div { - display: inline-block; - } - a { - display: inline-block; - margin-bottom: 4px; - padding: 5px 8px; - font-size: 0.8em; - color: $theme-gray; - border: 1px solid $theme-gray-light; - text-decoration: none; - &:hover { - color: $theme-color-main; - border-color: $theme-color-main; - background-color: $theme-gray-lighter; - } - } + .member-plugins { + margin-bottom: 20px; + a { + font-size: 0.8125rem; } } + } \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss b/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss index 320c950..da62bb5 100644 --- a/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss +++ b/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss @@ -1,5 +1,4 @@ // Base -@import url("http://fonts.googleapis.com/css?family=Droid+Sans:400,700"); @import "bootstrap/mixins"; @import "bootstrap/variables"; @import "base/mixins"; @@ -7,7 +6,7 @@ @import "base/unity"; @import "base/pagination"; @import "base/orbitbar-override"; -@import "base/genernal"; +@import "base/global"; // Layout @import "layout/header"; @@ -29,11 +28,3 @@ // Widget @import "widget/breadcrumb"; @import "widget/sitemenu"; - -html { - font-size: 100%; -} -body { - margin-top: 40px; // needed for Orbit bar - font-size: inherit; -} \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/assets/stylesheets/template/widget/sitemenu.scss b/app/templates/orbit_bootstrap/assets/stylesheets/template/widget/sitemenu.scss index 02b965d..693db3f 100644 --- a/app/templates/orbit_bootstrap/assets/stylesheets/template/widget/sitemenu.scss +++ b/app/templates/orbit_bootstrap/assets/stylesheets/template/widget/sitemenu.scss @@ -1,86 +1,52 @@ -.submenu-wrap { - @include clearfix(); +.sitemenu-wrap { padding: 10px 0; - - .submenu__title { + @include clearfix; + .sitemenu__title { display: none; } - - .submenu__list { - list-style: none; - padding: 0; + .sitemenu__list { margin: 0; + padding: 0; + list-style: none; } - - .submenu__item.level-1 { + .sitemenu__item.level-1 { + font-size: 0.8125rem; position: relative; float: left; margin-right: 1%; margin-bottom: 12px; - } - - .submenu__link.level-1 { - float: left; + padding: 8px .8em; padding-bottom: 8px; - font-size: 13px; - font-size: 0.8125rem; - background: $theme-color-second; color: #fff; - padding: 8px 0.8em; - border-radius: 0.2em; - + border-radius: .2em; + background: $theme-color-second; &:hover { background: darken($theme-color-second, 10%); } } - - .submenu__item:hover .dropdown { - display: block; - } - - .touch .submenu__item .dropdown { - display: none !important; - } - - // Submenu dropdown - .submenu__list.dropdown { - display: none; - padding: 20px 0 0 0; - position: absolute; - left: 0; - top: 80%; - border-radius: 2px; - z-index: 200; - } - - - .submenu__list .dropdown:before { - content: ""; - border-style: solid; - border-width: 0px 7px 7px 7px; - border-color: transparent transparent $theme-color-main transparent; - position: absolute; - top: 15px; - left: 15px; - } - - .submenu__item.level-2 { - display: block; - padding: 4px 8px; - background: $theme-color-main; - font-size: 0.8125rem; - } - - .submenu__link.level-2 { + .sitemenu__link.level-1 { + margin-right: .25rem; color: #fff; - white-space: nowrap; } - - .submenu__list.hidden--item { - display: none; - - &:before { - display: none; + .sitemenu___dropdown-toggle { + font-size: 0.75rem; + padding: 2px .3125rem; + cursor: pointer; + } + // sitemenu dropdown + .sitemenu__list.dropdown-menu { + min-width: 100%; + margin-top: 4px; + border: none; + border-radius: .2em; + background: $theme-color-main; + } + .sitemenu__link.level-2 { + color: #fff; + font-size: 0.8125rem; + padding: 4px 0.625rem; + &:hover { + background: lighten($theme-color-second, 5%); } } -} +} \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/home/index.html.erb b/app/templates/orbit_bootstrap/home/index.html.erb index d1102e4..086ef7f 100644 --- a/app/templates/orbit_bootstrap/home/index.html.erb +++ b/app/templates/orbit_bootstrap/home/index.html.erb @@ -3,7 +3,7 @@ <%= render_partial("head") %> - + <%= render_orbit_bar %> <%= render_header %>
diff --git a/app/templates/orbit_bootstrap/home/pagination.html.erb b/app/templates/orbit_bootstrap/home/pagination.html.erb index 96c2b2f..0c22683 100644 --- a/app/templates/orbit_bootstrap/home/pagination.html.erb +++ b/app/templates/orbit_bootstrap/home/pagination.html.erb @@ -1,3 +1,5 @@ - \ No newline at end of file + diff --git a/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget1.html.erb b/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget1.html.erb index f1c354c..31c154f 100644 --- a/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget1.html.erb +++ b/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget1.html.erb @@ -1,4 +1,4 @@ -
+
    + + diff --git a/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2.html.erb b/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2.html.erb new file mode 100644 index 0000000..842ebc3 --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2.html.erb @@ -0,0 +1,18 @@ +
    +
    + {{html}} +
    +
      +
      + diff --git a/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2_video.html.erb b/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2_video.html.erb index 6b77a90..22c4aa5 100644 --- a/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2_video.html.erb +++ b/app/templates/orbit_bootstrap/modules/ad_banner/_ad_banner_widget2_video.html.erb @@ -1,4 +1,4 @@ -
      +
      \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/archive/_archive_widget1.html.erb b/app/templates/orbit_bootstrap/modules/archive/_archive_widget1.html.erb index 761b3e1..e5bfe75 100644 --- a/app/templates/orbit_bootstrap/modules/archive/_archive_widget1.html.erb +++ b/app/templates/orbit_bootstrap/modules/archive/_archive_widget1.html.erb @@ -1,4 +1,4 @@ -
      +

      {{widget-title}}

      • diff --git a/app/templates/orbit_bootstrap/modules/archive/archive_index1.html.erb b/app/templates/orbit_bootstrap/modules/archive/archive_index1.html.erb index d7fafa8..b66ea44 100644 --- a/app/templates/orbit_bootstrap/modules/archive/archive_index1.html.erb +++ b/app/templates/orbit_bootstrap/modules/archive/archive_index1.html.erb @@ -1,4 +1,4 @@ -
        +

        {{page-title}}

        • diff --git a/app/templates/orbit_bootstrap/modules/archive/archive_index2.html.erb b/app/templates/orbit_bootstrap/modules/archive/archive_index2.html.erb index b54a794..be5c2ca 100644 --- a/app/templates/orbit_bootstrap/modules/archive/archive_index2.html.erb +++ b/app/templates/orbit_bootstrap/modules/archive/archive_index2.html.erb @@ -6,6 +6,7 @@

          + diff --git a/app/templates/orbit_bootstrap/modules/archive/show.html.erb b/app/templates/orbit_bootstrap/modules/archive/show.html.erb index 11a8c05..12085b7 100644 --- a/app/templates/orbit_bootstrap/modules/archive/show.html.erb +++ b/app/templates/orbit_bootstrap/modules/archive/show.html.erb @@ -1,7 +1,7 @@
          -

          +

          {{title}} -

          +

          diff --git a/app/templates/orbit_bootstrap/modules/calendar/index.html.erb b/app/templates/orbit_bootstrap/modules/calendar/index.html.erb index abdd5cf..f573205 100644 --- a/app/templates/orbit_bootstrap/modules/calendar/index.html.erb +++ b/app/templates/orbit_bootstrap/modules/calendar/index.html.erb @@ -1,15 +1,15 @@
          -
          +
          @@ -17,12 +17,12 @@
          - - - - + + + +
          -
          @@ -33,7 +33,7 @@
          -
          Loading...
          +
          diff --git a/app/templates/orbit_bootstrap/modules/web_resource/_widget.html.erb b/app/templates/orbit_bootstrap/modules/web_resource/_web_res_widget1.html.erb similarity index 100% rename from app/templates/orbit_bootstrap/modules/web_resource/_widget.html.erb rename to app/templates/orbit_bootstrap/modules/web_resource/_web_res_widget1.html.erb diff --git a/app/templates/orbit_bootstrap/modules/web_resource/_widget1.html.erb b/app/templates/orbit_bootstrap/modules/web_resource/_web_res_widget2.html.erb similarity index 100% rename from app/templates/orbit_bootstrap/modules/web_resource/_widget1.html.erb rename to app/templates/orbit_bootstrap/modules/web_resource/_web_res_widget2.html.erb diff --git a/app/templates/orbit_bootstrap/modules/web_resource/index.html.erb b/app/templates/orbit_bootstrap/modules/web_resource/web_res_index1.html.erb similarity index 100% rename from app/templates/orbit_bootstrap/modules/web_resource/index.html.erb rename to app/templates/orbit_bootstrap/modules/web_resource/web_res_index1.html.erb diff --git a/app/templates/orbit_bootstrap/modules/web_resource/index1.html.erb b/app/templates/orbit_bootstrap/modules/web_resource/web_res_index2.html.erb similarity index 100% rename from app/templates/orbit_bootstrap/modules/web_resource/index1.html.erb rename to app/templates/orbit_bootstrap/modules/web_resource/web_res_index2.html.erb diff --git a/app/templates/orbit_bootstrap/widgets/site_menu_widget/_widget.html.erb b/app/templates/orbit_bootstrap/widgets/site_menu_widget/_widget.html.erb index b45ef1d..cc90a14 100644 --- a/app/templates/orbit_bootstrap/widgets/site_menu_widget/_widget.html.erb +++ b/app/templates/orbit_bootstrap/widgets/site_menu_widget/_widget.html.erb @@ -1,11 +1,11 @@ - @@ -245,10 +250,27 @@ } } + function check_module_updates(){ + $("#progress_msg").html("<%= t("update_manager_.updating_orbit") %>"); + $("#new_update_container").fadeOut(function(){ + $("#update_done").fadeOut(function(){ + $("#update_status").fadeIn(function(){ + $("#update_progress").fadeIn(); + $.get("<%= admin_site_bundle_install_path %>",function(result){ + $("#update_progress").fadeOut(function(){$("#update_done").fadeIn();}); + $("#update_status").fadeIn(); + }); + }); + }); + }); + } + $(document).ready(function(){ check_updates(); get_update_history(); + $("#module_update_btn").click(check_module_updates); + $("#chech_update_btn").click(check_updates); $("#update_btn").click(function(){ diff --git a/app/views/store_api/render_license_denied.html.erb b/app/views/store_api/render_license_denied.html.erb new file mode 100644 index 0000000..1f3535a --- /dev/null +++ b/app/views/store_api/render_license_denied.html.erb @@ -0,0 +1,19 @@ + +
          +

          License Denied.

          +

          Please contact www.rulingdigital.com.

          +
          \ No newline at end of file diff --git a/built_in_extensions.rb b/built_in_extensions.rb index 1d66330..2f9148e 100644 --- a/built_in_extensions.rb +++ b/built_in_extensions.rb @@ -2,7 +2,7 @@ gem 'announcement', git: 'http://gitlab.tp.rulingcom.com/saurabh/announcement-te gem 'ad_banner', git: 'http://gitlab.tp.rulingcom.com/saurabh/adbanner-test.git' gem "archive", git: 'http://gitlab.tp.rulingcom.com/saurabh/archive.git' gem 'gallery', git: 'http://gitlab.tp.rulingcom.com/saurabh/gallery.git' -gem 'links', git: 'http://gitlab.tp.rulingcom.com/saurabh/links.git' +gem 'web_resource', git: 'http://gitlab.tp.rulingcom.com/saurabh/links.git' gem 'page_content', git: 'http://gitlab.tp.rulingcom.com/saurabh/pagecontent.git' gem 'faq', git: 'http://gitlab.tp.rulingcom.com/saurabh/faq.git' diff --git a/config/environment.rb b/config/environment.rb index e75f352..344ddbf 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -5,6 +5,7 @@ require File.expand_path('../application', __FILE__) Orbit::Application.initialize! Orbit::Application.config.secret_key_base = 'acc6ffc5a7d360c9cf2a7bdb4ddf9a897942ec6767413a5c0324a0fa8b86197a96298288a66bd46d8770d8b6edf509aad65716961c2c364ce006b475e6cfd418' OrbitApp.cleanup_modules +OrbitApp.check_module_permissions if Site.count == 0 site = Site.new diff --git a/config/locales/en.yml b/config/locales/en.yml index 659ca3a..4168243 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -603,6 +603,7 @@ en: check_update: Check Update checking_update: Checking for Updates system_update: Install Updates + module_update: Module Updates update_done: System is update to date update_faild: Update failed. Merge is require in the update. Please login to server and update manually. update_history: Update Histroy diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 9f99e3c..27993ad 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -612,6 +612,7 @@ zh_tw: check_update: 檢查更新 checking_update: 檢查更新中 system_update: 安裝更新 + module_update: 模組更新 update_done: 系統已是最新版本 update_faild: 更新失敗. 更新需要合併程式碼. 請登入伺服器手動進行更新. update_history: 更新紀錄 diff --git a/config/routes.rb b/config/routes.rb index 8d95df9..73d5b9f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,7 @@ Orbit::Application.routes.draw do get "/page_parts/getwidgets" => "page_parts#getwidgets" get "/page_parts/info" => "page_parts#info" get "/page_parts/edit_sub_part" => "page_parts#edit_sub_part" + get "/admin/license_denied" => "store_api#render_license_denied" resources :pages resources :page_parts do @@ -29,6 +30,7 @@ Orbit::Application.routes.draw do post "/store/confirmation" => "store_api#confirmation" post "/store/install_module" => "store_api#install_module" post "/store/uninstall_module" => "store_api#uninstall_module" + post "/store/restart_srever_after_install" => "store_api#restart_server_after_install" # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". @@ -95,7 +97,7 @@ Orbit::Application.routes.draw do get "members/get_role_fields/:id" => "members#get_role_fields", :as => :get_role_fields get "members/import_members" => "members#import_members" - get "members/unapproved_members" => "members#unapproved_members" + get "members/unapproved_members" => "members#unapproved_members" resources :members do collection do @@ -196,8 +198,9 @@ Orbit::Application.routes.draw do get 'get_update_history' get 'check_updates' get 'update_orbit' + get 'bundle_install' get 'restart_server' - get 'delete_mail_log' + get 'delete_mail_log' end resources :designs do diff --git a/config/unicorn.rb b/config/unicorn.rb index 4e5c8d1..21ebddb 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -26,4 +26,4 @@ before_fork do |server, worker| rescue Errno::ENOENT, Errno::ESRCH end end -end \ No newline at end of file +end diff --git a/lib/orbit_app/helper/side_bar_renderer.rb b/lib/orbit_app/helper/side_bar_renderer.rb index e4fe6a9..ede07be 100644 --- a/lib/orbit_app/helper/side_bar_renderer.rb +++ b/lib/orbit_app/helper/side_bar_renderer.rb @@ -13,12 +13,14 @@ module SideBarRenderer @app_available_for = af if display? content_tag :div, class: "sub-nav-block #{@icon_class}" do - concat content_tag :h4, I18n.t(@head_label) - concat (content_tag :ul, class: "nav nav-list" do - @context_links.sort_by {| obj | obj.priority}.map{ |link| - link.render(request, params, @current_module_app, @current_user, @belong_module_app, link.get_active_action, link.available_for) - }.join.html_safe - end) + if @belong_module_app.store_permission_granted + concat content_tag :h4, I18n.t(@head_label) + concat (content_tag :ul, class: "nav nav-list" do + @context_links.sort_by {| obj | obj.priority}.map{ |link| + link.render(request, params, @current_module_app, @current_user, @belong_module_app, link.get_active_action, link.available_for) + }.join.html_safe + end) + end end end end @@ -33,9 +35,17 @@ module SideBarRenderer @app_available_for = available_for if display? content_tag :li, class: (module_sidebar_active? ? 'active' : nil) do - link_to Rails.application.routes.url_helpers.send(@head_link) do - content_tag :span do - content_tag(:i, nil, class: @icon_class) + if @belong_module_app.store_permission_granted + link_to Rails.application.routes.url_helpers.send(@head_link) do + content_tag :span do + content_tag(:i, nil, class: @icon_class) + end + end + else + link_to "/admin/license_denied", class: "license-denied" do + content_tag :span, class: "icons-blocked" do + content_tag(:i, nil, class: @icon_class) + end end end end diff --git a/lib/orbit_app/register_module.rb b/lib/orbit_app/register_module.rb index 44797d7..ad9b2da 100644 --- a/lib/orbit_app/register_module.rb +++ b/lib/orbit_app/register_module.rb @@ -20,5 +20,53 @@ module OrbitApp end end end + + def check_module_permissions + store_token = Site.first.store_token + module_apps = ModuleApp.all + exceptions = OrbitStore::MODULE_EXCEPTIONS + if !store_token.nil? + ids = [] + module_index = {} + module_apps.each do |ma| + ids << ma.key + module_index[ma.key] = ma + end + params_to_send = {'store_token' => store_token, "apps" => ids} + uri = URI.parse(OrbitStore::URL) + http = Net::HTTP.new(uri.host,uri.port) + request = Net::HTTP::Post.new("/store/check_module_permissions") + request.body = params_to_send.to_query + response = http.request(request) rescue nil + if !response.nil? + data = JSON.parse(response.body) + if response.code == "200" + if data["success"] + permissions = data["permissions"] + permissions.each do |permission| + ma = module_index[permission["app"]] + ma.store_permission_granted = (exceptions.include?(ma.key) ? true : permission["granted"]) + ma.save + end + else + module_apps.each do |ma| + ma.store_permission_granted = (exceptions.include?(ma.key) ? true : false) + ma.save + end + end + end + else + module_apps.each do |ma| + ma.store_permission_granted = (exceptions.include?(ma.key) ? true : false) + ma.save + end + end + else + module_apps.each do |ma| + ma.store_permission_granted = (exceptions.include?(ma.key) ? true : false) + ma.save + end + end + end end end \ No newline at end of file diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb index 6b46264..53e9d1b 100644 --- a/lib/orbit_core_lib.rb +++ b/lib/orbit_core_lib.rb @@ -62,7 +62,11 @@ module OrbitCoreLib return end if !@module_app.nil? - check_user_can_use + if @module_app.store_permission_granted || params["controller"] == "admin/authorizations" + check_user_can_use + else + redirect_to admin_license_denied_path + end else if current_user.nil? || !current_user.is_admin? if params["controller"] != "admin/assets" diff --git a/lib/tasks/register_with_store.rake b/lib/tasks/register_with_store.rake new file mode 100644 index 0000000..9e76058 --- /dev/null +++ b/lib/tasks/register_with_store.rake @@ -0,0 +1,24 @@ +namespace :register_with_store do + task :register,[:arg] => :environment do |task,args| + modules = ModuleApp.all + ids = modules.collect{|ma| ma.key} + store_token = Site.first.store_token + module_apps = ModuleApp.all + exceptions = OrbitStore::MODULE_EXCEPTIONS + if !store_token.nil? + params_to_send = {'store_token' => store_token, "apps" => ids} + uri = URI.parse(OrbitStore::URL) + http = Net::HTTP.new(uri.host,uri.port) + request = Net::HTTP::Post.new("/store/register_old_sites_modules") + request.body = params_to_send.to_query + response = http.request(request) rescue nil + if response.nil? + puts "Cannot connect to store." + else + puts "All modules registered." + end + else + puts "Cannot register modules, site is not registered with store." + end + end +end \ No newline at end of file