blogit 1.0.0.rc1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -31
- data/Rakefile +6 -2
- data/app/assets/stylesheets/blogit/themes/default.css +4 -0
- data/app/assets/stylesheets/blogit/themes/default.css.map +7 -0
- data/app/assets/stylesheets/blogit/themes/default.min.css +2 -0
- data/app/assets/stylesheets/blogit/themes/default.min.css.map +7 -0
- data/app/assets/stylesheets/blogit/themes/default.sass +2 -0
- data/app/assets/stylesheets/blogit/themes/default/base/_colors.sass +1 -0
- data/app/assets/stylesheets/blogit/themes/default/base/_typography.sass +1 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_archives.sass +18 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_comments.sass +7 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_forms.sass +9 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_headers.sass +4 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_posts.sass +8 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_related_posts_list.sass +3 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_share_bars.sass +7 -0
- data/app/{views/blogit/posts/_no_comments.html.erb → assets/stylesheets/blogit/themes/default/blocks/_tag_list.sass} +0 -0
- data/app/assets/stylesheets/blogit/themes/default/blocks/_tags.sass +4 -0
- data/app/controllers/blogit/application_controller.rb +15 -31
- data/app/controllers/blogit/comments_controller.rb +48 -30
- data/app/controllers/blogit/posts_controller.rb +52 -86
- data/app/helpers/blogit/application_helper.rb +59 -69
- data/app/helpers/blogit/comments_helper.rb +20 -0
- data/app/helpers/blogit/layout_helper.rb +33 -0
- data/app/helpers/blogit/posts_helper.rb +36 -34
- data/app/models/blogit/post.rb +55 -6
- data/app/views/blogit/archive/_list.html.erb +5 -0
- data/app/views/blogit/archive/_month.html.erb +9 -0
- data/app/views/blogit/archive/_year.html.erb +7 -0
- data/app/views/blogit/{posts → comments}/_active_record_comments.html.erb +2 -1
- data/app/views/blogit/comments/_comment.html.erb +10 -14
- data/app/views/blogit/comments/_comments_count.html.erb +8 -0
- data/app/views/blogit/{posts → comments}/_disqus_comments.html.erb +0 -0
- data/app/views/blogit/comments/_form.html.erb +25 -18
- data/app/views/blogit/comments/_no_comments.html.erb +0 -0
- data/app/views/blogit/comments/create.js.erb +2 -2
- data/app/views/blogit/posts/_archiveable.html.erb +3 -0
- data/app/views/blogit/posts/_blog_post_spacer.html.erb +1 -1
- data/app/views/blogit/posts/_blogger_information.html.erb +9 -4
- data/app/views/blogit/posts/_meta_tags.html.erb +32 -0
- data/app/views/blogit/posts/_post.html.erb +6 -9
- data/app/views/blogit/posts/_post_footer.html.erb +1 -0
- data/app/views/blogit/posts/_post_head.html.erb +3 -2
- data/app/views/blogit/posts/_related.html.erb +7 -16
- data/app/views/blogit/posts/_related_post.html.erb +4 -0
- data/app/views/blogit/posts/_share_bar.html.erb +5 -6
- data/app/views/blogit/posts/_tags.html.erb +8 -0
- data/app/views/blogit/posts/index.html.erb +16 -11
- data/app/views/blogit/posts/show.html.erb +28 -4
- data/app/views/blogit/tags/_tag.html.erb +3 -0
- data/config/locales/en.yml +3 -2
- data/config/spring.rb +1 -0
- data/db/migrate/20150618184415_add_description_to_posts.rb +5 -0
- data/lib/blogit.rb +4 -5
- data/lib/blogit/archive.rb +8 -0
- data/lib/blogit/archive/archive_error.rb +3 -0
- data/lib/blogit/archive/archiveable.rb +20 -0
- data/lib/blogit/archive/list.rb +52 -0
- data/lib/blogit/archive/month.rb +34 -0
- data/lib/blogit/archive/year.rb +40 -0
- data/lib/blogit/blogs.rb +11 -5
- data/lib/blogit/configuration.rb +157 -147
- data/lib/blogit/parsers/html_parser.rb +6 -3
- data/lib/blogit/parsers/markdown_parser.rb +30 -5
- data/lib/blogit/parsers/textile_parser.rb +18 -8
- data/lib/blogit/renderers/html_with_albino.rb +1 -1
- data/lib/blogit/version.rb +1 -1
- data/lib/generators/templates/blogit.rb +23 -57
- data/lib/tasks/blogit.rake +42 -0
- data/lib/tasks/blogit/css.rake +22 -0
- data/lib/tasks/blogit/doc.rake +21 -0
- data/lib/tasks/seed_blog_posts.yml +95 -0
- data/lib/validators/absence_validator.rb +2 -2
- data/spec/blogit_spec.rb +3 -3
- data/spec/controllers/blogit/comments_controller_spec.rb +31 -86
- data/spec/controllers/blogit/posts_controller_spec.rb +33 -344
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/stylesheets/application.sass +7 -0
- data/spec/dummy/app/assets/stylesheets/base.sass +1 -0
- data/spec/dummy/app/assets/stylesheets/base/_html.sass +15 -0
- data/spec/dummy/app/assets/stylesheets/blocks.sass +1 -0
- data/spec/dummy/app/assets/stylesheets/blocks/_layout.sass +21 -0
- data/spec/dummy/app/views/layouts/application.html.erb +21 -18
- data/spec/dummy/app/views/layouts/custom.html.erb +2 -1
- data/spec/dummy/config.ru +0 -1
- data/spec/dummy/config/application.rb +1 -0
- data/spec/dummy/config/database.yml +5 -3
- data/spec/dummy/config/environments/production.rb +7 -2
- data/spec/dummy/config/environments/test.rb +6 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/{20140511174024_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb → 20150619080551_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb} +0 -0
- data/spec/dummy/db/migrate/{20140511174025_add_missing_unique_indices.acts_as_taggable_on_engine.rb → 20150619080552_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +0 -0
- data/spec/dummy/db/migrate/{20140511174026_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb → 20150619080553_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +0 -0
- data/spec/dummy/db/migrate/20150619080554_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
- data/spec/dummy/db/migrate/20150619080555_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
- data/spec/dummy/db/schema.rb +9 -7
- data/spec/dummy/db/seeds.rb +17 -0
- data/spec/dummy/lib/tasks/dummy.rake +29 -0
- data/spec/dummy/log/development.log +22286 -1489
- data/spec/dummy/log/test.log +4608 -11518
- data/spec/factories.rb +10 -5
- data/spec/helpers/blogit/application_helper_spec.rb +10 -73
- data/spec/helpers/blogit/posts_helper_spec.rb +8 -63
- data/spec/injectables/dummy_archiveable.rb +6 -0
- data/spec/lib/archive/list_spec.rb +60 -0
- data/spec/lib/archive/month_spec.rb +17 -0
- data/spec/lib/archive/year_spec.rb +38 -0
- data/spec/lib/blogit/parsers/html_parser_spec.rb +1 -1
- data/spec/lib/blogit/parsers/markdown_parser_spec.rb +7 -6
- data/spec/lib/blogit/parsers/textile_parser_spec.rb +1 -1
- data/spec/lib/blogs_spec.rb +2 -2
- data/spec/lib/configuration_spec.rb +21 -49
- data/spec/models/blogit/comment_spec.rb +19 -19
- data/spec/models/blogit/post_spec.rb +63 -28
- data/spec/rails_helper.rb +28 -0
- data/spec/spec_helper.rb +2 -11
- data/spec/support/helpers/css_matchers.rb +42 -0
- metadata +193 -124
- data/app/assets/stylesheets/blogit/index.css +0 -84
- data/app/views/blogit/comments/_admin_links.html.erb +0 -3
- data/app/views/blogit/posts/_comments_count.html.erb +0 -5
- data/app/views/blogit/posts/_form.html.erb +0 -49
- data/app/views/blogit/posts/_post_body.html.erb +0 -1
- data/app/views/blogit/posts/_post_links.html.erb +0 -6
- data/app/views/blogit/posts/edit.html.erb +0 -3
- data/app/views/blogit/posts/new.html.erb +0 -3
- data/lib/tasks/blog_tasks.rake +0 -4
- data/spec/dummy/app/assets/stylesheets/application.css +0 -21
- data/spec/dummy/config/initializers/blogit.rb +0 -88
- data/spec/dummy/db/migrate/20140511174028_create_blogit_posts.blogit.rb +0 -16
- data/spec/dummy/db/migrate/20140511174029_create_blogit_comments.blogit.rb +0 -16
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/tmp/cache/assets/CB5/DD0/sprockets%2F346324d2a51df58457807bee661c449c +0 -0
- data/spec/dummy/tmp/cache/assets/CB6/ED0/sprockets%2F4390d06699f3ad4262e342be530f9f91 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CE7/230/sprockets%2F6f493a817d97133a8dbf674bcd322670 +0 -0
- data/spec/dummy/tmp/cache/assets/CEA/490/sprockets%2F9697d4fb1ed26d80f3c715611c8d4373 +0 -0
- data/spec/dummy/tmp/cache/assets/CEE/310/sprockets%2F89642af8492e579dcd7162a0e2b7f155 +0 -0
- data/spec/dummy/tmp/cache/assets/D01/8C0/sprockets%2F332d5a9ce3e800c6c4a7a99058023ba2 +0 -0
- data/spec/dummy/tmp/cache/assets/D11/CC0/sprockets%2F3a12dfa6665b5318fa99d097203ac7e7 +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D3D/1E0/sprockets%2Ffbaabd57fa2c9d426f0c318156705667 +0 -0
- data/spec/dummy/tmp/cache/assets/D3E/920/sprockets%2F3efa8d0fc958c223647cb704183b65ca +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D61/6F0/sprockets%2F02da53eeca228bcef0c49278517111fe +0 -0
- data/spec/dummy/tmp/cache/assets/DCA/9B0/sprockets%2Fdf0e8f8a85e5d4056b3fe1cec3b7131a +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/E02/A60/sprockets%2Fb32faeede196f7a933c3a2794e7ed0bd +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/02da53eeca228bcef0c49278517111fe +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2ff93f9f5ed9970021c7704ff93237c8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/332d5a9ce3e800c6c4a7a99058023ba2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/346324d2a51df58457807bee661c449c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3a12dfa6665b5318fa99d097203ac7e7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3ed52366904e135bd833590814b6ac6d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4390d06699f3ad4262e342be530f9f91 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6f493a817d97133a8dbf674bcd322670 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/89642af8492e579dcd7162a0e2b7f155 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/89dc196c51ae83634b664c0c33052008 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8dd8236b00c868ba248fe30cd9c14c2a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9239a04d094a872c1cf77ac391072ea8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b3ffb6bd243399012806331ce393ae4f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d53accc3e58037ee4005e41221b8846b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/df0e8f8a85e5d4056b3fe1cec3b7131a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/routing/post_routing_spec.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c100074e27c335df3fbbc251e983062f76a5e52
|
4
|
+
data.tar.gz: d482a38203f1de73be23c06a03c5d1729d3020c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ac47d957cfaacee0dcfb48217c912ead6fc0de4a06015096c5c7231c8a1da671c24e4dc4069df687d0c7289c06c14dd01d970d62d62945e668d24b6d83ce39
|
7
|
+
data.tar.gz: 44bd76bb85d8bd99a2fb0ea88a1f6c5074911a6e81241dc7f99134cabe2e96214123b9dbff8148bfb09d18b38462c685caa3d9053249a219d6b93815fdf73031
|
data/README.md
CHANGED
@@ -5,20 +5,18 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
|
8
|
-
# Blogit
|
8
|
+
# Blogit - A Rails blogging solution
|
9
9
|
|
10
|
-
Blogit
|
11
|
-
|
12
|
-
* Is Rack based;
|
13
|
-
* Is a complete MVC solution based on Rails engines;
|
14
|
-
* Aims to work right out of the box but remain fully customisable.
|
10
|
+
Blogit lets you add a blog to your Ruby on Rails application in just a few seconds.
|
15
11
|
|
16
12
|
## Installation
|
17
13
|
|
18
|
-
Add
|
14
|
+
Add these to your Gemfile
|
19
15
|
|
20
16
|
``` ruby
|
21
17
|
gem "blogit"
|
18
|
+
# Blogit depends on ActsAsTaggableOn
|
19
|
+
gem "acts-as-taggable-on"
|
22
20
|
```
|
23
21
|
|
24
22
|
...and run `bundle install` to install the gem.
|
@@ -28,11 +26,18 @@ Next, run:
|
|
28
26
|
``` bash
|
29
27
|
# add an initializer to config/initializers with all of the configuration options
|
30
28
|
$ rails g blogit:install
|
29
|
+
|
31
30
|
# This will add the necessary migrations to your app's db/migrate directory
|
32
31
|
rake blogit:install:migrations
|
32
|
+
|
33
|
+
# You don't need to run again this if you've already done so
|
34
|
+
rake acts\_as\_taggable\_on:install:migrations
|
35
|
+
|
33
36
|
# This will run any pending migrations
|
34
37
|
rake db:migrate
|
38
|
+
|
35
39
|
```
|
40
|
+
|
36
41
|
then add the following to your routes.rb file:
|
37
42
|
|
38
43
|
``` bash
|
@@ -40,39 +45,34 @@ then add the following to your routes.rb file:
|
|
40
45
|
mount Blogit::Engine => "/blog"
|
41
46
|
```
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
... and finally, declare which of your models acts as blogger in your app (usually User).
|
48
|
+
Finally, declare which of your models acts as blogger in your app (probably User or Admin).
|
46
49
|
|
47
50
|
``` ruby
|
48
|
-
class User
|
51
|
+
class User < ActiveRecord::Base
|
49
52
|
|
50
53
|
blogs
|
51
54
|
|
52
55
|
end
|
53
56
|
```
|
54
57
|
|
55
|
-
|
58
|
+
Go to http://localhost:3000/blog and see your marvelous new blog.
|
56
59
|
|
57
|
-
Running `rails g blogit:install` will add an initializer file named blogit.rb. In here
|
58
|
-
you can set various configuration options. Please [read the documentation](http://rubydoc.info/gems/blogit/Blogit/Configuration) for a full list of the options available.
|
59
60
|
|
60
|
-
##
|
61
|
+
## Batteries included
|
61
62
|
|
62
|
-
|
63
|
+
Blogit provides you with the following features
|
63
64
|
|
64
65
|
* An XML Sitemap located at `/blog/posts.xml`
|
65
66
|
* An RSS feed located at `/blog/posts.rss`
|
66
|
-
* Sitemap submission to the major search engines (via [Pingr](http://github.com/katanacode/pingr "Pingr") - off by default)
|
67
|
-
* Page Caching and Sweeping
|
68
67
|
* Internationalization (see the [locales file](config/locales/en.yml) for configurable options)
|
69
68
|
* Share links (Google+, Twitter & Facebook)
|
70
69
|
* [Disquss Comments](http://disqus.com)
|
71
70
|
* Code Syntax Highlighting CSS file (add `*= require pygments` to your app's stylesheet)
|
71
|
+
* CSS themes
|
72
72
|
|
73
|
-
##
|
73
|
+
## Documentation
|
74
74
|
|
75
|
-
|
75
|
+
Full documentation and how-to guides available here: http://blogit.katanacode.com
|
76
76
|
|
77
77
|
## Issues
|
78
78
|
|
@@ -81,25 +81,18 @@ If you discover a problem with Blogit, please let us know about it.
|
|
81
81
|
**Remember** to search the [issues list](https://github.com/KatanaCode/blogit/issues) first in case your issue has already been raised
|
82
82
|
by another Githuber
|
83
83
|
|
84
|
-
## Documentation
|
85
|
-
|
86
|
-
Full documentation is available here: http://rubydoc.info/gems/blogit
|
87
84
|
|
88
85
|
## Contributing
|
89
86
|
|
90
|
-
|
87
|
+
Want to help make Blogit better?. Please read the [contribution guidelines](http://blogit.katanacode.com/doc/file.Contributing.html) for more information on how you can contribute.
|
91
88
|
|
92
89
|
## Legal Stuff
|
93
90
|
|
94
|
-
|
95
|
-
|
96
|
-
See (LEGAL)[LEGAL] for full details.
|
91
|
+
See [LEGAL][GithubLicence] for full details.
|
97
92
|
|
98
93
|
## Credits
|
99
94
|
|
100
|
-
|
101
|
-
|
102
|
-
with generous contributions from:
|
95
|
+
Blogit was developed by [Katana Code](http://katanacode.com) with generous contributions from:
|
103
96
|
|
104
97
|
* [Philou](https://github.com/philou)
|
105
98
|
* [Stewart McKee](https://github.com/stewartmckee)
|
@@ -107,4 +100,8 @@ with generous contributions from:
|
|
107
100
|
|
108
101
|
## About Katana Code
|
109
102
|
|
110
|
-
Katana Code are [
|
103
|
+
Katana Code are [web developers based in Edinburgh, Scotland](http://katanacode.com/ "Katana Code").
|
104
|
+
|
105
|
+
Copyright © 2011 - 2015 [Katana Code Ltd.](http://katanacode.com)
|
106
|
+
|
107
|
+
[GithubLicence]: https://github.com/KatanaCode/blogit/blob/master/MIT-LICENSE
|
data/Rakefile
CHANGED
@@ -11,7 +11,11 @@ load 'rails/tasks/engine.rake'
|
|
11
11
|
|
12
12
|
Bundler::GemHelper.install_tasks
|
13
13
|
|
14
|
-
|
14
|
+
|
15
|
+
Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each {|f| load f }
|
16
|
+
|
17
|
+
Dir[File.join(File.dirname(__FILE__), 'spec/dummy/lib/tasks/**/*.rake')].each {|f| load f}
|
18
|
+
|
15
19
|
|
16
20
|
require 'rspec/core'
|
17
21
|
require 'rspec/core/rake_task'
|
@@ -20,4 +24,4 @@ desc "Run all specs in spec directory (excluding plugin specs)"
|
|
20
24
|
|
21
25
|
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
22
26
|
|
23
|
-
task :default => :spec
|
27
|
+
task :default => :spec
|
@@ -0,0 +1 @@
|
|
1
|
+
$color-font-default: #444444
|
@@ -0,0 +1 @@
|
|
1
|
+
$font-size-xl: 2em
|
@@ -0,0 +1,18 @@
|
|
1
|
+
.blogit_archive
|
2
|
+
|
3
|
+
.blogit_archive__list
|
4
|
+
padding: 0
|
5
|
+
list-style-type: none
|
6
|
+
|
7
|
+
.blogit_archive__list--months
|
8
|
+
padding-left: 0.5em
|
9
|
+
display: none
|
10
|
+
|
11
|
+
.blogit_archive__list--archiveables
|
12
|
+
margin-bottom: 0.5em
|
13
|
+
padding-left: 0.5em
|
14
|
+
display: none
|
15
|
+
|
16
|
+
.blogit_archive__item
|
17
|
+
.blogit_archive__item--post
|
18
|
+
margin: 0.5em 0
|
File without changes
|
@@ -3,44 +3,28 @@ module Blogit
|
|
3
3
|
# Inherits from the application's controller instead of ActionController::Base
|
4
4
|
class ApplicationController < ::ApplicationController
|
5
5
|
|
6
|
-
helper Blogit::ApplicationHelper
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# A helper method to access the Blogit::configuration
|
17
|
-
# at the class level
|
6
|
+
helper Blogit::ApplicationHelper
|
7
|
+
helper Blogit::LayoutHelper
|
8
|
+
helper Blogit::PostsHelper
|
9
|
+
helper Blogit::CommentsHelper
|
10
|
+
|
11
|
+
helper_method :blogit_conf
|
12
|
+
|
13
|
+
# A helper method to access the {Blogit::configuration} at the class level.
|
14
|
+
#
|
15
|
+
# Returns a Blogit::Configuration
|
18
16
|
def self.blogit_conf
|
19
17
|
Blogit::configuration
|
20
18
|
end
|
21
19
|
|
22
|
-
# A helper method to access the Blogit::configuration
|
23
|
-
#
|
20
|
+
# A helper method to access the {Blogit::configuration} at the controller instance
|
21
|
+
# level.
|
22
|
+
#
|
23
|
+
# Returns a Blogit::Configuration
|
24
24
|
def blogit_conf
|
25
25
|
self.class.blogit_conf
|
26
26
|
end
|
27
27
|
|
28
|
-
# Returns the currently logged in blogger by calling
|
29
|
-
# whatever Blogit.current_blogger_method is set to
|
30
|
-
def current_blogger
|
31
|
-
send blogit_conf.current_blogger_method
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns true or false if current_blogger is present
|
35
|
-
def is_blogger_logged_in?
|
36
|
-
!!current_blogger
|
37
|
-
end
|
38
|
-
|
39
|
-
# Returns true if the current_blogger is the owner of the post
|
40
|
-
# @param post An instance of Blogit::Post
|
41
|
-
def this_blogger?(post)
|
42
|
-
current_blogger == post.blogger
|
43
|
-
end
|
44
|
-
|
45
28
|
end
|
29
|
+
|
46
30
|
end
|
@@ -1,47 +1,65 @@
|
|
1
1
|
module Blogit
|
2
|
+
|
3
|
+
# Handles requests for creating Blogit::Comments
|
2
4
|
class CommentsController < ApplicationController
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
# Accessor method for the comment being created
|
7
|
+
#
|
8
|
+
# Returns a Blogit::Comment
|
9
|
+
attr_reader :comment
|
10
|
+
|
11
|
+
# Accessor method for the Post we're adding a Comment to
|
12
|
+
#
|
13
|
+
# Returns Post
|
14
|
+
attr_reader :post
|
15
|
+
|
16
|
+
# Handles POST requests to /blogit/comments.html and /blogit/comments.js
|
6
17
|
def create
|
7
|
-
|
8
|
-
|
18
|
+
set_post_from_post_id
|
19
|
+
set_comment_as_new
|
20
|
+
comment.save
|
9
21
|
respond_to do |format|
|
10
|
-
format.js
|
11
|
-
|
12
|
-
@comment.save
|
13
|
-
}
|
14
|
-
|
15
|
-
format.html {
|
16
|
-
if @comment.save
|
17
|
-
redirect_to(post, notice: t(:successfully_added_comment, scope: 'blogit.comments'))
|
18
|
-
else
|
19
|
-
render "blogit/posts/show"
|
20
|
-
end
|
21
|
-
}
|
22
|
-
|
22
|
+
format.js { create_respond_to_js }
|
23
|
+
format.html { create_respond_to_html }
|
23
24
|
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
private
|
24
29
|
|
30
|
+
|
31
|
+
# Set this controller's post attribute to the current Post
|
32
|
+
def set_post_from_post_id
|
33
|
+
@post = Blogit::Post.find(params[:post_id])
|
25
34
|
end
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
@comment.
|
30
|
-
respond_to do |format|
|
31
|
-
format.html { redirect_to(post, notice: t(:successfully_removed_comment, scope: 'blogit.comments'))}
|
32
|
-
format.js
|
33
|
-
end
|
36
|
+
# Set this controller's comment attribute as a new comment with params
|
37
|
+
def set_comment_as_new
|
38
|
+
@comment = post.comments.new(comment_params)
|
34
39
|
end
|
35
40
|
|
36
|
-
|
41
|
+
# The create action render call when format is JS
|
42
|
+
def create_respond_to_js
|
43
|
+
render status: (comment.persisted? ? :created : :bad_request)
|
44
|
+
end
|
37
45
|
|
46
|
+
# The create action render call when format is HTML
|
47
|
+
def create_respond_to_html
|
48
|
+
if comment.persisted?
|
49
|
+
redirect_to(post,
|
50
|
+
notice: t(:successfully_added_comment, scope: 'blogit.comments'))
|
51
|
+
else
|
52
|
+
render "blogit/posts/show"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# The comment attribute params
|
57
|
+
#
|
58
|
+
# Returns a Hash
|
38
59
|
def comment_params
|
39
60
|
params.require(:comment).permit(:name, :nickname, :email, :body, :website)
|
40
61
|
end
|
41
|
-
|
42
|
-
def post
|
43
|
-
@post ||= Blogit::Post.find(params[:post_id])
|
44
|
-
end
|
45
62
|
|
46
63
|
end
|
47
|
-
|
64
|
+
|
65
|
+
end
|
@@ -1,114 +1,80 @@
|
|
1
1
|
module Blogit
|
2
2
|
|
3
|
-
#
|
4
|
-
# the main_app
|
3
|
+
# Handles requests for viewing Blogit::Posts
|
5
4
|
class PostsController < ::Blogit::ApplicationController
|
6
5
|
|
6
|
+
# The current Blogit::Post being displayed.
|
7
|
+
#
|
8
|
+
# Returns a Blogit::Post with id from params
|
9
|
+
attr_reader :post
|
10
|
+
|
11
|
+
# The current Posts being displayed
|
12
|
+
#
|
13
|
+
# Returns ActiveRecord::Relation for Post table
|
14
|
+
attr_reader :posts
|
15
|
+
|
7
16
|
# If a layout is specified, use that. Otherwise, fall back to the default
|
8
17
|
layout Blogit.configuration.layout if Blogit.configuration.layout
|
9
18
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
#
|
18
|
-
unless Blogit.configuration.include_admin_actions
|
19
|
-
before_filter :raise_404, except: [:index, :show]
|
20
|
-
end
|
21
|
-
|
22
|
-
blogit_authenticate(except: [:index, :show, :tagged])
|
23
|
-
|
19
|
+
# Handles GET requests to /blogit/posts.html, /blogit/posts.xml, and /blogit/posts.rss
|
20
|
+
# Possible formats include:
|
21
|
+
#
|
22
|
+
# "XML" - calls {#set_posts_for_feed}.
|
23
|
+
# "RSS" - calls {#set_posts_for_feed}.
|
24
|
+
# "HTML" - calls {#set_posts_for_index_page}.
|
25
|
+
#
|
26
|
+
# Returns nil
|
24
27
|
def index
|
25
28
|
respond_to do |format|
|
26
|
-
format.xml
|
27
|
-
|
28
|
-
}
|
29
|
-
format.html {
|
30
|
-
@posts = if is_blogger_logged_in?
|
31
|
-
Post.for_index(params[Kaminari.config.param_name])
|
32
|
-
else
|
33
|
-
Post.active.for_index(params[Kaminari.config.param_name])
|
34
|
-
end
|
35
|
-
}
|
36
|
-
format.rss {
|
37
|
-
@posts = Post.active.order('created_at DESC')
|
38
|
-
}
|
29
|
+
format.xml { set_posts_for_feed }
|
30
|
+
format.rss { set_posts_for_feed }
|
31
|
+
format.html { set_posts_for_index_page }
|
39
32
|
end
|
40
33
|
end
|
41
34
|
|
35
|
+
# Handles GET requests to /blogit/posts/:id.html
|
42
36
|
def show
|
43
|
-
|
37
|
+
set_post
|
44
38
|
end
|
45
39
|
|
40
|
+
# Handles GET requests to /blogit/posts/tagged/:tag.html. Renders the index template
|
41
|
+
# with Posts tagged with tag in *tag* parameter
|
46
42
|
def tagged
|
47
|
-
|
48
|
-
@posts = Post.for_index(param_name).tagged_with(params[:tag])
|
43
|
+
set_posts_for_tagged_page
|
49
44
|
render :index
|
50
45
|
end
|
51
46
|
|
52
|
-
def new
|
53
|
-
@post = current_blogger.blog_posts.new(post_paramters)
|
54
|
-
end
|
55
|
-
|
56
|
-
def edit
|
57
|
-
@post = current_blogger.blog_posts.find(params[:id])
|
58
|
-
end
|
59
|
-
|
60
|
-
def create
|
61
|
-
@post = current_blogger.blog_posts.new(post_paramters)
|
62
|
-
if @post.save
|
63
|
-
redirect_to @post, notice: t(:blog_post_was_successfully_created, scope: 'blogit.posts')
|
64
|
-
else
|
65
|
-
render action: "new"
|
66
|
-
end
|
67
|
-
end
|
68
47
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
render action: "edit"
|
76
|
-
end
|
48
|
+
private
|
49
|
+
|
50
|
+
|
51
|
+
# Set {#post} based on the :id param
|
52
|
+
def set_post
|
53
|
+
@post = Post.active_with_id(params[:id])
|
77
54
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@
|
82
|
-
redirect_to posts_url, notice: t(:blog_post_was_successfully_destroyed, scope: 'blogit.posts')
|
55
|
+
|
56
|
+
# The page parameter value for the current locale
|
57
|
+
def page_number
|
58
|
+
@page_number ||= params[Kaminari.config.param_name]
|
83
59
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
else
|
89
|
-
{}
|
90
|
-
end
|
60
|
+
|
61
|
+
# Sets {#posts} for the XML feed
|
62
|
+
def set_posts_for_feed
|
63
|
+
@posts ||= Post.for_feed
|
91
64
|
end
|
92
65
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
66
|
+
# Sets {#posts} for the HTML index page
|
67
|
+
#
|
68
|
+
# tag - The tag name to filter Posts by (default: nil)
|
69
|
+
#
|
70
|
+
def set_posts_for_index_page(tag = nil)
|
71
|
+
@posts ||= Post.for_index(page_number)
|
98
72
|
end
|
99
|
-
|
100
|
-
|
101
|
-
#
|
102
|
-
def
|
103
|
-
|
104
|
-
when Array
|
105
|
-
search_engines = blogit_conf.ping_search_engines
|
106
|
-
when true
|
107
|
-
search_engines = Pingr::SUPPORTED_SEARCH_ENGINES
|
108
|
-
end
|
109
|
-
for search_engine in search_engines
|
110
|
-
Pingr::Request.new(search_engine, posts_url(format: :xml)).ping
|
111
|
-
end
|
73
|
+
|
74
|
+
# Sets {#posts} for the HTML index page when a tag parameter is present
|
75
|
+
#
|
76
|
+
def set_posts_for_tagged_page
|
77
|
+
@posts = set_posts_for_index_page.tagged_with(params[:tag])
|
112
78
|
end
|
113
79
|
|
114
80
|
end
|