public
Description: HomeMarks is a web based GUI to build HTML start pages.
Homepage: http://www.homemarks.com/
Clone URL: git://github.com/metaskills/homemarks.git
Click here to lend your support to: homemarks and make a donation at www.pledgie.com !
Move updating/creating bookmarks for a box to BoxesController.
metaskills (author)
Sun Jul 20 16:50:48 -0700 2008
commit  c2c07510f948b1269b5eff968e3c56461f5ebbd7
tree    7d7f8752d4a29e35c78a2b14f9dac5bc1a45fa1a
parent  4fc9a111973ea4e244d48893e16f9318dd05ce8c
...
1
2
3
4
 
5
6
7
...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
1
2
3
 
4
5
6
7
...
13
14
15
 
 
 
 
 
 
 
 
 
 
 
16
17
18
0
@@ -1,7 +1,7 @@
0
 class BookmarksController < ApplicationController
0
   
0
   prepend_before_filter :ignore_lost_sortable_requests
0
- before_filter :find_bookmark, :except => [ :create, :update_box ]
0
+ before_filter :find_bookmark, :except => [ :create ]
0
   # TODO [DEMO] Controller filters
0
   # after_filter :expire_user_home_cache, :only => [ :new_in_box, :save_links ]
0
   # after_filter :expire_correct_fragment, :only => [ :sort, :trash ]
0
@@ -13,17 +13,6 @@ class BookmarksController < ApplicationController
0
     render_json_data(@bookmark.id)
0
   end
0
   
0
- def update_box
0
- @box = current_user.boxes.find(params[:box_id])
0
- @new_bookmarks = params[:new_bookmarks] ? @box.bookmarks.create(params[:new_bookmarks].values) : []
0
- @box.bookmarks.each do |bm|
0
- @updated_bookmarks ||= []
0
- bm.attributes = params[:bookmarks][bm.id.to_s]
0
- @updated_bookmarks << bm and bm.save! if bm.changed?
0
- end
0
- render_json_data({:new_bookmarks => @new_bookmarks, :updated_bookmarks => @updated_bookmarks})
0
- end
0
-
0
   def sort
0
     head :ok
0
     # find_dopped_on_box
...
42
43
44
 
 
 
 
 
 
 
 
 
 
45
46
47
...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
0
@@ -42,6 +42,16 @@ class BoxesController < ApplicationController
0
     head :ok
0
   end
0
   
0
+ def bookmarks
0
+ @new_bookmarks = params[:new_bookmarks] ? @box.bookmarks.create(params[:new_bookmarks].values) : []
0
+ @box.bookmarks.each do |bm|
0
+ @updated_bookmarks ||= []
0
+ bm.attributes = params[:bookmarks][bm.id.to_s]
0
+ @updated_bookmarks << bm and bm.save! if bm.changed?
0
+ end
0
+ render_json_data({:new_bookmarks => @new_bookmarks, :updated_bookmarks => @updated_bookmarks})
0
+ end
0
+
0
   
0
   protected
0
   
...
10
11
12
13
14
 
 
15
16
17
...
10
11
12
 
 
13
14
15
16
17
0
@@ -10,8 +10,8 @@ ActionController::Routing::Routes.draw do |map|
0
   map.resource :trashbox
0
   map.resources :columns, :collection => { :sort => :put }
0
   map.resources :boxes, :collection => { :sort => :put },
0
- :member => { :toggle_collapse => :put, :colorize => :put, :change_title => :put }
0
- map.resources :bookmarks, :collection => { :sort => :put, :update_box => :put },
0
+ :member => { :toggle_collapse => :put, :colorize => :put, :change_title => :put, :bookmarks => :put }
0
+ map.resources :bookmarks, :collection => { :sort => :put },
0
                               :member => { :foo => :put }
0
   
0
   map.myhome 'myhome', :controller => 'users', :action => 'home', :conditions => {:method => :get}
...
87
88
89
90
 
91
92
93
...
87
88
89
 
90
91
92
93
0
@@ -87,7 +87,7 @@ var Box = Class.create(HomeMarksApp,{
0
       TABLE({id:'bookmark_header_table',border:'0'},[
0
         TR([TD({id:'bookmark_header_name'},'Name:'),TD({id:'bookmark_header_url'},'Location:')])
0
       ]),
0
- FORM({action:'/bookmarks/update_box',id:'modal_form'},[
0
+ FORM({action:'/boxes/'+this.id+'/bookmarks',id:'modal_form'},[
0
         DIV({id:'bookmark_scroll'},[
0
           TABLE({id:'bookmark_edit_table',border:'0'},this.bookmarkRows())
0
         ])

Comments

    No one has commented yet.