-
Notifications
You must be signed in to change notification settings - Fork 132
feat: add web project templates (HTML, PHP, JS) #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Degrace15
wants to merge
12
commits into
Acode-Foundation:main
Choose a base branch
from
Degrace15:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−13
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
98e09f4
Create plug.json
Degrace15 ca97868
Add files via upload
Degrace15 7c1ef05
Add files via upload
Degrace15 b062f81
Delete plug.json
Degrace15 db50659
Update main.js
Degrace15 e44c44f
Update main.js
Degrace15 9a0bbde
Update main.js
Degrace15 68d7827
Update plugin.json
Degrace15 e6b2aa8
Update README.md
Degrace15 8f0756c
Update plugin.json
Degrace15 5100464
Update plugin.json
Degrace15 abafd7d
Update main.js
Degrace15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Project Creator Plugin for Acode | ||
|
|
||
| A lightweight and efficient plugin for the Acode editor that allows you to instantly generate boilerplate project structures for web development (HTML5, PHP, and JavaScript) directly inside your active workspace. | ||
|
|
||
| ## Features | ||
|
|
||
| - **HTML5 Template:** Instantly creates an `index.html` structure (pre-linked with style and script), a starter `style.css`, and a `script.js` file. | ||
| - **PHP Template:** Generates a clean starter `index.php` file. | ||
| - **JavaScript Template:** Generates a basic `index.js` file for quick scripting or Node.js environments. | ||
| - **Native UI Integration:** Uses Acode's official built-in modules for a seamless prompt and file refresh experience. | ||
|
|
||
| ## How to Use | ||
|
|
||
| 1. Open a folder in Acode's file manager (required so the plugin knows where to create the files). | ||
| 2. Open the Command Palette in Acode (`Ctrl+Shift+P` or via the sidebar menu). | ||
| 3. Search for and select **"Open Project Creator"**. | ||
| 4. Choose the template you want to generate from the popup selection list. | ||
| 5. The files will be created instantly and your file tree will automatically refresh! | ||
|
|
||
| ## Project Structure Created | ||
|
|
||
| ### HTML5 Option | ||
| ```text | ||
| your-folder/ | ||
| ├── index.html | ||
| ├── style.css | ||
| └── script.js |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import plugin from "./plugin.json"; | ||
|
|
||
| function init(baseUrl, $page, cache) { | ||
| const commands = acode.require("commands"); | ||
|
|
||
| commands.addCommand({ | ||
| name: "project-creator", | ||
| description: "Open Project Creator", | ||
| exec: async () => { | ||
| // 1. Récupérer le module openFolder pour obtenir le dossier actif | ||
| const openFolder = acode.require("openFolder"); | ||
|
|
||
| const currentFolder = openFolder.target; | ||
| if (!currentFolder || !currentFolder.url) { | ||
| acode.alert("Erreur", "Veuillez d'abord ouvrir ou sélectionner un dossier dans le gestionnaire de fichiers d'Acode."); | ||
| return; | ||
| } | ||
|
|
||
| // 2. Récupérer le module select pour afficher le menu de choix | ||
| const select = acode.require("select"); | ||
| const options = [ | ||
| ["html", "Template Web HTML5 (index.html, style.css, script.js)"], | ||
| ["php", "Template PHP (index.php)"], | ||
| ["js", "Template JavaScript (index.js)"] | ||
| ]; | ||
|
|
||
| const choice = await select("Créer un modèle de projet", options); | ||
| if (!choice) return; // L'utilisateur a annulé | ||
|
|
||
| try { | ||
| // 3. Récupérer proprement le module fsOperation requis par Acode | ||
| const fsOperation = acode.require("fsOperation"); | ||
| const fs = fsOperation(currentFolder.url); | ||
|
Degrace15 marked this conversation as resolved.
|
||
|
|
||
| if (choice === "html") { | ||
| await fs.createFile("index.html", `<!DOCTYPE html> | ||
| <html lang="fr"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Mon Projet HTML</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| </head> | ||
| <body> | ||
| <h1>Projet HTML5 initialisé ! 🚀</h1> | ||
| <script src="script.js"></script> | ||
| </body> | ||
| </html>`); | ||
| await fs.createFile("style.css", `/* Styles du projet */\nbody {\n font-family: sans-serif;\n background-color: #f0f0f0;\n}`); | ||
| await fs.createFile("script.js", `// Code JavaScript\nconsole.log("Le script est chargé !");`); | ||
|
|
||
| window.toast("Structure HTML5 créée avec succès ! ✔️"); | ||
| } | ||
|
|
||
| else if (choice === "php") { | ||
| await fs.createFile("index.php", `<?php\n// Template PHP\necho "<h1>Hello depuis PHP ! 🐘</h1>";\n?>`); | ||
| window.toast("Template PHP créé avec succès ! ✔️"); | ||
| } | ||
|
|
||
| else if (choice === "js") { | ||
| await fs.createFile("index.js", `// Template JavaScript\nconsole.log("Hello Node.js / JS !");`); | ||
| window.toast("Template JS créé avec succès ! ✔️"); | ||
| } | ||
|
|
||
| // 4. Récupérer le module fileList et rafraîchir proprement l'affichage | ||
| const fileList = acode.require("fileList"); | ||
| if (fileList && typeof fileList.refresh === "function") { | ||
| fileList.refresh(); | ||
| } | ||
|
|
||
| } catch (error) { | ||
| acode.alert("Erreur de création", "Impossible de générer les fichiers : " + error.message); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| function unmount() { | ||
| const commands = acode.require("commands"); | ||
| commands.removeCommand("project-creator"); | ||
| } | ||
|
|
||
| acode.setPluginInit(plugin.id, init); | ||
| acode.setPluginUnmount(plugin.id, unmount); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,22 @@ | ||
| { | ||
| "$schema": "https://acode.app/schema/plugin/v0.1.0.json", | ||
| "id": "acode.plugin", | ||
| "name": "Plugin", | ||
| "main": "main.js", | ||
| "$schema": "https://raw.githubusercontent.com/Acode-Foundation/acode-plugin/main/schema.json", | ||
| "id": "com.Degrace15.projectcreator", | ||
| "name": "Project Creator", | ||
| "version": "1.0.0", | ||
| "repository": "https://github.com/Acode-Foundation/acode-plugin.git", | ||
| "icon": "icon.png", | ||
| "minVersionCode": 290, | ||
| "description": "Quickly generate boilerplate project templates for HTML, PHP, and JavaScript.", | ||
| "author": "KIMINOU Degrace", | ||
| "icon": "icon.png", | ||
| "main": "main.js", | ||
| "readme": "README.md", | ||
| "license": "MIT", | ||
| "keywords": [], | ||
| "price": 0, | ||
| "permissions": [], | ||
| "author": { | ||
| "name": "", | ||
| "email": "", | ||
| "github": "" | ||
| } | ||
| "keywords": [ | ||
| "template", | ||
| "boilerplate", | ||
| "html", | ||
| "php", | ||
| "javascript", | ||
| "creator" | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.