All Projects → simukappu → Activity_notification

simukappu / Activity_notification

Licence: mit
Integrated user activity notifications for Ruby on Rails

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Activity notification

Gravatar image tag
A configurable and documented Rails view helper for adding gravatars into your Rails application
Stars: ✭ 359 (-6.27%)
Mutual labels:  rails
Qteventbus
iOS事件总线,支持AppDelegate解耦,支持基于响应链的局部总线
Stars: ✭ 365 (-4.7%)
Mutual labels:  notification
Angular Token
🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:
Stars: ✭ 376 (-1.83%)
Mutual labels:  rails
Orientation
Your best weapon in the fight against outdated documentation.
Stars: ✭ 361 (-5.74%)
Mutual labels:  rails
Solidus
🛒Solidus, Rails eCommerce System
Stars: ✭ 3,985 (+940.47%)
Mutual labels:  rails
Interactor Rails
Interactor Rails provides Rails support for the Interactor gem.
Stars: ✭ 369 (-3.66%)
Mutual labels:  rails
Bootstrap Generators
Bootstrap-generators provides Twitter Bootstrap generators for Rails
Stars: ✭ 355 (-7.31%)
Mutual labels:  rails
Devise masquerade
Extension for devise, enable login as functionality. Add link to the masquerade_path(resource) and use it.
Stars: ✭ 380 (-0.78%)
Mutual labels:  rails
Socify
🚀 Socify is an open source social networking platform written in Ruby on Rails
Stars: ✭ 363 (-5.22%)
Mutual labels:  rails
Learn Rails
An example Rails 5.1 app to accompany the "Learn Ruby on Rails" book.
Stars: ✭ 375 (-2.09%)
Mutual labels:  rails
Loaf
Manages and displays breadcrumb trails in Rails app - lean & mean.
Stars: ✭ 360 (-6.01%)
Mutual labels:  rails
Aprenda Rubyonrails
🇧🇷 Recursos para aprender Ruby e Rails
Stars: ✭ 363 (-5.22%)
Mutual labels:  rails
Rails Template
A best & newest & fastest rails 6.x template for senior rails developer.
Stars: ✭ 372 (-2.87%)
Mutual labels:  rails
Notifications
🛎 Notifications Center engine like GitHub or other application for any Rails applications.
Stars: ✭ 359 (-6.27%)
Mutual labels:  notification
Annotate models
Annotate Rails classes with schema and routes info
Stars: ✭ 3,849 (+904.96%)
Mutual labels:  rails
Diplomat
A HTTP Ruby API for Consul
Stars: ✭ 358 (-6.53%)
Mutual labels:  rails
Railstrap
RailStrap is a HTML5 Ruby On Rails 4 Ruby 2.0.0 bootstrap
Stars: ✭ 365 (-4.7%)
Mutual labels:  rails
Deep pluck
Allow you to pluck attributes from nested associations without loading a bunch of records.
Stars: ✭ 385 (+0.52%)
Mutual labels:  rails
Second level cache
Write Through and Read Through caching library inspired by CacheMoney and cache_fu, support ActiveRecord 4, 5 and 6.
Stars: ✭ 380 (-0.78%)
Mutual labels:  rails
Suspenders
A Rails template with our standard defaults, ready to deploy to Heroku.
Stars: ✭ 3,748 (+878.59%)
Mutual labels:  rails

ActivityNotification

Build Status Coverage Status Dependency Inline docs Gem Version Gem Downloads MIT License

activity_notification provides integrated user activity notifications for Ruby on Rails. You can easily use it to configure multiple notification targets and make activity notifications with notifiable models, like adding comments, responding etc.

activity_notification supports Rails 5.0+ with ActiveRecord, Mongoid and Dynamoid ORM. It is tested for MySQL, PostgreSQL, SQLite3 with ActiveRecord, MongoDB with Mongoid and Amazon DynamoDB with Dynamoid. If you are using Rails 4.2, use v2.1.4 or older version of activity_notification.

About

activity_notification provides following functions:

  • Notification API for your Rails application (creating and managing notifications, query for notifications)
  • Notification models (stored with ActiveRecord, Mongoid or Dynamoid ORM)
  • Notification controllers (managing open/unopen of notifications, providing link to notifiable activity page)
  • Notification views (presentation of notifications)
  • Automatic tracked notifications (generating notifications along with the lifecycle of notifiable models)
  • Grouping notifications (grouping like "Kevin and 7 other users posted comments to this article")
  • Email notification
  • Batch email notification (event driven or periodical email notification, daily or weekly etc)
  • Push notification with Action Cable
  • Subscription management (subscribing and unsubscribing for each target and notification type)
  • REST API backend and OpenAPI Specification
  • Integration with Devise authentication
  • Activity notifications stream integrated into cloud computing using Amazon DynamoDB Streams
  • Optional notification targets (Configurable optional notification targets like Amazon SNS, Slack, SMS and so on)

Online Demo

You can see an actual application using this gem here:

