kealy_cms 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ class CategoriesController < ApplicationController
2
+ protect_from_forgery
3
+ def show
4
+ @category = Category.find(params[:id])
5
+ respond_to do |format|
6
+ format.html # index.html.erb
7
+ end
8
+ end
9
+ end
@@ -24,7 +24,7 @@ class CmsController < ApplicationController
24
24
  end
25
25
  end
26
26
  def blog
27
- @posts = Post
27
+ @posts = Post.all
28
28
  respond_to do |format|
29
29
  format.html # index.html.erb
30
30
  end
@@ -0,0 +1,20 @@
1
+ class CommentsController < ApplicationController
2
+ protect_from_forgery
3
+ def show
4
+ @comment = Comment.find(params[:id])
5
+ respond_to do |format|
6
+ format.html # index.html.erb
7
+ end
8
+ end
9
+ def index
10
+ @comments = Comment.all
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ end
14
+ end
15
+ def create
16
+ @comment = Comment.new(params[:comment])
17
+ @comment.post_id = Post.find(params[:post_id]).id
18
+ @comment.save
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ class PagesController < ApplicationController
2
+ protect_from_forgery
3
+ def show
4
+ @page = Page.find(params[:id])
5
+ respond_to do |format|
6
+ format.html # index.html.erb
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ class PostsController < ApplicationController
2
+ protect_from_forgery
3
+ def show
4
+ @post = Post.find(params[:id])
5
+ @comment = Comment.new
6
+ @comments = @post.comments.where(:approved=>true)
7
+ @tags = @post.tags
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ end
11
+ end
12
+ def index
13
+ @posts = Post.all
14
+ respond_to do |format|
15
+ format.html # index.html.erb
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ class TagsController < ApplicationController
2
+ protect_from_forgery
3
+ def show
4
+ @tag = Tag.find(params[:id])
5
+ @posts = @tag.posts
6
+ render '/posts/index'
7
+ end
8
+ def index
9
+ @tags = Tag.find(:all)
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ end
13
+ end
14
+ end
@@ -1,2 +1,3 @@
1
1
  class Comment < ActiveRecord::Base
2
+ belongs_to :post
2
3
  end
@@ -1,8 +1,7 @@
1
1
  class Page < ActiveRecord::Base
2
- has_and_belongs_to_many :categories
3
2
  has_many :page_parts
4
3
  accepts_nested_attributes_for :page_parts
5
4
  acts_as_tree
6
- validates_presence_of :title
7
5
  has_friendly_id :title, :use_slug => true
6
+ validates_presence_of :title
8
7
  end
@@ -3,4 +3,6 @@ class PagePart < ActiveRecord::Base
3
3
  def div_title
4
4
  self.title.gsub(/\s+/, "")
5
5
  end
6
+ validates_uniqueness_of :title, :scope => :page_id
7
+ validates_presence_of :title
6
8
  end
@@ -1,4 +1,7 @@
1
1
  class Post < ActiveRecord::Base
2
2
  has_and_belongs_to_many :tags
3
3
  has_and_belongs_to_many :categories
4
+ has_many :comments
5
+ has_friendly_id :title, :use_slug => true
6
+ validates_presence_of :title
4
7
  end
@@ -0,0 +1,7 @@
1
+ <div class="comment">
2
+ <span class="author"><%= comment.author %></span>
3
+ <span class="date"><%= comment.created_at %></span>
4
+ <div class="content">
5
+ <%= comment.content %>
6
+ </div>
7
+ </div>
@@ -0,0 +1,2 @@
1
+ $('#comments-container').html("has been submitted");
2
+ $('#comments-count').html("<%= @comment.post.comments.count %>");
@@ -0,0 +1,12 @@
1
+ <div class="row span3">
2
+ <% @page.page_parts.each do |f| %>
3
+ <%= f.title %>
4
+ <br />
5
+ <% end %>
6
+ </div>
7
+ <div class="row span10">
8
+ <% @page.page_parts.each do |f| %>
9
+ <%= f.content %>
10
+ <br />
11
+ <% end %>
12
+ </div>
@@ -0,0 +1 @@
1
+ Sorry there are no posts matching your criteria.
@@ -0,0 +1,6 @@
1
+ <div class="blog-post">
2
+ <h2 class="title"><%= link_to post.title, post %></h2>
3
+ <div class="content">
4
+ <%= raw post.content %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,13 @@
1
+ <%= form_for [@post, @comment], :remote=>true do |f| %>
2
+ <div class="field">
3
+ <%= f.label :author %><br />
4
+ <%= f.text_field :author %>
5
+ </div>
6
+ <div class="field">
7
+ <%= f.label :content %><br />
8
+ <%= f.text_area :content %>
9
+ </div>
10
+ <div class="actions">
11
+ <%= f.submit %>
12
+ </div>
13
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% if @posts.first %>
2
+ <p>There are <%= @posts.count %> posts matching your selection.</p>
3
+ <%= render :partial => "/posts/blog/post", :collection => @posts, :as => "post" %>
4
+ <% else %>
5
+ <%= render '/posts/blog/no_post' %>
6
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <h2><%= @post.title %></h2>
2
+ <div class="post">
3
+ <%= raw @post.content %>
4
+ </div>
5
+
6
+ <div class="tags">
7
+ <%= render :partial => "/tags/tag", :collection => @post.tags, :as => "tag" %>
8
+ </div>
9
+
10
+
11
+
12
+
13
+ <% if @comments.first %>
14
+ There are <span id="comments-count"><%= @comments.count %></span> comments.
15
+ <% else %>
16
+ There are no comments.
17
+ <% end %>
18
+
19
+
20
+
21
+ <%= render :partial => "/comments/comment", :collection => @post.comments, :as => "comment" %>
22
+
23
+
24
+ <div id="comments-container"></div>
25
+
26
+
27
+
28
+ <%= render '/posts/comments/form' %>
@@ -0,0 +1 @@
1
+ <%= link_to tag.name, tag %><br />
@@ -1,7 +1,9 @@
1
1
  Rails.application.routes.draw do
