Class: Blogit::Configuration

Inherits:
Object
  • Object
show all
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

ACTIVE_STATES =

An Array containing the default states for Posts that are considered "active". ("Active" 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" 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)

Instance Method Details

- (Object) active_states

List of states that will be visible to the public

Defaults to ACTIVE_STATES


98
# File 'lib/blogit/configuration.rb', line 98

config_accessor(:active_states) { ACTIVE_STATES }

- (Object) ajax_comments

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 }

- (Object) blogger_display_name_method

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 }

- (Object) current_blogger_method

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 }

- (Object) datetime_format

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 }

- (Object) default_parser

The default format for parsing the blog content.

Defaults to :markdown


80
# File 'lib/blogit/configuration.rb', line 80

config_accessor(:default_parser) { :markdown }

- (Object) default_parser_class


131
132
133
# File 'lib/blogit/configuration.rb', line 131

def default_parser_class
  "Blogit::Parsers::#{default_parser.to_s.classify}Parser".constantize
end

- (Object) disqus_shortname

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)

- (Object) disqus_shortname=(shortname)

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.

Parameters:

  • shortname

    A String with the diquss username to use.


141
142
143
144
145
146
147
148
# File 'lib/blogit/configuration.rb', line 141

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

- (Object) hidden_states

List of states that will hide the posts from the public.

Defaults to HIDDEN_STATES


104
# File 'lib/blogit/configuration.rb', line 104

config_accessor(:hidden_states) { HIDDEN_STATES }

- (Object) highlight_code_syntax

Should text within "``" or "" be highlighted as code? Defaults to true @note - At the moment this only works when default_parser is :markdown


86
# File 'lib/blogit/configuration.rb', line 86

config_accessor(:highlight_code_syntax) { true }

- (Object) include_comments

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 }

- (Object) include_share_bar

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 }

- (Object) layout

The layout to be used by the posts controller

Defaults to nil


121
# File 'lib/blogit/configuration.rb', line 121

config_accessor :layout

- (Object) posts_per_page

Number of posts to show per page. This is a configuration for Kaminari (default: 5)

Returns:

  • an Integer


67
# File 'lib/blogit/configuration.rb', line 67

config_accessor(:posts_per_page) { 5 }

- (Object) redcarpet_options

When using redcarpet as content parser, pass these options as defaults

Defaults to REDCARPET_OPTIONS


92
# File 'lib/blogit/configuration.rb', line 92

config_accessor(:redcarpet_options) { REDCARPET_OPTIONS }

- (Object) rss_feed_description

The description to use in the index.rss template. (default: "Latest from [My Application]")

Returns:

  • a String


115
# File 'lib/blogit/configuration.rb', line 115

config_accessor(:rss_feed_description, instance_reader: false)

- (Object) rss_feed_title

The title to use in the index.rss template. (default: [My Application] Blog Posts")

Returns:

  • a String


110
# File 'lib/blogit/configuration.rb', line 110

config_accessor(:rss_feed_title, instance_reader: false)

- (Object) show_post_description

Should show a description of the blog post on the index and RSS feed.

Defaults to true


128
# File 'lib/blogit/configuration.rb', line 128

config_accessor(:show_post_description) { true }

- (Object) twitter_username

Twitter username used in the share bar. (default: nil)


47
# File 'lib/blogit/configuration.rb', line 47

config_accessor(:twitter_username)