Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 2331 Bytes
1 | class Admin::SidebarController < Admin::BaseController |
2 | def index |
3 | @available = available |
4 | # Reset the staged position based on the active position. |
5 | Sidebar.delete_all(['blog_id = ? and active_position is null', |
6 | this_blog.id]) |
7 | @active = this_blog.sidebars |
8 | flash[:sidebars] = @active.map {|sb| sb.id } |
9 | end |
10 | |
11 | def set_active |
12 | # Get all available plugins |
13 | |
14 | klass_for = available.inject({}) do |hash, klass| |
15 | hash.merge({ klass.short_name => klass }) |
16 | end |
17 | # Get all already active plugins |
18 | activemap = flash[:sidebars].inject({}) do |h, sb_id| |
19 | sb = Sidebar.find(sb_id.to_i) |
20 | sb ? h.merge(sb.html_id => sb_id) : h |
21 | end |
22 | |
23 | # Figure out which plugins are referenced by the params[:active] array and |
24 | # lay them out in a easy accessible sequential array |
25 | flash[:sidebars] = params[:active].inject([]) do |array, name| |
26 | if klass_for.has_key?(name) |
27 | @new_item = klass_for[name].create!(:blog => this_blog) |
28 | @target = name |
29 | array << @new_item.id |
30 | elsif activemap.has_key?(name) |
31 | array << activemap[name] |
32 | else |
33 | array |
34 | end |
35 | end |
36 | end |
37 | |
38 | def remove |
39 | flash[:sidebars] = flash[:sidebars].reject do |sb_id| |
40 | sb_id == params[:id].to_i |
41 | end |
42 | @element_to_remove = params[:element] |
43 | end |
44 | |
45 | def publish |
46 | Sidebar.transaction do |
47 | position = 0 |
48 | params[:configure] ||= { } |
49 | this_blog.sidebars.update_all('active_position = null') |
50 | flash[:sidebars].each do |id| |
51 | sidebar = Sidebar.find(id) |
52 | sb_attribs = params[:configure][id.to_s] || {} |
53 | # If it's a checkbox and unchecked, convert the 0 to false |
54 | # This is ugly. Anyone have an improvement? |
55 | sidebar.fields.each do |field| |
56 | sb_attribs[field.key] = field.canonicalize(sb_attribs[field.key]) |
57 | end |
58 | |
59 | sidebar.update_attributes(:config => sb_attribs, |
60 | :active_position => position) |
61 | position += 1 |
62 | end |
63 | Sidebar.delete_all(['blog_id = ? and active_position is null', |
64 | this_blog.id]) |
65 | end |
66 | index |
67 | end |
68 | |
69 | protected |
70 | def show_available |
71 | render :partial => 'availables', :object => available |
72 | end |
73 | |
74 | def available |
75 | ::Sidebar.available_sidebars |
76 | end |
77 | helper_method :available |
78 | end |