sofa_blog 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -1
- data/Gemfile.lock +83 -65
- data/LICENSE +1 -1
- data/README.md +27 -23
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/sofa_blog/application.js +7 -0
- data/app/assets/javascripts/sofa_blog/posts.js +2 -0
- data/app/assets/stylesheets/sofa_blog/admin.css +57 -0
- data/app/assets/stylesheets/sofa_blog/application.css +73 -0
- data/app/assets/stylesheets/sofa_blog/reset.css +1 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/sofa_blog/admin/base_controller.rb +3 -0
- data/app/controllers/sofa_blog/admin/comments_controller.rb +74 -0
- data/app/controllers/sofa_blog/admin/posts_controller.rb +55 -0
- data/app/controllers/sofa_blog/posts_controller.rb +13 -0
- data/app/helpers/sofa_blog/posts_helper.rb +2 -0
- data/app/helpers/sofa_blog_helper.rb +12 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/sofa_blog/comment.rb +53 -0
- data/app/models/{blog_post.rb → sofa_blog/post.rb} +25 -25
- data/app/models/{blog_tag.rb → sofa_blog/tag.rb} +11 -10
- data/app/models/sofa_blog/tagging.rb +9 -0
- data/app/views/layouts/application.html.erb +17 -0
- data/app/views/sofa_blog/admin/_html_head.html.erb +1 -0
- data/app/views/sofa_blog/admin/_navigation.html.erb +1 -0
- data/app/views/sofa_blog/admin/comments/_comment.html.erb +21 -0
- data/app/views/sofa_blog/admin/comments/_form.html.erb +27 -0
- data/app/views/sofa_blog/admin/comments/_status.html.erb +7 -0
- data/app/views/sofa_blog/admin/comments/approve.js.erb +1 -0
- data/app/views/sofa_blog/admin/comments/disapprove.js.erb +1 -0
- data/app/views/sofa_blog/admin/comments/edit.html.erb +6 -0
- data/app/views/sofa_blog/admin/comments/index.html.erb +7 -0
- data/app/views/sofa_blog/admin/comments/new.html.erb +14 -0
- data/app/views/sofa_blog/admin/posts/_form.html.erb +35 -0
- data/app/views/sofa_blog/admin/posts/_post.html.erb +21 -0
- data/app/views/sofa_blog/admin/posts/edit.html.erb +5 -0
- data/app/views/sofa_blog/admin/posts/index.html.erb +7 -0
- data/app/views/sofa_blog/admin/posts/new.html.erb +5 -0
- data/app/views/sofa_blog/posts/_post.html.erb +21 -0
- data/app/views/sofa_blog/posts/index.html.erb +5 -0
- data/config/application.rb +48 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +25 -0
- data/{tmp → config}/environment.rb +0 -1
- data/config/environments/development.rb +33 -0
- data/config/environments/production.rb +51 -0
- data/config/environments/test.rb +42 -0
- data/config/initializers/secret_token.rb +3 -0
- data/config/initializers/sofa_blog.rb +12 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +14 -9
- data/config.ru +4 -0
- data/db/migrate/01_create_sofa_blog.rb +29 -28
- data/db/schema.rb +59 -0
- data/db/seeds.rb +7 -0
- data/lib/sofa_blog/configuration.rb +21 -0
- data/lib/sofa_blog/engine.rb +13 -10
- data/lib/sofa_blog/form_builder.rb +50 -0
- data/lib/sofa_blog.rb +21 -2
- data/script/rails +6 -0
- data/sofa_blog.gemspec +89 -47
- data/test/fixtures/.gitkeep +0 -0
- data/test/fixtures/sofa_blog/comments.yml +6 -0
- data/test/fixtures/sofa_blog/posts.yml +7 -0
- data/test/functional/.gitkeep +0 -0
- data/test/functional/sofa_blog/admin/comments_controller_test.rb +59 -0
- data/test/functional/sofa_blog/admin/posts_controller_test.rb +76 -0
- data/test/functional/sofa_blog/posts_controller_test.rb +7 -0
- data/test/test_helper.rb +37 -0
- data/test/unit/.gitkeep +0 -0
- data/test/unit/comment_test.rb +55 -0
- data/test/unit/helpers/sofa_blog/posts_helper_test.rb +4 -0
- data/test/unit/post_test.rb +44 -0
- data/test/unit/tag_test.rb +7 -0
- data/test/unit/tagging_test.rb +7 -0
- metadata +145 -103
- data/.DS_Store +0 -0
- data/app/.DS_Store +0 -0
- data/app/controllers/cms_admin/blog_comments_controller.rb +0 -66
- data/app/controllers/cms_admin/blog_posts_controller.rb +0 -48
- data/app/models/blog_comment.rb +0 -45
- data/app/models/blog_tagging.rb +0 -8
- data/app/views/.DS_Store +0 -0
- data/app/views/cms_admin/blog_comments/_blog_comment.html.erb +0 -22
- data/app/views/cms_admin/blog_comments/_form.html.erb +0 -24
- data/app/views/cms_admin/blog_comments/_status.html.erb +0 -7
- data/app/views/cms_admin/blog_comments/approve.rjs +0 -1
- data/app/views/cms_admin/blog_comments/disapprove.rjs +0 -1
- data/app/views/cms_admin/blog_comments/edit.html.erb +0 -7
- data/app/views/cms_admin/blog_comments/index.html.erb +0 -7
- data/app/views/cms_admin/blog_comments/new.html.erb +0 -6
- data/app/views/cms_admin/blog_posts/_blog_post.html.erb +0 -21
- data/app/views/cms_admin/blog_posts/_form.html.erb +0 -33
- data/app/views/cms_admin/blog_posts/edit.html.erb +0 -7
- data/app/views/cms_admin/blog_posts/index.html.erb +0 -8
- data/app/views/cms_admin/blog_posts/new.html.erb +0 -5
- data/app/views/sofa_blog/_head.html.erb +0 -1
- data/app/views/sofa_blog/_nav.html.erb +0 -1
- data/config/.DS_Store +0 -0
- data/doc/sofa.png +0 -0
- data/lib/generators/README +0 -12
- data/lib/generators/blog_generator.rb +0 -33
- data/public/stylesheets/content.css +0 -53
- data/tmp/application.rb +0 -15
- data/tmp/boot.rb +0 -13
- data/tmp/initializers/formatted_form_builder.rb +0 -141
- data/tmp/initializers/wristband.rb +0 -1
- /data/{public/javascripts/jquery.autocomplete.pack.js → app/assets/javascripts/sofa_blog/jquery.autocomplete.js} +0 -0
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,83 +1,101 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rack (~> 1.
|
15
|
-
rack-mount (~> 0.
|
16
|
-
rack-test (~> 0.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
builder (~>
|
22
|
-
i18n (~> 0.
|
23
|
-
activerecord (3.0.
|
24
|
-
activemodel (= 3.0.
|
25
|
-
activesupport (= 3.0.
|
26
|
-
arel (~> 2.
|
27
|
-
tzinfo (~> 0.3.
|
28
|
-
activeresource (3.0.
|
29
|
-
activemodel (= 3.0.
|
30
|
-
activesupport (= 3.0.
|
31
|
-
activesupport (3.0.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
4
|
+
actionmailer (3.1.0.rc8)
|
5
|
+
actionpack (= 3.1.0.rc8)
|
6
|
+
mail (~> 2.3.0)
|
7
|
+
actionpack (3.1.0.rc8)
|
8
|
+
activemodel (= 3.1.0.rc8)
|
9
|
+
activesupport (= 3.1.0.rc8)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
i18n (~> 0.6)
|
13
|
+
rack (~> 1.3.2)
|
14
|
+
rack-cache (~> 1.0.3)
|
15
|
+
rack-mount (~> 0.8.2)
|
16
|
+
rack-test (~> 0.6.1)
|
17
|
+
sprockets (~> 2.0.0.beta.15)
|
18
|
+
activemodel (3.1.0.rc8)
|
19
|
+
activesupport (= 3.1.0.rc8)
|
20
|
+
bcrypt-ruby (~> 3.0.0)
|
21
|
+
builder (~> 3.0.0)
|
22
|
+
i18n (~> 0.6)
|
23
|
+
activerecord (3.1.0.rc8)
|
24
|
+
activemodel (= 3.1.0.rc8)
|
25
|
+
activesupport (= 3.1.0.rc8)
|
26
|
+
arel (~> 2.2.1)
|
27
|
+
tzinfo (~> 0.3.29)
|
28
|
+
activeresource (3.1.0.rc8)
|
29
|
+
activemodel (= 3.1.0.rc8)
|
30
|
+
activesupport (= 3.1.0.rc8)
|
31
|
+
activesupport (3.1.0.rc8)
|
32
|
+
multi_json (~> 1.0)
|
33
|
+
arel (2.2.1)
|
34
|
+
bcrypt-ruby (3.0.0)
|
35
|
+
builder (3.0.0)
|
36
|
+
erubis (2.7.0)
|
37
|
+
git (1.2.5)
|
38
|
+
hike (1.2.1)
|
39
|
+
i18n (0.6.0)
|
40
|
+
jeweler (1.6.4)
|
41
|
+
bundler (~> 1.0)
|
42
|
+
git (>= 1.2.5)
|
43
|
+
rake
|
44
|
+
jquery-rails (1.0.14)
|
45
|
+
railties (~> 3.0)
|
46
|
+
thor (~> 0.14)
|
47
|
+
mail (2.3.0)
|
47
48
|
i18n (>= 0.4.0)
|
48
49
|
mime-types (~> 1.16)
|
49
50
|
treetop (~> 1.4.8)
|
50
51
|
mime-types (1.16)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
rack-mount (0.
|
52
|
+
multi_json (1.0.3)
|
53
|
+
polyglot (0.3.2)
|
54
|
+
rack (1.3.2)
|
55
|
+
rack-cache (1.0.3)
|
56
|
+
rack (>= 0.4)
|
57
|
+
rack-mount (0.8.2)
|
57
58
|
rack (>= 1.0.0)
|
58
|
-
rack-
|
59
|
+
rack-ssl (1.3.2)
|
60
|
+
rack
|
61
|
+
rack-test (0.6.1)
|
59
62
|
rack (>= 1.0)
|
60
|
-
rails (3.0.
|
61
|
-
actionmailer (= 3.0.
|
62
|
-
actionpack (= 3.0.
|
63
|
-
activerecord (= 3.0.
|
64
|
-
activeresource (= 3.0.
|
65
|
-
activesupport (= 3.0.
|
63
|
+
rails (3.1.0.rc8)
|
64
|
+
actionmailer (= 3.1.0.rc8)
|
65
|
+
actionpack (= 3.1.0.rc8)
|
66
|
+
activerecord (= 3.1.0.rc8)
|
67
|
+
activeresource (= 3.1.0.rc8)
|
68
|
+
activesupport (= 3.1.0.rc8)
|
66
69
|
bundler (~> 1.0)
|
67
|
-
railties (= 3.0.
|
68
|
-
railties (3.0.
|
69
|
-
actionpack (= 3.0.
|
70
|
-
activesupport (= 3.0.
|
70
|
+
railties (= 3.1.0.rc8)
|
71
|
+
railties (3.1.0.rc8)
|
72
|
+
actionpack (= 3.1.0.rc8)
|
73
|
+
activesupport (= 3.1.0.rc8)
|
74
|
+
rack-ssl (~> 1.3.2)
|
71
75
|
rake (>= 0.8.7)
|
72
|
-
|
73
|
-
|
76
|
+
rdoc (~> 3.4)
|
77
|
+
thor (~> 0.14.6)
|
78
|
+
rake (0.9.2)
|
79
|
+
rdoc (3.9.4)
|
80
|
+
rinku (1.2.2)
|
81
|
+
sprockets (2.0.0)
|
82
|
+
hike (~> 1.2)
|
83
|
+
rack (~> 1.0)
|
84
|
+
tilt (!= 1.3.0, ~> 1.1)
|
85
|
+
sqlite3 (1.3.4)
|
74
86
|
thor (0.14.6)
|
75
|
-
|
87
|
+
tilt (1.3.3)
|
88
|
+
treetop (1.4.10)
|
89
|
+
polyglot
|
76
90
|
polyglot (>= 0.3.1)
|
77
|
-
tzinfo (0.3.
|
91
|
+
tzinfo (0.3.29)
|
78
92
|
|
79
93
|
PLATFORMS
|
80
94
|
ruby
|
81
95
|
|
82
96
|
DEPENDENCIES
|
83
|
-
|
97
|
+
jeweler
|
98
|
+
jquery-rails
|
99
|
+
rails (>= 3.1.0.rc8)
|
100
|
+
rinku (>= 1.2.2)
|
101
|
+
sqlite3
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Sofa Blog
|
2
2
|
|
3
|
-
Sofa Blog is an
|
3
|
+
Sofa Blog is an simple blog management engine for Rails 3.1 apps. As a bonus it integrates seamlessly with [ComfortableMexicanSofa](https://github.com/twg/comfortable-mexican-sofa) (microCMS)
|
4
4
|
|
5
|
+
---
|
5
6
|
## Installation
|
6
7
|
|
7
8
|
Add gem definition to your Gemfile:
|
@@ -14,17 +15,27 @@ Then from the Rails project's root run:
|
|
14
15
|
rails g blog
|
15
16
|
rake db:migrate
|
16
17
|
|
18
|
+
You can immediately access it by going to
|
19
|
+
|
20
|
+
/posts
|
21
|
+
/admin/posts
|
22
|
+
|
23
|
+
|
24
|
+
---
|
25
|
+
|
17
26
|
## Usage
|
18
27
|
|
19
|
-
|
28
|
+
If you are using SofaBlog on it's own take a look in the initializer: `/config/initializers/sofa_blog.rb`. You probably want to set the admin controller to be something that handles user authentication within your app. Same goes for the `admin_route_prefix`.
|
29
|
+
|
30
|
+
If you are using SofaBlog in conjunction with ComfortableMexicanSofa everything will be configured automatically.
|
20
31
|
|
21
32
|
### The Blog Post
|
22
33
|
|
23
|
-
@post =
|
34
|
+
@post = SofaBlog::Post.first # Grab the first post
|
24
35
|
@post.title # The title of the post
|
25
36
|
@post.author # The name of the author
|
26
37
|
@post.content # The content of the post
|
27
|
-
@post.
|
38
|
+
@post.is_published? # Returns true if the post has been published
|
28
39
|
@post.created_at # Created at
|
29
40
|
@post.updated_at # Updated at
|
30
41
|
@post.comments_count # The total number of comments
|
@@ -32,35 +43,28 @@ After finishing installation you should be able to navigate to the CMS admin are
|
|
32
43
|
|
33
44
|
A blog post can be tagged with a comma separared list of words.
|
34
45
|
|
35
|
-
@post.
|
46
|
+
@post.tags.collect(&:name).join(', ') # Returns a comma-separated list of tags in the post
|
36
47
|
|
37
48
|
|
38
49
|
A few scopes are also available for your convenience:
|
39
50
|
|
40
|
-
|
41
|
-
|
42
|
-
|
51
|
+
SofaBlog::Post.published # All the published posts
|
52
|
+
SofaBlog::Post.tagged_with(params[:tag_id].to_i) # All the posts tagged with a specific tag_id
|
53
|
+
SofaBlog::Post.published.tagged_with(params[:tag_id].to_i) # All the published posts tagged with a specific tag_id
|
43
54
|
|
44
55
|
### The Comments
|
45
56
|
|
46
|
-
@comment = @post.
|
47
|
-
@comment.name
|
48
|
-
@comment.email
|
49
|
-
@comment.content
|
50
|
-
@comment.
|
51
|
-
@comment.
|
52
|
-
|
57
|
+
@comment = @post.comments.first # Grab the first comment
|
58
|
+
@comment.name # The name of the author
|
59
|
+
@comment.email # The email of the author
|
60
|
+
@comment.content # The comment
|
61
|
+
@comment.is_approved? # Returns true if the comment has been approved
|
62
|
+
@comment.created_at # Created at
|
63
|
+
@comment.updated_at # Updated at
|
64
|
+
|
53
65
|
|
54
|
-
## Dependencies
|
55
|
-
|
56
|
-
Sofa Blog depends on:
|
57
|
-
|
58
|
-
* **[ComfortableMexicanSofa](https://github.com/twg/comfortable-mexican-sofa)** - A tiny and powerful micro CMS for your Rails 3 application
|
59
|
-
|
60
66
|
* * *
|
61
67
|
|
62
|
-
![Looks pretty comfortable to me. No idea what makes it Mexican.](https://github.com/twg/sofa-blog/raw/master/doc/sofa.png)
|
63
|
-
|
64
68
|
Sofa Blog is released under the [MIT license](https://github.com/twg/sofa-blog/raw/master/LICENSE)
|
65
69
|
|
66
70
|
Copyright 2011 Jack Neto, [The Working Group Inc](http://www.twg.ca)
|
data/Rakefile
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
1
|
+
require File.expand_path('../config/application', __FILE__)
|
2
|
+
|
3
|
+
SofaBlog::Application.load_tasks
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'jeweler'
|
7
7
|
Jeweler::Tasks.new do |gem|
|
8
8
|
gem.name = 'sofa_blog'
|
9
|
-
gem.
|
9
|
+
gem.homepage = 'http://github.com/twg/sofa-blog'
|
10
|
+
gem.license = 'MIT'
|
11
|
+
gem.summary = 'SofaBlog is a blog engine for Rails 3.1 apps (and ComfortableMexicanSofa)'
|
10
12
|
gem.description = ''
|
11
13
|
gem.email = 'jack@theworkinggroup.ca'
|
12
|
-
gem.
|
13
|
-
gem.
|
14
|
-
gem.add_dependency('comfortable_mexican_sofa', '>=1.0.46')
|
14
|
+
gem.authors = ['Jack Neto', 'The Working Group Inc.']
|
15
|
+
gem.version = File.read('VERSION').chomp
|
15
16
|
end
|
16
17
|
Jeweler::GemcutterTasks.new
|
17
18
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require_tree .
|
@@ -0,0 +1,57 @@
|
|
1
|
+
/* === List items === */
|
2
|
+
ul.list.posts li .item .label,
|
3
|
+
ul.list.comments li .item .label {
|
4
|
+
margin-left: 0px ! important;
|
5
|
+
}
|
6
|
+
ul.list.comments li .item .label .sublabel em {
|
7
|
+
margin-left: 5px;
|
8
|
+
}
|
9
|
+
ul.list.comments li .item .content {
|
10
|
+
font-size: 11px;
|
11
|
+
font-weight: normal;
|
12
|
+
margin: 5px 0px 0 35px;
|
13
|
+
}
|
14
|
+
|
15
|
+
/* === Tags === */
|
16
|
+
span.tag {
|
17
|
+
font-size: 10px;
|
18
|
+
padding: 1px 5px;
|
19
|
+
background-color: #d5d5d5;
|
20
|
+
border-radius: 2px;
|
21
|
+
-moz-border-radius: 2px;
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
/* === Autocomplete === */
|
26
|
+
.ac_results {
|
27
|
+
padding: 0px;
|
28
|
+
border: 1px solid #999;
|
29
|
+
background-color: white;
|
30
|
+
overflow: hidden;
|
31
|
+
z-index: 99999;
|
32
|
+
color: #666;
|
33
|
+
}
|
34
|
+
.ac_results ul {
|
35
|
+
width: 100%;
|
36
|
+
list-style-position: outside;
|
37
|
+
list-style: none;
|
38
|
+
padding: 0;
|
39
|
+
margin: 0;
|
40
|
+
}
|
41
|
+
.ac_results ul li {
|
42
|
+
margin: 0px;
|
43
|
+
padding: 2px 5px;
|
44
|
+
cursor: default;
|
45
|
+
display: block;
|
46
|
+
font-size: 12px;
|
47
|
+
line-height: 16px;
|
48
|
+
overflow: hidden;
|
49
|
+
}
|
50
|
+
|
51
|
+
.ac_odd {
|
52
|
+
background-color: #eee;
|
53
|
+
}
|
54
|
+
.ac_over {
|
55
|
+
background-color: #C4EAF6;
|
56
|
+
color: #000;
|
57
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/*
|
2
|
+
= require ./reset
|
3
|
+
= require_self
|
4
|
+
*/
|
5
|
+
|
6
|
+
body {
|
7
|
+
padding: 25px;
|
8
|
+
font: 13px/18px Arial, sans-serif;
|
9
|
+
}
|
10
|
+
h1 {
|
11
|
+
font: bold 26px/34px Arial, sans-serif;
|
12
|
+
margin-bottom: 15px;
|
13
|
+
}
|
14
|
+
h2 {
|
15
|
+
font: bold 18px/20px Arial, sans-serif;
|
16
|
+
margin-bottom: 10px;
|
17
|
+
}
|
18
|
+
a {
|
19
|
+
color: #3875D7;
|
20
|
+
text-decoration: none;
|
21
|
+
}
|
22
|
+
a:hover {
|
23
|
+
text-decoration: underline;
|
24
|
+
}
|
25
|
+
table.formatted td,
|
26
|
+
table.formatted th {
|
27
|
+
padding: 2px 5px;
|
28
|
+
border-bottom: 1px dotted #ccc;
|
29
|
+
}
|
30
|
+
table.formatted th {
|
31
|
+
background-color: #666;
|
32
|
+
color: #fff;
|
33
|
+
}
|
34
|
+
table.formatted td img {
|
35
|
+
float: left;
|
36
|
+
padding: 2px;
|
37
|
+
margin-right: 2px;
|
38
|
+
}
|
39
|
+
table.formatted td .sublabel {
|
40
|
+
font-size: 11px;
|
41
|
+
line-height: 11px;
|
42
|
+
color: #888;
|
43
|
+
}
|
44
|
+
|
45
|
+
.form_element {
|
46
|
+
overflow: hidden;
|
47
|
+
margin-bottom: 5px;
|
48
|
+
}
|
49
|
+
.form_element .label {
|
50
|
+
width: 125px;
|
51
|
+
float: left;
|
52
|
+
text-align: right;
|
53
|
+
}
|
54
|
+
.form_element .value,
|
55
|
+
.form_element .errors {
|
56
|
+
margin-left: 135px;
|
57
|
+
}
|
58
|
+
.form_element .value input[type='text'],
|
59
|
+
.form_element .value textarea {
|
60
|
+
width: 400px;
|
61
|
+
}
|
62
|
+
|
63
|
+
.jcrop-holder {
|
64
|
+
margin-bottom: 15px;
|
65
|
+
}
|
66
|
+
|
67
|
+
.flash{
|
68
|
+
border: 2px solid #ccc;
|
69
|
+
padding: 10px;
|
70
|
+
margin-bottom: 15px;
|
71
|
+
text-align: center;
|
72
|
+
}
|
73
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var,optgroup{font-style:inherit;font-weight:inherit;}del,ins{text-decoration:none;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:baseline;}sub{vertical-align:baseline;}legend{color:#000;}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;}input,button,textarea,select{*font-size:100%;}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class SofaBlog::Admin::CommentsController < SofaBlog::Admin::BaseController
|
2
|
+
|
3
|
+
before_filter :load_post
|
4
|
+
before_filter :load_comment, :only => [:show, :edit, :update, :destroy, :approve, :disapprove]
|
5
|
+
before_filter :build_comment, :only => [:new, :create]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@comments = SofaBlog::Comment.order('created_at DESC')
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
render
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
render
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@comment.save!
|
21
|
+
flash[:notice] = 'Comment created'
|
22
|
+
redirect_to :action => :index
|
23
|
+
rescue ActiveRecord::RecordInvalid
|
24
|
+
flash.now[:error] = 'Failed to create Comment'
|
25
|
+
render :action => :new
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit
|
29
|
+
render
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
@comment.update_attributes(params[:comment])
|
34
|
+
flash[:notice] = 'Comment updated'
|
35
|
+
redirect_to :action => :index
|
36
|
+
rescue ActiveRecord::RecordInvalid
|
37
|
+
flash.now[:error] = 'Failed to update Comment'
|
38
|
+
render :action => :edit
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
@comment.destroy
|
43
|
+
flash[:notice] = 'Comment removed'
|
44
|
+
redirect_to :action => :index
|
45
|
+
end
|
46
|
+
|
47
|
+
def approve
|
48
|
+
@comment.approve!
|
49
|
+
end
|
50
|
+
|
51
|
+
def disapprove
|
52
|
+
@comment.disapprove!
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def load_post
|
58
|
+
@post = SofaBlog::Post.find(params[:post_id])
|
59
|
+
rescue ActiveRecord::RecordNotFound
|
60
|
+
flash[:error] = 'Blog post not found'
|
61
|
+
redirect_to sofa_blog_admin_posts_path
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_comment
|
65
|
+
@comment = SofaBlog::Comment.find(params[:id])
|
66
|
+
rescue ActiveRecord::RecordNotFound
|
67
|
+
flash[:error] = 'Comment not found'
|
68
|
+
redirect_to :action => :index
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_comment
|
72
|
+
@comment = @post.comments.build(params[:comment])
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class SofaBlog::Admin::PostsController < SofaBlog::Admin::BaseController
|
2
|
+
|
3
|
+
before_filter :build_post, :only => [:new, :create]
|
4
|
+
before_filter :load_post, :only => [:edit, :update, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@posts = SofaBlog::Post.order('created_at DESC')
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@post.is_published ||= true
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@post.save!
|
16
|
+
flash[:notice] = 'Blog post created'
|
17
|
+
redirect_to :action => :index
|
18
|
+
rescue ActiveRecord::RecordInvalid
|
19
|
+
flash.now[:error] = 'Failed to create BlogPost'
|
20
|
+
render :action => :new
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
render
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
@post.update_attributes!(params[:post])
|
29
|
+
flash[:notice] = 'Blog post updated'
|
30
|
+
redirect_to :action => :index
|
31
|
+
rescue ActiveRecord::RecordInvalid
|
32
|
+
flash.now[:error] = 'Failed to update BlogPost'
|
33
|
+
render :action => :edit
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@post.destroy
|
38
|
+
flash[:notice] = 'Blog post removed'
|
39
|
+
redirect_to :action => :index
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def load_post
|
45
|
+
@post = SofaBlog::Post.find(params[:id])
|
46
|
+
rescue ActiveRecord::RecordNotFound
|
47
|
+
flash[:error] = 'Blog post not found'
|
48
|
+
redirect_to :action => :index
|
49
|
+
end
|
50
|
+
|
51
|
+
def build_post
|
52
|
+
@post = SofaBlog::Post.new(params[:post])
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class SofaBlog::PostsController < ApplicationController
|
2
|
+
def index
|
3
|
+
@posts = SofaBlog::Post.published.all
|
4
|
+
rescue ActiveRecord::RecordNotFound
|
5
|
+
render :text => 'Post not found', :status => 404
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
@post = SofaBlog::Post.find(params[:id])
|
10
|
+
rescue ActiveRecord::RecordNotFound
|
11
|
+
render :text => 'Post not found', :status => 404
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SofaBlogHelper
|
2
|
+
|
3
|
+
def sofa_blog_form_for(record_or_name_or_array, *args, &proc)
|
4
|
+
options = args.extract_options!
|
5
|
+
form_for(
|
6
|
+
record_or_name_or_array,
|
7
|
+
*(args << options.merge(:builder => SofaBlog.config.form_builder.to_s.constantize)),
|
8
|
+
&proc
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
data/app/models/.gitkeep
ADDED
File without changes
|