Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commenteux

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commenteux

  • 1.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Commenteux

This is a mountable gem that add a presentation layer to acts_as_commentable.

Mount this gem into your app to automatically have access to screens that list and create comments on any of your resources. Those screen will be inserted in your current app layout. You can call the routes of the gem with ajax passing a parent div where you want the response to ben inserted.

Note that the presentation layer is based on bootstrap.

Also note that you must have acts_as_commentable installed and declared in your desired resources.

== Installation :

Add the following line to your Gemfile

=== Rails 4

gem 'commenteux'

== Usage

Mount the commenteux gem in your routes:

mount Commenteux::Engine => "/"

The routes that will be available are :

   GET  /commenteux/:resource/:resource_id(.:format)            commenteux/notes#index
   GET  /commenteux/:resource/:resource_id/new(.:format)        commenteux/notes#new
   POST /commenteux/:resource/:resource_id(.:format)            commenteux/notes#create
   GET    /commenteux/:resource/:resource_id/:id/edit(.:format) commenteux/notes#edit
   PATCH  /commenteux/:resource/:resource_id/:id(.:format)      commenteux/notes#update
   DELETE /commenteux/:resource/:resource_id(.:format)          commenteux/notes#destroy {:format=>:js}

where :resource is the name of your model (you can use namespace)

==== Model Add acts_as_commentable in your model who will have comments

acts_as_commentable :private, :public

:private, :public are a example if specific role needed.

==== Model - Ability By default, only the user with admin role can modify or delete a comment. You can add others rights into your ability class.

if @user.has_role?(:admin_shipment) can :manage, Comment end

====Include the needed javascript file in your application.js or application.js.coffee

==== Javascript //= require commenteux/application ==== CoffeeScript #= require commenteux/application

Call url of commenteux screens, for exemple, like that:

<%= link_to " Notes".html_safe, "/commenteux/client::contract/#{@contract.id}?parent_div=ajax_target&roles=public,private&display_list_notes=true", :id => "notes_tab", :data => {:remote => true} %>

where roles is obligated when specific roles are declared in the model. Parameter display_list_notes is optional. The gem will set by default to true. Provides the ability to hide the list of comments in the index page if the parameter is false.

With a binding like that in your application.js

$(document).delegate '#notes_tab', 'ajax:success', (e, data, status, xhr) -> $('.tab_header').removeClass('active') $('#notes_tab_header').addClass('active') $('#ajax_target').html(xhr.responseText)

==== Rails Internationalization (en.yml) If specific roles of acts_as_commentable are declared in model, declare their labels under en: like

en: public: "Administrator" private: "Delivery man"

== Credits

{Jack Dempsey}[http://github.com/jackdempsey] - The creator of acts_as_commentable.

== Contributors

{Serge Savoie}[http://github.com/seurdge]

{Rémi Gagnon}[http://github.com/rgagnon]

{Nicolas Demers}[http://github.com/nickdemers]

== More

http://www.groupefungo.ca

FAQs

Package last updated on 07 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc