Giter Club home page Giter Club logo

simple_discussion's Introduction

SimpleDiscussion - Forum engine for Ruby on Rails

Build Status Gem Version

SimpleDiscussion is a Rails forum gem extracting the GoRails forum. It includes categories, simple moderation, the ability to mark threads as solved, and more.

Out of the box, SimpleDiscussion comes with styling for Bootstrap v4 but you're free to customize the UI as much as you like by installing the views and tweaking the HTML.

GoRails Forum

Installation

Before you get started, SimpleDiscussion requires a User model in your application (for now).

Add this line to your application's Gemfile:

gem 'simple_discussion'

And then execute:

bundle

Install the migrations and migrate:

rails simple_discussion:install:migrations
rails db:migrate

Add SimpleDiscussion to your User model. The model must have name method which will be used to display the user's name on the forum. Currently only a model named User will work, but this will be fixed shortly.

class User < ActiveRecord::Base
  include SimpleDiscussion::ForumUser

  def name
    "#{first_name} #{last_name}"
  end
end

Optionally, you can add a moderator flag to the User model to allow users to edit threads and posts they didn't write.

rails g migration AddModeratorToUsers moderator:boolean
rails db:migrate

Add the following line to your config/routes.rb file:

mount SimpleDiscussion::Engine => "/forum"

Lastly, add the CSS to your application.css to load some default styles.

*= require simple_discussion

Usage

To get all the basic functionality, the only thing you need to do is add a link to SimpleDiscussion in your navbar.

<%= link_to "Forum", simple_discussion_path %>

This will take the user to the views inside the Rails engine and that's all you have to do!

Customizing All The Things!

If you'd like to customize the color schemas , then you can follow these steps

  • Create an scss file [simple_discussion_override_color.scss] and add the following code to it
// Colors of the button is depend on this brand-color
$brand-color: #42b983; 
// Color for icon and text of `Closed` / `solved` tag
$thread-solved-color: #42b983; 
// Color for icon and text of `Opened` / `Unsolved` tag
$thread-unsolved-color: #f29d38; 
// Button background color for primary buttons
$button-background-color: #fff;
// Shadown color when hovering over the buttons
$button-hover-shadow-color: rgba(77, 219, 155, .5); 
// active links color
$link-active-color: #000;
// inactive links color
$link-inactive-color: #555;
// Color for thread filter buttons on hover
$forum-thread-filter-btn-link-hover-background: #f3f4f6;
  • Add the scss file to application.scss.

    Note : Make sure that the file is imported before the simple_discussion.scss file

...
@import 'simple_discussion_override_color.scss';
@import 'simple_discussion';
...
  • Now, you can customize the colors, as per your need

If you'd like to customize the views that SimpleDiscussion uses, you can install the views to your Rails app:

rails g simple_discussion:views

You can also install a copy of the SimpleDiscussion controllers for advanced customization:

rails g simple_discussion:controllers

Helpers are available for override as well. They are used for rendering the user avatars, text formatting, and more.

rails g simple_discussion:helpers

NOTE: Keep in mind that the more customization you do, the tougher gem upgrades will be in the future.

Email And Slack Notifications

By default, SimpleDiscussion will attempt to send email and slack notifications for users subscribed to threads. To turn these off you can do the following in config/initializers/simple_discussion.rb

SimpleDiscussion.setup do |config|
  config.send_email_notifications = false # Default: true
  config.send_slack_notifications = false # Default: true
end

Slack notifications require you to set simple_discussion_slack_url in your config/secrets.yml. If you don't have this value set, it will not attempt Slack notifications even if they are enabled.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/excid3/simple_discussion. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the SimpleDiscussion project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

simple_discussion's People

Contributors

excid3 avatar tanmoysrt avatar scratchoo avatar tachyons avatar blimey85 avatar okendoken avatar amanpatel123 avatar afomera avatar anquinn avatar deepak05kr18 avatar shauryag2002 avatar tylerdiaz avatar yonnyquiceno avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.