slightcms 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -0,0 +1,19 @@
1
+ module Slightcms
2
+ class Layout < ActiveRecord::Base
3
+
4
+ set_table_name 'jakfdajef'
5
+
6
+ # Default order
7
+ default_scope :order => 'name'
8
+
9
+ # Associations
10
+ has_many :pages, :class_name => "SlightcmsPage"
11
+
12
+ # Validations
13
+ validates_presence_of :name
14
+ validates_uniqueness_of :name
15
+ validates_presence_of :content
16
+
17
+ end
18
+
19
+ end
data/lib/slightcms.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  module Slightcms
3
3
 
4
4
  # :stopdoc:
5
- VERSION = '0.0.4'
5
+ VERSION = '0.0.5'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
@@ -44,5 +44,5 @@ module Slightcms
44
44
 
45
45
  end # module Slightcms
46
46
 
47
- Slightcms.require_all_libs_relative_to(__FILE__)
48
- require "app/models/slightcms_layout"
47
+ # Slightcms.require_all_libs_relative_to(__FILE__)
48
+ require "app/models/layout"
data/slightcms.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{slightcms}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthias Nitsch"]
@@ -28,9 +28,7 @@ Gem::Specification.new do |s|
28
28
  "generators/slightcms_setup/slightcms_setup_generator.rb",
29
29
  "generators/slightcms_setup/templates/INSTALL",
30
30
  "generators/slightcms_setup/templates/slightcms_setup_migration.rb",
31
- "lib/app/models/slightcms_layout.rb",
32
- "lib/app/models/slightcms_page.rb",
33
- "lib/app/models/slightcms_page_part.rb",
31
+ "lib/app/models/layout.rb",
34
32
  "lib/slightcms.rb",
35
33
  "slightcms.gemspec",
36
34
  "spec/slightcms_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slightcms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Nitsch
@@ -71,9 +71,7 @@ files:
71
71
  - generators/slightcms_setup/slightcms_setup_generator.rb
72
72
  - generators/slightcms_setup/templates/INSTALL
73
73
  - generators/slightcms_setup/templates/slightcms_setup_migration.rb
74
- - lib/app/models/slightcms_layout.rb
75
- - lib/app/models/slightcms_page.rb
76
- - lib/app/models/slightcms_page_part.rb
74
+ - lib/app/models/layout.rb
77
75
  - lib/slightcms.rb
78
76
  - slightcms.gemspec
79
77
  - spec/slightcms_spec.rb
@@ -1,14 +0,0 @@
1
- class SlightcmsLayout < ActiveRecord::Base
2
-
3
- # Default order
4
- default_scope :order => 'name'
5
-
6
- # Associations
7
- has_many :pages, :class_name => "SlightcmsPage"
8
-
9
- # Validations
10
- validates_presence_of :name
11
- validates_uniqueness_of :name
12
- validates_presence_of :content
13
-
14
- end
@@ -1,81 +0,0 @@
1
- class SlightcmsPage < ActiveRecord::Base
2
-
3
- acts_as_tree :order => "position"
4
- acts_as_list :scope => :parent_id
5
-
6
- # Default order
7
- default_scope :order => "position"
8
-
9
- # Associations
10
- belongs_to :layout, :class_name => :slightcms_layout
11
- has_many :parts, :class_name => :slightcms_page_part, :dependent => :destroy
12
-
13
- # Validations
14
- validates_presence_of :title
15
- validates_presence_of :slug
16
- validates_uniqueness_of :slug, :scope => :parent_id
17
-
18
- # Callbacks
19
- before_create :create_path
20
- before_validation do |record|
21
- if record.slug.blank? && !record.title.blank?
22
- create_slug(record)
23
- end
24
- end
25
-
26
- protected
27
-
28
- # Render the pages content
29
- def render_content
30
- content = self.layout.content
31
- self.parts each do |part|
32
- content.gsub!(/(#{Regexp.escape("<!-- slightcms:part:#{part.name} -->")})/mi, part.render_content)
33
- end
34
- end
35
-
36
- # Find a page by full path
37
- def find_by_path(path)
38
- find :first, :conditions => {:path => path, :published => true}, :include => [:layout, :parts]
39
- end
40
-
41
- private
42
-
43
- # Create a unique slug for SEO purposes
44
- def create_slug(record)
45
- proposed_slug = record.title.downcase.gsub!(/[^a-z1-9]+/, '-')
46
-
47
- existing = true
48
- suffix = ""
49
- i = 2
50
-
51
- # Check if slug already exists
52
- while existing != nil
53
- existing = self.class.find :first, :conditions => {:slug => proposed_slug + suffix}
54
- if existing
55
- suffix = "-#{i}"
56
- i += 1
57
- else
58
- self.slug = proposed_slug + suffix
59
- end
60
- end
61
- end
62
-
63
- # Create page's path
64
- def create_path
65
- self.path = parent.path + "/#{self.slug}"
66
- end
67
-
68
- # Generate the page's path and save the object
69
- def create_path!
70
- create_path
71
- save
72
- end
73
-
74
- # Update the children's path
75
- def update_children_path
76
- children.each do |child|
77
- create_path!
78
- end
79
- end
80
-
81
- end
@@ -1,18 +0,0 @@
1
- class SlightcmsPagePart < ActiveRecord::Base
2
-
3
- # Associations
4
- belongs_to :page, :class_name => "SlightcmsPage"
5
-
6
- # Validations
7
- validates_presence_of :name
8
- validates_uniqueness_of :name, :scope => :page_id
9
- validates_presence_of :content
10
-
11
- protected
12
-
13
- # Render the part's content
14
- def render_content
15
- RedCloth.new(self.content).to_html
16
- end
17
-
18
- end