Add auto-export feature: Enable automatic pushing of articles to GitHub on save, with configuration options in the plugin settings.

This commit is contained in:
interlope committed 2026-06-08 18:22:26 +02:00
1 parent 1f440494b3
commit b08116fba1
2 files changed
+15 -5

No files matched your search

+4 -2
View File
@@ -52,6 +52,7 @@ Article content with images like ![](../img/photo.png)
| Branch | Branch to push to (default: `main`). |
| Path Prefix | Optional subfolder prefix. Leave empty to export at the repo root. |
| Export drafts | When checked, draft articles are also exported. |
| Auto-export on save | When checked, articles are automatically pushed to GitHub whenever you save or modify them. Uncheck to only use manual bulk export. |
## Bulk export
@@ -59,8 +60,9 @@ The settings page includes an **Export all articles now** button that pushes all
## Behavior
- **On article save:** `article/index.md` is created or updated, and all images referenced in the content are uploaded to `img/`.
- **On article delete:** both `article/index.md` and all files in `img/` are deleted (GitHub removes the empty folders automatically).
- **On article save** (if auto-export is enabled): `article/index.md` is created or updated, and all images referenced in the content are uploaded to `img/`.
- **On article delete** (if auto-export is enabled): both `article/index.md` and all files in `img/` are deleted (GitHub removes the empty folders automatically).
- **Manual bulk export:** Use the "Export all articles now" button to push articles regardless of auto-export setting.
- **Errors** are displayed in the plugin settings panel and never interfere with Bludit's own save process.
## Requirements
+11 -3
View File
@@ -11,6 +11,7 @@ class pluginBluditGithub extends Plugin
'branch' => 'main',
'path' => '',
'exportDrafts' => false,
'autoExport' => true,
];
}
@@ -52,7 +53,14 @@ class pluginBluditGithub extends Plugin
$html .= '</div>';
$html .= '<div>';
$html .= '<label><input name="exportDrafts" type="checkbox" value="1" ' . $exportDrafts . '> Export draft articles</label>';
$html .= '<label><input name="exportDrafts" type="hidden" value="0">';
$html .= '<input name="exportDrafts" type="checkbox" value="1" ' . $exportDrafts . '> Export draft articles</label>';
$html .= '</div>';
$autoExport = $this->getValue('autoExport') ? 'checked' : '';
$html .= '<div>';
$html .= '<label><input name="autoExport" type="hidden" value="0">';
$html .= '<input name="autoExport" type="checkbox" value="1" ' . $autoExport . '> Auto-export on save <em>(uncheck to only use manual bulk export)</em></label>';
$html .= '</div>';
$html .= '<div style="margin-top:1.5em;padding-top:1em;border-top:1px solid #eee">';
@@ -82,7 +90,7 @@ class pluginBluditGithub extends Plugin
public function afterPageCreate($key)
{
try {
if (empty($key) || !$this->isConfigured()) {
if (empty($key) || !$this->isConfigured() || !$this->getValue('autoExport')) {
return;
}
$page = new Page($key);
@@ -97,7 +105,7 @@ class pluginBluditGithub extends Plugin
public function afterPageModify($key)
{
try {
if (empty($key) || !$this->isConfigured()) {
if (empty($key) || !$this->isConfigured() || !$this->getValue('autoExport')) {
return;
}
$page = new Page($key);