Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 2278 Bytes
1 | class Admin::SidebarController < Admin::BaseController |
2 | def index |
3 | @sidebars = ::SidebarController.available_sidebars.inject({}) do |hash,sb| |
4 | hash.merge({ sb.short_name => sb }) |
5 | end |
6 | # Reset the staged position based on the active position. |
7 | Sidebar.delete_all('active_position is null') |
8 | @active = Sidebar.find(:all, :order => 'active_position').select do |sb| |
9 | @sidebars[sb.controller] |
10 | end |
11 | flash[:sidebars] = @active.map {|sb| sb.id } |
12 | @available = @sidebars.values.sort { |a,b| a.name <=> b.name } |
13 | end |
14 | |
15 | def set_active |
16 | # Get all available plugins |
17 | |
18 | defaults_for = available.inject({}) do |hash, item| |
19 | hash.merge({ item.short_name => item.default_config }) |
20 | end |
21 | # Get all already active plugins |
22 | activemap = flash[:sidebars].inject({}) do |h, sb_id| |
23 | sb = Sidebar.find(sb_id.to_i) |
24 | sb ? h.merge({ sb.html_id => sb_id }) : h |
25 | end |
26 | |
27 | # Figure out which plugins are referenced by the params[:active] array and |
28 | # lay them out in a easy accessible sequential array |
29 | flash[:sidebars] = params[:active].inject([]) do |array, name| |
30 | if defaults_for.has_key?(name) |
31 | @new_item = Sidebar.create!(:controller => name, |
32 | :config => defaults_for[name]) |
33 | @target = name |
34 | array << @new_item.id |
35 | elsif activemap.has_key?(name) |
36 | array << activemap[name] |
37 | else |
38 | array |
39 | end |
40 | end |
41 | end |
42 | |
43 | def remove |
44 | flash[:sidebars] = flash[:sidebars].reject do |sb_id| |
45 | sb_id == params[:id].to_i |
46 | end |
47 | @element_to_remove = params[:element] |
48 | end |
49 | |
50 | def publish |
51 | Sidebar.transaction do |
52 | position = 0 |
53 | params[:configure] ||= [] |
54 | Sidebar.update_all('active_position = null') |
55 | flash[:sidebars].each do |id| |
56 | Sidebar.find(id).update_attributes(:config => params[:configure][id.to_s], |
57 | :active_position => position) |
58 | position += 1 |
59 | end |
60 | Sidebar.delete_all('active_position is null') |
61 | end |
62 | index |
63 | end |
64 | |
65 | protected |
66 | def show_available |
67 | render :partial => 'availables', :object => available |
68 | end |
69 | |
70 | def available |
71 | ::SidebarController.available_sidebars.sort { |a,b| a.name <=> b.name } |
72 | end |
73 | helper_method :available |
74 | end |