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
@@ -0,0 +1,34 @@
|
|
1
|
+
module Blogit
|
2
|
+
module Archive
|
3
|
+
|
4
|
+
# Used internally by {List} when creating a new archive list.
|
5
|
+
class Month
|
6
|
+
|
7
|
+
attr_reader :month_name
|
8
|
+
|
9
|
+
alias_method :to_s, :month_name
|
10
|
+
|
11
|
+
attr_reader :archiveables
|
12
|
+
|
13
|
+
# Creates a new {Month} object
|
14
|
+
#
|
15
|
+
# month_name - The name of the month for this collection of archiveables
|
16
|
+
# archiveables - A collection of _archiveable_ objects
|
17
|
+
#
|
18
|
+
def initialize(month_name, archiveables)
|
19
|
+
@month_name = month_name
|
20
|
+
@archiveables = archiveables
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# The name of the partial to load for a {Month} object
|
25
|
+
#
|
26
|
+
# Returns a String
|
27
|
+
def to_partial_path
|
28
|
+
self.class.name.underscore
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Blogit
|
2
|
+
module Archive
|
3
|
+
class Year
|
4
|
+
|
5
|
+
attr_accessor :year, :months
|
6
|
+
|
7
|
+
def initialize(year, archiveables)
|
8
|
+
@year = year
|
9
|
+
@months = create_months_from_archiveables(archiveables)
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
year
|
14
|
+
end
|
15
|
+
|
16
|
+
# The name of the partial to load for a {Year} object
|
17
|
+
#
|
18
|
+
# Returns a String
|
19
|
+
def to_partial_path
|
20
|
+
self.class.name.underscore
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
|
27
|
+
def create_months_from_archiveables(archiveables)
|
28
|
+
months_with_archiveables(archiveables).
|
29
|
+
map { |month, archs| Month.new(month, archs) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def months_with_archiveables(archiveables)
|
33
|
+
archiveables.chunk { |a|
|
34
|
+
I18n.localize(a.published_at, format: :plain_month_only)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/blogit/blogs.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
module Blogit
|
2
2
|
module Blogs
|
3
|
-
|
4
|
-
|
5
|
-
base.extend ClassMethods
|
6
|
-
end
|
3
|
+
|
4
|
+
extend ActiveSupport::Concern
|
7
5
|
|
8
6
|
module ClassMethods
|
9
7
|
|
10
8
|
# When called within a model (usually User) this creates
|
11
|
-
# a has-many assosciation between the model and
|
9
|
+
# a has-many assosciation between the model and {Post}
|
12
10
|
def blogs
|
11
|
+
@blogs = true
|
13
12
|
has_many :blog_posts, :as => "blogger", :class_name => "Blogit::Post"
|
14
13
|
end
|
14
|
+
|
15
|
+
# Has this model been registered as a blogging model?
|
16
|
+
#
|
17
|
+
# Returns true or false
|
18
|
+
def blogs?
|
19
|
+
@blogs == true
|
20
|
+
end
|
15
21
|
|
16
22
|
end
|
17
23
|
|
data/lib/blogit/configuration.rb
CHANGED
@@ -1,182 +1,192 @@
|
|
1
1
|
module Blogit
|
2
|
+
|
3
|
+
# This class handles the global configuration options for Blogit.
|
4
|
+
# When you run `rails g blogit:install` this will add an initializer file to
|
5
|
+
# config/initializers/blogit.rb with all of the default configurations applied.
|
6
|
+
#
|
7
|
+
# You can read about each of the individual configuration options below.
|
2
8
|
class Configuration
|
9
|
+
|
10
|
+
include ActiveSupport::Configurable
|
11
|
+
|
12
|
+
# An Array containing the default states for {Blogit::Post Posts} that are considered
|
13
|
+
# "active". ("Active" {Post posts} are those that can be viewed by the public).
|
14
|
+
ACTIVE_STATES = [:published]
|
3
15
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
# An Array containing the default states for {Blogit::Post Posts} that are considered
|
17
|
+
# "hidden". ("Hidden" {Post posts} are those that may not be viewed by the public).
|
18
|
+
HIDDEN_STATES = [:draft, :archive]
|
19
|
+
|
20
|
+
# When using redcarpet as content parser, pass these options as defaults.
|
21
|
+
REDCARPET_OPTIONS = {
|
22
|
+
hard_wrap: true,
|
23
|
+
filter_html: true,
|
24
|
+
autolink: true,
|
25
|
+
no_intra_emphasis: true,
|
26
|
+
fenced_code_blocks: true,
|
27
|
+
gh_blockcode: true,
|
28
|
+
}
|
29
|
+
|
30
|
+
##
|
31
|
+
# How do you want to handle comments for your blog?
|
32
|
+
# Valid options are :active_record, :disquss, or :no for none.
|
33
|
+
# (default: :active_record)
|
34
|
+
config_accessor(:include_comments) { :active_record }
|
35
|
+
|
36
|
+
##
|
37
|
+
# When using :disqus comments, what is the shortname of your forum?
|
38
|
+
# (default: nil)
|
39
|
+
config_accessor(:disqus_shortname, instance_writer: false)
|
40
|
+
|
41
|
+
##
|
42
|
+
# Load a javascript-based share bar on each blog post?. (default: true)
|
43
|
+
config_accessor(:include_share_bar) { true }
|
44
|
+
|
45
|
+
##
|
46
|
+
# Twitter username used in the share bar. (default: nil)
|
47
|
+
config_accessor(:twitter_username)
|
48
|
+
|
49
|
+
##
|
16
50
|
# The name of the controller method we'll call to return the current blogger.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# is :markdown
|
37
|
-
attr_accessor :highlight_code_syntax
|
38
|
-
|
39
|
-
# The name of the before filter we'll call to authenticate the current user.
|
40
|
-
# Defaults to :login_required
|
41
|
-
attr_accessor :authentication_method
|
42
|
-
|
43
|
-
# If set to true, only the user who authored the post may, edit or destroy.
|
44
|
-
# Defaults to false
|
45
|
-
attr_accessor :author_edits_only
|
46
|
-
|
51
|
+
# (default: :current_user)
|
52
|
+
config_accessor(:current_blogger_method) { :current_user }
|
53
|
+
|
54
|
+
##
|
55
|
+
# What method do we call on blogger to return their display name? (default: :username)
|
56
|
+
config_accessor(:blogger_display_name_method) { :username }
|
57
|
+
|
58
|
+
##
|
59
|
+
# Which DateTime::FORMATS format do we use to display blog and comment publish time
|
60
|
+
# (default: :short)
|
61
|
+
config_accessor(:datetime_format) { :short }
|
62
|
+
|
63
|
+
##
|
64
|
+
# Number of {Blogit::Post posts} to show per page. This is a configuration for {https://github.com/amatsuda/kaminari Kaminari} (default: 5)
|
65
|
+
#
|
66
|
+
# Returns an Integer
|
67
|
+
config_accessor(:posts_per_page) { 5 }
|
68
|
+
|
69
|
+
##
|
47
70
|
# If set to true, the comments form will POST and DELETE to the comments
|
48
71
|
# controller using AJAX calls.
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# yourself elsewhere in the app
|
55
|
-
attr_accessor :include_admin_actions
|
56
|
-
|
57
|
-
# If set to true, links for new posts, editing posts and deleting comments
|
58
|
-
# will be available. If set to false, you'll have to set these
|
59
|
-
# yourself in the templates.
|
60
|
-
attr_accessor :include_admin_links
|
61
|
-
|
72
|
+
#
|
73
|
+
# Returns true or false
|
74
|
+
config_accessor(:ajax_comments) { true }
|
75
|
+
|
76
|
+
##
|
62
77
|
# The default format for parsing the blog content.
|
78
|
+
#
|
63
79
|
# Defaults to :markdown
|
64
|
-
|
65
|
-
|
80
|
+
config_accessor(:default_parser) { :markdown }
|
81
|
+
|
82
|
+
##
|
83
|
+
# Should text within "```" or "`" be highlighted as code?
|
84
|
+
# Defaults to true
|
85
|
+
# @note - At the moment this only works when default_parser is :markdown
|
86
|
+
config_accessor(:highlight_code_syntax) { true }
|
87
|
+
|
88
|
+
##
|
66
89
|
# When using redcarpet as content parser, pass these options as defaults
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
90
|
+
#
|
91
|
+
# Defaults to {REDCARPET_OPTIONS}
|
92
|
+
config_accessor(:redcarpet_options) { REDCARPET_OPTIONS }
|
93
|
+
|
94
|
+
##
|
95
|
+
# List of states that will be visible to the public
|
96
|
+
#
|
97
|
+
# Defaults to ACTIVE_STATES
|
98
|
+
config_accessor(:active_states) { ACTIVE_STATES }
|
99
|
+
|
100
|
+
##
|
101
|
+
# List of states that will hide the posts from the public.
|
102
|
+
#
|
103
|
+
# Defaults to HIDDEN_STATES
|
104
|
+
config_accessor(:hidden_states) { HIDDEN_STATES }
|
105
|
+
|
106
|
+
##
|
74
107
|
# The title of the RSS feed for the blog posts
|
108
|
+
#
|
75
109
|
# Defaults to "[Application Name] Blog Posts"
|
76
|
-
|
77
|
-
|
110
|
+
config_accessor(:rss_feed_title, instance_reader: false)
|
111
|
+
|
112
|
+
##
|
78
113
|
# The description of the RSS feed for the blog posts
|
79
114
|
# Defaults to "[Application Name] Blog Posts"
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# the "main_app." prefix ?
|
84
|
-
attr_accessor :inline_main_app_named_routes
|
85
|
-
|
86
|
-
# Should blogit ping search engines with your sitemap
|
87
|
-
# when posts are created, updated or destroyed?
|
88
|
-
# Defaults to false
|
89
|
-
attr_accessor :ping_search_engines
|
90
|
-
|
115
|
+
config_accessor(:rss_feed_description, instance_reader: false)
|
116
|
+
|
117
|
+
##
|
91
118
|
# The layout to be used by the posts controller
|
119
|
+
#
|
92
120
|
# Defaults to nil
|
93
|
-
|
94
|
-
|
95
|
-
# list of states that will be visible to the public
|
96
|
-
attr_accessor :active_states
|
97
|
-
|
98
|
-
# list of states that will hide the posts from the public.
|
99
|
-
attr_accessor :hidden_states
|
100
|
-
|
101
|
-
# list of states for the Post state machine in order or lifecycle, aggregation of hidden_states and active_states
|
102
|
-
#attr_accessor :post_states
|
103
|
-
|
104
|
-
# When using redcarpet as content parser, pass these options as defaults.
|
105
|
-
REDCARPET_OPTIONS = {
|
106
|
-
hard_wrap: true,
|
107
|
-
filter_html: true,
|
108
|
-
autolink: true,
|
109
|
-
no_intra_emphasis: true,
|
110
|
-
fenced_code_blocks: true,
|
111
|
-
gh_blockcode: true,
|
112
|
-
}
|
113
|
-
|
114
|
-
#default values for active_state
|
115
|
-
ACTIVE_STATES = [:published]
|
116
|
-
|
117
|
-
#default values for hidden_state
|
118
|
-
HIDDEN_STATES = [:draft, :archive]
|
119
|
-
|
120
|
-
def initialize
|
121
|
-
@include_comments = :active_record
|
122
|
-
@disqus_shortname = ""
|
123
|
-
@include_share_bar = false
|
124
|
-
@twitter_username = ""
|
125
|
-
@current_blogger_method = :current_user
|
126
|
-
@blogger_display_name_method = :username
|
127
|
-
@datetime_format = :short
|
128
|
-
@posts_per_page = 5
|
129
|
-
@authentication_method = :login_required
|
130
|
-
@author_edits_only = false
|
131
|
-
@ajax_comments = true
|
132
|
-
@include_admin_actions = true
|
133
|
-
@include_admin_links = true
|
134
|
-
@cache_pages = false
|
135
|
-
@default_parser = :markdown
|
136
|
-
@highlight_code_syntax = true
|
137
|
-
@rss_feed_title = "#{Rails.application.engine_name.titleize} Blog Posts"
|
138
|
-
@rss_feed_description = "#{Rails.application.engine_name.titleize} Blog Posts"
|
139
|
-
@ping_search_engines = false
|
140
|
-
@redcarpet_options = REDCARPET_OPTIONS
|
141
|
-
@active_states = ACTIVE_STATES
|
142
|
-
@hidden_states = HIDDEN_STATES
|
143
|
-
end
|
121
|
+
config_accessor :layout
|
144
122
|
|
123
|
+
##
|
124
|
+
# Should show a description of the blog post on the index
|
125
|
+
# and RSS feed.
|
126
|
+
#
|
127
|
+
# Defaults to true
|
128
|
+
config_accessor(:show_post_description) { true }
|
129
|
+
|
130
|
+
|
145
131
|
def default_parser_class
|
146
|
-
"Blogit::Parsers::#{
|
132
|
+
"Blogit::Parsers::#{default_parser.to_s.classify}Parser".constantize
|
147
133
|
end
|
148
134
|
|
149
|
-
#
|
150
|
-
#
|
135
|
+
# Sets {#disqus_shortname}.
|
136
|
+
# If the user has defined a disqus shortname but hasn't set include_comments to
|
137
|
+
# :disqus will print a warning to the console.
|
138
|
+
#
|
139
|
+
# shortname - A String with the diquss username to use.
|
140
|
+
#
|
151
141
|
def disqus_shortname=(shortname)
|
152
|
-
if
|
153
|
-
|
142
|
+
return if shortname.blank?
|
143
|
+
unless include_comments == :disqus
|
144
|
+
blogit_warn "You've set config.disqus_shortname in your blogit config file but " \
|
145
|
+
"config.include_comments is not set to :disqus"
|
154
146
|
end
|
155
147
|
@disqus_shortname = shortname
|
156
148
|
end
|
157
149
|
|
158
|
-
#
|
159
|
-
#
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@twitter_username = username
|
150
|
+
# The title to use in the index.rss template. (default: [My Application] Blog
|
151
|
+
# Posts")
|
152
|
+
#
|
153
|
+
# Returns a String
|
154
|
+
def rss_feed_title
|
155
|
+
@rss_feed_title ||= "#{rails_app_name} Blog Posts"
|
165
156
|
end
|
166
157
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
def
|
172
|
-
|
158
|
+
# The description to use in the index.rss template.
|
159
|
+
# (default: "Latest from [My Application]")
|
160
|
+
#
|
161
|
+
# Returns a String
|
162
|
+
def rss_feed_description
|
163
|
+
@rss_feed_description ||= "Latest from #{rails_app_name}"
|
173
164
|
end
|
174
165
|
|
166
|
+
|
167
|
+
|
175
168
|
private
|
176
169
|
|
170
|
+
|
171
|
+
# The name of this application derived from the app's engine name.
|
172
|
+
# If your Rails app module is KatanaCode, the application name will be "Katana Code"
|
173
|
+
#
|
174
|
+
# Returns a String
|
175
|
+
def rails_app_name
|
176
|
+
Rails.application.engine_name.titleize
|
177
|
+
end
|
178
|
+
|
179
|
+
# Print a warning message to $STDOUT with the prefix "[Blogit]: "
|
180
|
+
#
|
181
|
+
# Examples
|
182
|
+
#
|
183
|
+
# blogit_warn("Blogit is not a toy!")
|
184
|
+
# # => "[Blogit]: Blogit is not a toy!"
|
185
|
+
#
|
177
186
|
def blogit_warn(message)
|
178
187
|
warn "[Blogit]: #{message}"
|
179
188
|
end
|
180
189
|
|
181
190
|
end
|
182
|
-
|
191
|
+
|
192
|
+
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
class Blogit::Parsers::HtmlParser
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
# A String containing the content to be parsed
|
4
|
+
attr_reader :content
|
5
|
+
|
6
|
+
alias_method :parsed, :content
|
4
7
|
|
5
8
|
def initialize(content)
|
6
|
-
@
|
9
|
+
@content = content
|
7
10
|
end
|
8
11
|
|
9
12
|
end
|