├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── cat.png ├── index.js ├── package.json └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '4' 4 | - '5' 5 | cache: 6 | directories: 7 | - node_modules 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # rich-message change log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | This project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | ## [1.0.2](https://github.com/moose-team/rich-message/compare/v1.0.1...v1.0.2) 8 | 9 | * fix channel name parsing bug ([#8](https://github.com/moose-team/rich-message/issues/8)) 10 | * add tests ([#9](https://github.com/moose-team/rich-message/pull/9)) 11 | * simplify internal directory structure 12 | * move `cat.png` into `rich-message` module 13 | * update `.travis.yml` to target node 4 & 5, remove outdated optimizations 14 | * add usage example 15 | 16 | ## [1.0.1](https://github.com/moose-team/rich-message/compare/v1.0.0...v1.0.1) 17 | 18 | * fix channel link formatting ([#6](https://github.com/moose-team/rich-message/pull/6)) 19 | * use MOOSE Team MIT License ([#7](https://github.com/moose-team/rich-message/pull/7)) 20 | 21 | ## 1.0.0 22 | * initial release 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Contributions welcome! Please check past issues and pull requests before you open your own issue or pull request to avoid duplicating a frequently asked question. 4 | 5 | In addition to improving the project, refactoring code, and implementing features, this project welcomes the following types of contributions: 6 | 7 | - **Ideas**: participate in an issue thread or start your own to have your voice heard. 8 | - **Writing**: contribute your expertise in an area by helping expand the included content. 9 | - **Copy editing**: fix typos, clarify language, and generally improve the quality of the content. 10 | - **Formatting**: help keep content easy to read with consistent formatting. 11 | 12 | ## Install 13 | 14 | Fork and clone the repo, then `npm install` to install all dependencies. 15 | 16 | ## Testing 17 | 18 | Tests are run with `npm test`. Please ensure all tests are passing before submitting a pull request (unless you're creating a failing test to increase test coverage or show a problem). 19 | 20 | ## Code Style 21 | 22 | [![standard][standard-image]][standard-url] 23 | 24 | This repository uses [`standard`][standard-url] to maintain code style and consistency and avoid style arguments. `npm test` runs `standard` so you don't have to! 25 | 26 | [standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg 27 | [standard-url]: https://github.com/feross/standard 28 | [semistandard-image]: https://cdn.rawgit.com/flet/semistandard/master/badge.svg 29 | [semistandard-url]: https://github.com/Flet/semistandard 30 | 31 | --- 32 | 33 | # Collaborating Guidelines 34 | 35 | **This is an OPEN Open Source Project.** 36 | 37 | ## What? 38 | 39 | Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. 40 | 41 | ## Rules 42 | 43 | There are a few basic ground-rules for contributors: 44 | 45 | 1. **No `--force` pushes** or modifying the Git history in any way. 46 | 1. **Non-master branches** ought to be used for ongoing work. 47 | 1. **External API changes and significant modifications** ought to be subject to an **internal pull-request** to solicit feedback from other contributors. 48 | 1. Internal pull-requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor. 49 | 1. Contributors should attempt to adhere to the prevailing code style. 50 | 51 | ## Releases 52 | 53 | Declaring formal releases remains the prerogative of the project maintainer. 54 | 55 | ## Changes to this arrangement 56 | 57 | This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change. 58 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # [MIT License](https://spdx.org/licenses/MIT) 2 | 3 | Copyright (c) 2015-2016 [MOOSE Team](http://moose-team.github.io) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rich-message 2 | 3 | > Turn a plain message into a rich HTML message 4 | 5 | [![npm][npm-image]][npm-url] 6 | [![travis][travis-image]][travis-url] 7 | 8 | [npm-image]: https://img.shields.io/npm/v/rich-message.svg?style=flat-square 9 | [npm-url]: https://www.npmjs.com/package/rich-message 10 | [travis-image]: https://img.shields.io/travis/moose-team/rich-message.svg?style=flat-square 11 | [travis-url]: https://travis-ci.org/moose-team/rich-message 12 | 13 | ## Install 14 | 15 | ``` 16 | npm install rich-message 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | var richMessage = require('rich-message') 23 | var basicMessage = { 24 | text: 'hi maxogden', // text entered by a user 25 | username: 'mafintosh', // github username 26 | timestamp: Date.now() 27 | } 28 | var username = 'maxogden' // current user's github username (used for highlighting) 29 | 30 | var output = richMessage(basicMessage, username) 31 | // { text: 'hi maxogden', 32 | // username: 'mafintosh', 33 | // timestamp: 1458939703123, 34 | // anon: false, 35 | // avatar: 'https://github.com/mafintosh.png', 36 | // timeago: '2:01 PM', 37 | // html: '
hi maxogden
hi maxogden
' + 80 | 'cats ' + 81 | 'isaacs/npm#1234' + 82 | '
' + 97 | 'cat
cat' + 98 | '' + 113 | 'cat' + 114 | '
' +
143 | 'cat
cat' +
144 | '
cat1
' 154 | } 155 | 156 | var message2 = { 157 | text: 'cat2', 158 | html: 'cat2
' 159 | } 160 | 161 | var output = mergeMessages(message1, message2) 162 | var expected = { 163 | text: 'cat1\ncat2', 164 | html: 'cat1
cat2
' 165 | } 166 | 167 | t.deepEqual(output, expected) 168 | t.end() 169 | }) 170 | --------------------------------------------------------------------------------