Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 2209 Bytes
1 | class HomePageDataset < Dataset::Base |
2 | |
3 | def load |
4 | create_page "Home", :slug => "/", :parent_id => nil, |
5 | :description => "The homepage", |
6 | :keywords => "Home, Page" do |
7 | create_page_part "body", :content => "Hello world!" |
8 | create_page_part "sidebar", :content => "<r:title /> sidebar." |
9 | create_page_part "extended", :content => "Just a test." |
10 | create_page_part "titles", :content => "<r:title /> <r:page:title />" |
11 | end |
12 | end |
13 | |
14 | helpers do |
15 | def create_page(name, attributes={}) |
16 | attributes = page_params(attributes.reverse_merge(:title => name)) |
17 | body = attributes.delete(:body) || name |
18 | symbol = name.symbolize |
19 | create_record :page, symbol, attributes |
20 | if block_given? |
21 | old_page_id = @current_page_id |
22 | @current_page_id = page_id(symbol) |
23 | yield |
24 | @current_page_id = old_page_id |
25 | end |
26 | if pages(symbol).parts.empty? |
27 | create_page_part "#{name}_body".symbolize, :name => "body", :content => body + ' body.', :page_id => page_id(symbol) |
28 | end |
29 | end |
30 | def page_params(attributes={}) |
31 | title = attributes[:title] || unique_page_title |
32 | attributes = { |
33 | :title => title, |
34 | :breadcrumb => title, |
35 | :slug => title.symbolize.to_s.gsub("_", "-"), |
36 | :class_name => nil, |
37 | :status_id => Status[:published].id, |
38 | :published_at => Time.now.to_s(:db) |
39 | }.update(attributes) |
40 | attributes[:parent_id] = @current_page_id || page_id(:home) unless attributes.has_key?(:parent_id) |
41 | attributes |
42 | end |
43 | |
44 | def create_page_part(name, attributes={}) |
45 | attributes = page_part_params(attributes.reverse_merge(:name => name)) |
46 | create_record :page_part, name.symbolize, attributes |
47 | end |
48 | def page_part_params(attributes={}) |
49 | name = attributes[:name] || "unnamed" |
50 | attributes = { |
51 | :name => name, |
52 | :content => name, |
53 | :page_id => @current_page_id |
54 | }.update(attributes) |
55 | end |
56 | |
57 | private |
58 | @@unique_page_title_call_count = 0 |
59 | def unique_page_title |
60 | @@unique_page_title_call_count += 1 |
61 | "Page #{@@unique_page_title_call_count}" |
62 | end |
63 | end |
64 | end |