Skip to content

Commit 143f985

Browse files
committed
feat(editor): add built-in file editor for direct GitHub file management in Moodle
1 parent aa0f16b commit 143f985

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ A Moodle local plugin that syncs course content from a GitHub repository. Conten
1515
- **GitHub webhook** endpoint for instant sync on push
1616
- **CLI tool** for bulk syncing all configured courses
1717
- **PAT encryption** at rest using Moodle's Sodium-based encryption
18+
- **Built-in file editor** — browse, edit, and commit files back to GitHub directly from within Moodle
1819
- **Per-course configuration** with capability-based access control
1920
- **Sync history** with commit SHA tracking and detailed operation logs
2021

@@ -279,6 +280,25 @@ Sync only auto-sync courses:
279280
php local/githubsync/cli/sync_all.php --auto-only
280281
```
281282

283+
### File Editor
284+
285+
The plugin includes a built-in file editor that lets you browse, view, edit, and commit repository files directly from Moodle — no need to switch to GitHub or a local IDE for quick content changes.
286+
287+
**Accessing the editor:** From the GitHub Sync configuration page for a course, click the **File Editor** link. Requires the `local/githubsync:configure` capability.
288+
289+
**What you can do:**
290+
291+
- **Browse** the full repository file tree in a collapsible sidebar
292+
- **View** any text file by clicking it in the tree
293+
- **Edit** file content in a textarea with keyboard shortcuts (Tab inserts spaces, Ctrl+S / Cmd+S saves)
294+
- **Commit** changes back to GitHub with a commit message
295+
296+
**Conflict detection:** The editor tracks each file's Git blob SHA. If someone else modifies the file between your load and save, GitHub returns a conflict and the editor prompts you to reload before saving.
297+
298+
**Binary files** (images, PDFs, archives, fonts, media) are shown in the tree but are not editable.
299+
300+
**PAT requirements:** Your GitHub Personal Access Token must have **write access** to commit changes. For fine-grained tokens, set the "Contents" permission to "Read and write". For classic tokens, ensure the "repo" scope is enabled. Read-only tokens can still browse and view files but cannot save.
301+
282302
## Capabilities
283303

284304
| Capability | Description | Default roles |
@@ -387,6 +407,7 @@ local/githubsync/
387407
lib.php # Navigation hooks and pluginfile handler
388408
config.php # Per-course configuration page
389409
sync.php # Sync trigger page
410+
editor.php # File editor entry page
390411
webhook.php # GitHub webhook endpoint
391412
settings.php # Global admin settings
392413
LICENSE # GNU GPL v3
@@ -398,14 +419,24 @@ local/githubsync/
398419
db/
399420
install.xml # Database schema
400421
access.php # Capability definitions
422+
services.php # External function (AJAX) registration
401423
tasks.php # Scheduled task registration
402424
lang/en/
403425
local_githubsync.php # Language strings
426+
templates/
427+
editor.mustache # File editor UI template
428+
amd/src/
429+
editor.js # File editor frontend logic
430+
repository.js # AJAX service calls
404431
classes/
405432
form/
406433
config_form.php # Per-course config form (moodleform)
407434
github/
408435
client.php # GitHub REST API client
436+
external/
437+
get_file_tree.php # AJAX: list repo files
438+
get_file_content.php # AJAX: fetch file content + SHA
439+
update_file.php # AJAX: commit file changes to GitHub
409440
sync/
410441
engine.php # Core sync orchestrator
411442
course_builder.php # Creates/updates Moodle course structure

0 commit comments

Comments
 (0)