Login as the following test users to experience user activity notifications:

Email Password Admin?
[email protected] changeit Yes
[email protected] changeit
[email protected] changeit
[email protected] changeit

The deployed demo application is included in this gem's source code as a test application here: /spec/rails_app

Notification index and plugin notifications

plugin-notifications-image

activity_notification deeply uses PublicActivity as reference in presentation layer.

Subscription management of notifications

subscription-management-image

Amazon SNS as optional notification target

optional-target-amazon-sns-email-image

Slack as optional notification target

optional-target-slack-image

Public REST API reference as OpenAPI Specification

REST API reference as OpenAPI Specification is published in SwaggerHub here:

You can see sample single page application using Vue.js as a part of example Rails application here:

This sample application works with activity_notification REST API backend.

Table of Contents

Getting Started

This getting started shows easy setup description of activity_notification. See Setup for more details.

Gem installation

You can install activity_notification as you would any other gem:

$ gem install activity_notification

or in your Gemfile:

gem 'activity_notification'

After you install activity_notification and add it to your Gemfile, you need to run the generator:

$ bin/rails generate activity_notification:install

The generator will install an initializer which describes all configuration options of activity_notification.

Database setup

When you use activity_notification with ActiveRecord ORM as default configuration, create migration for notifications and migrate the database in your Rails project:

$ bin/rails generate activity_notification:migration
$ bin/rake db:migrate

See Database setup for other ORMs.

Configuring models

Configure your target model (e.g. app/models/user.rb). Add acts_as_target configuration to your target model to get notifications.

class User < ActiveRecord::Base
  acts_as_target
end

Then, configure your notifiable model (e.g. app/models/comment.rb). Add acts_as_notifiable configuration to your notifiable model representing activity to notify for each of your target model. You have to define notification targets for all notifications from this notifiable model by :targets option. Other configurations are optional. :notifiable_path option is a path to move when the notification is opened by the target user.

class Article < ActiveRecord::Base
  belongs_to :user
  has_many :comments, dependent: :destroy
  has_many :commented_users, through: :comments, source: :user
end

class Comment < ActiveRecord::Base
  belongs_to :article
  belongs_to :user

  acts_as_notifiable :users,
    targets: ->(comment, key) {
      ([comment.article.user] + comment.article.reload.commented_users.to_a - [comment.user]).uniq
    },
    notifiable_path: :article_notifiable_path

  def article_notifiable_path
    article_path(article)
  end
end

See Configuring models for more details.

Configuring views

activity_notification provides view templates to customize your notification views. See Configuring views for more details.

Configuring routes

activity_notification also provides routing helper for notifications. Add notify_to method to config/routes.rb for the target (e.g. :users):

Rails.application.routes.draw do
  notify_to :users
end

See Configuring routes for more details.

You can also configure activity_notification routes as REST API backend with api_mode option like this:

Rails.application.routes.draw do
  scope :api do
    scope :"v2" do
      notify_to :users, api_mode: true
    end
  end
end

See Routes as REST API backend and REST API backend for more details.

Creating notifications

You can trigger notifications by setting all your required parameters and triggering notify on the notifiable model, like this:

@comment.notify :users, key: "comment.reply"

The first argument is the plural symbol name of your target model, which is configured in notifiable model by acts_as_notifiable. The new instances of ActivityNotification::Notification model will be generated for the specified targets.

See Creating notifications for more details.

Displaying notifications

activity_notification also provides notification views. You can prepare target notifications, render them in your controller, and show them provided or custom notification views.

See Displaying notifications for more details.

Run example Rails application

Test module includes example Rails application in spec/rails_app. Pull git repository and you can run the example application as common Rails application.

$ git pull https://github.com/simukappu/activity_notification.git
$ cd activity_notification
$ bundle install —path vendor/bundle
$ cd spec/rails_app
$ bin/rake db:migrate
$ bin/rake db:seed
$ bin/rails server

Then, you can access http://localhost:3000 for the example application.

Setup

See Setup.

Functions

See Functions.

Testing

See Testing.

Documentation

See API Reference for more details.

RubyDoc.info does not support parsing methods in included and class_methods of ActiveSupport::Concern currently. To read complete documents, please generate YARD documents on your local environment:

$ git pull https://github.com/simukappu/activity_notification.git
$ cd activity_notification
$ bundle install —path vendor/bundle
$ bundle exec yard doc
$ bundle exec yard server

Then you can see the documents at http://localhost:8808/docs/index.

Common Examples

See example Rails application in /spec/rails_app.

You can also try this example Rails application as Online Demo here:

You can login as test users to experience user activity notifications. For more details, see Online Demo.

Contributing

We encourage you to contribute to activity_notification! Please check out the Contributing to activity_notification guide for guidelines about how to proceed.

Everyone interacting in activity_notification codebases, issue trackers, and pull requests is expected to follow the activity_notification Code of Conduct.

We appreciate any of your contribution!

License

activity_notification project rocks and uses MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].