+ Bienvenue sur Mira Stream +
+ + ++ Ton header est maintenant rendu par un composant React local, sans librairie externe. +
+ +diff --git a/.github/commit-policy.md b/.github/commit-policy.md
index aae166f..ce9cdf1 100644
--- a/.github/commit-policy.md
+++ b/.github/commit-policy.md
@@ -14,15 +14,10 @@ Optional body with more details.
## Prefixes
- [+] New feature or file added
- [-] File or feature removed
-- [~] Modification or update
-- [!] Bug fix
-- [*] Refactor or cleanup
+- [~] Modification or update or other
- [?] Tests
-- [#] Configuration or build
## Examples
[+] Add user authentication module
[-] Remove deprecated payment API
[~] Update README with new install steps
-[!] Fix crash on null pointer in parser
-[*] Refactor database connection pool
diff --git a/.github/workflows/La-Mira.yml b/.github/workflows/La-Mira.yml
index 91e9aab..6496e48 100644
--- a/.github/workflows/La-Mira.yml
+++ b/.github/workflows/La-Mira.yml
@@ -7,8 +7,8 @@ on:
branches: [ "main" ]
jobs:
-
build:
+ environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
diff --git a/main.go b/main.go
index 2367060..f60890a 100644
--- a/main.go
+++ b/main.go
@@ -3,36 +3,58 @@ package main
import (
"fmt"
"log"
+ "os"
"server/server"
)
func main() {
- fmt.Println("Démarage du serveur")
+ fmt.Println("Démarage du serveur...")
cfg := server.ServerStart()
fmt.Println("Terminal du serveur :")
for {
var rep string
+ var path string
fmt.Print("$MIRA-Stream> ")
_, err := fmt.Scan(&rep)
if err != nil {
log.Fatalln("error input")
}
- if rep == "-exit" {
+ if rep == "exit" {
break
}
- if rep == "-vfolder" {
+ if rep == "vfolder" {
server.ChangeVFolder(&cfg)
fmt.Printf("After change : %+v\n", cfg)
continue
}
- if rep == "-list" {
+ if rep == "list" {
server.TakeFolder(&cfg)
continue
}
- if rep == "-config" {
+ if rep == "config" {
server.ViewConfig(cfg)
continue
}
+ if rep == "start" && cfg.StartStatut == 0 {
+ go server.SimpleHost(cfg)
+ cfg.StartStatut = 1
+ continue
+ }
+ if rep == "cd" {
+ _, err := fmt.Scan(&path)
+ if err != nil {
+ log.Fatalln("error cd")
+ }
+ os.Chdir(path)
+ cfg.Path, err = os.Getwd()
+ fmt.Printf("DEBUG CD : %v\n", cfg.Path)
+ continue
+ }
+ if rep == "ls" {
+ folder, _ := os.ReadDir(cfg.Path)
+ fmt.Printf("DEBUG LS : %+v\n", folder)
+ continue
+ }
fmt.Println("Command not found.")
}
}
diff --git a/server/server.go b/server/server.go
index 959e3cc..3fc7350 100644
--- a/server/server.go
+++ b/server/server.go
@@ -18,12 +18,14 @@ type conf struct {
Host string `toml:"host"`
} `toml:"server"`
Path string
+ StartStatut int
}
func LoadConf(path string) (conf, error) {
var cfg conf
_, err := toml.DecodeFile(path, &cfg)
cfg.Path, err = os.Getwd()
+ cfg.StartStatut = 0
return cfg, err
}
diff --git a/server/server_request.go b/server/server_request.go
new file mode 100644
index 0000000..486e72d
--- /dev/null
+++ b/server/server_request.go
@@ -0,0 +1,76 @@
+package server
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "os"
+)
+
+type Item struct {
+ ID int `json:"id"`
+ Name string `json:"name"`
+}
+
+type Folder struct {
+ Name string `json:"name"`
+ Type string `json:"type"`
+}
+
+var items = []Item{
+ {ID: 1, Name: "Item A"},
+ {ID: 2, Name: "Item B"},
+}
+
+func SearchInFolder() ([]Folder) {
+ entries, err := os.ReadDir(".")
+ if err != nil {
+ return nil
+ }
+ folders := make([]Folder, 0, len(entries))
+ for _, entry := range entries {
+ entryType := "file"
+ if entry.IsDir() {
+ entryType = "dir"
+ }
+ folders = append(folders, Folder{
+ Name: entry.Name(),
+ Type: entryType,
+ })
+ }
+ return folders
+}
+
+func itemsHandler(w http.ResponseWriter, r *http.Request) {
+ // Allow the Vite dev server to read API responses from the browser.
+ w.Header().Set("Access-Control-Allow-Origin", "http://localhost:5173")
+ w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
+ w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
+
+ if r.Method == http.MethodOptions {
+ w.WriteHeader(http.StatusNoContent)
+ return
+ }
+
+ switch r.Method {
+ case http.MethodGet:
+ // On renvoie la liste en JSON
+ w.Header().Set("Content-Type", "application/json")
+ if err := json.NewEncoder(w).Encode(SearchInFolder()); err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ fmt.Fprintln(w, "Erreur d'encodage JSON")
+ }
+ default:
+ w.WriteHeader(http.StatusMethodNotAllowed)
+ w.Write([]byte("Méthode non autorisée"))
+ }
+}
+
+func SimpleHost(cfg conf) {
+ http.HandleFunc("/", itemsHandler)
+ fmt.Println("API lancer")
+ err := http.ListenAndServe(":8000", nil)
+ if err != nil {
+ fmt.Println("error server")
+ }
+}
diff --git a/web-client/src/App.jsx b/web-client/src/App.jsx
index 9f6b51e..6b7c04a 100644
--- a/web-client/src/App.jsx
+++ b/web-client/src/App.jsx
@@ -1,15 +1,96 @@
-import { useState } from 'react'
+import { useState, useRef } from 'react'
import './App.css'
+function HttpRequest() {
+ fetch('http://localhost:8000/')
+ .then((res) => {
+ if (!res.ok) throw new Error(`HTTP ${res.status}`)
+ return res.json()
+ })
+ .then((data) => {
+ console.log('JSON OK:', data)
+ })
+ .catch((err) => {
+ console.error('Erreur requête:', err)
+ })
+}
+
function App() {
const [count, setCount] = useState(0)
+ const items = [
+ { label: 'Ce connecter' },
+ { label: 'Github' },
+ ]
+
+ const sectionRef = useRef(null)
+
+ const handleScroll = () => {
+ sectionRef.current?.scrollIntoView({ behavior: 'smooth' })
+ }
+
return (
-
+ Ton header est maintenant rendu par un composant React local, sans librairie externe. +
+ +