Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psychobunny/nodebb-plugin-blog-comments
Lets NodeBB act as a comments engine/widget for your blog
https://github.com/psychobunny/nodebb-plugin-blog-comments
Last synced: 8 days ago
JSON representation
Lets NodeBB act as a comments engine/widget for your blog
- Host: GitHub
- URL: https://github.com/psychobunny/nodebb-plugin-blog-comments
- Owner: psychobunny
- License: bsd-2-clause
- Created: 2014-02-14T23:41:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-06-09T13:59:58.000Z (over 1 year ago)
- Last Synced: 2024-10-16T18:19:14.314Z (23 days ago)
- Language: JavaScript
- Size: 363 KB
- Stars: 98
- Watchers: 12
- Forks: 55
- Open Issues: 40
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodebb - blog-comments - Lets NodeBB act as a comments engine/widget for your blog. (Plugins)
README
# NodeBB Blog Comments
Lets NodeBB act as a comments engine/widget for your blog. Currently supports both [Ghost](https://ghost.org/) and [WordPress](http://wordpress.org/). There is a separate repo for [PencilBlue](https://github.com/theunknownartisthour/nodebb-comments-pencilblue) support. If you'd like to see support for other CMS/blog systems, please submit an issue on our tracker.
The comments are exposed to any plugin you have built into the core, so it is completely possible to have emoticons, embedded video, and/or whatever else you want in the comments section of your blog.
Articles are published to a forum category of your choice, and will gain a tag that links it back to the original article.
## What's new in 0.8x
* The WP-JSON plugin is no longer required. This plugin will now use the built-in JSON API.
* The comments snippet has changed, please update your integration code as necessary
* Fixed a bug that caused errors when no [ACAO](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin) header was defined## Upgrading to 0.6x
Getting `Unexpected end of JSON input` for `/comments/publish`? On your blog's post template (ex. `post.hbs` for Ghost) where you have installed the blog comments script, find the following line:
```
{{../post.markdown}}
```and above, add:
```
{{../post.title}}
```## What's new in 0.3x
* Fixed quite a few server crashes (especially when publishing)
* Compatible with NodeBB 0.6x+ and Ghost 0.5.10
* Added tags support for Ghost
* Added comment support in general## Screenshots
![blog comments](http://i.imgur.com/pPO42Hy.png)
## Installation
First install the plugin:
npm install nodebb-plugin-blog-comments
Activate the plugin in the ACP and reboot NodeBB. Head over to the Blog Comments section in the ACP and select the Category ID you'd like to publish your blog content to (default is Category 1). Make sure you put the correct URL to your blog.
### Ghost Installation
Paste this any where in `yourtheme/post.hbs`, somewhere between `{{#post}}` and `{{/post}}`. All you have to edit is line 3 (`nbb.url`) - put the URL to your NodeBB forum's home page here.
var nbb = {};
nbb.url = '//your.nodebb.com'; // EDIT THIS
nbb.cid = 1; // OPTIONAL. Forces a Category ID in NodeBB.
// Omit it to fallback to specified IDs in the admin panel.(function() {
nbb.articleID = '{{../post.id}}';
nbb.tags = [{{#../post.tags}}"{{name}}",{{/../post.tags}}];
nbb.script = document.createElement('script'); nbb.script.type = 'text/javascript'; nbb.script.async = true;
nbb.script.src = nbb.url + '/plugins/nodebb-plugin-blog-comments/lib/ghost.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(nbb.script);
})();{{../post.title}}
{{../post.markdown}}
Please enable JavaScript to view comments
```If you wish, you can move `` to where you want to place the actual comments widget.
### Wordpress Installation
Replace the contents of `/wp-content/themes/YOUR_THEME/comments.php` with the following (back-up the old comments.php, just in case):
```html
const nodeBBURL = '//your.nodebb.com';
const wordpressURL = '<?php get_site_url(); ?>';
const articleID = \''.get_the_ID().'\';
const categoryID = null; // OPTIONAL. Forces a Category ID in NodeBB.
// Omit it to fallback to specified IDs in the admin panel.(function() {
var nbb = document.createElement('script'); nbb.type = 'text/javascript'; nbb.async = true;
nbb.src = nodeBBURL + '/plugins/nodebb-plugin-blog-comments/lib/wordpress.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(nbb);
})();Please enable JavaScript to view comments
```### General - PHP example
Paste this any where that you want load commenting system. All you have to edit is line 3 (`nodeBBURL`) - put the URL to your NodeBB forum's home page here. You can also use any template engine (hbs, eco...) instead of PHP.```html
var nodeBBURL = '//your.nodebb.com',<?php
echo "articleID = " .getId().";";
$obj = new stdClass();
$obj->title_plain = "";
$obj->url="";
$obj->tags = [];
$obj->markDownContent= "";
$obj->cid = 1; // OPTIONAL. Forces a Category ID in NodeBB.
// Omit it to fallback to specified IDs in the admin panel.
echo "var articleData =" .json_encode($obj).";";
?>(function() {
var nbb = document.createElement('script'); nbb.type = 'text/javascript'; nbb.async = true;
nbb.src = nodeBBURL + '/plugins/nodebb-plugin-blog-comments/lib/generalphp.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(nbb);
})();
Please enable JavaScript to view comments
```You must have some getId() function on your website, for example:
**For a PHP website**
```php
```If you don't have such ID, you can use this function that generates a unique ID from the URL:
```php
```### Comments Counter
You may optionally put a "# of comments" counter anywhere on the page with the following code:
```html
Comments
```A mechanism to query the number of comments on another separate page will be available in a future release.
### Author and Category information
![](http://i.imgur.com/NyLs4LQ.png)
To use NodeBB's category and author information (instead of using Ghost's user/tag system), there are two elements that this plugin searches for:
```html
Published by in
```### Publishing
Head over to the article that you'd like to publish. The code will detect if you're both an administrator of your blog and NodeBB (so ensure that you're logged into both) and will display a publish button if so.
You may also create a `publishers` group in NodeBB to allow a group of regular users to have publish rights.
### Multiple blogs
You may use a comma-separated entry of blogs in the ACP to support publishing from a network of separate blogs to your forum. You can also choose to put each blog in its own dedicated category, or place them all into one category.
## Sites using this plugin
* [NodeBB's Blog](http://blog.nodebb.org) (Wordpress).
* [The Unknown Artist Hour](http://theunknownartisthour.com) (Ghost).
* [Strange Adventures In](https://strangeadventures.in) (Ghost).
* [V2MM](https://v2mm.tech) (Ghost).Please submit a PR to add your site here :)
## TODO
* Republishing (for now you can just edit both the article and the published blog).
* Pull CSS files from appropriate plugins? Ability to load custom CSS to style widget.