This commit is contained in:
Joshua Milton 2012-06-26 16:59:29 +08:00
parent 7f0267aedd
commit 8c7a0fdf0a
2 changed files with 288 additions and 288 deletions

View File

@ -1,193 +1,193 @@
Orbit::Application.routes.draw do Orbit::Application.routes.draw do
devise_for :users devise_for :users
# routes for sinatra app # routes for sinatra app
match '/site/set_registered', :to => CentralServerExchangeApp match '/site/set_registered', :to => CentralServerExchangeApp
match '/site/public_key', :to => CentralServerExchangeApp match '/site/public_key', :to => CentralServerExchangeApp
match '/site/update', :to => GithubApp match '/site/update', :to => GithubApp
match '/purchase/:type', :to => CentralServerExchangeApp match '/purchase/:type', :to => CentralServerExchangeApp
match 'load_orbit_bar' => 'pages#load_orbit_bar' match 'load_orbit_bar' => 'pages#load_orbit_bar'
# routes for admin # routes for admin
namespace :admin do namespace :admin do
resources :assets resources :assets
resources :app_auths resources :app_auths
resources :object_auths do resources :object_auths do
collection do collection do
match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init
end end
member do member do
match ':id/create_role',:action => 'create_role',:via => "post",:as => :create_role match ':id/create_role',:action => 'create_role',:via => "post",:as => :create_role
match 'remove/:type/:target_id' ,:action=> 'remove_role',:via => "delete",:as =>:remove match 'remove/:type/:target_id' ,:action=> 'remove_role',:via => "delete",:as =>:remove
end end
end end
resources :ad_banners do resources :ad_banners do
collection do collection do
match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
end end
resources :ad_images ,:except => [:show,:index] resources :ad_images ,:except => [:show,:index]
end end
resources :dashboards resources :dashboards
resources :designs do resources :designs do
collection do collection do
get 'upload_package' get 'upload_package'
post 'upload_package' post 'upload_package'
end end
member do member do
post 'edit_file' => 'designs#edit_file' post 'edit_file' => 'designs#edit_file'
end end
end end
resources :infos do resources :infos do
get 'add_attribute_field' get 'add_attribute_field'
end end
resources :items resources :items
resources :links do resources :links do
member do member do
get 'delete' get 'delete'
end end
end end
resources :pages do resources :pages do
member do member do
get 'delete' get 'delete'
get 'reload_themes' get 'reload_themes'
end end
end end
resources :module_apps do resources :module_apps do
resources :app_auths do resources :app_auths do
member do member do
match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove
end end
end end
member do member do
match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager
match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager
match 'remove_manager/:app_manager_id' ,:action=> 'remove_manager',:via => "delete",:as =>:remove_manager match 'remove_manager/:app_manager_id' ,:action=> 'remove_manager',:via => "delete",:as =>:remove_manager
match 'remove_sub_manager/:app_sub_manager_id' ,:action=> 'remove_sub_manager',:via => "delete",:as =>:remove_sub_manager match 'remove_sub_manager/:app_sub_manager_id' ,:action=> 'remove_sub_manager',:via => "delete",:as =>:remove_sub_manager
get 'reload_frontend_pages' get 'reload_frontend_pages'
end end
end end
resources :page_parts do resources :page_parts do
member do member do
get 'reload_widgets' get 'reload_widgets'
end end
end end
resources :purchases do resources :purchases do
collection do collection do
get 'install_app' get 'install_app'
end end
member do member do
get 'download' get 'download'
end end
end end
resources :roles do resources :roles do
get 'add_sub_role' get 'add_sub_role'
get 'add_attribute_field' get 'add_attribute_field'
end end
resources :sites resources :sites
resources :snippets resources :snippets
resources :tags resources :tags
resources :translations resources :translations
resources :users resources :users
end end
# end admin # end admin
namespace :panel do namespace :panel do
resources :users resources :users
end end
match '/desktop/'=>'desktop#index' match '/desktop/'=>'desktop#index'
# Sinatra Routes start # Sinatra Routes start
match '/desktop/desktop', :to => Desktopapp::DesktopApp # match '/desktop/desktop', :to => Desktopapp::DesktopApp
match '/desktop/app_manager', :to => Desktopapp::DesktopApp # match '/desktop/app_manager', :to => Desktopapp::DesktopApp
match '/desktop/sections', :to => Desktopapp::DesktopApp # match '/desktop/sections', :to => Desktopapp::DesktopApp
match '/desktop/settings', :to => Desktopapp::DesktopApp # match '/desktop/settings', :to => Desktopapp::DesktopApp
match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp # match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp
match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp # match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp
match '/desktop/getgroups/', :to => Desktopapp::DesktopApp # match '/desktop/getgroups/', :to => Desktopapp::DesktopApp
match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp # match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp
match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp # match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp
match '/desktop/settingsections/', :to => Desktopapp::DesktopApp # match '/desktop/settingsections/', :to => Desktopapp::DesktopApp
match '/desktop/getapplist/', :to => Desktopapp::DesktopApp # match '/desktop/getapplist/', :to => Desktopapp::DesktopApp
match '/desktop/newpositions/', :to => Desktopapp::DesktopApp # match '/desktop/newpositions/', :to => Desktopapp::DesktopApp
match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp # match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp
match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications # match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications
match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications # match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications
match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications # match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications
match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications # match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications
# match '/desktop/twitter/', :to => Desktopapp::Otheraccounts # match '/desktop/twitter/', :to => Desktopapp::Otheraccounts
# match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts # match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts
# match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts # match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts
# match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts # match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts
match '/desktop_appstore/appstore', :to => Desktopapp::DesktopAppAppstore # match '/desktop_appstore/appstore', :to => Desktopapp::DesktopAppAppstore
match '/desktop_appstore/widgets', :to => Desktopapp::DesktopAppAppstore # match '/desktop_appstore/widgets', :to => Desktopapp::DesktopAppAppstore
match '/desktop_appstore/getuserwidgets', :to => Desktopapp::DesktopAppAppstore # match '/desktop_appstore/getuserwidgets', :to => Desktopapp::DesktopAppAppstore
match '/desktop_appstore/widgets_settings', :to => Desktopapp::DesktopAppAppstore # match '/desktop_appstore/widgets_settings', :to => Desktopapp::DesktopAppAppstore
# Sinatra Routes end # Sinatra Routes end
# match '/desktop/desktop'=>'desktop#desktop' match '/desktop/desktop'=>'desktop#desktop'
# match '/desktop/app_manager'=>'desktop#app_manager' match '/desktop/app_manager'=>'desktop#app_manager'
# match '/desktop/sections'=>'desktop#sections' match '/desktop/sections'=>'desktop#sections'
# match '/desktop/settings'=>'desktop#settings' match '/desktop/settings'=>'desktop#settings'
# match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings' match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings'
# match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings' match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings'
# match '/desktop/getgroups/'=>'desktop#getgroups' match '/desktop/getgroups/'=>'desktop#getgroups'
# match '/desktop/getsectionlist/'=>'desktop#getsectionlist' match '/desktop/getsectionlist/'=>'desktop#getsectionlist'
# match '/desktop/settingthemes/'=>'desktop#settingthemes' match '/desktop/settingthemes/'=>'desktop#settingthemes'
# match '/desktop/settingsections/'=>'desktop#settingsections' match '/desktop/settingsections/'=>'desktop#settingsections'
# match '/desktop/getapplist/'=>'desktop#getapplist' match '/desktop/getapplist/'=>'desktop#getapplist'
# match '/desktop/newpositions/'=>'desktop#newpositions' match '/desktop/newpositions/'=>'desktop#newpositions'
# match '/desktop/settingconnection/'=>'desktop#settingconnection' match '/desktop/settingconnection/'=>'desktop#settingconnection'
# match '/desktop/journal_p/'=>'desktop_publications#journal_p' match '/desktop/journal_p/'=>'desktop_publications#journal_p'
# match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list' match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list'
# match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add' match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add'
# match '/desktop_publications/getjournals' => 'desktop_publications#getjournals' match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
match '/desktop/twitter/'=>'otheraccounts#twitter' match '/desktop/twitter/'=>'otheraccounts#twitter'
match '/desktop/forgmail/'=>'otheraccounts#gmail' match '/desktop/forgmail/'=>'otheraccounts#gmail'
match '/desktop/getaccounts'=>'otheraccounts#getaccounts' match '/desktop/getaccounts'=>'otheraccounts#getaccounts'
match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo' match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo'
# match '/desktop_appstore/appstore'=>'desktop_appstore#appstore' match '/desktop_appstore/appstore'=>'desktop_appstore#appstore'
# match '/desktop_appstore/widgets'=>'desktop_appstore#widgets' match '/desktop_appstore/widgets'=>'desktop_appstore#widgets'
# match '/desktop_appstore/getuserwidgets'=>'desktop_appstore#getuserwidgets' match '/desktop_appstore/getuserwidgets'=>'desktop_appstore#getuserwidgets'
# match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings' match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings'
match '/desktop/temp_func/'=>'desktop#temp_func' match '/desktop/temp_func/'=>'desktop#temp_func'
match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request| match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true") !request.query_string.include?("inner=true")
} }
match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request| match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true") !request.query_string.include?("inner=true")
} }
# routes for gridfs files # routes for gridfs files
match "/gridfs/*path" => "gridfs#serve" match "/gridfs/*path" => "gridfs#serve"
# match "/images/*path" => "gridfs#serve_images" # match "/images/*path" => "gridfs#serve_images"
# match "/admin/pages/images/*path" => "gridfs#serve_images" # match "/admin/pages/images/*path" => "gridfs#serve_images"
# routes for pages to generate # routes for pages to generate
match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request| match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request|
!request.path.starts_with?("/panel") !request.path.starts_with?("/panel")
} }
root :to => 'pages#index' root :to => 'pages#index'
end end

