diff --git a/Gemfile b/Gemfile index ff991b5..8132d77 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem 'mongoid', github: "mongoid/mongoid" gem "mini_magick", "3.5.0" gem 'carrierwave' gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' - +gem 'zip-zip' gem 'kaminari' gem "impressionist" gem "chartkick" 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/javascripts/validator.js b/app/assets/javascripts/validator.js index 847a6d4..435d4d7 100644 --- a/app/assets/javascripts/validator.js +++ b/app/assets/javascripts/validator.js @@ -25,6 +25,9 @@ var FormValidator = function(form){ nospace : function(value){ return (/\s/.test(value) ? false : true); }, + lowercase : function(value){ + return (value == value.toLowerCase() ? true : false); + }, email : function(value){ var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(value); @@ -40,35 +43,39 @@ var FormValidator = function(form){ var _attachSubmitHandler = function(){ fv.form.on("submit",function(){ - failed_elements = []; - $.each(elements_data,function(key,element){ - var validators = element.validators, - messages = element.messages, - el = fv.form.find("#" + key); - for(i = 0; i < validators.length; i++){ - var error_span = (fv.form.find("div[for=" + key + "]").length ? $("div[for=" + key + "]") : $("
")); - if(typeof fv.validate_functions[validators[i]] == "function"){ - if(!fv.validate_functions[validators[i]](el.val(),el)){ - error_span.text(messages[i]); - el.after(error_span); - failed_elements.push(el); - break; - }else{ - error_span.remove(); - } + return fv.isFormValidated(); + }) + } + + this.isFormValidated = function(){ + failed_elements = []; + $.each(elements_data,function(key,element){ + var validators = element.validators, + messages = element.messages, + el = fv.form.find("#" + key); + for(i = 0; i < validators.length; i++){ + var error_span = (fv.form.find("div[for=" + key + "]").length ? $("div[for=" + key + "]") : $("
")); + if(typeof fv.validate_functions[validators[i]] == "function"){ + if(!fv.validate_functions[validators[i]](el.val(),el)){ + error_span.text(messages[i]); + el.after(error_span); + failed_elements.push(el); + break; }else{ - console.info("Not validating for " + validators[i] + ". Skipping."); + error_span.remove(); } + }else{ + console.info("Not validating for " + validators[i] + ". Skipping."); } - }) - if(failed_elements.length){ - var offset = failed_elements[0].offset().top - fv.form.offset().top + fv.form.scrollTop(); - fv.form.parent().animate({scrollTop:offset-50}, '300', 'swing'); - return false; - }else{ - return true; } }) + if(failed_elements.length){ + var offset = failed_elements[0].offset().top - fv.form.offset().top + fv.form.scrollTop(); + fv.form.parent().animate({scrollTop:offset-50}, '300', 'swing'); + return false; + }else{ + return true; + } } var _putFieldsValidatorAndMessage = function(){ 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/assets/stylesheets/lib/orbit_bar/orbit-bar.scss.erb b/app/assets/stylesheets/lib/orbit_bar/orbit-bar.scss.erb index 8b60f83..4d74081 100644 --- a/app/assets/stylesheets/lib/orbit_bar/orbit-bar.scss.erb +++ b/app/assets/stylesheets/lib/orbit_bar/orbit-bar.scss.erb @@ -318,7 +318,7 @@ $orbit-bar-bgc-lighter: lighten($orbit-bar-bgc, 20%) !default; display: none; top: 0; margin: 0 2em; - padding: 0.3em 0; + padding: 0; color: #FFF; font-size: 1.4em; text-align: center; @@ -328,6 +328,9 @@ $orbit-bar-bgc-lighter: lighten($orbit-bar-bgc, 20%) !default; a { color: #FFF; } + .page-main & { + padding: 0.3em 0; + } } .orbit-bar-search-sign-language { float: right; @@ -339,6 +342,7 @@ $orbit-bar-bgc-lighter: lighten($orbit-bar-bgc, 20%) !default; input[type="search"] { color: $orbit-bar-bgc-lighter; border: none; + margin-bottom: 0; border-radius: 1.7em; line-height: 1.3em; padding: 0.2em 0.8em; diff --git a/app/controllers/admin/module_store_controller.rb b/app/controllers/admin/module_store_controller.rb index c6ac85f..7385bbd 100644 --- a/app/controllers/admin/module_store_controller.rb +++ b/app/controllers/admin/module_store_controller.rb @@ -3,7 +3,7 @@ class Admin::ModuleStoreController < OrbitAdminController def index @extensions = [] - @downloaded_extensions = get_downloaded_extension + @downloaded_extensions = [] # if current_site.site_token? # if current_site.store_confirmation # @extensions = get_extensions diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 87175db..acb8485 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -106,7 +106,9 @@ class Admin::SitesController < OrbitAdminController else result = "success" # 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=built_in_extensions.rb bundle update && bundle` } + Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` } + end render :text => result @@ -117,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/members_controller.rb b/app/controllers/members_controller.rb index 13cb49d..aba6008 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -139,29 +139,44 @@ class MembersController < ApplicationController plugins = OrbitApp::Plugin::Registration.all rescue nil plugin_list = plugins.collect.with_index do |plugin, idx| intro = PersonalPluginIntro.find_by(member_profile_id: member.id, _type: "#{plugin.app_name}Intro") rescue nil - if intro.nil? or intro.complete_list - plugin_data = plugin.app_name.constantize.where(member_profile_id: member) rescue nil - pd = plugin_data.collect do |p| - slug_title = ["JournalPaper","WritingConference"].include?(plugin.app_name) ? p.create_link : p.slug_title - { - "data_title" => slug_title, - "link_to_show" => OrbitHelper.url_to_plugin_show(p.to_param,plugin.module_app_name.underscore) - } + if !intro.blank? + if !intro.complete_list.blank? + plugin_data = plugin.app_name.constantize.where(member_profile_id: member) rescue nil + pd = plugin_data.collect do |p| + slug_title = ["JournalPaper","WritingConference"].include?(plugin.app_name) ? p.create_link : p.slug_title + { + "data_title" => slug_title, + "link_to_show" => OrbitHelper.url_to_plugin_show(p.to_param,plugin.module_app_name.underscore) + } + end end - elsif intro.brief_intro == true - pd = [] - pd << {"data_title" => intro.text.html_safe} - end - { + if !intro.brief_intro.blank? + pdi = [] + pdi << {"data_intro_title" => intro.text.html_safe} + end + + if intro.complete_list.blank? + complete_display = "hide" + end + + if intro.brief_intro.blank? + brief_display = "hide" + end + end + + { "plugin_data" => pd, + "plugin_data_intro" => pdi, + "complete_display" => complete_display, + "brief_display" => brief_display, "plugin_name" => plugin.module_app_name.underscore, "plugin_title" => t('module_name.'+plugin.module_app_name.underscore), "plugin_class" => idx==0 ? "active" : "" - } + } end - plugin_list = plugin_list.reject{|plugin| plugin['plugin_data'].blank?} + plugin_list = plugin_list.reject{|plugin| plugin['plugin_data'].blank? and plugin['plugin_data_intro'].blank?} { "plugins" => plugin_list, "profile_data" => profile_data, @@ -175,7 +190,6 @@ class MembersController < ApplicationController def member_data(member, fields_to_show) profile_data = [] fields_to_show.each do |field| - # debugger case field['type'] when 'profile' field_data = member.get_attribute_data(field) rescue {} diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b243590..7bda6bf 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -11,7 +11,7 @@ class PagesController < ApplicationController before_filter :set_edit_mode def index - @pages = Page.all + @pages = Page.all # render json: @pages end @@ -76,10 +76,14 @@ class PagesController < ApplicationController params[:url] = page.url categories = [] if page.module == "member" - page.categories.each do |c| - category = Role.find(c) rescue nil - if !category.nil? && !category.disabled - categories << c + 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 @@ -89,8 +93,8 @@ class PagesController < ApplicationController 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 @@ -186,30 +190,38 @@ class PagesController < ApplicationController "id" => cat.id.to_s } end + tags = module_app.tags.collect do |t| + { + "name" => t.name, + "id" => t.id.to_s + } + end else categories = [] + tags = [] end end roles = roles.nil? ? [] : roles categories = categories.nil? ? [] : categories + tags = tags.nil? ? [] : tags if module_app.data_count.nil? - render :json => {"categories" => categories, "tags" => module_app.tags,"roles" => roles,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>false}, "locale" => I18n.locale.to_s}.to_json + render :json => {"categories" => categories, "tags" => tags,"roles" => roles,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>false}, "locale" => I18n.locale.to_s}.to_json else - render :json => {"categories" => categories, "tags" => module_app.tags,"roles" => roles,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>true,"start"=>module_app.data_count.begin, "end" => module_app.data_count.end}, "locale" => I18n.locale.to_s}.to_json + render :json => {"categories" => categories, "tags" => tags,"roles" => roles,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>true,"start"=>module_app.data_count.begin, "end" => module_app.data_count.end}, "locale" => I18n.locale.to_s}.to_json end end def new - @page = Page.new( + @page = Page.new( :enabled_for_mobile=>true, :menu_enabled_for=>["en", "zh_tw"], :enabled_for=>["en", "zh_tw"], :enabled_for_sitemap=>["en", "zh_tw"] ) - @pages = Page.where(:page_id.ne => "" , :page_id.exists => true) - @modules = ModuleApp.all.frontend_enabled.order_by(:key=>'asc') + @pages = Page.where(:page_id.ne => "" , :page_id.exists => true) + @modules = ModuleApp.all.frontend_enabled.order_by(:key=>'asc') end @@ -260,7 +272,7 @@ class PagesController < ApplicationController end end - private + private def get_layouts(module_app) layout_types = [] @@ -432,6 +444,7 @@ class PagesController < ApplicationController p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, :enabled_for_mobile, :member_sort_position, enabled_for_sitemap: [], enabled_for: [],menu_enabled_for: [], categories: [], tags: [], role_status: [], name_translations: valid_locales, external_url_translations: valid_locales) p["role_status"] = p["role_status"] || [] p["categories"] = p["categories"] || [] + p["tags"] = p["tags"] || [] p["enabled_for"] = p["enabled_for"] || [] p["menu_enabled_for"] = p["menu_enabled_for"] || [] p["enabled_for_sitemap"] = p["enabled_for_sitemap"] || [] diff --git a/app/controllers/store_api_controller.rb b/app/controllers/store_api_controller.rb index 50eb645..4bd74e8 100644 --- a/app/controllers/store_api_controller.rb +++ b/app/controllers/store_api_controller.rb @@ -1,3 +1,6 @@ +require "net/http" +require 'open-uri' +require 'zip/zip' class StoreApiController < ApplicationController def confirmation site_token = params[:site_token] @@ -11,4 +14,80 @@ class StoreApiController < ApplicationController render :json => {"success" => false}.to_json end end + + def install_module + if current_site.store_token.nil? + response = {"success" => false} + elsif current_site.store_token == params[:site_token] + file = File.join(Rails.root,"downloaded_extensions.rb") + g = "gem '#{params[:module_key]}', git: '#{params[:git_path]}'" + File.open(file,"a+") { |f| f.puts(g) } + if !directory_exists?(File.join(Rails.root,"app","templates","#{Site.first.template}","modules","#{params[:module_key]}")) + download_template(params[:template],params[:template_filename]) + end + response = {"success" => true} + else + response = {"success" => false} + end + render :json => response.to_json + if response["success"] + bundle_install + # give_permissions(params[:module_key]) + end + end + + def uninstall_module + file = File.join(Rails.root,"downloaded_extensions.rb") + data = File.read(file) + g = "gem '#{params[:module_key]}', git: '#{params[:git_path]}'\n" + data = data.gsub(g,"") + File.write(file,data) + bundle_install + 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` } + %x(kill -s USR2 `cat tmp/pids/unicorn.pid`) + 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") + if !directory_exists?(dir) + Dir.mkdir dir + end + zipfile = File.join(Rails.root, "public" , "template_cache", name) + open(zipfile, 'wb') do |fo| + fo.print open(url).read + end + unzip_file(zipfile,destination) + end + + def directory_exists?(directory) + File.directory?(directory) + end + + def unzip_file (file, destination) + Zip::ZipFile.open(file) { |zip_file| + zip_file.each { |f| + f_path=File.join(destination, f.name) + FileUtils.mkdir_p(File.dirname(f_path)) + zip_file.extract(f, f_path) unless File.exist?(f_path) + } + } + FileUtils.rm_rf(File.join(Rails.root,"public","template_cache")) + end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a794839..2c071be 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -64,6 +64,8 @@ module ApplicationHelper end site_footer = site_footer.nil? ? "" : site_footer html = html.gsub("{{footer-data}}",site_footer) + counter = Page.root.view_count.to_s rescue "" + html = html.gsub("{{site-counter}}",counter) html.html_safe end 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/footer.html.erb b/app/templates/orbit_bootstrap/home/footer.html.erb index 76aa7cc..110eb8f 100644 --- a/app/templates/orbit_bootstrap/home/footer.html.erb +++ b/app/templates/orbit_bootstrap/home/footer.html.erb @@ -1,5 +1,6 @@ \ 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 4c1f061..d7ea768 100644 --- a/built_in_extensions.rb +++ b/built_in_extensions.rb @@ -3,7 +3,7 @@ gem 'news', git: 'http://gitlab.tp.rulingcom.com/root/nccu-news.git' 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' #Personal Plugins diff --git a/config/environment.rb b/config/environment.rb index a176bdd..437818a 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 b6a8a6f..3142ec2 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 be21e96..4dad87b 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -613,6 +613,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 cd62b5e..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 @@ -27,6 +28,9 @@ Orbit::Application.routes.draw do get "/module/:name" => "home#index" get "/module/:name/show" => "home#show" 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". @@ -93,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 @@ -194,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/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