Skip to content

Commit

Permalink
make config class compatible with rails < 4
Browse files Browse the repository at this point in the history
AS::Configurable's `config_accessor` supports a default block
only since rails 4 -- see rails/rails#7645.
  • Loading branch information
glaszig committed Mar 17, 2017
1 parent 01214ba commit e6e5612
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions lib/blogit/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Configuration
# How do you want to handle comments for your blog?
# Valid options are :active_record, :disquss, or :no for none.
# (default: :active_record)
config_accessor(:include_comments) { :active_record }
config_accessor(:include_comments)
config.include_comments = :active_record

##
# When using :disqus comments, what is the shortname of your forum?
Expand All @@ -40,7 +41,8 @@ class Configuration

##
# Load a javascript-based share bar on each blog post?. (default: true)
config_accessor(:include_share_bar) { true }
config_accessor(:include_share_bar)
config.include_share_bar = true

##
# Twitter username used in the share bar. (default: nil)
Expand All @@ -49,64 +51,75 @@ class Configuration
##
# The name of the controller method we'll call to return the current blogger.
# (default: :current_user)
config_accessor(:current_blogger_method) { :current_user }
config_accessor(:current_blogger_method)
config.current_blogger_method = :current_user

##
# What method do we call on blogger to return their display name? (default: :username)
config_accessor(:blogger_display_name_method) { :username }
config_accessor(:blogger_display_name_method)
config.blogger_display_name_method = :username

##
# Which DateTime::FORMATS format do we use to display blog and comment publish time
# (default: :short)
config_accessor(:datetime_format) { :short }
config_accessor(:datetime_format)
config.datetime_format = :short

##
# Number of {Blogit::Post posts} to show per page. This is a configuration for {https://github.com/amatsuda/kaminari Kaminari} (default: 5)
#
# Returns an Integer
config_accessor(:posts_per_page) { 5 }
config_accessor(:posts_per_page)
config.posts_per_page = 5

##
# If set to true, the comments form will POST and DELETE to the comments
# controller using AJAX calls.
#
# Returns true or false
config_accessor(:ajax_comments) { true }
config_accessor(:ajax_comments)
config.ajax_comments = true

##
# The default format for parsing the blog content.
#
# Defaults to :markdown
config_accessor(:default_parser) { :markdown }
config_accessor(:default_parser)
config.default_parser = :markdown

##
# Should text within "```" or "`" be highlighted as code?
# Defaults to true
# @note - At the moment this only works when default_parser is :markdown
config_accessor(:highlight_code_syntax) { true }
config_accessor(:highlight_code_syntax)
config.highlight_code_syntax = true

##
# The renderer used for code highlighting
# Defaults to :albino
config_accessor(:syntax_highlighter) { :albino }
config_accessor(:syntax_highlighter)
config.syntax_highlighter = :albino

##
# When using redcarpet as content parser, pass these options as defaults
#
# Defaults to {REDCARPET_OPTIONS}
config_accessor(:redcarpet_options) { REDCARPET_OPTIONS }
config_accessor(:redcarpet_options)
config.redcarpet_options = REDCARPET_OPTIONS

##
# List of states that will be visible to the public
#
# Defaults to ACTIVE_STATES
config_accessor(:active_states) { ACTIVE_STATES }
config_accessor(:active_states)
config.active_states = ACTIVE_STATES

##
# List of states that will hide the posts from the public.
#
# Defaults to HIDDEN_STATES
config_accessor(:hidden_states) { HIDDEN_STATES }
config_accessor(:hidden_states)
config.hidden_states = HIDDEN_STATES

##
# The title of the RSS feed for the blog posts
Expand All @@ -130,7 +143,8 @@ class Configuration
# and RSS feed.
#
# Defaults to true
config_accessor(:show_post_description) { true }
config_accessor(:show_post_description)
config.show_post_description = true


def default_parser_class
Expand Down

0 comments on commit e6e5612

Please sign in to comment.