Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

cmtt-ru/newrphus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Newrphus

Let users send misprints from your website to Slack.

License Latest Stable Version

Library contains PHP back-end library and Javascript front-end file. You should use both of them to make misprint reporter works.

How it works

When user selects text on a page and presses Ctrl+Enter, the Newrphus sends POST request to url. You can also include userId parameter to track users. Right after the keypress event, it calls callback function, where you can tell user that report was sent.

How to use

  1. Create new Incoming webhook in Slack.

  2. Install PHP library with Composer.

  3. Create backend handler for JS Ajax call.

    $newrphus = new TJ\Newrphus();
    $reviewer->setSlackSettings([
        'endpoint' => 'https://hooks.slack.com/services/ABCDE/QWERTY',
        'channel' => '#misprints'
    ]);
    $reviewer->report($_POST['misprintText'], $_POST['misprintUrl']);

    If you want to customize Slack message, see example.php.

  4. Include js to the page, where you want to track misprints.

    <script src="js/newrphus.js"></script>
    <script>
      newrphus.init({
        url: 'example.php',
        userId: 12345,
        callback: function() {
          alert('Misprint sent');
        }
      });
    </script>
  5. Tell users to select text and press Ctrl+Enter to send report.

Installing via Composer

composer.phar require tjournal/newrphus

Then include Composer's autoloader:

require 'vendor/autoload.php';