From 2083e0bf4fdcb0c81347de8651e394fbdeb80cf3 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 7 May 2012 19:00:50 +0800 Subject: [PATCH] =?UTF-8?q?widget=20structure=20improvised=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 10 - app/assets/javascripts/orbitdesktop.js | 18 +- .../desktop_appstore_controller.rb | 5 + app/models/desktop_widget.rb | 11 ++ app/models/user/user.rb | 1 + app/views/desktop/appstore/widgets.html.erb | 12 +- config/routes.rb | 1 + .../4fa7810ac88514014d7c59bc.js} | 0 .../img/bg_blue.png | Bin .../img/bg_green.png | Bin .../img/bg_orange.png | Bin .../index.html.erb | 12 +- .../temp/bg_blue.png | Bin .../temp/bg_green.png | Bin .../temp/bg_orange.png | Bin .../temp/clock.css | 0 .../4fa7812ec88514014d7c59bd.js} | 0 .../date.js | 0 .../index.html.erb | 0 .../4fa78140c88514014d7c59be.js} | 0 .../img/google_64.png | Bin .../index.html.erb | 2 +- .../4fa78153c88514014d7c59bf.js} | 2 +- .../events.json | 0 .../index.html.erb | 0 .../4fa78161c88514014d7c59c0.js} | 0 .../index.html.erb | 0 .../4fa78170c88514014d7c59c1.js} | 0 .../index.html | 0 .../index.html.erb | 0 .../4fa7817cc88514014d7c59c2.js} | 0 .../img/sunny.png | Bin .../index.html.erb | 2 +- .../4fa7818cc88514014d7c59c3.js} | 0 .../index.html.erb | 0 .../4fa78197c88514014d7c59c4.js} | 0 .../index.html.erb | 0 public/desktop_widgets/clock1/clock1.js | 171 ------------------ public/desktop_widgets/clock1/img/bg_blue.png | Bin 9624 -> 0 bytes .../desktop_widgets/clock1/img/bg_green.png | Bin 6820 -> 0 bytes .../desktop_widgets/clock1/img/bg_orange.png | Bin 9761 -> 0 bytes public/desktop_widgets/clock1/index.html.erb | 76 -------- .../desktop_widgets/clock1/temp/bg_blue.png | Bin 16038 -> 0 bytes .../desktop_widgets/clock1/temp/bg_green.png | Bin 15812 -> 0 bytes .../desktop_widgets/clock1/temp/bg_orange.png | Bin 16256 -> 0 bytes public/desktop_widgets/clock1/temp/clock.css | 69 ------- 46 files changed, 54 insertions(+), 338 deletions(-) create mode 100644 app/models/desktop_widget.rb rename public/desktop_widgets/{clock/clock.js => 4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js} (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/img/bg_blue.png (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/img/bg_green.png (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/img/bg_orange.png (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/index.html.erb (61%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/temp/bg_blue.png (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/temp/bg_green.png (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/temp/bg_orange.png (100%) rename public/desktop_widgets/{clock => 4fa7810ac88514014d7c59bc}/temp/clock.css (100%) rename public/desktop_widgets/{gmail/gmail.js => 4fa7812ec88514014d7c59bd/4fa7812ec88514014d7c59bd.js} (100%) rename public/desktop_widgets/{gmail => 4fa7812ec88514014d7c59bd}/date.js (100%) rename public/desktop_widgets/{gmail => 4fa7812ec88514014d7c59bd}/index.html.erb (100%) rename public/desktop_widgets/{googlesearch/googlesearch.js => 4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js} (100%) rename public/desktop_widgets/{googlesearch => 4fa78140c88514014d7c59be}/img/google_64.png (100%) rename public/desktop_widgets/{googlesearch => 4fa78140c88514014d7c59be}/index.html.erb (85%) rename public/desktop_widgets/{school_events/school_events.js => 4fa78153c88514014d7c59bf/4fa78153c88514014d7c59bf.js} (84%) rename public/desktop_widgets/{school_events => 4fa78153c88514014d7c59bf}/events.json (100%) rename public/desktop_widgets/{school_events => 4fa78153c88514014d7c59bf}/index.html.erb (100%) rename public/desktop_widgets/{timetable/timetable.js => 4fa78161c88514014d7c59c0/4fa78161c88514014d7c59c0.js} (100%) rename public/desktop_widgets/{timetable => 4fa78161c88514014d7c59c0}/index.html.erb (100%) rename public/desktop_widgets/{twitter/twitter.js => 4fa78170c88514014d7c59c1/4fa78170c88514014d7c59c1.js} (100%) rename public/desktop_widgets/{twitter => 4fa78170c88514014d7c59c1}/index.html (100%) rename public/desktop_widgets/{twitter => 4fa78170c88514014d7c59c1}/index.html.erb (100%) rename public/desktop_widgets/{weather/weather.js => 4fa7817cc88514014d7c59c2/4fa7817cc88514014d7c59c2.js} (100%) rename public/desktop_widgets/{weather => 4fa7817cc88514014d7c59c2}/img/sunny.png (100%) rename public/desktop_widgets/{weather => 4fa7817cc88514014d7c59c2}/index.html.erb (91%) rename public/desktop_widgets/{weather1/weather1.js => 4fa7818cc88514014d7c59c3/4fa7818cc88514014d7c59c3.js} (100%) rename public/desktop_widgets/{weather1 => 4fa7818cc88514014d7c59c3}/index.html.erb (100%) rename public/desktop_widgets/{youtube/youtube.js => 4fa78197c88514014d7c59c4/4fa78197c88514014d7c59c4.js} (100%) rename public/desktop_widgets/{youtube => 4fa78197c88514014d7c59c4}/index.html.erb (100%) delete mode 100755 public/desktop_widgets/clock1/clock1.js delete mode 100644 public/desktop_widgets/clock1/img/bg_blue.png delete mode 100644 public/desktop_widgets/clock1/img/bg_green.png delete mode 100644 public/desktop_widgets/clock1/img/bg_orange.png delete mode 100755 public/desktop_widgets/clock1/index.html.erb delete mode 100755 public/desktop_widgets/clock1/temp/bg_blue.png delete mode 100755 public/desktop_widgets/clock1/temp/bg_green.png delete mode 100755 public/desktop_widgets/clock1/temp/bg_orange.png delete mode 100755 public/desktop_widgets/clock1/temp/clock.css diff --git a/Gemfile.lock b/Gemfile.lock index c81c0574..339bae0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,8 +88,6 @@ GEM factory_girl_rails (1.7.0) factory_girl (~> 2.6.0) railties (>= 3.0.0) - faraday (0.8.0) - multipart-post (~> 1.1) fastercsv (1.5.4) haml (3.1.4) hike (1.2.1) @@ -123,7 +121,6 @@ GEM encrypted_strings (~> 0.3.3) mongoid (~> 2) multi_json (1.1.0) - multipart-post (1.1.5) nokogiri (1.5.2) nokogiri (1.5.2-x86-mingw32) orm_adapter (0.0.6) @@ -201,7 +198,6 @@ GEM tilt (~> 1.3.2) sexp_processor (3.1.0) shoulda-matchers (1.0.0) - simple_oauth (0.1.7) simplecov (0.6.1) multi_json (~> 1.0) simplecov-html (~> 0.5.3) @@ -227,11 +223,6 @@ GEM treetop (1.4.10) polyglot polyglot (>= 0.3.1) - twitter (2.2.0) - activesupport (>= 2.3.9, < 4) - faraday (~> 0.7) - multi_json (~> 1.0) - simple_oauth (~> 0.1) tzinfo (0.3.32) uglifier (1.2.3) execjs (>= 0.3.0) @@ -285,6 +276,5 @@ DEPENDENCIES spork sprockets tinymce-rails - twitter uglifier watchr diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index ecb39f0a..fa20b1cc 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -1101,7 +1101,22 @@ var orbitDesktop = function(dom){ } $("div#apps_store div#panel_r").load("/desktop_appstore/widgets",function(){ - bindHandlers(); + $.getJSON("/desktop_appstore/getuserwidgets",function(userwidgets){ + var column = $('
'), + counter = 1, + li; + $.each(userwidgets,function(i,widge){ + li = $('
  • '+widge.name+'
    '+widge.shape+'
  • '); + column.find("ul").append(li); + if(counter%5==0){ + $("#journal_p div#paper_list div.overview").append(column); + column = $('
    '); + } + counter++; + }) + //alert(column); + $("#apps_store div#widget_list").append(column); + }) }) } @@ -1109,7 +1124,6 @@ var orbitDesktop = function(dom){ $(o.contentHolder).empty().load("/desktop_appstore/"+target,function(){ widgets(); bindHandlers(); - }); }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); diff --git a/app/controllers/desktop_appstore_controller.rb b/app/controllers/desktop_appstore_controller.rb index 3114cafa..82e27412 100644 --- a/app/controllers/desktop_appstore_controller.rb +++ b/app/controllers/desktop_appstore_controller.rb @@ -8,4 +8,9 @@ class DesktopAppstoreController< ApplicationController render "desktop/appstore/widgets", :layout => false end + def getuserwidgets + @widgets = current_user.desktop_widgets + render :json=>@widgets.to_json + end + end \ No newline at end of file diff --git a/app/models/desktop_widget.rb b/app/models/desktop_widget.rb new file mode 100644 index 00000000..b0c0699e --- /dev/null +++ b/app/models/desktop_widget.rb @@ -0,0 +1,11 @@ +class DesktopWidget + include Mongoid::Document + include Mongoid::Timestamps + + field :name + field :author + field :shape + field :user_id + + belongs_to :user +end \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index d09e563e..aca7959b 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 + has_many :desktop_widgets, :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/widgets.html.erb b/app/views/desktop/appstore/widgets.html.erb index 294d571f..5cbb049b 100644 --- a/app/views/desktop/appstore/widgets.html.erb +++ b/app/views/desktop/appstore/widgets.html.erb @@ -1 +1,11 @@ -this is widget page... \ No newline at end of file +
    +
    +
    +
    +
    Your Widgets
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 27eb9770..08320cd2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -129,6 +129,7 @@ Orbit::Application.routes.draw do match '/desktop_appstore/appstore'=>'desktop_appstore#appstore' match '/desktop_appstore/widgets'=>'desktop_appstore#widgets' + match '/desktop_appstore/getuserwidgets'=>'desktop_appstore#getuserwidgets' 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 {