Class: Blogit::Configuration
- Inherits:
-
Object
- Object
- Blogit::Configuration
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/blogit/configuration.rb
Overview
This class handles the global configuration options for Blogit.
When you run `rails g blogit:install` this will add an initializer file to
config/initializers/blogit.rb with all of the default configurations applied.
You can read about each of the individual configuration options below.
Constant Summary collapse
- ACTIVE_STATES =
An Array containing the default states for Posts that are considered
"active". ("Active" {Post posts} are those that can be viewed by the public).
[:published]
- HIDDEN_STATES =
An Array containing the default states for Posts that are considered
"hidden". ("Hidden" {Post posts} are those that may not be viewed by the public).
[:draft, :archive]
- REDCARPET_OPTIONS =
When using redcarpet as content parser, pass these options as defaults.
{ hard_wrap: true, filter_html: true, autolink: true, no_intra_emphasis: true, fenced_code_blocks: true, gh_blockcode: true, }
Instance Method Summary collapse
-
#active_states ⇒ Object
List of states that will be visible to the public.
-
#ajax_comments ⇒ Object
If set to true, the comments form will POST and DELETE to the comments controller using AJAX calls.
-
#blogger_display_name_method ⇒ Object
What method do we call on blogger to return their display name? (default: :username).
-
#current_blogger_method ⇒ Object
The name of the controller method we’ll call to return the current blogger.
-
#datetime_format ⇒ Object
Which DateTime::FORMATS format do we use to display blog and comment publish time (default: :short).
-
#default_parser ⇒ Object
The default format for parsing the blog content.
- #default_parser_class ⇒ Object
-
#disqus_shortname ⇒ Object
When using :disqus comments, what is the shortname of your forum? (default: nil).
-
#disqus_shortname=(shortname) ⇒ Object
Sets #disqus_shortname.
-
#hidden_states ⇒ Object
List of states that will hide the posts from the public.
-
#highlight_code_syntax ⇒ Object
Should text within ““‘” or “`” be highlighted as code? Defaults to true.
-
#include_comments ⇒ Object
How do you want to handle comments for your blog? Valid options are :active_record, :disquss, or :no for none.
-
#include_share_bar ⇒ Object
Load a javascript-based share bar on each blog post?.
-
#layout ⇒ Object
The layout to be used by the posts controller.
-
#posts_per_page ⇒ Object
Number of posts to show per page.
-
#redcarpet_options ⇒ Object
When using redcarpet as content parser, pass these options as defaults.
-
#rss_feed_description ⇒ Object
The description to use in the index.rss template.
-
#rss_feed_title ⇒ Object
The title to use in the index.rss template.
-
#show_post_description ⇒ Object
Should show a description of the blog post on the index and RSS feed.
-
#syntax_highlighter ⇒ Object
The renderer used for code highlighting Defaults to :albino.
-
#twitter_username ⇒ Object
Twitter username used in the share bar.
Instance Method Details
#active_states ⇒ Object
List of states that will be visible to the public
Defaults to ACTIVE_STATES
103 |
# File 'lib/blogit/configuration.rb', line 103 config_accessor(:active_states) { ACTIVE_STATES } |
#ajax_comments ⇒ Object
If set to true, the comments form will POST and DELETE to the comments controller using AJAX calls.
Returns true or false
74 |
# File 'lib/blogit/configuration.rb', line 74 config_accessor(:ajax_comments) { true } |
#blogger_display_name_method ⇒ Object
What method do we call on blogger to return their display name? (default: :username)
56 |
# File 'lib/blogit/configuration.rb', line 56 config_accessor(:blogger_display_name_method) { :username } |
#current_blogger_method ⇒ Object
The name of the controller method we’ll call to return the current blogger.
(default: :current_user)
52 |
# File 'lib/blogit/configuration.rb', line 52 config_accessor(:current_blogger_method) { :current_user } |
#datetime_format ⇒ Object
Which DateTime::FORMATS format do we use to display blog and comment publish time
(default: :short)
61 |
# File 'lib/blogit/configuration.rb', line 61 config_accessor(:datetime_format) { :short } |
#default_parser ⇒ Object
The default format for parsing the blog content.
Defaults to :markdown
80 |
# File 'lib/blogit/configuration.rb', line 80 config_accessor(:default_parser) { :markdown } |
#default_parser_class ⇒ Object
136 137 138 |
# File 'lib/blogit/configuration.rb', line 136 def default_parser_class "Blogit::Parsers::#{default_parser.to_s.classify}Parser".constantize end |
#disqus_shortname ⇒ Object
When using :disqus comments, what is the shortname of your forum?
(default: nil)
39 |
# File 'lib/blogit/configuration.rb', line 39 config_accessor(:disqus_shortname, instance_writer: false) |
#disqus_shortname=(shortname) ⇒ Object
Sets #disqus_shortname.
If the user has defined a disqus shortname but hasn't set include_comments to
:disqus will print a warning to the console.
shortname - A String with the diquss username to use.
146 147 148 149 150 151 152 153 |
# File 'lib/blogit/configuration.rb', line 146 def disqus_shortname=(shortname) return if shortname.blank? unless include_comments == :disqus blogit_warn "You've set config.disqus_shortname in your blogit config file but " \ "config.include_comments is not set to :disqus" end @disqus_shortname = shortname end |
#hidden_states ⇒ Object
List of states that will hide the posts from the public.
Defaults to HIDDEN_STATES
109 |
# File 'lib/blogit/configuration.rb', line 109 config_accessor(:hidden_states) { HIDDEN_STATES } |
#highlight_code_syntax ⇒ Object
-
At the moment this only works when default_parser is :markdown
Should text within ““‘” or “`” be highlighted as code? Defaults to true
86 |
# File 'lib/blogit/configuration.rb', line 86 config_accessor(:highlight_code_syntax) { true } |
#include_comments ⇒ Object
How do you want to handle comments for your blog?
Valid options are :active_record, :disquss, or :no for none.
(default: :active_record)
34 |
# File 'lib/blogit/configuration.rb', line 34 config_accessor(:include_comments) { :active_record } |
#include_share_bar ⇒ Object
Load a javascript-based share bar on each blog post?. (default: true)
43 |
# File 'lib/blogit/configuration.rb', line 43 config_accessor(:include_share_bar) { true } |
#layout ⇒ Object
The layout to be used by the posts controller
Defaults to nil
126 |
# File 'lib/blogit/configuration.rb', line 126 config_accessor :layout |
#posts_per_page ⇒ Object
67 |
# File 'lib/blogit/configuration.rb', line 67 config_accessor(:posts_per_page) { 5 } |
#redcarpet_options ⇒ Object
When using redcarpet as content parser, pass these options as defaults
Defaults to REDCARPET_OPTIONS
97 |
# File 'lib/blogit/configuration.rb', line 97 config_accessor(:redcarpet_options) { REDCARPET_OPTIONS } |
#rss_feed_description ⇒ Object
The description to use in the index.rss template.
(default: "Latest from [My Application]")
Returns a String
120 |
# File 'lib/blogit/configuration.rb', line 120 config_accessor(:rss_feed_description, instance_reader: false) |
#rss_feed_title ⇒ Object
The title to use in the index.rss template. (default: [My Application] Blog
Posts")
Returns a String
115 |
# File 'lib/blogit/configuration.rb', line 115 config_accessor(:rss_feed_title, instance_reader: false) |
#show_post_description ⇒ Object
Should show a description of the blog post on the index and RSS feed.
Defaults to true
133 |
# File 'lib/blogit/configuration.rb', line 133 config_accessor(:show_post_description) { true } |
#syntax_highlighter ⇒ Object
The renderer used for code highlighting Defaults to :albino
91 |
# File 'lib/blogit/configuration.rb', line 91 config_accessor(:syntax_highlighter) { :albino } |
#twitter_username ⇒ Object
Twitter username used in the share bar. (default: nil)
47 |
# File 'lib/blogit/configuration.rb', line 47 config_accessor(:twitter_username) |