2
- match '/blog' => 'cms#blog'
3
- match '/blog/:id' => 'cms#post'
4
- match '/categories/:id' => 'cms#category'
5
- match '/tags/:id' => 'cms#tag'
6
- match '/:id' => 'cms#page'
2
+ # resources :pages
3
+ resources :posts, :only => [:show, :index] do
4
+ resources :comments
5
+ end
6
+ resources :categories, :only => [:show, :index]
7
+ resources :tags, :only => [:show, :index]
8
+ resources :pages, :only => [:show], :path => "/"
7
9
  end
@@ -3,6 +3,7 @@ class CreateCms < ActiveRecord::Migration
3
3
  create_table :posts do |t|
4
4
  t.string :title
5
5
  t.text :content
6
+ t.integer :post_id
6
7
 
7
8
  t.timestamps
8
9
  end
@@ -49,7 +50,7 @@ class CreateCms < ActiveRecord::Migration
49
50
  t.integer :parent_id
50
51
  t.integer :post_id
51
52
  t.boolean :approved
52
- t.string :author_name
53
+ t.string :author
53
54
  t.string :author_website
54
55
  t.string :author_email
55
56
  t.text :content
@@ -0,0 +1,20 @@
1
+
2
+
3
+ Started GET "/" for 127.0.0.1 at 2011-10-29 12:54:10 +0530
4
+
5
+ SQLite3::CantOpenException (unable to open database file):
6
+
7
+
8
+ Rendered /home/john/.rvm/gems/ruby-1.9.2-p290@thrasys/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.4ms)
9
+ Rendered /home/john/.rvm/gems/ruby-1.9.2-p290@thrasys/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (32.4ms)
10
+ Rendered /home/john/.rvm/gems/ruby-1.9.2-p290@thrasys/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (61.9ms)
11
+
12
+
13
+ Started GET "/foo" for 127.0.0.1 at 2011-10-29 12:54:13 +0530
14
+
15
+ SQLite3::CantOpenException (unable to open database file):
16
+
17
+
18
+ Rendered /home/john/.rvm/gems/ruby-1.9.2-p290@thrasys/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
19
+ Rendered /home/john/.rvm/gems/ruby-1.9.2-p290@thrasys/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.6ms)
20
+ Rendered /home/john/.rvm/gems/ruby-1.9.2-p290@thrasys/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.0ms)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kealy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-27 00:00:00.000000000Z
12
+ date: 2011-10-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &22736300 !ruby/object:Gem::Requirement
16
+ requirement: &21506920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *22736300
24
+ version_requirements: *21506920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &22735640 !ruby/object:Gem::Requirement
27
+ requirement: &21503960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *22735640
35
+ version_requirements: *21503960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: friendly_id
38
- requirement: &22734660 !ruby/object:Gem::Requirement
38
+ requirement: &21501880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *22734660
46
+ version_requirements: *21501880
47
47
  description: ditto above
48
48
  email:
49
49
  - jdkealy@gmail.com
@@ -51,8 +51,24 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
+ - app/controllers/comments_controller.rb
55
+ - app/controllers/pages_controller.rb
56
+ - app/controllers/posts_controller.rb
57
+ - app/controllers/categories_controller.rb
58
+ - app/controllers/tags_controller.rb
54
59
  - app/controllers/cms_controller.rb
55
- - app/views/cms/blog.html.erb
60
+ - app/views/tags/_tag.html.erb
61
+ - app/views/pages/show.html.erb
62
+ - app/views/comments/_comment.html.erb
63
+ - app/views/comments/create.js.erb
64
+ - app/views/posts/show.html.erb
65
+ - app/views/posts/comments/_form.html.erb
66
+ - app/views/posts/blog/_no_post.html.erb
67
+ - app/views/posts/blog/_post.html.erb
68
+ - app/views/posts/blog/post/_comment.html.erb
69
+ - app/views/posts/blog/post/_meta.html.erb
70
+ - app/views/posts/blog/post/_comments.html.erb
71
+ - app/views/posts/index.html.erb
56
72
  - app/views/cms/page.html.erb
57
73
  - app/models/page_part.rb
58
74
  - app/models/comment.rb
@@ -92,6 +108,7 @@ files:
92
108
  - test/dummy/app/controllers/application_controller.rb
93
109
  - test/dummy/app/views/layouts/application.html.erb
94
110
  - test/dummy/config.ru
111
+ - test/dummy/log/development.log
95
112
  - test/dummy/Rakefile
96
113
  - test/dummy/config/environment.rb
97
114
  - test/dummy/config/locales/en.yml
@@ -157,6 +174,7 @@ test_files:
157
174
  - test/dummy/app/controllers/application_controller.rb
158
175
  - test/dummy/app/views/layouts/application.html.erb
159
176
  - test/dummy/config.ru
177
+ - test/dummy/log/development.log
160
178
  - test/dummy/Rakefile
161
179
  - test/dummy/config/environment.rb
162
180
  - test/dummy/config/locales/en.yml
@@ -1 +0,0 @@
1
- hi