Skip to content

kurenn/talkie

Repository files navigation

Talkie

Build Status Test Coverage

Talkie is highly customizable comments engine to easily integrate threads to any existing model, inspired by commontator and with simplicity as the drive for this. Its intention is to be a full solution for your application in case you need to provide your users with the ability to open a forum anywhere.

Installation

Talkie works with Rails 5.0 onwards. The first step is to add it to your Gemfile:

gem "talkie"

And then run the bundle install.

Next, you need to run the install generator:

$ rails generate talkie:install

At this point, a thanks message will appear in the console. Be aware that you need to have a current_user method with the logged in user, there is no guest support currently

The generator will install an initializer which describes ALL Talkie's configuration options. It is highly recommended that you take a look at it. Also notice that a new migration is provided, you need to migrate your database:

$ rails db:migrate

Usage

After running the generator, you need to set up the models you need to add comments to and the ones who are able to post them.

  1. For the models to be able to comment to:
acts_as_commentable
  1. For the models to be able to create comments(commonly the User model):
acts_as_talker

After that you just need to call the helper to render the comments thread. So let's say you have an Article model on which you desire to add this:

app/views/articles/show.html.erb

<%= talkie_on @article %>

For more options on how to customize the render of the comments, check out the customization section.

After this, you need to add the default styles and JS provided by the gem, just add them to the corresponding manifests like so:

app/assets/stylesheets/application.scss

@import "talkie/application";

app/assets/javascripts/application.js

//= require talkie/application

Customization

Talkie, currently only offers 3 options for the talkie_on helper method:

Name Description
nested Whether users are able to reply to comments or not. Default: false
display_user_avatar Whether the helper should render an avatar. Default: false
display_user_handler Whether the helper should render the user handler. Default: false
deletable Whether the helper should render the delete link. Default: false

Don't worry about those nasty N+1 queries, Talkie is smart enough to take care of them. You don't need to restart the server for chanes on this invokation.

There is another way to customize Talkie, and that is at the initializer provided by the install generator, you can check that here

Styles

Talkie is all about customization, so almost every default style provided by the gem can be overwritten through sass variables, which you can find here. Make sure you add the variables right before importing the sass talkie manifest:

@import "my_variables_to_override";
@import "talkie/application";

Enabling mentions

Talkie comes with a handy feature that you can toggle in order to enable/disable user mentions.

To enable it, just go to you talkie.rb initializer file and uncomment or add:

config.enable_mentions = true

For customization, check the template, you can basically override anything to fulfill your needs.

When enabling this module, you need to setup your mailer configuration, as with each mentions the commenter subscribes to the comment and receives an email, just be aware of that.

If you have a hard time understanding this, you can check the dummy application I use for testing or contact me

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake to run the tests.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kurenn/talkie. 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 Talkie project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

A Rails Engine to easily integrate comments

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published