SwankInnovations / radiant-prototype forked from radiant/radiant-prototype

Prototype of the user-interface of Radiant CMS.

This URL has Read+Write access

radiant-prototype / view_helpers.rb
100644 53 lines (39 sloc) 1.295 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module ViewHelpers
  def params
    request.query.dup
  end
  
  
  # The NavTab Class holds the structure of a navigation tab (including
  # its sub-nav items).
  class NavTab < Array
    attr_reader :name, :proper_name
 
    def initialize(name, proper_name)
      @name, @proper_name = name, proper_name
    end
 
    def [](id)
      unless id.kind_of? Fixnum
        self.find {|subnav_item| subnav_item.name.to_s == id.to_s }
      else
        super
      end
    end
  end
 
 
  # simple structure for storing the properties of a
  # tab's sub items.
  class NavSubItem
    attr_reader :name, :proper_name, :url
 
    def initialize(name, proper_name, url = "#")
      @name, @proper_name, @url = name, proper_name, url
    end
  end
 
 
  def nav_tabs
    content = NavTab.new(:content, "Content")
    content << NavSubItem.new(:pages, "Pages", "/admin/pages/")
    content << NavSubItem.new(:snippets, "Snippets", "/admin/snippets/")
  
    design = NavTab.new(:design, "Design")
    design << NavSubItem.new(:layouts, "Layouts", "/admin/layouts/")
  
    settings = NavTab.new(:settings, "Settings")
    settings << NavSubItem.new(:users, "Users", "/admin/users/")
    settings << NavSubItem.new(:extensions, "Extensions", "/admin/extensions/")
  
    [content, design, settings]
  end
end