First commit

This commit is contained in:
algzb committed 2020-09-11 16:52:50 +02:00
1 parent bc68b75b12
commit 001c660f4f
4 files changed
+176

No files matched your search

+17
View File
@@ -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 <a href=\"https://github.com/apps/utterances\">install the Utterrances app</a> on it. Do you need help? <a href=\"https://algzb.com/github-comments-plugin-for-bludit\">Leave a comment</a>. ",
"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"
}
+10
View File
@@ -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": ""
}
+132
View File
@@ -0,0 +1,132 @@
<?php
class utterances extends Plugin {
public function init()
{
$this->dbFields = array(
'myUtterancesRepo'=>'',
'enablePages'=>true,
'enableStatic'=>true,
'enableSticky'=>true,
'utterancesTheme'=>''
);
}
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $L->get('utterances-installation');
$html .= '</div>';
// Add your Utterances GitHub repository
$html .= '<div>';
$html .= '<label>'.$L->get('utterances-repository').'</label>';
$html .= '<input name="myUtterancesRepo" id="jsmyUtterancesRepo" type="text" value="'.$this->getValue('myUtterancesRepo').'">';
$html .= '<span class="tip">'.$L->get('utterances-tip').'</span>';
$html .= '</div>';
// Disable comments on static pages
$html .= '<div>';
$html .= '<label>'.$L->get('enable-utterances-on-pages').'</label>';
$html .= '<select name="enablePages">';
$html .= '<option value="true" '.($this->getValue('enablePages')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enablePages')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
// Disable comments on static pages
$html .= '<div>';
$html .= '<label>'.$L->get('enable-utterances-on-static-pages').'</label>';
$html .= '<select name="enableStatic">';
$html .= '<option value="true" '.($this->getValue('enableStatic')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enableStatic')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
// Disable comments on sticky posts
$html .= '<div>';
$html .= '<label>'.$L->get('enable-utterances-on-sticky-pages').'</label>';
$html .= '<select name="enableSticky">';
$html .= '<option value="true" '.($this->getValue('enableSticky')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enableSticky')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
// Chose the GitHub theme for the comments
$html .= '<div>';
$html .= '<label>'.$L->get('utterances-select-theme').'</label>';
$html .= '<select name="utterancesTheme">';
$html .= '<option value="github-light" '.($this->getValue('utterancesTheme')==='github-light'?'selected':'').'>'.$L->get('GitHub Light').'</option>';
$html .= '<option value="github-dark" '.($this->getValue('utterancesTheme')==='github-dark'?'selected':'').'>'.$L->get('GitHub Dark').'</option>';
$html .= '<option value="github-dark-orange" '.($this->getValue('utterancesTheme')==='github-dark-orange'?'selected':'').'>'.$L->get('GitHub Dark Orange').'</option>';
$html .= '<option value="icy-dark" '.($this->getValue('utterancesTheme')==='icy-dark'?'selected':'').'>'.$L->get('Icy Dark').'</option>';
$html .= '<option value="dark-blue" '.($this->getValue('utterancesTheme')==='dark-blue'?'selected':'').'>'.$L->get('Dark Blue').'</option>';
$html .= '<option value="photon-dark" '.($this->getValue('utterancesTheme')==='photon-dark'?'selected':'').'>'.$L->get('Photon Dark').'</option>';
$html .= '</select>';
$html .= '</div>';
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
<script src="https://utteranc.es/client.js"
repo='$myUtterancesRepo'
issue-term="pathname"
theme='$utterancesTheme'
crossorigin="anonymous"
async>
</script>
EOF;
return $code;
}
}
+17
View File
@@ -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.