View File

@ -1,96 +1,96 @@
class Desktopapp::DesktopAppAppstore < Sinatra::Base class Desktopapp::DesktopAppAppstore < Sinatra::Base
register Sinatra::Warden
get '/desktop_appstore/appstore' do get '/desktop_appstore/appstore' do
erb :appstore erb :appstore
end end
get '/desktop_appstore/widgets' do get '/desktop_appstore/widgets' do
erb :'appstore/widgets' erb :'appstore/widgets'
end end
get '/desktop_appstore/getuserwidgets' do get '/desktop_appstore/getuserwidgets' do
# @widgets = current_user.desktop.desktop_widgets # @widgets = current_user.desktop.desktop_widgets
# @groups = Array.new # @groups = Array.new
# @sections = current_user.desktop.sections # @sections = current_user.desktop.sections
# @sections.each do |section| # @sections.each do |section|
# @groups << section.groups # @groups << section.groups
# end # end
# @widgets.each do |widget| # @widgets.each do |widget|
# @count = 0; # @count = 0;
# @sectionids = Array.new # @sectionids = Array.new
# @groups.each do |group| # @groups.each do |group|
# group.each do |grp| # group.each do |grp|
# @widge = 0 # @widge = 0
# @gid = widget.id.to_s # @gid = widget.id.to_s
# @widge = grp.tiles.where(:data_content.all => [@gid]).count # @widge = grp.tiles.where(:data_content.all => [@gid]).count
# @count = @count + @widge # @count = @count + @widge
# if @widge > 0 # if @widge > 0
# @sectionids << grp.section_id # @sectionids << grp.section_id
# end # end
# end # end
# end # end
# if @count > 0 # if @count > 0
# widget.status = "Installed" # widget.status = "Installed"
# widget.section = @sectionids # widget.section = @sectionids
# else # else
# widget.status = "Downloaded" # widget.status = "Downloaded"
# end # end
# end # end
# @widgets.to_json # @widgets.to_json
current_user.to_json current_user.to_json
end end
get '/desktop_appstore/widgets_settings' do get '/desktop_appstore/widgets_settings' do
what = params["what"] what = params["what"]
@widgetid = params["widget"] @widgetid = params["widget"]
@sectionid = params["section"] @sectionid = params["section"]
@msg = Array.new @msg = Array.new
case what case what
when "remove" when "remove"
@section = Section.find(@sectionid) @section = Section.find(@sectionid)
@groups = @section.groups @groups = @section.groups
@groups.each do |group| @groups.each do |group|
@tile = group.tiles.where(:data_content.all => [@widgetid]) @tile = group.tiles.where(:data_content.all => [@widgetid])
if @tile.count > 0 if @tile.count > 0
@thistile = @tile @thistile = @tile
end end
end end
@t = Tile.find(@thistile.first.id) @t = Tile.find(@thistile.first.id)
@t.delete @t.delete
@msg << {"success"=>true} @msg << {"success"=>true}
when "add" when "add"
@widget = current_user.desktop.desktop_widgets.find(@widgetid) @widget = current_user.desktop.desktop_widgets.find(@widgetid)
@section = Section.find(@sectionid) @section = Section.find(@sectionid)
@groups = @section.groups @groups = @section.groups
@totalwidgets = 0 @totalwidgets = 0
@groups.each do |group| @groups.each do |group|
@tile = group.tiles.where(:data_content.all => [@widgetid]).count @tile = group.tiles.where(:data_content.all => [@widgetid]).count
if @tile > 0 if @tile > 0
@msg << {"success"=>false,"error"=>"Duplicate widget"} @msg << {"success"=>false,"error"=>"Duplicate widget"}
else else
no_of_widgets = group.tiles.where(:data_category.all => ["widget"]).count no_of_widgets = group.tiles.where(:data_category.all => ["widget"]).count
@totalwidgets = @totalwidgets + no_of_widgets @totalwidgets = @totalwidgets + no_of_widgets
end end
end end
if @totalwidgets >= 12 if @totalwidgets >= 12
@msg << {"success"=>false,"error"=>"Section full"} @msg << {"success"=>false,"error"=>"Section full"}
else else
wshape = @widget.shape wshape = @widget.shape
wdata_content = @widgetid wdata_content = @widgetid
wdata_category = "widget" wdata_category = "widget"
wname = @widget.name wname = @widget.name
if @groups.first.tiles.where(:data_category.all => ["widget"]).count >= 6 if @groups.first.tiles.where(:data_category.all => ["widget"]).count >= 6
groupid = @groups.last.id groupid = @groups.last.id
else else
groupid = @groups.first.id groupid = @groups.first.id
end end
Tile.create(data_category: wdata_category,data_content: wdata_content, group_id: groupid, position: 10, title: wname, shape: wshape) Tile.create(data_category: wdata_category,data_content: wdata_content, group_id: groupid, position: 10, title: wname, shape: wshape)
@msg << {"success"=>true} @msg << {"success"=>true}
end end
end end
@msg.to_json @msg.to_json
end end
end end