Giter VIP home page Giter VIP logo

rbcomment's Introduction

RbComment

Build Status Scrutinizer Quality Score Code Coverage Total Downloads Latest Stable Version License

Zend Framework 2 module for drop-in, self-hosted comments, with email notifications, Akismet, ZfcUser and Gravatar integration.

Table of contents

Installation

  1. Add the module key to your composer.json file
    {
        "require": {
            "robertboloc/rbcomment": "^2.0"
        }
    }
  1. Run composer update

  2. Import the schema from data/schema.sql into your database.

  3. Add the new module to your application's modules list in config/application.config.php

    'modules' => array(
        'Application',
        'RbComment', // Add this
    ),

Usage

In your views use the rbComment helper to display the count, the list and a form for adding new comments. Invoke it where you want your comments box to appear. Simple isn't it? This helper can be used in any view.

<?php echo $this->rbComment($theme) ?>

The $theme parameter is used to specify the theme of the comments box (if none is specified default is used).

Currently, the module is designed to allow only one comment box per page, as it uses the page uri to identify a thread.

Themes

The module comes with 2 themes for now. To implement new ones create a new partial using as base the existing ones.

Use your new theme calling $this->rbComment('yourpartial')

The current themes (and possible values of the $theme parameter if not using a custom partial) are :

default

Basic theme with no external dependencies. Contains the minimum styling to make it look decent.

<?php echo $this->rbComment() ?>

uikit

uikit

This theme requires the UIkit CSS framework. Use this theme if your project is based on the UIkit framework.

<?php echo $this->rbComment('uikit') ?>

uikit

bootstrap3

This theme requires the Bootstrap v3.x.x CSS framework. Use this theme if your project is based on the Bootstrap framework, version 3.

<?php echo $this->rbComment('bootstrap3') ?>

bootstrap3

Configuration

The default configuration of the module can be found in the file config/module.config.php. To override the defaults, add your values under the rb_comment key in the config/autoload/local.php file of your application, using the same structure as in the defaults.

Currently the configurable parameters are:

default_visibility

This parameter controls the visibility of the newly published comments. If set to 1 all new published comments will be visible. If 0 they will not be shown. This is useful for moderation.

strings

This array contains the translations for the strings used in the comments box. To change or translate to another language override these values with your own.

email

This array contains email notifications parameters

'email' => array(
    /**
     * Send email notifications.
     */
    'notify' => false,
    /**
     * Email addresses where to send the notification.
     */
    'to' => array(),
    /**
     * From header. Usually something like [email protected]
     */
    'from' => '',
    /**
     * Subject of the notification email.
     */
    'subject' => 'New Comment',
    /**
     * Text of the comment link.
     */
    'context_link_text' => 'See this comment in context',
),

For sending the emails the module uses a service factory called RbComment\Mailer. As a default it configures a sendmail transport. This should be changed in production and customized to your needs (probably with smtp). To do this rewrite the service factory RbComment\Mailer.

akismet

The module provides integration with the Akismet service. Comments marked as spam will be hidden (not deleted) and no notification will be sent. To use this feature the following params must be configured:

'akismet' => array(
    /**
     * If this is true, the comment will be checked for spam.
     */
    'enabled' => false,
    /**
     * Your Akismet api key.
     */
    'api_key' => '',
    /**
     * Akismet uses IP addresses. If you are behind a proxy this SHOULD
     * be configured to avoid false positives.
     * Uses the class \Zend\Http\PhpEnvironment\RemoteAddress
     */
    'proxy' => array(
        /**
         * Use proxy addresses or not.
         */
        'use' => false,
        /**
         * List of trusted proxy IP addresses.
         */
        'trusted' => array(
        ),
        /**
         * HTTP header to introspect for proxies.
         */
        'header' => 'X-Forwarded-For',
    ),
),

zfc_user

By default the ZfcUser integration is disabled. To use it you must update this flag in your config file.

'zfc_user' => array(
    /**
     * This enables the ZfcUser integration.
     */
    'enabled' => false,
),

gravatar

By default the Gravatar integration is disabled. To use it you must update this flag in your config file.

'gravatar' => array(
    /**
     * This enables the Gravatar integration.
     */
    'enabled' => false,
),

CLI

The following cli commands are available:

delete spam Delete all comments marked as spam from the database

This can be added to your cron to periodically remove spam from the database and keep your tables clean and light.

Roadmap

If you want to contribute to the development of this module and don't know where to start you can pick one of this tasks :

  • Allow multiple instances of the comments box on the same page
  • Use AJAX for storing/retrieving comments
  • Emoji integration
  • Block spammers by IP
  • More themes

Notes

  • If you are using the BjyAuthorize module (or any other route restricting module) make sure the route rbcomment is publicly accessible.

  • This module assumes you have a database adapter configured.

rbcomment's People

Contributors

robertmarsal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rbcomment's Issues

plugin ?

Is there (or they get you) extensions "wordpress" and co

ZfcUser

Hi I was wondering if you have thought of making a ZfcUser integration option.
I also would like to set something other than the uri as an identifier. So Its possible to have multiple commenting forms on the same page.

csrf issue

I found a problem where the csrf element would fail validation if a second comment was added ( to the same thread or a new thread).
I don't think this is an issue with RbComment but I mention it in case anyone else encounters it.
I was able to get round it by forcing a regeneration of the csrf hash. I did this in the theme partial by adding:

$this->form->get('csrf')->prepareElement($this->form);

before outputting the form()->openTag.

Closure in module config will cause fatal if config cache is enabled

instead of putting it to module.config.php you can move all closures into Module.php or seperate Factory class which implements FactoryInterface.

in that case application with your module will be able to cache configuration and factories with closures will be loaded in your Module.php

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.