Update metadata and enhance README with plugin settings details

This commit is contained in:
interlope committed 2026-06-02 18:54:43 +02:00
1 parent 39e8b0b78a
commit b335ea4709
3 files changed
+73 -92

No files matched your search

+7 -7
View File
@@ -1,10 +1,10 @@
{
"author": "ALGZB",
"email": "hello@algzb.com",
"website": "https://algzb.com/github-comments-plugin-for-bludit",
"version": "1.0",
"releaseDate": "2020-09-10",
"author": "spleenftw",
"email": "",
"website": "https://github.com/Spleenftw/github-comments-for-bludit",
"version": "1.2.0",
"releaseDate": "2026-06-02",
"license": "MIT",
"compatible": "3.13.1",
"notes": ""
"compatible": "3.22.0",
"notes": "Fixed enable/disable toggles (PHP truthy-string bug); added Follow Site Theme option (reads blowdit-theme cookie); repo guard renders nothing when repo is unconfigured; htmlspecialchars escaping on repo and theme output."
}
+55 -85
View File
@@ -9,124 +9,94 @@ class utterances extends Plugin {
'enablePages' => true,
'enableStatic' => true,
'enableSticky' => true,
'utterancesTheme'=>''
'followSiteTheme' => true,
'utterancesTheme' => 'github-dark'
);
}
private function isOn($key)
{
$v = $this->getValue($key);
return ($v === true || $v === 'true' || $v === 1 || $v === '1');
}
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $L->get('utterances-installation');
$html .= '</div>';
$toggle = function ($key, $label) use ($L) {
$on = $this->isOn($key);
return '<div><label>'.$label.'</label>'
. '<select name="'.$key.'">'
. '<option value="true" '.($on ? 'selected' : '').'>'.$L->get('enabled').'</option>'
. '<option value="false" '.(!$on ? 'selected' : '').'>'.$L->get('disabled').'</option>'
. '</select></div>';
};
// Add your Utterances GitHub repository
$html = '<div class="alert alert-primary" role="alert">'.$L->get('utterances-installation').'</div>';
$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>';
$html .= '<div><label>'.$L->get('utterances-repository').'</label>';
$html .= '<input name="myUtterancesRepo" id="jsmyUtterancesRepo" type="text" value="'.htmlspecialchars($this->getValue('myUtterancesRepo'), ENT_QUOTES, 'UTF-8').'">';
$html .= '<span class="tip">'.$L->get('utterances-tip').'</span></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>';
$html .= $toggle('enablePages', $L->get('enable-utterances-on-pages'));
$html .= $toggle('enableStatic', $L->get('enable-utterances-on-static-pages'));
$html .= $toggle('enableSticky', $L->get('enable-utterances-on-sticky-pages'));
$html .= $toggle('followSiteTheme', 'Follow site theme (recommended)');
$t = $this->getValue('utterancesTheme');
$html .= '<div><label>'.$L->get('utterances-select-theme').'</label><select name="utterancesTheme">';
foreach (array('github-light','github-dark','github-dark-orange','icy-dark','dark-blue','photon-dark') as $opt) {
$html .= '<option value="'.$opt.'" '.($t === $opt ? 'selected' : '').'>'.$opt.'</option>';
}
$html .= '</select></div>';
return $html;
}
public function pageEnd()
{
global $url;
global $WHERE_AM_I;
global $url, $WHERE_AM_I, $page;
// Do not shows Utterances on page not found
if ($url->notFound()) { return false; }
if ($WHERE_AM_I !== 'page') { return false; }
if (!isset($page)) { return false; }
if ($url->notFound()) {
return false;
$show = ($page->published() && $this->isOn('enablePages'))
|| ($page->isStatic() && $this->isOn('enableStatic'))
|| ($page->sticky() && $this->isOn('enableSticky'));
return $show ? $this->javascript() : false;
}
if ($WHERE_AM_I==='page') {
global $page;
if ($page->published() && $this->getValue('enablePages')) {
return $this->javascript();
private function resolveTheme()
{
if ($this->isOn('followSiteTheme')) {
$cookie = isset($_COOKIE['blowdit-theme']) ? $_COOKIE['blowdit-theme'] : '';
return ($cookie === 'light') ? 'github-light' : 'github-dark';
}
if ($page->isStatic() && $this->getValue('enableStatic')) {
return $this->javascript();
$t = $this->getValue('utterancesTheme');
return ($t !== '') ? $t : 'github-dark';
}
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');
$repo = trim($this->getValue('myUtterancesRepo'));
if ($repo === '') { return false; }
$code = <<<EOF
$repo = htmlspecialchars($repo, ENT_QUOTES, 'UTF-8');
$theme = htmlspecialchars($this->resolveTheme(), ENT_QUOTES, 'UTF-8');
return <<<EOF
<section class="utterances-comments">
<script src="https://utteranc.es/client.js"
repo='$myUtterancesRepo'
repo="$repo"
issue-term="pathname"
theme='$utterancesTheme'
theme="$theme"
crossorigin="anonymous"
async>
</script>
</section>
EOF;
return $code;
}
}
+11
View File
@@ -16,6 +16,17 @@ The plugin uses [Utterrrances](https://utteranc.es/) to manage the comments.
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.
## Settings
| Setting | Default | Description |
|---|---|---|
| Repository | *(empty)* | GitHub repo in `OWNER/REPO` format. Comments are disabled until this is set. |
| Enable on pages | Enabled | Show comments on regular posts. |
| Enable on static pages | Enabled | Show comments on static pages. |
| Enable on sticky pages | Enabled | Show comments on sticky posts. |
| Follow site theme | Enabled | Reads the `blowdit-theme` cookie and selects `github-light` or `github-dark` automatically. Disable to pick a fixed theme below. |
| Theme | github-dark | Manual theme override (ignored when Follow site theme is on). |
## Demo and support
I'm using the plugin in my blog. [Check it out and leave a comment.](https://algzb.com/github-comments-plugin-for-bludit)