diff --git a/languages/en.json b/languages/en.json new file mode 100644 index 0000000..d101a1e --- /dev/null +++ b/languages/en.json @@ -0,0 +1,17 @@ +{ + "plugin-data": + { + "name": "GitHub Comments", + "description": "Add a comment section in your blog using GitHub issues." + }, + "utterances-shortname": "Your GitHub repository", + "utterances-installation": "You need to create a public GitHub repository and install the Utterrances app on it. Do you need help? Leave a comment. ", + "utterances-repository": "Your Utterances Github repository", + "utterances-tip": "The public GitHub repo where you installed Utterrances (USER/REPO).", + "enable-utterances-on-pages": "Comments on pages", + "enable-utterances-on-static-pages": "Comments on static pages", + "enable-utterances-on-sticky-pages": "Comments on sticky pages", + "utterances-select-theme": "Select the comment section theme" + + +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..445dc6c --- /dev/null +++ b/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "ALGZB", + "email": "hello@algzb.com", + "website": "https://algzb.com/github-comments-plugin-for-bludit", + "version": "1.0", + "releaseDate": "2020-09-10", + "license": "MIT", + "compatible": "3.13.1", + "notes": "" +} diff --git a/plugin.php b/plugin.php new file mode 100644 index 0000000..4ea3333 --- /dev/null +++ b/plugin.php @@ -0,0 +1,132 @@ +dbFields = array( + 'myUtterancesRepo'=>'', + 'enablePages'=>true, + 'enableStatic'=>true, + 'enableSticky'=>true, + 'utterancesTheme'=>'' + ); + } + + public function form() + { + global $L; + + $html = ''; + + // Add your Utterances GitHub repository + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= ''.$L->get('utterances-tip').''; + $html .= '
'; + + // Disable comments on static pages + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + // Disable comments on static pages + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + // Disable comments on sticky posts + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + // Chose the GitHub theme for the comments + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + + return $html; + } + + public function pageEnd() + { + global $url; + global $WHERE_AM_I; + +// Do not shows Utterances on page not found + + if ($url->notFound()) { + return false; + } + + if ($WHERE_AM_I==='page') { + global $page; + if ($page->published() && $this->getValue('enablePages')) { + return $this->javascript(); + } + if ($page->isStatic() && $this->getValue('enableStatic')) { + return $this->javascript(); + } + if ($page->sticky() && $this->getValue('enableSticky')) { + return $this->javascript(); + } + } + + return false; + } + + +// Utterances javascript + + private function javascript() + { + global $page; + $pageURL = $page->permalink(); + $pageID = $page->uuid(); + $myUtterancesRepo = $this->getValue('myUtterancesRepo'); + $utterancesTheme = $this->getValue('utterancesTheme'); + +$code = << + + +EOF; + return $code; + } + +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..003c784 --- /dev/null +++ b/readme.md @@ -0,0 +1,17 @@ +# GitHub comments plugin for Bludit + +GitHub Comments is a plugging for [Bludit File Manager System](https://www.bludit.com/). This plugin was modeled after the Disqus plugin for Bludit. + +The plugin uses [Utterrrances](https://utteranc.es/), an open source lightweight comments system built on GitHub issues. + +## How to install + +1. Create an open GitHub repository. +2. Install the [Utterances App](https://github.com/apps/utterances) in your GitHub repository. +3. Download GitHub Comments and extract it in your **bl-plugins** directory. +4. Go to your Bludit admin panel and activate the GitHub Comments plugin. +5. Go to the pluging settings and enter your repository using the format **OWNER/REPO** . Do not add the url address and double check white spaces. + +## Demo + +Check the comment section on the blog.