diff --git a/Gemfile b/Gemfile index 11a9dc2e..d59de3e8 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'sprockets' gem 'tinymce-rails' gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem 'mongoid-encryptor', :require => 'mongoid/encryptor' +# gem 'twitter' # Gems used only for assets and not required # in production environments by default. diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 48bf2ef1..9ae7d8b8 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -26,7 +26,7 @@ var orbitDesktop = function(dom){ this.transitionTime = 500; this.currenthtml = "desktop.html"; this.currentface = "home"; - this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":""}; + this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":"","appstore":""}; this.tp = ""; this.sectionList; this.initialize = function(){ @@ -55,7 +55,7 @@ var orbitDesktop = function(dom){ $(document).ready(function(){o.loadWallpaper(customwallpaper);o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();}); }) } - }; + } this.changeTheme = function(theme){ // this function is used for changing theme o.theme = theme; $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ @@ -112,6 +112,15 @@ var orbitDesktop = function(dom){ }); } }); + $("a#d_appstore").click(function(){ + var target = $(this).attr("href"); + if(o.currenthtml!=target){ + o.desktopData[o.currentface] = $(o.contentHolder).html(); + $("#content").hide("drop",o.transitionTime,function(){ + o.initializeAppstore(target); + }); + } + }); $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); @@ -314,9 +323,7 @@ var orbitDesktop = function(dom){ }; this.tempFunc = function(th){ - o.confirm("What","","",function(reply){ - alert(reply); - }) + $.post("desktop/twitter",function(){}); }; this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization @@ -1020,7 +1027,7 @@ var orbitDesktop = function(dom){ bindSecondaryHandlers(); } - $("div#settings div#panel_r").load("/desktop/journal_p_list",function(){ + $("div#journal_p div#panel_r").load("/desktop/journal_p_list",function(){ $.getJSON("/desktop_publications/getjournals",function(journals){ journalData = eval(journals); journalview(); @@ -1048,7 +1055,7 @@ var orbitDesktop = function(dom){ .delay(1500) .addClass('op00', 500); } - $("div#settings div#panel_r").load("/desktop/journal_p_add",function(){ + $("div#journal_p div#panel_r").load("/desktop/journal_p_add",function(){ bindHandlers(); }) } @@ -1064,6 +1071,161 @@ var orbitDesktop = function(dom){ list(); } }; + this.initializeAppstore = function(target){ + o.currenthtml = target; + o.currentface = "appstore"; + var bindHandlers = function(){ + $('.s_menu a').on({ + click: function(){ + if(!$(this).hasClass('active')){ + var tfunc = $(this).attr('href'); + switch(tfunc){ + case 'widgets': + widgets(); + break; + } + $('.s_menu a').removeClass('thmc1 thmtxt active'); + $(this).addClass('thmc1 thmtxt active'); + } + }, + mouseenter: function(){ + if(!$(this).hasClass('active')){ + $(this).switchClass('admtxt','thmc1 thmtxt',0); + } + }, + mouseleave: function(){ + var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; + $(this).switchClass(t,'admtxt',0); + } + }); + } + var widgets = function(){ + var bindHandlers = function(){ + $("#widget_list a").click(function(){ + var sectionid = $(this).attr("for"); + var widgetid = $(this).parent().parent().attr("for"); + switch($(this).attr("href")){ + case "addthis": + $this = $(this); + o.confirm({ + message: "Are you sure you want to add this widget?", + buttons: ['Yes','No'], + highlighted: 1 + },function(reply){ + if(reply){ + $.post("desktop_appstore/widgets_settings",{section:sectionid, widget:widgetid, what:"add"},function(result){ + if(result[0].success){ + $this.attr("href","removethis"); + $targetDom = $this.parent().parent().find("div.status"); + $parentDom = $this.parent(); + if($targetDom.find("a").length == 0) + $targetDom.html("Status : Installed on"); + $targetDom.append(" ").append($this); + if($parentDom.find("a").length == 0) + $parentDom.empty(); + o.desktopData["home"]=""; + o.notify("Widget added.","success",2); + }else{ + o.notify(result[0].error,"imp",2); + } + }) + } + }) + break; + case "removethis": + $this = $(this); + o.confirm({ + message: "Are you sure you want to remove this widget?", + buttons: ['Yes','No'], + highlighted: 2 + },function(reply){ + if(reply){ + $.post("desktop_appstore/widgets_settings",{section:sectionid, widget:widgetid, what:"remove"},function(result){ + if(result[0].success){ + $this.attr("href","addthis"); + $targetDom = $this.parent().parent().find("div.not_status"); + $parentDom = $this.parent(); + if($targetDom.html()=="") + $targetDom.html("Install on"); + $targetDom.append(" ").append($this); + if($parentDom.find("a").length == 0) + $parentDom.html("Status : Downloaded"); + o.desktopData["home"]=""; + o.notify("Widget removed.","success",2); + } + }) + } + }) + break; + } + return false; + }) + } + $("div#apps_store div#panel_r").load("/desktop_appstore/widgets",function(){ + $.getJSON("/desktop_appstore/getuserwidgets",function(userwidgets){ + var column = $('
'), + counter = 1, + li; + $.each(userwidgets,function(i,widge){ + if(!widge.status)widge.status = "Downloaded"; + var brick = widge.shape.split(' '), + bw = parseInt(brick[0].substr(1)), + bh = parseInt(brick[1].substr(1)), + shp = bw+" X "+bh; + li = $('
  • '+widge.name+'
    Author : '+widge.author+'
    Shape : '+shp+'
    Status : '+widge.status+'
  • '); + var cur_section_names = new Array(); + var section_names = new Array(); + var section_links = new Array(); + if(widge.section){ + var s_name_list = ""; + $.each(widge.section,function(x,sec){ + $.each(o.sectionList,function(j,s){ + if(s._id==sec){ + cur_section_names.push(s.name); + s_name_list+= ""+s.name +" "; + } + }) + }) + var section_names = o.getArrayfromJson(o.sectionList,"name"); + var section_links = o.getArrayfromJson(o.sectionList,"_id"); + var s_name_list_not = ""; + $.each(section_names,function(j,sec_name){ + if($.inArray(sec_name,cur_section_names)==-1){ + var sec_link = section_links[j]; + s_name_list_not+= ""+sec_name+" "; + } + }) + li.find("div.status").html("Status : Installed on "+s_name_list); + if(s_name_list_not) + li.find("div.not_status").html("Install on "+s_name_list_not); + }else{ + li.find("div.not_status").html("Install on "+o.sectionList[0].name+", "+o.sectionList[1].name+", "+o.sectionList[2].name+", "+o.sectionList[3].name); + } + //console.log(section_names); + column.find("ul").append(li); + if(counter%4==0){ + $("#apps_store div#widget_list").append(column); + column = $('
    '); + } + counter++; + }) + $("#apps_store div#widget_list").append(column); + bindHandlers(); + }) + }) + } + + if(!o.desktopData[o.currentface]){ + $(o.contentHolder).empty().load("/desktop_appstore/"+target,function(){ + widgets(); + bindHandlers(); + }); + }else{ + $(o.contentHolder).html(o.desktopData[o.currentface]); + widgets(); + bindHandlers(); + } + } this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper var ww = $(window).width(); diff --git a/app/assets/javascripts/orbitdesktopAPI.js b/app/assets/javascripts/orbitdesktopAPI.js index 51eed919..de093973 100644 --- a/app/assets/javascripts/orbitdesktopAPI.js +++ b/app/assets/javascripts/orbitdesktopAPI.js @@ -79,6 +79,13 @@ var orbitDesktopAPI = function(){ }); $confirm.stop(1,1).fadeIn(); }; + this.getArrayfromJson = function(tjson,key){ + var tempArray = new Array; + $.each(tjson,function(i,val){ + tempArray.push(val[key]); + }) + return tempArray; + } }; orbitDesktopAPI.prototype.notifyImgPath = "temp"; orbitDesktopAPI.prototype.wallpaperPath = "temp"; diff --git a/app/controllers/desktop_appstore_controller.rb b/app/controllers/desktop_appstore_controller.rb new file mode 100644 index 00000000..d05160c2 --- /dev/null +++ b/app/controllers/desktop_appstore_controller.rb @@ -0,0 +1,97 @@ +class DesktopAppstoreController< ApplicationController + + def appstore + render "desktop/appstore", :layout => false + end + + def widgets + render "desktop/appstore/widgets", :layout => false + end + + def getuserwidgets + @widgets = current_user.desktop.desktop_widgets + @groups = Array.new + @sections = current_user.desktop.sections + + @sections.each do |section| + @groups << section.groups + end + + @widgets.each do |widget| + @count = 0; + @sectionids = Array.new + @groups.each do |group| + group.each do |grp| + @widge = 0 + @gid = widget.id.to_s + @widge = grp.tiles.where(:data_content.all => [@gid]).count + @count = @count + @widge + if @widge > 0 + @sectionids << grp.section_id + end + end + end + if @count > 0 + widget.status = "Installed" + widget.section = @sectionids + else + widget.status = "Downloaded" + end + end + render :json=>@widgets.to_json + end + + def widgets_settings + what = params["what"] + @widgetid = params["widget"] + @sectionid = params["section"] + @msg = Array.new + case what + when "remove" + @section = Section.find(@sectionid) + @groups = @section.groups + @groups.each do |group| + @tile = group.tiles.where(:data_content.all => [@widgetid]) + if @tile.count > 0 + @thistile = @tile + end + end + @t = Tile.find(@thistile.first.id) + @t.delete + @msg << {"success"=>true} + when "add" + @widget = current_user.desktop.desktop_widgets.find(@widgetid) + @section = Section.find(@sectionid) + @groups = @section.groups + @totalwidgets = 0 + @groups.each do |group| + @tile = group.tiles.where(:data_content.all => [@widgetid]).count + if @tile > 0 + @msg << {"success"=>false,"error"=>"Duplicate widget"} + else + no_of_widgets = group.tiles.where(:data_category.all => ["widget"]).count + @totalwidgets = @totalwidgets + no_of_widgets + end + end + if @totalwidgets >= 12 + @msg << {"success"=>false,"error"=>"Section full"} + else + wshape = @widget.shape + wdata_content = @widgetid + wdata_category = "widget" + wname = @widget.name + if @groups.first.tiles.where(:data_category.all => ["widget"]).count >= 6 + groupid = @groups.last.id + else + groupid = @groups.first.id + end + Tile.create(data_category: wdata_category,data_content: wdata_content, group_id: groupid, position: 10, title: wname, shape: wshape) + @msg << {"success"=>true} + end + end + + render :json=>@msg.to_json + end + +end + diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index ed93c48c..0679daed 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -1,7 +1,7 @@ class DesktopPublicationsController< ApplicationController - def journal_p - render "desktop/journal_p", :layout => false - end + def journal_p + render "desktop/journal_p", :layout => false + end def journal_p_list render "desktop/journal_pages/list", :layout => false diff --git a/app/controllers/otheraccounts_controller.rb b/app/controllers/otheraccounts_controller.rb index 0abc14a2..ea6cff24 100644 --- a/app/controllers/otheraccounts_controller.rb +++ b/app/controllers/otheraccounts_controller.rb @@ -3,6 +3,7 @@ class OtheraccountsController< ApplicationController require 'rexml/document' require 'net/http' require 'net/https' + # require 'twitter' include REXML def saveaccountinfo @@ -50,6 +51,12 @@ class OtheraccountsController< ApplicationController end def twitter + # token = "Yh9qYe0lhWk27TZJamnhrA" + # secret = "iBgxJ5BrxfGFLkp7aB6pyCSzd0zcJiYDqJGFBK6Wdo" + # oauth = Twitter::OAuth.new(token,secret) + + # oauth_token = oauth.request_token.token + # oauth_secret = oauth.request_token.secret end diff --git a/app/models/desktop.rb b/app/models/desktop.rb index e2918adc..e8c1e9c4 100644 --- a/app/models/desktop.rb +++ b/app/models/desktop.rb @@ -9,6 +9,7 @@ class Desktop belongs_to :user has_many :sections, :autosave => true, :dependent => :destroy + has_many :desktop_widgets, :autosave => true, :dependent => :destroy before_create :initialize_section diff --git a/app/models/desktop_widget.rb b/app/models/desktop_widget.rb new file mode 100644 index 00000000..eb0446de --- /dev/null +++ b/app/models/desktop_widget.rb @@ -0,0 +1,13 @@ +class DesktopWidget + include Mongoid::Document + include Mongoid::Timestamps + + field :name + field :author + field :shape + field :desktop_id + field :status + field :section + + belongs_to :desktop +end \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index d09e563e..c33d64fc 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -19,6 +19,7 @@ class User has_one :desktop, :autosave => true, :dependent => :destroy has_many :other_accounts, :autosave => true, :dependent => :destroy has_many :journals, :autosave => true, :dependent => :destroy + belongs_to :role has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true diff --git a/app/views/desktop/appstore.html.erb b/app/views/desktop/appstore.html.erb new file mode 100644 index 00000000..c92ac427 --- /dev/null +++ b/app/views/desktop/appstore.html.erb @@ -0,0 +1,26 @@ +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/desktop/appstore/widgets.html.erb b/app/views/desktop/appstore/widgets.html.erb new file mode 100644 index 00000000..4fd150c4 --- /dev/null +++ b/app/views/desktop/appstore/widgets.html.erb @@ -0,0 +1,11 @@ +
    Your Widgets
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb index d3faa4c7..6dddb734 100644 --- a/app/views/desktop/journal_p.html.erb +++ b/app/views/desktop/journal_p.html.erb @@ -1,10 +1,13 @@
    -
    diff --git a/app/views/desktop/settings/connections.html.erb b/app/views/desktop/settings/connections.html.erb index 52de6f24..148762da 100644 --- a/app/views/desktop/settings/connections.html.erb +++ b/app/views/desktop/settings/connections.html.erb @@ -39,5 +39,6 @@
    +
    diff --git a/config/routes.rb b/config/routes.rb index 99bf251d..10a73b21 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,15 +116,22 @@ Orbit::Application.routes.draw do match '/desktop/newpositions/'=>'desktop#newpositions' match '/desktop/settingconnection/'=>'desktop#settingconnection' + match '/desktop/journal_p/'=>'desktop_publications#journal_p' match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list' match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add' match '/desktop_publications/getjournals' => 'desktop_publications#getjournals' - + match '/desktop/twitter/'=>'otheraccounts#twitter' match '/desktop/forgmail/'=>'otheraccounts#gmail' match '/desktop/getaccounts'=>'otheraccounts#getaccounts' match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo' + + match '/desktop_appstore/appstore'=>'desktop_appstore#appstore' + match '/desktop_appstore/widgets'=>'desktop_appstore#widgets' + match '/desktop_appstore/getuserwidgets'=>'desktop_appstore#getuserwidgets' + match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings' + match '/desktop/temp_func/'=>'desktop#temp_func' diff --git a/public/desktop_widgets/clock/clock.js b/public/desktop_widgets/4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js similarity index 100% rename from public/desktop_widgets/clock/clock.js rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js diff --git a/public/desktop_widgets/clock/img/bg_blue.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png similarity index 100% rename from public/desktop_widgets/clock/img/bg_blue.png rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png diff --git a/public/desktop_widgets/clock/img/bg_green.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png similarity index 100% rename from public/desktop_widgets/clock/img/bg_green.png rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png diff --git a/public/desktop_widgets/clock/img/bg_orange.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png similarity index 100% rename from public/desktop_widgets/clock/img/bg_orange.png rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png diff --git a/public/desktop_widgets/clock/index.html.erb b/public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb similarity index 61% rename from public/desktop_widgets/clock/index.html.erb rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb index bdf81c65..2a69e24c 100755 --- a/public/desktop_widgets/clock/index.html.erb +++ b/public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb @@ -51,16 +51,16 @@ .clock .bg.left{ left:0px; } /* Individual styles for each color: */ -.orange .bg.left{ background:url(desktop_widgets/clock/img/bg_orange.png) no-repeat left top; } -.green .bg.left{ background:url(desktop_widgets/clock/img/bg_green.png) no-repeat left top; } -.blue .bg.left{ background:url(desktop_widgets/clock/img/bg_blue.png) no-repeat left top; } +.orange .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png) no-repeat left top; } +.green .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png) no-repeat left top; } +.blue .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png) no-repeat left top; } /* The right part of the background: */ .clock .bg.right{ left:37.5px; } -.orange .bg.right{ background:url(desktop_widgets/clock/img/bg_orange.png) no-repeat right top; } -.green .bg.right{ background:url(desktop_widgets/clock/img/bg_green.png) no-repeat right top; } -.blue .bg.right{ background:url(desktop_widgets/clock/img/bg_blue.png) no-repeat right top; } +.orange .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png) no-repeat right top; } +.green .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png) no-repeat right top; } +.blue .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png) no-repeat right top; } .clock .front.left{ diff --git a/public/desktop_widgets/clock/temp/bg_blue.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png similarity index 100% rename from public/desktop_widgets/clock/temp/bg_blue.png rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png diff --git a/public/desktop_widgets/clock/temp/bg_green.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png similarity index 100% rename from public/desktop_widgets/clock/temp/bg_green.png rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png diff --git a/public/desktop_widgets/clock/temp/bg_orange.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png similarity index 100% rename from public/desktop_widgets/clock/temp/bg_orange.png rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png diff --git a/public/desktop_widgets/clock/temp/clock.css b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css similarity index 100% rename from public/desktop_widgets/clock/temp/clock.css rename to public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css diff --git a/public/desktop_widgets/gmail/gmail.js b/public/desktop_widgets/4fa7812ec88514014d7c59bd/4fa7812ec88514014d7c59bd.js similarity index 100% rename from public/desktop_widgets/gmail/gmail.js rename to public/desktop_widgets/4fa7812ec88514014d7c59bd/4fa7812ec88514014d7c59bd.js diff --git a/public/desktop_widgets/gmail/date.js b/public/desktop_widgets/4fa7812ec88514014d7c59bd/date.js similarity index 100% rename from public/desktop_widgets/gmail/date.js rename to public/desktop_widgets/4fa7812ec88514014d7c59bd/date.js diff --git a/public/desktop_widgets/gmail/index.html.erb b/public/desktop_widgets/4fa7812ec88514014d7c59bd/index.html.erb similarity index 100% rename from public/desktop_widgets/gmail/index.html.erb rename to public/desktop_widgets/4fa7812ec88514014d7c59bd/index.html.erb diff --git a/public/desktop_widgets/googlesearch/googlesearch.js b/public/desktop_widgets/4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js similarity index 100% rename from public/desktop_widgets/googlesearch/googlesearch.js rename to public/desktop_widgets/4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js diff --git a/public/desktop_widgets/googlesearch/img/google_64.png b/public/desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png similarity index 100% rename from public/desktop_widgets/googlesearch/img/google_64.png rename to public/desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png diff --git a/public/desktop_widgets/googlesearch/index.html.erb b/public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb similarity index 85% rename from public/desktop_widgets/googlesearch/index.html.erb rename to public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb index 8aaf8210..341b8d81 100644 --- a/public/desktop_widgets/googlesearch/index.html.erb +++ b/public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb @@ -22,7 +22,7 @@ input {