diff --git a/main.go b/main.go
index c305b73..0159c1d 100644
--- a/main.go
+++ b/main.go
@@ -538,7 +538,7 @@ h1{font-size:48px;font-weight:700;margin-bottom:8px}
func provisionMinIO(ak, sk, bucket string) {
log.Printf("[MinIO] Provisioning %s", ak)
- exec.Command("mc", "alias", "set", "cosmos", "http://127.0.0.1:9000", "unityadmin", "UnityAdmin2026!").Run()
+ exec.Command("mc", "alias", "set", "cosmos", "http://127.0.0.1:9010", "unityadmin", "UnityAdmin2026!").Run()
exec.Command("mc", "admin", "user", "add", "cosmos", ak, sk).Run()
exec.Command("mc", "mb", "--ignore-existing", "cosmos/"+bucket).Run()
exec.Command("mc", "version", "enable", "cosmos/"+bucket).Run()
diff --git a/oortconsole.go b/oortconsole.go
index ad5479c..e6c8756 100644
--- a/oortconsole.go
+++ b/oortconsole.go
@@ -16,6 +16,7 @@ import (
"os"
"os/exec"
"path"
+ "path/filepath"
"strconv"
"strings"
"time"
@@ -25,7 +26,7 @@ import (
"github.com/minio/minio-go/v7/pkg/credentials"
)
-const minioEndpoint = "127.0.0.1:9000"
+const minioEndpoint = "127.0.0.1:9010"
const publicMinioEndpoint = "cosmos.linuxguy.space"
// authS3Console validates the session and returns (accessKey, secretKey, bucket).
@@ -134,6 +135,8 @@ func RegisterS3ConsoleRoutes(mux *http.ServeMux) {
mux.HandleFunc("/oort/api/password", handleS3Password)
mux.HandleFunc("/oort/api/objects/move", handleS3Move)
mux.HandleFunc("/oort/api/buckets/rename", handleS3RenameBucket)
+ mux.HandleFunc("/oort/api/nas/info", handleMornyeNASInfo)
+ mux.HandleFunc("/oort/api/nas/enable-streaming", handleMornyeNASEnableStreaming)
}
// ─── Console HTML page ────────────────────────────────────────────────────────
@@ -1160,16 +1163,161 @@ var proxyTransport = &http.Transport{
}
+type MornyeTrackItem struct {
+ Key string `json:"key"`
+ Name string `json:"name"`
+ Title string `json:"title"`
+ Size int64 `json:"size"`
+ Format string `json:"format"`
+ StreamURL string `json:"stream_url"`
+ LastModified string `json:"last_modified"`
+}
+
+func handleMornyeNASInfo(w http.ResponseWriter, r *http.Request) {
+ ak, sk, defBucket, ok := authS3Console(r)
+ if !ok {
+ jsonErr(w, "unauthorized", 401)
+ return
+ }
+ var username, name string
+ scyllaSession.Query(`SELECT username, name FROM cosmos.users WHERE service='git' AND email=?`, ak).Scan(&username, &name)
+ if username == "" {
+ username = strings.Split(ak, "@")[0]
+ }
+
+ var defDisp string
+ scyllaSession.Query(`SELECT bucket_display_name FROM cosmos.users WHERE service='git' AND email=?`, ak).Scan(&defDisp)
+ if defDisp == "" {
+ defDisp = "mybucket"
+ }
+
+ type NASBucketInfo struct {
+ Name string `json:"name"`
+ DisplayName string `json:"display_name"`
+ IsDefault bool `json:"is_default"`
+ IsPublic bool `json:"is_public"`
+ NASUrl string `json:"nas_url"`
+ PlaylistUrl string `json:"playlist_url"`
+ TrackCount int `json:"track_count"`
+ MusicBytes int64 `json:"music_bytes"`
+ }
+
+ var bucketList []NASBucketInfo
+ rawBuckets := []struct{ name, disp string }{ {defBucket, defDisp} }
+
+ iter := scyllaSession.Query(`SELECT bucket_name, display_name FROM cosmos.buckets WHERE owner_email = ?`, ak).Iter()
+ var b, disp string
+ for iter.Scan(&b, &disp) {
+ if disp == "" { disp = b }
+ rawBuckets = append(rawBuckets, struct{ name, disp string }{b, disp})
+ }
+ iter.Close()
+
+ mc, _ := minioClient(ak, sk)
+ ctx := context.Background()
+
+ for i, rb := range rawBuckets {
+ if rb.name == "" { continue }
+
+ cmd := exec.Command("mc", "anonymous", "get", "cosmos/"+rb.name)
+ out, _ := cmd.CombinedOutput()
+ isPub := strings.Contains(string(out), "download") || strings.Contains(string(out), "public")
+
+ trackCount := 0
+ var musicBytes int64 = 0
+ if mc != nil {
+ for obj := range mc.ListObjects(ctx, rb.name, minio.ListObjectsOptions{Recursive: true}) {
+ if obj.Err == nil && !strings.HasSuffix(obj.Key, "/") {
+ lower := strings.ToLower(obj.Key)
+ if strings.HasSuffix(lower, ".flac") || strings.HasSuffix(lower, ".mp3") ||
+ strings.HasSuffix(lower, ".wav") || strings.HasSuffix(lower, ".m4a") ||
+ strings.HasSuffix(lower, ".aac") || strings.HasSuffix(lower, ".ogg") ||
+ strings.HasSuffix(lower, ".opus") || strings.HasSuffix(lower, ".alac") {
+ trackCount++
+ musicBytes += obj.Size
+ }
+ }
+ }
+ }
+
+ bucketList = append(bucketList, NASBucketInfo{
+ Name: rb.name,
+ DisplayName: rb.disp,
+ IsDefault: (i == 0),
+ IsPublic: isPub,
+ NASUrl: fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/", username, rb.disp),
+ PlaylistUrl: fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/playlist.m3u", username, rb.disp),
+ TrackCount: trackCount,
+ MusicBytes: musicBytes,
+ })
+ }
+
+ jsonOK(w, map[string]any{
+ "username": username,
+ "name": name,
+ "email": ak,
+ "secret_key": sk,
+ "s3_endpoint": "https://cosmos.linuxguy.space",
+ "default_bucket": defBucket,
+ "buckets": bucketList,
+ })
+}
+
+func handleMornyeNASEnableStreaming(w http.ResponseWriter, r *http.Request) {
+ if r.Method != "POST" {
+ jsonErr(w, "method not allowed", 405)
+ return
+ }
+ ak, _, defBucket, ok := authS3Console(r)
+ if !ok {
+ jsonErr(w, "unauthorized", 401)
+ return
+ }
+ var req struct {
+ Bucket string `json:"bucket"`
+ }
+ json.NewDecoder(r.Body).Decode(&req)
+ if req.Bucket == "" { req.Bucket = defBucket }
+
+ isOwner := false
+ if req.Bucket == defBucket {
+ isOwner = true
+ } else {
+ var owner string
+ if err := scyllaSession.Query(`SELECT owner_email FROM cosmos.buckets WHERE bucket_name=?`, req.Bucket).Scan(&owner); err == nil && owner == ak {
+ isOwner = true
+ }
+ }
+ if !isOwner {
+ jsonErr(w, "forbidden", 403)
+ return
+ }
+
+ cmd := exec.Command("mc", "anonymous", "set", "download", "cosmos/"+req.Bucket)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ log.Printf("[NAS] enable streaming error for %s: %v | %s", req.Bucket, err, string(out))
+ jsonErr(w, "failed to enable streaming", 500)
+ return
+ }
+ jsonOK(w, map[string]any{"success": true, "bucket": req.Bucket, "status": "streaming_enabled"})
+}
+
func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path string) {
- idx := strings.Index(path, "/")
- if idx == -1 {
+ trimmed := strings.Trim(path, "/")
+ var displayBucket, objectKey string
+ if idx := strings.Index(trimmed, "/"); idx != -1 {
+ displayBucket = trimmed[:idx]
+ objectKey = trimmed[idx+1:]
+ } else {
+ displayBucket = trimmed
+ objectKey = ""
+ }
+ if displayBucket == "" {
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(404)
w.Write([]byte("
404 - Not Found "))
return
}
- displayBucket := path[:idx]
- objectKey := path[idx+1:]
cacheKey := username + ":" + displayBucket
var actualBucket string
@@ -1218,9 +1366,93 @@ func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path
publicBucketCache.Store(cacheKey, actualBucket)
}
+ // Check if this is a Mornye NAS root, index.json, or playlist.m3u request
+ isPlaylist := objectKey == "playlist.m3u" || objectKey == "mornye.m3u" || r.URL.Query().Get("format") == "m3u"
+ isJSON := objectKey == "index.json" || objectKey == "mornye.json" || r.URL.Query().Get("format") == "json" || strings.Contains(r.Header.Get("Accept"), "application/json")
+ isRoot := (objectKey == "")
+
+ if isRoot || isPlaylist || isJSON {
+ mc, err := minio.New(minioEndpoint, &minio.Options{
+ Creds: credentials.NewStaticV4("unityadmin", "UnityAdmin2026!", ""),
+ Secure: false,
+ })
+ if err != nil {
+ http.Error(w, "NAS storage backend error", 500)
+ return
+ }
+
+ var tracks []MornyeTrackItem
+ var totalBytes int64 = 0
+
+ ctx := context.Background()
+ for obj := range mc.ListObjects(ctx, actualBucket, minio.ListObjectsOptions{Recursive: true}) {
+ if obj.Err == nil && !strings.HasSuffix(obj.Key, "/") {
+ lower := strings.ToLower(obj.Key)
+ ext := strings.TrimPrefix(filepath.Ext(lower), ".")
+ name := filepath.Base(obj.Key)
+ title := strings.TrimSuffix(name, filepath.Ext(name))
+ displayTitle := strings.ReplaceAll(title, "_", " ")
+
+ isAudio := ext == "flac" || ext == "mp3" || ext == "wav" || ext == "m4a" || ext == "aac" || ext == "ogg" || ext == "opus" || ext == "alac"
+ if isAudio || isRoot {
+ streamURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/%s", username, displayBucket, url.PathEscape(obj.Key))
+ tracks = append(tracks, MornyeTrackItem{
+ Key: obj.Key,
+ Name: name,
+ Title: displayTitle,
+ Size: obj.Size,
+ Format: strings.ToUpper(ext),
+ StreamURL: streamURL,
+ LastModified: obj.LastModified.Format(time.RFC3339),
+ })
+ totalBytes += obj.Size
+ }
+ }
+ }
+
+ w.Header().Set("Access-Control-Allow-Origin", "*")
+ w.Header().Set("Access-Control-Allow-Headers", "*")
+ w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")
+
+ if isPlaylist {
+ w.Header().Set("Content-Type", "audio/x-mpegurl; charset=utf-8")
+ w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename=\"%s-mornye.m3u\"", displayBucket))
+ var buf strings.Builder
+ buf.WriteString("#EXTM3U\n")
+ buf.WriteString(fmt.Sprintf("#PLAYLIST:Mornye NAS - %s - %s\n\n", username, displayBucket))
+ for _, t := range tracks {
+ buf.WriteString(fmt.Sprintf("#EXTINF:-1,%s\n%s\n", t.Title, t.StreamURL))
+ }
+ w.Write([]byte(buf.String()))
+ return
+ }
+
+ if isJSON {
+ w.Header().Set("Content-Type", "application/json; charset=utf-8")
+ json.NewEncoder(w).Encode(map[string]any{
+ "service": "Mornye NAS",
+ "version": "2.0",
+ "status": "online",
+ "account": username,
+ "bucket": displayBucket,
+ "nas_url": fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/", username, displayBucket),
+ "playlist_url": fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/playlist.m3u", username, displayBucket),
+ "s3_endpoint": "https://cosmos.linuxguy.space",
+ "tracks_count": len(tracks),
+ "total_bytes": totalBytes,
+ "tracks": tracks,
+ })
+ return
+ }
+
+ // Web player page
+ renderMornyeNASWebPlayer(w, username, displayBucket, tracks, totalBytes)
+ return
+ }
+
targetPath := fmt.Sprintf("/%s/%s", actualBucket, objectKey)
- targetUrl, _ := url.Parse("http://127.0.0.1:9000")
+ targetUrl, _ := url.Parse("http://127.0.0.1:9010")
proxy := httputil.NewSingleHostReverseProxy(targetUrl)
proxy.Transport = proxyTransport
@@ -1230,9 +1462,35 @@ func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path
proxy.ModifyResponse = func(resp *http.Response) error {
if resp.StatusCode == 403 {
resp.StatusCode = 403
- resp.Body = io.NopCloser(strings.NewReader("403 - Access Denied Public access is not enabled for this bucket.
"))
- resp.Header.Set("Content-Length", fmt.Sprintf("%d", len("403 - Access Denied Public access is not enabled for this bucket.
")))
+ resp.Body = io.NopCloser(strings.NewReader("403 - Access Denied Public streaming access is not enabled for this Mornye NAS bucket. Enable public streaming in Oort NAS Console.
"))
+ resp.Header.Set("Content-Length", fmt.Sprintf("%d", len("403 - Access Denied Public streaming access is not enabled for this Mornye NAS bucket. Enable public streaming in Oort NAS Console.
")))
resp.Header.Set("Content-Type", "text/html")
+ return nil
+ }
+ resp.Header.Set("Access-Control-Allow-Origin", "*")
+ resp.Header.Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")
+ resp.Header.Set("Access-Control-Allow-Headers", "Range, Authorization, Content-Type")
+ resp.Header.Set("Access-Control-Expose-Headers", "Content-Range, Content-Length, Accept-Ranges")
+ resp.Header.Set("Accept-Ranges", "bytes")
+
+ lowerKey := strings.ToLower(objectKey)
+ switch {
+ case strings.HasSuffix(lowerKey, ".flac"):
+ resp.Header.Set("Content-Type", "audio/flac")
+ case strings.HasSuffix(lowerKey, ".mp3"):
+ resp.Header.Set("Content-Type", "audio/mpeg")
+ case strings.HasSuffix(lowerKey, ".wav"):
+ resp.Header.Set("Content-Type", "audio/wav")
+ case strings.HasSuffix(lowerKey, ".m4a"):
+ resp.Header.Set("Content-Type", "audio/mp4")
+ case strings.HasSuffix(lowerKey, ".aac"):
+ resp.Header.Set("Content-Type", "audio/aac")
+ case strings.HasSuffix(lowerKey, ".ogg"):
+ resp.Header.Set("Content-Type", "audio/ogg")
+ case strings.HasSuffix(lowerKey, ".opus"):
+ resp.Header.Set("Content-Type", "audio/opus")
+ case strings.HasSuffix(lowerKey, ".lrc"):
+ resp.Header.Set("Content-Type", "text/plain; charset=utf-8")
}
return nil
}
@@ -1242,6 +1500,229 @@ func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path
recordHit(actualBucket, tw.statusCode, tw.bytes, false, r.Header.Get("CF-IPCountry"), "read")
}
+func renderMornyeNASWebPlayer(w http.ResponseWriter, username, displayBucket string, tracks []MornyeTrackItem, totalBytes int64) {
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ nasURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/", username, displayBucket)
+ playlistURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/playlist.m3u", username, displayBucket)
+ jsonURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/index.json", username, displayBucket)
+
+ var sizeStr string
+ tb := float64(totalBytes)
+ if tb > 1024*1024*1024 {
+ sizeStr = fmt.Sprintf("%.2f GB", tb/(1024*1024*1024))
+ } else {
+ sizeStr = fmt.Sprintf("%.1f MB", tb/(1024*1024))
+ }
+
+ tracksJSON, _ := json.Marshal(tracks)
+
+ html := fmt.Sprintf(`
+
+
+
+
+Mornye NAS · @%s / %s
+
+
+
+
+
+
+
+
+
+ Configure this dedicated URL into your Mornye Music Streaming App to access your network-attached library with lossless byte-range playback:
+
+
+
+
+
+
Tracks: %d audio file(s)
+
Library Size: %s
+
Protocol: RFC 7233 Byte-Range Streaming
+
DAC / Hi-Res: Bit-Perfect 24-bit/192kHz Ready
+
+
+
+
+
+
Music Library
+ ▶ Play All
+
+
+
+
+
+
+ #
+ Track Name
+ Format
+ Size
+ Actions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
No track playing
+
Select a track to stream
+
+
+
⏭
+
+
+
+
+`,
+ username, displayBucket,
+ username, displayBucket,
+ nasURL, nasURL, playlistURL, jsonURL,
+ len(tracks), sizeStr,
+ string(tracksJSON),
+ )
+ w.Write([]byte(html))
+}
+
+
func handleS3BucketSettings(w http.ResponseWriter, r *http.Request) {
ak, _, defBucket, ok := authS3Console(r)
if !ok {
@@ -1713,7 +2194,7 @@ func handleS3CDNProxy(w http.ResponseWriter, r *http.Request) {
targetPath := "/" + bucket + "/" + key
- targetUrl, _ := url.Parse("http://127.0.0.1:9000")
+ targetUrl, _ := url.Parse("http://127.0.0.1:9010")
proxy := httputil.NewSingleHostReverseProxy(targetUrl)
proxy.Director = func(req *http.Request) {
req.URL.Scheme = targetUrl.Scheme
diff --git a/templates/index.html b/templates/index.html
index ddd20e4..e0672c3 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -636,34 +636,34 @@ footer.show{transform:translateY(0)}
-
+
-
02 — Oort
-
S3 storage.Your hardware.
+
02 — Oort NAS for Mornye
+
Mornye NAS.Your music hardware.
- S3-compatible object storage built on MinIO.
- Versioning, lifecycle policies, multipart uploads —
- every S3 API call, zero cloud bills.
+ High-performance Network Attached Storage built for Mornye music streaming
+ and sovereign S3 object cloud. Unique isolated streaming URLs for every account,
+ lossless FLAC byte-range delivery, zero cloud bills.
-
Open Oort ↗
+
Open Mornye NAS ↗
-
oort · live Nominal
+
oort · nas live Nominal
-
+
diff --git a/templates/oort.html b/templates/oort.html
index da65e90..b31941a 100644
--- a/templates/oort.html
+++ b/templates/oort.html
@@ -3,8 +3,8 @@
-
Oort — Sovereign S3 Object Storage · Cosmos
-
+
Oort — High-Performance NAS for Mornye & Sovereign Storage · Cosmos
+
@@ -867,8 +867,8 @@ footer {
- OORT CLOUD · CELESTIAL STORAGE
- AWS S3 PROTOCOL · SIGNATURE V4
+ OORT NAS FOR MORNYE · CELESTIAL STORAGE
+ LOSSLESS FLAC STREAMING · S3 PROTOCOL
00:00:00 UTC
@@ -879,16 +879,16 @@ footer {
- OBJECT STORAGE · S3 COMPATIBLE
+ MORNYE NAS · ZERO-DELAY AUDIO STREAMING
Storage for
- the infinite.
+ Mornye streaming.
-
S3-compatible object storage engineered for infinite scale and zero exposure. Complete AWS SDK compatibility, versioned buckets, custom domains, and live global analytics.
+
High-performance Network Attached Storage (NAS) engineered for Mornye music streaming and sovereign object cloud. Unique streaming URLs for every account, lossless FLAC byte-range delivery, and infinite hardware capacity.
diff --git a/templates/oortconsole.html b/templates/oortconsole.html
index ac73125..b873d1e 100644
--- a/templates/oortconsole.html
+++ b/templates/oortconsole.html
@@ -845,6 +845,10 @@ input:checked + .slider:before { transform: translateX(16px); }
Dashboard
+
Analytics
@@ -907,8 +911,8 @@ input:checked + .slider:before { transform: translateX(16px); }
-
- Cloud Drive
+
+ Mornye NAS
@@ -1205,6 +1209,223 @@ input:checked + .slider:before { transform: translateX(16px); }
+
+
+
+
+
+
+
+
+
+
+
+
+
Your Unique Mornye NAS Storage Space
+
+ Account: @loading · Space:
+
+ Loading spaces…
+
+
+
+
+
+
+
+ Streaming Ready
+
+
+
+
+
+
+
Mornye NAS URL:
+
+ https://cosmos.linuxguy.space/oort/…/
+
+
+
+
+ Copy Mornye NAS URL
+
+
+
+ Copy M3U Link
+
+
+
+ Web Player ↗
+
+
+
+
+
+
+
+
Network Storage Endpoint
+
https://cosmos.linuxguy.space
+
+
+
NAS Space / Bucket
+
—
+
+
+
Access Key (Email)
+
—
+
+
+
+
+
+
+
+
+
+
0
+
In this Mornye space
+
+
+
+
+
0 B
+
FLAC & MP3 library size
+
+
+
+
+
HTTP 206 Partial
+
Instant seek & zero delay
+
+
+
+
+
24b / 192kHz
+
Lossless studio pass-through
+
+
+
+
+
+
+
Drop Music Files Here or Click to Upload
+
Supports FLAC (16/24-bit), MP3, WAV, AAC, M4A, OGG, and LRC lyrics. Streamed directly to Mornye.
+
+
+
+
+
+
+
NAS Audio Library
+
0 tracks
+
+
+
+
+
+
+
+
+ Play All
+
+
+
+
+
+
+
+
+ #
+ Track Title & Filename
+ Format
+ Size
+ Modified
+ Actions
+
+
+
+ Loading audio tracks…
+
+
+
+
+
+
+
+
+
+
+
+
Now Playing
+
FLAC · Zero-Delay Stream
+
+
+
+ ⏭
+ ✕
+
+
+
@@ -1942,6 +2163,7 @@ function switchView(name, bucket, prefix) {
loadObjects();
}
if (name === 'dashboard') loadDashboard();
+ if (name === 'nas') loadMornyeNASView();
if (name === 'analytics') loadAnalytics();
if (name === 'account') populateAccount();
if (name === 'security') populateSecurity();
@@ -1959,9 +2181,10 @@ function updateTopbar(view) {
const bc = document.getElementById('topbarBreadcrumb');
const labels = {
dashboard: 'Dashboard',
+ nas: 'Mornye NAS Management',
account: 'Profile & API Keys',
security: 'Security Settings',
- browser: (typeof uiMode !== 'undefined' && uiMode === 's3' ? 'Bucket: ' : 'Drive: ') + getBucketDisplayName(state.bucket),
+ browser: (typeof uiMode !== 'undefined' && uiMode === 's3' ? 'Bucket: ' : 'NAS Space: ') + getBucketDisplayName(state.bucket),
};
const label = labels[view] || view;
bc.innerHTML = `
${label} `;
@@ -2950,7 +3173,7 @@ function setMode(mode, skipAnim = false) {
if (!skipAnim && layer && txt) {
txt.textContent = isS3
? 'Switching to S3 Object Storage…'
- : 'Switching to Cloud Drive…';
+ : 'Switching to Mornye NAS…';
layer.style.pointerEvents = 'all';
layer.style.opacity = '1';
}
@@ -2961,18 +3184,18 @@ function setMode(mode, skipAnim = false) {
// Sidebar section label (first one is the buckets section)
const sectionLabels = document.querySelectorAll('.sidebar-section-label');
if (sectionLabels[0]) {
- sectionLabels[0].textContent = isS3 ? 'Buckets' : 'Drives';
+ sectionLabels[0].textContent = isS3 ? 'Buckets' : 'Music NAS Spaces';
}
// "Create bucket" link in sidebar
const createBucketLink = document.querySelector('.sidebar-create-bucket span');
if (createBucketLink) {
- createBucketLink.textContent = isS3 ? 'Create bucket' : 'Create drive';
+ createBucketLink.textContent = isS3 ? 'Create bucket' : 'New NAS Space';
}
// "Create bucket" modal title
const cbTitle = document.querySelector('#modal-create-bucket .modal-title');
- if (cbTitle) cbTitle.textContent = isS3 ? 'Create Bucket' : 'Create Drive';
+ if (cbTitle) cbTitle.textContent = isS3 ? 'Create Bucket' : 'Create Mornye NAS Space';
// Stat card labels
const bucketsLabel = document.querySelector('[id="dash-buckets"] + .stat-card-meta, .stat-card-label');
@@ -2982,9 +3205,9 @@ function setMode(mode, skipAnim = false) {
const card = dashBuckets.closest('.stat-card');
if (card) {
const label = card.querySelector('.stat-card-label');
- if (label) label.textContent = isS3 ? 'Buckets' : 'Drives';
+ if (label) label.textContent = isS3 ? 'Buckets' : 'NAS Spaces';
const meta = card.querySelector('.stat-card-meta');
- if (meta) meta.textContent = isS3 ? 'Active buckets' : 'Active drives';
+ if (meta) meta.textContent = isS3 ? 'Active buckets' : 'Active NAS spaces';
}
}
@@ -2993,8 +3216,8 @@ function setMode(mode, skipAnim = false) {
if (dbl) {
const cardTitle = dbl.closest('.chart-card')?.querySelector('.chart-card-title');
const cardSub = dbl.closest('.chart-card')?.querySelector('.chart-card-sub');
- if (cardTitle) cardTitle.textContent = isS3 ? 'Buckets' : 'Drives';
- if (cardSub) cardSub.textContent = isS3 ? 'Your storage buckets' : 'Your cloud drives';
+ if (cardTitle) cardTitle.textContent = isS3 ? 'Buckets' : 'Mornye NAS Spaces';
+ if (cardSub) cardSub.textContent = isS3 ? 'Your storage buckets' : 'Your network audio storage spaces';
}
// Dashboard page title subtitle
@@ -3002,12 +3225,12 @@ function setMode(mode, skipAnim = false) {
if (pageSub) {
pageSub.textContent = isS3
? 'S3-compatible object storage overview'
- : 'Cloud drive storage overview';
+ : 'Mornye NAS & high-resolution music streaming overview';
}
// User role in sidebar
const roleLabel = document.querySelector('.user-role');
- if (roleLabel) roleLabel.textContent = isS3 ? 'S3 Object Storage' : 'Cloud Drive';
+ if (roleLabel) roleLabel.textContent = isS3 ? 'S3 Object Storage' : 'Mornye NAS Storage';
// Browser "New Folder" button — only show in Drive mode
const mkdirBtn = document.querySelector('[onclick="openModal(\'modal-mkdir\')"]');
@@ -4388,6 +4611,310 @@ async function executeRenameBucket() {
}
}
}
+
+/* ══════════════════════════════════════════════════════════════
+ MORNYE NAS MANAGEMENT & STREAMING CONTROLLER
+══════════════════════════════════════════════════════════════ */
+let mornyeNASData = null;
+let currentNASTracks = [];
+let allNASTracksUnfiltered = [];
+let currentNASBucket = null;
+let currentNASTrackIdx = -1;
+
+function escapeHtml(s) {
+ if (!s) return '';
+ return s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
+}
+
+async function loadMornyeNASView() {
+ const r = await api('/oort/api/nas/info');
+ if (!r) return;
+ mornyeNASData = r;
+
+ const userPill = document.getElementById('nas-user-pill');
+ if (userPill) userPill.textContent = '@' + (r.username || 'user');
+
+ const akVal = document.getElementById('nas-access-key-val');
+ if (akVal) akVal.textContent = r.email || '';
+
+ const skVal = document.getElementById('nas-secret-key-val');
+ if (skVal) {
+ skVal.dataset.secret = r.secret_key || '';
+ skVal.textContent = '••••••••••••••••';
+ }
+
+ const sel = document.getElementById('nas-space-selector');
+ if (sel) {
+ sel.innerHTML = '';
+ (r.buckets || []).forEach(b => {
+ const opt = document.createElement('option');
+ opt.value = b.name;
+ opt.textContent = `${b.display_name} (${b.track_count} tracks)`;
+ if (state.bucket && b.name === state.bucket) opt.selected = true;
+ sel.appendChild(opt);
+ });
+ }
+
+ const activeBucket = (sel && sel.value) || (r.buckets && r.buckets[0]?.name);
+ if (activeBucket) {
+ onNASSpaceChanged(activeBucket);
+ }
+}
+
+function onNASSpaceChanged(bucketName) {
+ if (!mornyeNASData) return;
+ const b = (mornyeNASData.buckets || []).find(x => x.name === bucketName) || (mornyeNASData.buckets && mornyeNASData.buckets[0]);
+ if (!b) return;
+ currentNASBucket = b;
+ state.bucket = b.name;
+
+ const primaryUrlEl = document.getElementById('nas-primary-url');
+ if (primaryUrlEl) primaryUrlEl.textContent = b.nas_url;
+
+ const activeBucketEl = document.getElementById('nas-active-bucket-name');
+ if (activeBucketEl) activeBucketEl.textContent = b.name;
+
+ const badgeWrap = document.getElementById('nas-streaming-badge');
+ if (badgeWrap) {
+ if (b.is_public) {
+ badgeWrap.innerHTML = `
+
+
+ Streaming Ready
+ `;
+ } else {
+ badgeWrap.innerHTML = `
+
+ ⚡ Enable Streaming for Mornye
+ `;
+ }
+ }
+
+ loadNASTracks(b.name);
+}
+
+async function loadNASTracks(bucketName) {
+ const tbody = document.getElementById('nas-tracks-tbody');
+ if (tbody) {
+ tbody.innerHTML = `
Loading audio tracks… `;
+ }
+
+ const r = await api(`/oort/api/objects?bucket=${bucketName}&prefix=`);
+ if (!r) {
+ if (tbody) tbody.innerHTML = `
Failed to load tracks. `;
+ return;
+ }
+
+ const audioExts = ['flac', 'mp3', 'wav', 'm4a', 'aac', 'ogg', 'opus', 'alac'];
+ const allObjects = r.objects || [];
+ allNASTracksUnfiltered = allObjects.filter(o => {
+ if (o.is_dir) return false;
+ const ext = o.name.split('.').pop().toLowerCase();
+ return audioExts.includes(ext);
+ });
+ currentNASTracks = [...allNASTracksUnfiltered];
+
+ let totalBytes = 0;
+ currentNASTracks.forEach(t => { totalBytes += (t.size || 0); });
+
+ const statTracks = document.getElementById('nas-stat-tracks');
+ if (statTracks) statTracks.textContent = currentNASTracks.length;
+
+ const statSize = document.getElementById('nas-stat-size');
+ if (statSize) statSize.textContent = fmtBytes(totalBytes);
+
+ const countBadge = document.getElementById('nas-track-count-badge');
+ if (countBadge) countBadge.textContent = `${currentNASTracks.length} track${currentNASTracks.length === 1 ? '' : 's'}`;
+
+ renderNASTrackRows(currentNASTracks);
+}
+
+function filterNASTracks(query) {
+ const q = (query || '').toLowerCase().trim();
+ if (!q) {
+ currentNASTracks = [...allNASTracksUnfiltered];
+ } else {
+ currentNASTracks = allNASTracksUnfiltered.filter(t => t.name.toLowerCase().includes(q));
+ }
+ renderNASTrackRows(currentNASTracks);
+}
+
+function renderNASTrackRows(tracks) {
+ const tbody = document.getElementById('nas-tracks-tbody');
+ if (!tbody) return;
+
+ if (!tracks.length) {
+ tbody.innerHTML = `
+ 🎵
+ No music tracks in this NAS space yet
+ Drag and drop audio files above or click Upload Music to start streaming to Mornye.
+ `;
+ return;
+ }
+
+ tbody.innerHTML = tracks.map((t, idx) => {
+ const ext = t.name.split('.').pop().toUpperCase();
+ const pillClass = ['FLAC', 'MP3', 'WAV'].includes(ext) ? `pill-${ext}` : 'pill-OTHER';
+ const streamUrl = `${currentNASBucket ? currentNASBucket.nas_url : ''}${encodeURIComponent(t.key)}`;
+ const dateStr = t.last_modified ? new Date(t.last_modified).toLocaleDateString('en-US', {month:'short', day:'numeric', year:'numeric'}) : '—';
+ const escKey = t.key.replace(/'/g, "\\'");
+
+ return `
+
+ ${idx + 1}
+
+ ${escapeHtml(t.name.replace(/\.[^/.]+$/, '').replace(/_/g, ' '))}
+ ${escapeHtml(t.name)}
+
+ ${ext}
+ ${fmtBytes(t.size)}
+ ${dateStr}
+
+ ▶ Play
+ ⬇
+ 🔗
+ 🗑
+
+ `;
+ }).join('');
+}
+
+function playNASTrack(idx) {
+ if (idx < 0 || idx >= currentNASTracks.length) return;
+ currentNASTrackIdx = idx;
+ const t = currentNASTracks[idx];
+ const bar = document.getElementById('nas-audio-player-bar');
+ const audio = document.getElementById('nas-global-audio');
+ const title = document.getElementById('nas-player-title');
+ const sub = document.getElementById('nas-player-sub');
+ const ext = t.name.split('.').pop().toUpperCase();
+
+ const streamUrl = `${currentNASBucket.nas_url}${encodeURIComponent(t.key)}`;
+ if (title) title.textContent = t.name.replace(/\.[^/.]+$/, '').replace(/_/g, ' ');
+ if (sub) sub.textContent = `${ext} · ${fmtBytes(t.size)} · Zero-Delay Stream`;
+
+ if (bar) bar.style.display = 'flex';
+ if (audio) {
+ audio.src = streamUrl;
+ audio.play();
+ audio.onended = () => { playNextNASTrack(); };
+ }
+}
+
+function playNextNASTrack() {
+ if (!currentNASTracks.length) return;
+ const next = (currentNASTrackIdx + 1) % currentNASTracks.length;
+ playNASTrack(next);
+}
+
+function playAllNASTracks() {
+ if (currentNASTracks.length > 0) playNASTrack(0);
+}
+
+function closeNASAudioPlayer() {
+ const bar = document.getElementById('nas-audio-player-bar');
+ const audio = document.getElementById('nas-global-audio');
+ if (audio) { audio.pause(); audio.src = ''; }
+ if (bar) bar.style.display = 'none';
+}
+
+function copyNASPrimaryURL() {
+ if (!currentNASBucket) return;
+ copyText(currentNASBucket.nas_url, 'Unique Mornye NAS URL copied! Paste this in your Mornye App settings.');
+}
+
+function copyNASPlaylistURL() {
+ if (!currentNASBucket) return;
+ copyText(currentNASBucket.playlist_url, 'Mornye M3U Playlist stream URL copied!');
+}
+
+function openNASWebPlayer() {
+ if (!currentNASBucket) return;
+ window.open(currentNASBucket.nas_url, '_blank');
+}
+
+function copyStreamURL(url) {
+ copyText(url, 'Track direct stream URL copied!');
+}
+
+function toggleNASSecretKey() {
+ const el = document.getElementById('nas-secret-key-val');
+ if (!el) return;
+ if (el.textContent === '••••••••••••••••') {
+ el.textContent = el.dataset.secret || '—';
+ } else {
+ el.textContent = '••••••••••••••••';
+ }
+}
+
+async function enableNASPublicStreaming(bucketName) {
+ toast('Configuring public streaming for Mornye…', 'info');
+ const r = await api('/oort/api/nas/enable-streaming', {
+ method: 'POST',
+ body: JSON.stringify({ bucket: bucketName })
+ });
+ if (r && r.success) {
+ toast('Public streaming active! Mornye can now stream from this space.', 'success');
+ if (mornyeNASData) {
+ const b = mornyeNASData.buckets.find(x => x.name === bucketName);
+ if (b) b.is_public = true;
+ }
+ onNASSpaceChanged(bucketName);
+ } else {
+ toast('Failed to enable streaming', 'error');
+ }
+}
+
+function triggerNASMusicUpload() {
+ const inp = document.getElementById('nas-music-input');
+ if (inp) inp.click();
+}
+
+function uploadNASMusicFiles(files) {
+ if (!files || !files.length) return;
+ if (!currentNASBucket) { toast('Select a NAS space first', 'error'); return; }
+ state.bucket = currentNASBucket.name;
+ queueFiles(files);
+ setTimeout(() => { loadNASTracks(currentNASBucket.name); }, 2500);
+}
+
+function onNASDragOver(e) {
+ e.preventDefault();
+ const dz = document.getElementById('nas-dropzone');
+ if (dz) {
+ dz.style.borderColor = '#a855f7';
+ dz.style.background = 'rgba(168,85,247,0.06)';
+ }
+}
+
+function onNASDragLeave(e) {
+ e.preventDefault();
+ const dz = document.getElementById('nas-dropzone');
+ if (dz) {
+ dz.style.borderColor = 'rgba(168,85,247,0.3)';
+ dz.style.background = 'rgba(255,255,255,0.015)';
+ }
+}
+
+function onNASDrop(e) {
+ e.preventDefault();
+ onNASDragLeave(e);
+ if (e.dataTransfer && e.dataTransfer.files) {
+ uploadNASMusicFiles(e.dataTransfer.files);
+ }
+}
+
+function copyText(txt, msg) {
+ if (navigator.clipboard && navigator.clipboard.writeText) {
+ navigator.clipboard.writeText(txt).then(() => {
+ toast(msg || 'Copied to clipboard!');
+ }).catch(() => {
+ prompt('Copy this URL:', txt);
+ });
+ } else {
+ prompt('Copy this URL:', txt);
+ }
+}