Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 13
- Log:
Initial import of Typo 2.6.0 sources from a downloaded Tarball.
Typo is a Ruby On Rails based blog engine.
- Author:
- adh
- Date:
- Sat Jul 22 22:25:02 +0100 2006
- Size:
- 2392 Bytes
1 | require_dependency 'sidebars/sidebar_controller' |
2 | |
3 | class Admin::SidebarController < Admin::BaseController |
4 | def index |
5 | @sidebars = Sidebars::SidebarController.available_sidebars.inject({}) do |hash,sidebar| |
6 | hash[sidebar.short_name]=sidebar |
7 | hash |
8 | end |
9 | |
10 | @active = Sidebar.find_all_staged.select {|s| @sidebars[s.controller] } |
11 | @available = @sidebars.values.sort { |a,b| a.name <=> b.name } |
12 | end |
13 | |
14 | def show_available |
15 | render :partial => 'availables', :object => available |
16 | end |
17 | |
18 | def set_active |
19 | |
20 | # Get all available plugins |
21 | availablemap = available.inject({}) do |hash, item| |
22 | hash[item.short_name] = item |
23 | hash |
24 | end |
25 | |
26 | # Get all already active plugins |
27 | activemap = Sidebar.find_all_staged.inject({}) do |hash, item| |
28 | hash[item.html_id] = item |
29 | hash |
30 | end |
31 | |
32 | # Figure out which plugins are referenced by the params[:active] array and |
33 | # lay them out in a easy accessible sequencial array |
34 | @active = params[:active].inject([]) do |array, name| |
35 | if availablemap.has_key?(name) |
36 | newitem = Sidebar.new |
37 | newitem.controller = name |
38 | newitem.staged_config= availablemap[name].default_config |
39 | |
40 | array.push newitem |
41 | elsif activemap.has_key?(name) |
42 | array.push activemap[name] |
43 | end |
44 | array |
45 | end |
46 | |
47 | # Update the staged_position of all the sidebar items in accordance with |
48 | # the params[:active] array |
49 | Sidebar.transaction do |
50 | Sidebar.update_all('staged_position=null') |
51 | @active.each_index do |i| |
52 | @active[i].staged_position=i |
53 | @active[i].save |
54 | end |
55 | Sidebar.purge |
56 | end |
57 | |
58 | render :partial => 'actives', :object => @active |
59 | end |
60 | |
61 | def save_config |
62 | sidebar = Sidebar.find(params[:id]) |
63 | sidebar.staged_config=params[:configure] |
64 | sidebar.save |
65 | |
66 | render :nothing => true |
67 | end |
68 | |
69 | def nothing |
70 | render :nothing => true |
71 | end |
72 | |
73 | def remove |
74 | sidebar = Sidebar.find(params[:id]) |
75 | sidebar.staged_position = nil |
76 | sidebar.save |
77 | |
78 | render :nothing => true |
79 | end |
80 | |
81 | def publish |
82 | Sidebar.transaction do |
83 | Sidebar.find(:all).each do |sidebar| |
84 | sidebar.publish |
85 | sidebar.save |
86 | end |
87 | Sidebar.purge |
88 | end |
89 | render :partial=>'publish' |
90 | end |
91 | |
92 | private |
93 | |
94 | def available |
95 | Sidebars::SidebarController.available_sidebars.sort { |a,b| a.name <=> b.name } |
96 | end |
97 | end |