npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bigbinary/neeto-comments-frontend

v2.1.0

Published

A repo acts as the source of truth for the new nano's structure, configs, data etc.

Downloads

3

Readme

neeto-comments-nano

The neeto-comments-nano manages comments within an application, notifying mentioned users via email based on their preferences.

Contents

  1. Development with Host Application
  2. Instructions for Publishing

Development with Host Application

Engine

The engine handles the backend of the comments table and notifies preferred users via email upon the creation of a new comment.

Installation

  1. Add this line to your application's Gemfile:

     source "NEETO_GEM_SERVER_URL" do
       # ..existing gems
    
       gem "neeto-comments-engine"
     end
  2. And then execute:

    bundle install
  3. Add this line to your application's config/routes.rb file:

     mount NeetoCommentsEngine::Engine => "/neeto_comments_engine"
  4. Run the command to bring in all migrations required from the engine to the host application:

    bundle exec rails neeto_comments_engine:install:migrations
  5. Add the migrations to the database:

    bundle exec rails db:migrate

Usage

Model

NeetoCommentsEngine::Comment (source code)

This model has the following polymorphic associations

belongs_to :commentable, polymorphic: true
belongs_to :creator, polymorphic: true

Here, commentable is the entity for which we add a comment. For example, In NeetoPlanner, Task is a commentable entity. We can add comments in a Task as follows:

has_many :comments, as: :commentable, dependent: :destroy

Similarly creator is the entity which created the comment.

In the host app, we can use the Comment model by inheriting from it as follows:

class Comment < NeetoCommentsEngine::Comment
  self.table_name = "neeto_comments_engine_comments"
end

The following methods are required in the inherited model of the host app to notify users mentioned in the comment as soon as a comment is created:

    def email_data
      {
        preference_link:,      # Notification preference URL
        organization_name:,
        link_title:,           # Title
        subject:,              # Subject
        reply_to:              # Reply to email
      }
    end

The get_mentioned_ids_from_content method returns the list of ids of the mentioned users that needs to be notified and can be used as follows:

    def notifiable_users
      user_list = get_mentioned_ids_from_content(content)
      User.where(id: user_list)
    end

Controllers

NeetoCommentsEngine::Api::V1::CommentsController (source code)

In the host app, we can inherit the CommentsController as follows:

class Api::V1::CommentsController < NeetoCommentsEngine::Api::V1::CommentsController
  private

    def load_commentable!
      # required method in the host application to load the commentable entity
    end
end

Concern

NeetoCommentsEngine::NotificationPreferences (source code)

Include the following concern to the commentable model

include NeetoCommentsEngine::NotificationPreferences

The notify_mentioned_user?(user) returns a boolean value which decides whether to send email to that user or not. By default the method returns true. This can be overriden by the host application.

   def notify_mentioned_user?(user)
     true
   end

The notify_mentions_via_email? returns a boolean value which decides whether to send email for that commentable entity or not. By default the method returns true. This can be overriden by the host application.

    def notify_mentions_via_email?
      true
    end

Instructions for Publishing

Consult the building and releasing packages guide for details on how to publish.