forked from saurabh/orbit4-5
added widget support for orbit.. now have the ability to install widgets from store
This commit is contained in:
parent
e11581c0ee
commit
9b958354c2
|
@ -287,15 +287,14 @@ class Admin::ImportController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
when "gallery"
|
||||
if @@thread.alive?
|
||||
render :json => {"success" => true, "total_images" => @@import_stats["total_images"], "current_status" => @@import_stats["current_status"], "current_album_id" => @@import_stats["current_album_id"], "current_album_name" => @@import_stats["current_album_name"]}
|
||||
else
|
||||
if @@import_stats["current_status"] == @@import_stats["total_images"]
|
||||
render :json => {"success" => true, "total_images" => @@import_stats["total_images"], "current_status" => @@import_stats["current_status"], "current_album_id" => @@import_stats["current_album_id"], "current_album_name" => @@import_stats["current_album_name"]}
|
||||
else
|
||||
render :json => {"success" => false, "current_album_id" => @@import_stats["current_album_id"], "current_album_name" => @@import_stats["current_album_name"]}
|
||||
end
|
||||
end
|
||||
# if @@import_stats["current_status"] <= (@@import_stats["total_images"] + 1)
|
||||
# render :json => {"success" => true, "total_images" => @@import_stats["total_images"], "current_status" => @@import_stats["current_status"], "current_album_id" => @@import_stats["current_album_id"], "current_album_name" => @@import_stats["current_album_name"]}
|
||||
# elsif @@import_stats["current_status"] == @@import_stats["total_images"]
|
||||
# render :json => {"success" => true, "total_images" => @@import_stats["total_images"], "current_status" => @@import_stats["current_status"], "current_album_id" => @@import_stats["current_album_id"], "current_album_name" => @@import_stats["current_album_name"]}
|
||||
# else
|
||||
# render :json => {"success" => false, "current_album_id" => @@import_stats["current_album_id"], "current_album_name" => @@import_stats["current_album_name"]}
|
||||
# end
|
||||
render :json => @@import_stats.to_json
|
||||
when "links"
|
||||
if @@thread.alive?
|
||||
render :json => {"success" => true, "current_import" => @@import_stats["current_import"], "total_links" => @@import_stats["total_links"], "current_status" => @@import_stats["current_status"], "current_link_id" => @@import_stats["current_link_id"], "current_link_name" => @@import_stats["current_album_name"]}
|
||||
|
@ -311,7 +310,7 @@ class Admin::ImportController < OrbitAdminController
|
|||
|
||||
def rss2_galleries
|
||||
uri = URI.parse(params['url'])
|
||||
@@thread = Thread.new do
|
||||
# @@thread = Thread.new do
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
request = Net::HTTP::Get.new(uri.request_uri)
|
||||
response = http.request(request)
|
||||
|
@ -352,9 +351,9 @@ class Admin::ImportController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@thread.join
|
||||
@@thread.abort_on_exception = true
|
||||
# end
|
||||
# @@thread.join
|
||||
# @@thread.abort_on_exception = true
|
||||
render :json => {"success" => true}.to_json
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class PagePartsController < ApplicationController
|
|||
@part_number = params[:part]
|
||||
@page_id = params[:page_id]
|
||||
@modules = ModuleApp.widget_enabled
|
||||
@modules = @modules.concat(OrbitWidget.all)
|
||||
@no_orbit_bar = @no_side_bar = true
|
||||
@select_number = 0
|
||||
@html_class = "page-parts"
|
||||
|
@ -21,6 +22,7 @@ class PagePartsController < ApplicationController
|
|||
@part_number = params[:id]
|
||||
@select_number = @part.sub_parts.count
|
||||
@modules = ModuleApp.widget_enabled
|
||||
@modules = @modules.concat(OrbitWidget.all)
|
||||
@no_orbit_bar = @no_side_bar = true
|
||||
@html_class = "page-parts"
|
||||
render :layout => "structure"
|
||||
|
@ -32,6 +34,7 @@ class PagePartsController < ApplicationController
|
|||
@select_number = @part.sub_parts.index(@subpart)
|
||||
@kind = @subpart.kind
|
||||
@modules = ModuleApp.widget_enabled
|
||||
@modules = @modules.concat(OrbitWidget.all)
|
||||
if @kind == "module_widget"
|
||||
@widget_types = []
|
||||
module_name = @subpart.module
|
||||
|
@ -41,9 +44,15 @@ class PagePartsController < ApplicationController
|
|||
w = File.basename(w, ".*")
|
||||
@widget_types << w.gsub("_","") if w != "index" && w != "show"
|
||||
end
|
||||
|
||||
app = ModuleApp.find_by_key(module_name)
|
||||
@categories = app.categories
|
||||
Dir.glob("#{Rails.root}/app/templates/#{@key}/widgets/#{module_name.downcase}/*").each do |w|
|
||||
next if File.ftype(w).eql?("directory")
|
||||
w = File.basename(w, ".*")
|
||||
w = File.basename(w, ".*")
|
||||
@widget_types << w.gsub("_","") if w != "index" && w != "show"
|
||||
end
|
||||
app = ModuleApp.find_by_key(module_name) rescue nil
|
||||
app = OrbitWidget.find_by_key(module_name) if app.nil?
|
||||
@categories = app.categories rescue []
|
||||
@widget_methods = app.get_registration.get_widget_methods
|
||||
@widget_settings = app.get_registration.get_widget_settings
|
||||
@data_count = nil
|
||||
|
@ -100,9 +109,16 @@ class PagePartsController < ApplicationController
|
|||
w = File.basename(w, ".*")
|
||||
@widget_types << w.gsub("_","") if w != "index" && w != "show"
|
||||
end
|
||||
module_name = module_name.downcase.singularize
|
||||
app = ModuleApp.find_by_key(module_name)
|
||||
@categories = app.categories
|
||||
Dir.glob("#{Rails.root}/app/templates/#{@key}/widgets/#{module_name.downcase}/*").each do |w|
|
||||
next if File.ftype(w).eql?("directory")
|
||||
w = File.basename(w, ".*")
|
||||
w = File.basename(w, ".*")
|
||||
@widget_types << w.gsub("_","") if w != "index" && w != "show"
|
||||
end
|
||||
module_name = module_name.downcase.singularize
|
||||
app = ModuleApp.find_by_key(module_name) rescue nil
|
||||
app = OrbitWidget.find_by_key(module_name) if app.nil?
|
||||
@categories = app.categories rescue []
|
||||
@widget_methods = app.get_registration.get_widget_methods
|
||||
@widget_settings = app.get_registration.get_widget_settings
|
||||
@data_count = nil
|
||||
|
|
|
@ -48,7 +48,12 @@ module PagesHelper
|
|||
controller_name = controller_name.downcase.singularize
|
||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
if !File.exists?f
|
||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_widget.html.erb");
|
||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'widgets', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
if !File.exists?f
|
||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_widget.html.erb");
|
||||
else
|
||||
f = File.join('../templates', "#{@key}", 'widgets', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
end
|
||||
else
|
||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class OrbitWidget
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :title, type: String
|
||||
field :key, type: String
|
||||
|
||||
def get_registration
|
||||
OrbitApp::Widget::Registration.find_by_key(key)
|
||||
end
|
||||
|
||||
def self.find_by_key(key)
|
||||
self.find_by(:key => key)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
<div data-ps="">
|
||||
<h3>{{widget_title}}</h3>
|
||||
<ul data-list="pages" data-level="0">
|
||||
<li>
|
||||
<a href="{{url}}" target="{{target}}">{{page_name}}</a>
|
||||
<ul data-list="children" data-level="1">
|
||||
<li>
|
||||
<a href="{{url}}" target="{{target}}">{{page_name}}</a>
|
||||
<ul data-list="children" data-level="2">
|
||||
<li>
|
||||
<a href="{{url}}" target="{{target}}">{{page_name}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -256,7 +256,7 @@
|
|||
$("#alert-msg").text("There was an unknown error");
|
||||
$(".alert-danger").removeClass("hide").show();
|
||||
})
|
||||
startCheckingGalleryImportStatus();
|
||||
setTimeout("startCheckingGalleryImportStatus()",700);
|
||||
}
|
||||
|
||||
var startCheckinglinksImportStatus = function(){
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<label href="#none" class="btn btn-large <%= @subpart.kind == "none" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
||||
<label href="#none" class="btn btn-large <%= @subpart.nil? || @subpart.kind == "none" ? 'active' : '' rescue nil %>" data-toggle="tab">
|
||||
<%= t("page_part_kinds.none") %>
|
||||
<input type="radio" <%= @subpart.kind == "none" ? "checked" : "" rescue nil %> class="hide" value="none" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
|
||||
</label>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
<fieldset>
|
||||
<div class="input-area tab-content">
|
||||
<div id="none" class="parts-none tab-pane fade in <%= @subpart.kind == "none" ? 'active' : '' rescue nil %>"><%= t(:select_one_function) %></div>
|
||||
<div id="none" class="parts-none tab-pane fade in <%= @subpart.nil? || @subpart.kind == "none" ? 'active' : '' rescue nil %>"><%= t(:select_one_function) %></div>
|
||||
<div id="text" class="tab-pane fade in <%= @subpart.kind == "text" ? 'active' : '' rescue nil %>">
|
||||
<div class="nav-name">
|
||||
<strong><%= t(:language) %></strong>
|
||||
|
|
|
@ -10,18 +10,20 @@
|
|||
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_method]",options_for_select(@widget_methods, (@subpart.widget_method rescue nil))) %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @widget_settings['override_category_with'].nil? %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Category List :</label>
|
||||
<div class="controls">
|
||||
<% @categories.each do |category| %>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" <%= @subpart.categories.include?(category.id.to_s) ? "checked='checked'" : "" rescue nil %> value="<%= category.id.to_s %>" name="page_part[sub_parts_attributes][<%= @select_number %>][categories][]">
|
||||
<%= category.title %>
|
||||
</label>
|
||||
<% end %>
|
||||
<% if @widget_settings['override_category_with'].nil? %>
|
||||
<% if !@categories.blank? %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Category List :</label>
|
||||
<div class="controls">
|
||||
<% @categories.each do |category| %>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" <%= @subpart.categories.include?(category.id.to_s) ? "checked='checked'" : "" rescue nil %> value="<%= category.id.to_s %>" name="page_part[sub_parts_attributes][<%= @select_number %>][categories][]">
|
||||
<%= category.title %>
|
||||
</label>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @multiselect %>
|
||||
<div class="control-group">
|
||||
|
|
|
@ -6,4 +6,7 @@ gem 'links', git: 'git@gitlab.tp.rulingcom.com:saurabh/links.git'
|
|||
gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git'
|
||||
gem 'faq', git: 'git@gitlab.tp.rulingcom.com:saurabh/faq.git'
|
||||
#Personal Plugins
|
||||
gem 'personal_journal', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-journal.git'
|
||||
gem 'personal_journal', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-journal.git'
|
||||
|
||||
#widgets
|
||||
gem "site_menu_widget", git: 'git@gitlab.tp.rulingcom.com:saurabh/site-menu-widget.git'
|
|
@ -5,7 +5,9 @@ module OrbitApp
|
|||
if type[:type].eql?("ModuleApp")
|
||||
Module::Registration.new(name,&block)
|
||||
elsif type[:type] == "PersonalPlugin"
|
||||
Plugin::Registration.new(name,&block)
|
||||
Plugin::Registration.new(name,&block)
|
||||
elsif type[:type] == "OrbitWidget"
|
||||
Widget::Registration.new(name,&block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#This is a core class of Orbit Kernel. This class will register a module and set the properties defined in the module's initializer
|
||||
#file.
|
||||
module OrbitApp
|
||||
module Widget
|
||||
module Registration
|
||||
module ClassMethods
|
||||
|
||||
#initiate a blank array for registration
|
||||
cattr_accessor :registrations
|
||||
self.registrations = []
|
||||
|
||||
def new(name,&block)
|
||||
self.registrations << RegisteredWidget.new(name,&block)
|
||||
end
|
||||
|
||||
def find_by_key(key)
|
||||
self.registrations.each{|t|
|
||||
return t if t.key.eql?(key)
|
||||
}
|
||||
return nil
|
||||
end
|
||||
|
||||
def all
|
||||
return self.registrations
|
||||
end
|
||||
end
|
||||
|
||||
extend ClassMethods
|
||||
def self.included(other)
|
||||
other.extend( ClassMethods )
|
||||
end
|
||||
|
||||
class RegisteredWidget
|
||||
attr_reader :name,:key,:widget_label, :widget_methods, :widget_settings
|
||||
|
||||
def initialize(name,&block)
|
||||
@name = name
|
||||
@key = @name.underscore.singularize
|
||||
@widget_label = @name
|
||||
@widget_methods = []
|
||||
@widget_settings = {}
|
||||
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
setup_module_app
|
||||
end
|
||||
|
||||
def get_orbit_widget
|
||||
OrbitWidget.find_by(key: @key, title: name) rescue nil
|
||||
end
|
||||
|
||||
def setup_module_app
|
||||
orbit_widget = get_orbit_widget
|
||||
orbit_widget = OrbitWidget.new(:key=>@key,:title=>name) if orbit_widget.nil?
|
||||
# orbit_widget.refetch_setting!(self)
|
||||
orbit_widget.save(:validate=>false)
|
||||
end
|
||||
|
||||
%w{widget_label version organization author intro update_info}.each do |field|
|
||||
define_method(field){|var| instance_variable_set( "@" + field, var)}
|
||||
end
|
||||
|
||||
def widget_methods(widgets)
|
||||
@widget_methods = widgets
|
||||
end
|
||||
|
||||
def get_widget_methods
|
||||
@widget_methods
|
||||
end
|
||||
|
||||
def widget_settings(settings)
|
||||
@widget_settings = settings.first
|
||||
end
|
||||
|
||||
def get_widget_settings
|
||||
@widget_settings
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue