slightcms 0.0.11 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/.DS_Store +0 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +12 -0
  5. data/Gemfile.lock +90 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +14 -37
  8. data/Rakefile +45 -17
  9. data/VERSION +1 -1
  10. data/{lib/app/controller → app/controllers}/slightcms/pages_controller.rb +8 -8
  11. data/lib/generators/slightcms/install.rb +19 -0
  12. data/lib/generators/templates/README +7 -0
  13. data/lib/slightcms.rb +0 -59
  14. data/slightcms.gemspec +42 -76
  15. data/spec/slightcms_spec.rb +5 -4
  16. data/spec/spec_helper.rb +9 -12
  17. metadata +60 -98
  18. data/.bnsignore +0 -18
  19. data/.gitignore +0 -3
  20. data/History.rdoc +0 -4
  21. data/bin/slightcms +0 -7
  22. data/generators/slightcms_setup/INSTALL +0 -1
  23. data/generators/slightcms_setup/images/arrow_down.png +0 -0
  24. data/generators/slightcms_setup/images/arrow_up.png +0 -0
  25. data/generators/slightcms_setup/images/main-menu-bg-divider.gif +0 -0
  26. data/generators/slightcms_setup/images/main-menu-bg-hover.gif +0 -0
  27. data/generators/slightcms_setup/images/main-menu-bg.gif +0 -0
  28. data/generators/slightcms_setup/images/page.png +0 -0
  29. data/generators/slightcms_setup/images/page_add.png +0 -0
  30. data/generators/slightcms_setup/images/page_delete.png +0 -0
  31. data/generators/slightcms_setup/images/page_edit.png +0 -0
  32. data/generators/slightcms_setup/javascripts/jquery-1.4.min.js +0 -151
  33. data/generators/slightcms_setup/javascripts/slightcms.js +0 -0
  34. data/generators/slightcms_setup/slightcms_setup_generator.rb +0 -29
  35. data/generators/slightcms_setup/stylesheets/960.css +0 -1
  36. data/generators/slightcms_setup/stylesheets/reset.css +0 -1
  37. data/generators/slightcms_setup/stylesheets/slightcms.css +0 -0
  38. data/generators/slightcms_setup/stylesheets/text.css +0 -1
  39. data/generators/slightcms_setup/templates/migrate/slightcms_setup_migration.rb +0 -54
  40. data/lib/app/controller/slightcms/admin/assets_controller.rb +0 -47
  41. data/lib/app/controller/slightcms/admin/layouts_controller.rb +0 -65
  42. data/lib/app/controller/slightcms/admin/pages_controller.rb +0 -80
  43. data/lib/app/models/asset.rb +0 -65
  44. data/lib/app/models/layout.rb +0 -30
  45. data/lib/app/models/page.rb +0 -97
  46. data/lib/app/models/part.rb +0 -21
  47. data/lib/app/views/layouts/slightcms_admin_interface.html.erb +0 -36
  48. data/lib/app/views/slightcms/admin/assets/index.html.erb +0 -12
  49. data/lib/app/views/slightcms/admin/assets/new.html.erb +0 -10
  50. data/lib/app/views/slightcms/admin/layouts/edit.html.erb +0 -10
  51. data/lib/app/views/slightcms/admin/layouts/index.html.erb +0 -13
  52. data/lib/app/views/slightcms/admin/layouts/new.html.erb +0 -12
  53. data/lib/app/views/slightcms/admin/pages/_page_list_item.html.erb +0 -14
  54. data/lib/app/views/slightcms/admin/pages/_page_part_fields.html.erb +0 -4
  55. data/lib/app/views/slightcms/admin/pages/edit.html.erb +0 -19
  56. data/lib/app/views/slightcms/admin/pages/index.html.erb +0 -8
  57. data/lib/app/views/slightcms/admin/pages/new.html.erb +0 -20
  58. data/lib/app/views/slightcms/pages/show.html.erb +0 -1
  59. data/test/test_slightcms.rb +0 -0
File without changes
@@ -1,29 +0,0 @@
1
- class Rails::Generator::Commands::Create
2
- def draw_routes
3
- file_start = 'ActionController::Routing::Routes.draw do |map|'
4
- unless options[:pretend]
5
- gsub_file 'config/routes.rb', /(#{Regexp.escape(file_start)})/mi do |match|
6
- "#{match}\n map.slightcms_pages '/:path', :controller => :slightcms_pages, :action => :show\n"
7
- end
8
- end
9
- end
10
- end
11
-
12
- class SlightcmsSetupGenerator < Rails::Generator::Base
13
- def manifest
14
- record do |m|
15
- # Setup directories
16
- m.directory('public/slightcms/assets')
17
-
18
- # Setup migration file
19
- m.migration_template('migrate/slightcms_setup_migration.rb', 'db/migrate')
20
-
21
- # Setup routes in routes.rb
22
- # m.draw_routes
23
- end
24
- end
25
-
26
- def file_name
27
- "slightcms_setup"
28
- end
29
- end
@@ -1 +0,0 @@
1
- .container_12,.container_16{margin-left:auto;margin-right:auto;width:960px}.grid_1,.grid_2,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9,.grid_10,.grid_11,.grid_12,.grid_13,.grid_14,.grid_15,.grid_16{display:inline;float:left;position:relative;margin-left:10px;margin-right:10px}.container_12 .grid_3,.container_16 .grid_4{width:220px}.container_12 .grid_6,.container_16 .grid_8{width:460px}.container_12 .grid_9,.container_16 .grid_12{width:700px}.container_12 .grid_12,.container_16 .grid_16{width:940px}.alpha{margin-left:0}.omega{margin-right:0}.container_12 .grid_1{width:60px}.container_12 .grid_2{width:140px}.container_12 .grid_4{width:300px}.container_12 .grid_5{width:380px}.container_12 .grid_7{width:540px}.container_12 .grid_8{width:620px}.container_12 .grid_10{width:780px}.container_12 .grid_11{width:860px}.container_16 .grid_1{width:40px}.container_16 .grid_2{width:100px}.container_16 .grid_3{width:160px}.container_16 .grid_5{width:280px}.container_16 .grid_6{width:340px}.container_16 .grid_7{width:400px}.container_16 .grid_9{width:520px}.container_16 .grid_10{width:580px}.container_16 .grid_11{width:640px}.container_16 .grid_13{width:760px}.container_16 .grid_14{width:820px}.container_16 .grid_15{width:880px}.container_12 .prefix_3,.container_16 .prefix_4{padding-left:240px}.container_12 .prefix_6,.container_16 .prefix_8{padding-left:480px}.container_12 .prefix_9,.container_16 .prefix_12{padding-left:720px}.container_12 .prefix_1{padding-left:80px}.container_12 .prefix_2{padding-left:160px}.container_12 .prefix_4{padding-left:320px}.container_12 .prefix_5{padding-left:400px}.container_12 .prefix_7{padding-left:560px}.container_12 .prefix_8{padding-left:640px}.container_12 .prefix_10{padding-left:800px}.container_12 .prefix_11{padding-left:880px}.container_16 .prefix_1{padding-left:60px}.container_16 .prefix_2{padding-left:120px}.container_16 .prefix_3{padding-left:180px}.container_16 .prefix_5{padding-left:300px}.container_16 .prefix_6{padding-left:360px}.container_16 .prefix_7{padding-left:420px}.container_16 .prefix_9{padding-left:540px}.container_16 .prefix_10{padding-left:600px}.container_16 .prefix_11{padding-left:660px}.container_16 .prefix_13{padding-left:780px}.container_16 .prefix_14{padding-left:840px}.container_16 .prefix_15{padding-left:900px}.container_12 .suffix_3,.container_16 .suffix_4{padding-right:240px}.container_12 .suffix_6,.container_16 .suffix_8{padding-right:480px}.container_12 .suffix_9,.container_16 .suffix_12{padding-right:720px}.container_12 .suffix_1{padding-right:80px}.container_12 .suffix_2{padding-right:160px}.container_12 .suffix_4{padding-right:320px}.container_12 .suffix_5{padding-right:400px}.container_12 .suffix_7{padding-right:560px}.container_12 .suffix_8{padding-right:640px}.container_12 .suffix_10{padding-right:800px}.container_12 .suffix_11{padding-right:880px}.container_16 .suffix_1{padding-right:60px}.container_16 .suffix_2{padding-right:120px}.container_16 .suffix_3{padding-right:180px}.container_16 .suffix_5{padding-right:300px}.container_16 .suffix_6{padding-right:360px}.container_16 .suffix_7{padding-right:420px}.container_16 .suffix_9{padding-right:540px}.container_16 .suffix_10{padding-right:600px}.container_16 .suffix_11{padding-right:660px}.container_16 .suffix_13{padding-right:780px}.container_16 .suffix_14{padding-right:840px}.container_16 .suffix_15{padding-right:900px}.container_12 .push_3,.container_16 .push_4{left:240px}.container_12 .push_6,.container_16 .push_8{left:480px}.container_12 .push_9,.container_16 .push_12{left:720px}.container_12 .push_1{left:80px}.container_12 .push_2{left:160px}.container_12 .push_4{left:320px}.container_12 .push_5{left:400px}.container_12 .push_7{left:560px}.container_12 .push_8{left:640px}.container_12 .push_10{left:800px}.container_12 .push_11{left:880px}.container_16 .push_1{left:60px}.container_16 .push_2{left:120px}.container_16 .push_3{left:180px}.container_16 .push_5{left:300px}.container_16 .push_6{left:360px}.container_16 .push_7{left:420px}.container_16 .push_9{left:540px}.container_16 .push_10{left:600px}.container_16 .push_11{left:660px}.container_16 .push_13{left:780px}.container_16 .push_14{left:840px}.container_16 .push_15{left:900px}.container_12 .pull_3,.container_16 .pull_4{left:-240px}.container_12 .pull_6,.container_16 .pull_8{left:-480px}.container_12 .pull_9,.container_16 .pull_12{left:-720px}.container_12 .pull_1{left:-80px}.container_12 .pull_2{left:-160px}.container_12 .pull_4{left:-320px}.container_12 .pull_5{left:-400px}.container_12 .pull_7{left:-560px}.container_12 .pull_8{left:-640px}.container_12 .pull_10{left:-800px}.container_12 .pull_11{left:-880px}.container_16 .pull_1{left:-60px}.container_16 .pull_2{left:-120px}.container_16 .pull_3{left:-180px}.container_16 .pull_5{left:-300px}.container_16 .pull_6{left:-360px}.container_16 .pull_7{left:-420px}.container_16 .pull_9{left:-540px}.container_16 .pull_10{left:-600px}.container_16 .pull_11{left:-660px}.container_16 .pull_13{left:-780px}.container_16 .pull_14{left:-840px}.container_16 .pull_15{left:-900px}.clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}.clearfix:after{clear:both;content:' ';display:block;font-size:0;line-height:0;visibility:hidden;width:0;height:0}* html .clearfix,*:first-child+html .clearfix{zoom:1}
@@ -1 +0,0 @@
1
- html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outline:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
File without changes
@@ -1 +0,0 @@
1
- body{font:13px/1.5 'Helvetica Neue',Arial,'Liberation Sans',FreeSans,sans-serif}a:focus{outline:1px dotted}hr{border:0 #ccc solid;border-top-width:1px;clear:both;height:0}h1{font-size:25px}h2{font-size:23px}h3{font-size:21px}h4{font-size:19px}h5{font-size:17px}h6{font-size:15px}ol{list-style:decimal}ul{list-style:disc}li{margin-left:30px}p,dl,hr,h1,h2,h3,h4,h5,h6,ol,ul,pre,table,address,fieldset{margin-bottom:20px}
@@ -1,54 +0,0 @@
1
- class SlightcmsSetup < ActiveRecord::Migration
2
- def self.up
3
- # Create layouts-table
4
- create_table :slightcms_layouts do |t|
5
- t.string :name, :null => false
6
- t.text :content
7
- t.timestamps
8
- end
9
-
10
- # Create pages-table
11
- create_table :slightcms_pages do |t|
12
- t.integer :parent_id
13
- t.integer :layout_id
14
- t.integer :position
15
- t.string :path, :null => false
16
- t.string :title, :null => false
17
- t.string :slug, :null => false
18
- t.string :keywords
19
- t.string :description
20
- t.boolean :published
21
- t.timestamps
22
- end
23
- add_index :slightcms_pages, :parent_id
24
- add_index :slightcms_pages, :layout_id
25
- add_index :slightcms_pages, :path
26
- add_index :slightcms_pages, :published
27
-
28
- # Create page-parts-table
29
- create_table :slightcms_page_parts do |t|
30
- t.integer :page_id
31
- t.string :name, :null => false
32
- t.text :content, :null => false
33
- t.timestamps
34
- end
35
- add_index :slightcms_page_parts, :page_id
36
-
37
- # Create assets-table
38
- create_table :slightcms_assets do |t|
39
- t.string :name
40
- t.string :content_type
41
- t.string :filename
42
- t.integer :size
43
- t.timestamps
44
- end
45
-
46
- end
47
-
48
- def self.down
49
- drop_table :slightcms_layouts
50
- drop_table :slightcms_pages
51
- drop_table :slightcms_page_parts
52
- drop_table :slightcms_assets
53
- end
54
- end
@@ -1,47 +0,0 @@
1
- module Slightcms
2
-
3
- module Admin
4
-
5
- class AssetsController < ApplicationController
6
-
7
- layout "slightcms_admin_assets"
8
-
9
- # List all Assets
10
- def index
11
- @assets = Slightcms::Asset.find :all
12
- end
13
-
14
- # Render the form for uploading a new asset
15
- def new
16
- @asset = Slightcms::Asset.new
17
- end
18
-
19
- # Create a new Assert
20
- def create
21
- @asset = Slightcms::Asset.new(params[:slightcms_asset])
22
- if @asset.save
23
- flash[:notice] = "The asset was saved successfully."
24
- redirect_to slightcms_admin_assets_path
25
- else
26
- flash[:error] = "An error occured uploading your asset!"
27
- render :action => :new
28
- end
29
- end
30
-
31
- # Delet an existing asset
32
- def destroy
33
- @asset = Slightcms::Asset.find(params[:id])
34
- if @asset.destroy
35
- flash[:notice] = "The asset was deleted successfully."
36
- redirect_to slightcms_admin_assets_path
37
- else
38
- flash[:error] = "An error occured deleting the asset!"
39
- redirect_to slightcms_admin_assets_path
40
- end
41
- end
42
-
43
- end
44
-
45
- end
46
-
47
- end
@@ -1,65 +0,0 @@
1
- module Slightcms
2
-
3
- module Admin
4
-
5
- class LayoutsController < ApplicationController
6
-
7
- layout "slightcms_admin_layouts_list"
8
-
9
- # List all layouts
10
- def index
11
- @layouts = Slightcms::Layout.find :all
12
- end
13
-
14
- # Render the form for creating a layout
15
- def new
16
- @layout = Slightcms::Layout.new
17
- end
18
-
19
- # Create a new assert
20
- def create
21
- @layout = Slightcms::Layout.new(params[:slightcms_layout])
22
- if @layout.save
23
- flash[:notice] = "The layout was saved successfully."
24
- redirect_to slightcms_admin_layouts_path
25
- else
26
- flash[:error] = "An error occured saving the layout!"
27
- render :action => :new
28
- end
29
- end
30
-
31
- # Render the form for edit an existing layout
32
- def edit
33
- @layout = Slightcms::Layout.find(params[:id])
34
- end
35
-
36
- # Update an existing layout
37
- def update
38
- @layout = Slightcms::Layout.find(params[:id])
39
- @layout.update_attributes(params[:slightcms_layout])
40
- if @layout.save
41
- flash[:notice] = "The layout was saved successfully."
42
- redirect_to slightcms_admin_layouts_path
43
- else
44
- flash[:error] = "An error occured saving the layout."
45
- render :action => :edit
46
- end
47
- end
48
-
49
- # Delete an existing layout
50
- def destroy
51
- @layout = Slightcms::Layout.find(params[:id])
52
- if @layout.destroy
53
- flash[:notice] = "The layout was deleted successfully."
54
- redirect_to slightcms_admin_layouts_path
55
- else
56
- flash[:error] = "An error occured deleting the layout!"
57
- redirect_to slightcms_admin_layouts_path
58
- end
59
- end
60
-
61
- end
62
-
63
- end
64
-
65
- end
@@ -1,80 +0,0 @@
1
- module Slightcms
2
-
3
- module Admin
4
-
5
- class PagesController < ApplicationController
6
-
7
- layout "slightcms_admin_pages"
8
-
9
- # Show the page tree
10
- def index
11
- @pages = Slightcms::Page.find :all
12
- end
13
-
14
- # Render the new page form
15
- def new
16
- @page = Slightcms::Page.new
17
- @page.parts.build
18
- end
19
-
20
- # Create a new page
21
- def create
22
- @page = Slightcms::Page.new(params[:slightcms_page])
23
- if @page.save
24
- flash[:notice] = "The page was saved successfully."
25
- redirect_to slightcms_admin_pages_path
26
- else
27
- flash[:error] = "An error occured creating your page!"
28
- render :action => :new
29
- end
30
- end
31
-
32
- # Render the edit form
33
- def edit
34
- @page = Slightcms::Page.find(params[:id])
35
- end
36
-
37
- # Update an existing page
38
- def update
39
- @page = Slightcms::Page.find(params[:id])
40
- @page.update_attributes(params[:slightcms_page])
41
- if @page.save
42
- flash[:notice] = "The page was saved successfully."
43
- redirect_to slightcms_admin_pages_path
44
- else
45
- flash[:error] = "An error occured updating your page!"
46
- render :action => :edit
47
- end
48
- end
49
-
50
- # Delete an existing page
51
- def destroy
52
- @page = Slightcms::Page.find(params[:id])
53
- if @page.destroy
54
- flash[:notice] = "The page was removed successfully."
55
- redirect_to slightcms_pages_path
56
- else
57
- flash[:error] = "An error occured deleting the page!"
58
- redirect_to slightcms_admin_pages_path
59
- end
60
- end
61
-
62
- # Move the page up in page-tree
63
- def move_up
64
- @page = Slightcms::Page.find(params[:id])
65
- @page.move_higher
66
- redirect_to slightcms_admin_pages_path
67
- end
68
-
69
- # Move the page down in page-tree
70
- def move_down
71
- @page = Slightcms::Page.find(params[:id])
72
- @page.move_lower
73
- redirect_to slightcms_admin_pages_path
74
- end
75
-
76
- end
77
-
78
- end
79
-
80
- end
@@ -1,65 +0,0 @@
1
- module Slightcms
2
-
3
- class Asset < ActiveRecord::Base
4
-
5
- # Change default table name
6
- set_table_name "slightcms_assets"
7
-
8
- # Validations
9
- validates_presence_of :name
10
- validates_presence_of :filename
11
- validates_presence_of :size
12
- validates_presence_of :content_type
13
-
14
- # Callbacks
15
- after_create :store_file_in_filesystem
16
- after_destroy :remove_file_from_file_system
17
-
18
- def file=(uploaded_file)
19
- @uploaded_file = uploaded_file
20
- write_attribute(:content_type, @uploaded_file.content_type)
21
- write_attribute(:size, File.size(@uploaded_file))
22
- write_attribute(:filename, sanitize_filename(@uploaded_file.original_filename))
23
- end
24
-
25
- # Method to get the public file path
26
- def public_file_path
27
- "slightcms/assets/#{self.id}/#{self.filename}"
28
- end
29
-
30
- private
31
-
32
- # Method to store file in filesystem
33
- def store_file_in_filesystem
34
- if !File.exists?(File.dirname(absolute_file_path))
35
- Dir.mkdir(File.dirname(absolute_file_path))
36
- end
37
- if @uploaded_file.instance_of?(Tempfile)
38
- FileUtils.copy(@uploaded_file.local_path, absolute_file_path)
39
- else
40
- File.open(absolute_file_path, "wb") { |f| f.write(@uploaded_file.read) }
41
- end
42
- end
43
-
44
- # Method to remove the file from the filesystem
45
- def remove_file_from_file_system
46
- if File.exists?(absolute_file_path)
47
- File.delete(absolute_file_path)
48
- Dir.rmdir(File.dirname(absolute_file_path))
49
- end
50
- end
51
-
52
- # Method to get the absolute path for the file
53
- def absolute_file_path
54
- File.expand_path("#{RAILS_ROOT}/public/slightcms/assets/#{self.id}/#{self.filename}")
55
- end
56
-
57
- # Replace non standard signs with underscores
58
- def sanitize_filename(filename)
59
- just_filename = File.basename(filename)
60
- just_filename.gsub(/[^\w\.\_]/,'_')
61
- end
62
-
63
- end
64
-
65
- end
@@ -1,30 +0,0 @@
1
- module Slightcms
2
- class Layout < ActiveRecord::Base
3
-
4
- # Change default table name
5
- set_table_name 'slightcms_layouts'
6
-
7
- # Default order
8
- default_scope :order => 'name'
9
-
10
- # Associations
11
- has_many :pages, :class_name => "Slightcms::Page"
12
-
13
- # Validations
14
- validates_presence_of :name
15
- validates_uniqueness_of :name
16
- validates_presence_of :content
17
-
18
- # Create a file accessor
19
- attr_accessor :file
20
-
21
- # Write file to content if file is uploaded
22
- def file=(uploaded_file)
23
- unless uploaded_file.nil?
24
- write_attribute(:content, uploaded_file.read)
25
- end
26
- end
27
-
28
- end
29
-
30
- end
@@ -1,97 +0,0 @@
1
- module Slightcms
2
-
3
- class Page < ActiveRecord::Base
4
-
5
- # Change default table name
6
- set_table_name "slightcms_pages"
7
-
8
- acts_as_tree :order => "position"
9
- acts_as_list :scope => :parent_id
10
-
11
- # Default order
12
- default_scope :order => "position"
13
-
14
- # Associations
15
- belongs_to :layout, :class_name => "Slightcms::Layout"
16
- has_many :parts, :class_name => "Slightcms::Part", :dependent => :destroy
17
-
18
- # accept nested attributes for page-parts
19
- accepts_nested_attributes_for :parts,
20
- :reject_if => lambda { |a| a[:content].blank? },
21
- :allow_destroy => true
22
-
23
- # Validations
24
- validates_presence_of :title
25
- validates_presence_of :slug
26
- validates_uniqueness_of :slug, :scope => :parent_id
27
-
28
- # Callbacks
29
- before_validation :create_slug
30
- before_create :create_path
31
-
32
- # protected
33
-
34
- # Render the page's content
35
- def render_content
36
- content = self.layout.content
37
- content.gsub!(/(#{Regexp.escape("<!-- slightcms:page:title -->")})/mi, self.title)
38
- content.gsub!(/(#{Regexp.escape("<!-- slightcms:page:keywords -->")})/mi, self.keywords)
39
- content.gsub!(/(#{Regexp.escape("<!-- slightcms:page:description -->")})/mi, self.description)
40
- self.parts each do |part|
41
- content.gsub!(/(#{Regexp.escape("<!-- slightcms:part:#{part.name} -->")})/mi, part.render_content)
42
- end
43
- end
44
-
45
- # Find a page by full path
46
- def find_by_path(path)
47
- find :first, :conditions => {:path => path, :published => true}, :include => [:layout, :parts]
48
- end
49
-
50
- private
51
-
52
- # Create a unique slug for SEO purposes
53
- def create_slug
54
- if self.slug.blank? && !self.title.blank?
55
- proposed_slug = self.title.downcase.gsub!(/[^a-z1-9]+/, '-')
56
-
57
- existing = true
58
- suffix = ""
59
- i = 2
60
-
61
- # Check if slug already exists
62
- while existing != nil
63
- existing = self.class.find :first, :conditions => {:slug => proposed_slug + suffix}
64
- if existing
65
- suffix = "-#{i}"
66
- i += 1
67
- else
68
- self.slug = proposed_slug + suffix
69
- end
70
- end
71
- end
72
- end
73
-
74
- # Create page's path
75
- def create_path
76
- if parent.nil?
77
- write_attribute(:path, self.slug)
78
- else
79
- write_attribute(:path, parent.path + "/#{self.slug}")
80
- end
81
- end
82
-
83
- # Generate the page's path and save the object
84
- def create_path_and_save
85
- create_path
86
- save
87
- update_children_path
88
- end
89
-
90
- # Update the children's path
91
- def update_children_path
92
- children.each do |child|
93
- child.create_path_and_save
94
- end
95
- end
96
- end
97
- end