Skip to content

jailalawat/thredded

 
 

Repository files navigation

Thredded Code Climate Travis-CI

Thredded is a rails 4+ forum/messageboard engine. Its goal is to be as simple and feature rich as possible.

If you're looking for variations on a theme - see Discourse, Forem, Tectura or Heterotic Beast. The last two are forks from Rick Olsen and Courtenay's Altered Beast. Of those it should be noted that Forem is an engine - not a standalone app.

Installation

Add the gem to your Gemfile:

gem 'thredded'

Add an initializer to your app: config/initializers/thredded.rb. Configuration options:

Thredded.user_class = 'User'
Thredded.email_incoming_host = 'incoming.example.com'
Thredded.email_from = '[email protected]'
Thredded.email_outgoing_prefix = '[Thredded] '
Thredded.user_path = ->(user){ "/path/to/where/you/show/#{user}" }
Thredded.file_storage = :file # or :fog
Thredded.asset_root = 'http://assets.website.com/assets' # where important things, like emojis, might live
Thredded.layout = 'thredded' # looks for `app/views/layouts/thredded.html.erb`
Thredded.avatar_default = 'mm' # or other gravatar defaults or URL to an image
Thredded.queue_backend = :threaded_in_memory_queue # :sidekiq, :resque, or :delayed_job
Thredded.queue_memory_log_level = Logger::WARN # if using the threaded in memory queue it defaults to warn, but if you'd like more info, change to Logger::INFO or Logger::DEBUG
Thredded.queue_inline = false # change for environments you want to run jobs inline

Copy the migrations over to your parent application and migrate:

rake thredded:install:migrations db:migrate db:test:prepare

Mount the thredded engine in your routes file:

mount Thredded::Engine => '/forum'

Background Job Requirements

This gem has several gem agnostic background jobs. Currently resque, sidekiq, delayed_job, and a threaded in-memory queue are supported thanks to Richard Schneeman's Q gem. The configuration detailed above allows you to specify which job queue you prefer with Thredded.queue_backend. The available options are one of the following symbols - :threaded_in_memory_queue, :sidekiq, :resque, or :delayed_job.

When using the threaded in-memory queue you may optionally update its log-level for more granular debugging with the Thredded.queue_memory_log_level setting.

When running the app in a test environment you may want to set your queue to run the jobs inline. In your config you may want to set the option based on environment. EG:

Thredded.queue_inline = Rails.env.test?

Get Your Parent App Ready

There are a few things you need in your app to get things looking just right.

  1. Add a to_s method to your user model. The following example assumes a column in my user model called name:
class User < ActiveRecord::Base
  def to_s
    name
  end
end
  1. Ensure you have a view layout that thredded will wrap around its views.

A couple of notes with regards to your layout.

  • When using route helpers -- eg: new_session_path, et al -- make sure to prepend main_app to the helper: main_app.new_session_path as rails engines like thredded will not know about those routes' existence unless explicitly told so.
  • As noted above, by default thredded will look for a layout file in your application called thredded.html.erb. If you would like to use something else, like your main application layout, you may change it to that in your initializer.
  • The chosen layout has two content_tags available to yield - :thredded_page_title and :thredded_page_id. The views within thredded pass those up through to your layout if you would like to use them. Example layout:
<html>
  <head>
  <title>My Application | <%= yield :thredded_page_title %></title>
  </head>
  <body id="<%= yield :thredded_page_id %>">
    <%= yield %>
  </body>
</html>

About

A rails forum engine

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 98.9%
  • Other 1.1%