mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-27 07:31:46 +01:00
feat!: removes custom content help support (#2628)
This commit is contained in:
@@ -1,17 +1,5 @@
|
||||
<template>
|
||||
<div class="flex items-center justify-end gap-4">
|
||||
<template v-if="config.pages">
|
||||
<router-link
|
||||
:to="{ name: 'content-id', params: { id: page.id } }"
|
||||
:title="page.title"
|
||||
v-for="page in config.pages"
|
||||
:key="page.id"
|
||||
class="link-primary"
|
||||
>
|
||||
{{ page.title }}
|
||||
</router-link>
|
||||
</template>
|
||||
|
||||
<dropdown class="dropdown-end" @closed="latestTag = latest?.tag ?? config.version">
|
||||
<template #trigger>
|
||||
<mdi:announcement class="size-6 -rotate-12" />
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<template>
|
||||
<page-with-links>
|
||||
<section>
|
||||
<article class="prose" v-html="data.content" v-if="data"></article>
|
||||
</section>
|
||||
</page-with-links>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const { id } = defineProps<{ id: string }>();
|
||||
|
||||
const { data } = useFetch(() => withBase("/api/content/" + id), {
|
||||
refetch: true,
|
||||
})
|
||||
.get()
|
||||
.json<{ title: string; content: string }>();
|
||||
</script>
|
||||
<style lang="postcss" scoped></style>
|
||||
@@ -18,7 +18,6 @@ export interface Config {
|
||||
name: string;
|
||||
};
|
||||
profile?: Profile;
|
||||
pages?: { id: string; title: string }[];
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/yuin/goldmark"
|
||||
meta "github.com/yuin/goldmark-meta"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/parser"
|
||||
)
|
||||
|
||||
type Page struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content,omitempty"`
|
||||
}
|
||||
|
||||
func ReadAll() ([]Page, error) {
|
||||
var pages []Page
|
||||
files, err := filepath.Glob("data/content/*.md")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading /data/content/*.md: %w", err)
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
id := filepath.Base(file)
|
||||
id = id[0 : len(id)-3]
|
||||
page, err := Read(id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading %s: %w", id, err)
|
||||
}
|
||||
pages = append(pages, page)
|
||||
}
|
||||
|
||||
return pages, nil
|
||||
}
|
||||
|
||||
func Read(id string) (Page, error) {
|
||||
data, err := os.ReadFile("data/content/" + id + ".md")
|
||||
if err != nil {
|
||||
return Page{}, fmt.Errorf("error reading /data/content/%s.md: %w", id, err)
|
||||
}
|
||||
|
||||
markdown := goldmark.New(
|
||||
goldmark.WithExtensions(extension.GFM, meta.New()),
|
||||
)
|
||||
context := parser.NewContext()
|
||||
var buf bytes.Buffer
|
||||
if err := markdown.Convert(data, &buf, parser.WithContext(context)); err != nil {
|
||||
return Page{}, fmt.Errorf("error converting markdown: %w", err)
|
||||
}
|
||||
|
||||
metaData := meta.Get(context)
|
||||
page := Page{
|
||||
Content: buf.String(),
|
||||
Id: id,
|
||||
Title: id,
|
||||
}
|
||||
if title, ok := metaData["title"]; ok {
|
||||
page.Title = title.(string)
|
||||
}
|
||||
|
||||
return page, nil
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/amir20/dozzle/internal/content"
|
||||
"github.com/go-chi/chi/v5"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (h *handler) staticContent(w http.ResponseWriter, r *http.Request) {
|
||||
id := chi.URLParam(r, "id")
|
||||
content, err := content.Read(id)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
log.Warnf("error reading content: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if err := json.NewEncoder(w).Encode(content); err != nil {
|
||||
log.Errorf("json encoding error while streaming %v", err.Error())
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/amir20/dozzle/internal/analytics"
|
||||
"github.com/amir20/dozzle/internal/content"
|
||||
"github.com/amir20/dozzle/internal/docker"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -33,7 +32,6 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
|
||||
events := make(chan docker.ContainerEvent)
|
||||
stats := make(chan docker.ContainerStat)
|
||||
|
||||
pages, _ := content.ReadAll()
|
||||
b := analytics.BeaconEvent{
|
||||
Name: "events",
|
||||
Version: h.config.Version,
|
||||
@@ -43,7 +41,6 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
|
||||
HasCustomBase: h.config.Base != "/",
|
||||
HasCustomAddress: h.config.Addr != ":8080",
|
||||
Clients: len(h.clients),
|
||||
HasDocumentation: len(pages) > 0,
|
||||
HasActions: h.config.EnableActions,
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/amir20/dozzle/internal/auth"
|
||||
"github.com/amir20/dozzle/internal/content"
|
||||
"github.com/amir20/dozzle/internal/docker"
|
||||
"github.com/amir20/dozzle/internal/profile"
|
||||
|
||||
@@ -54,16 +53,6 @@ func (h *handler) executeTemplate(w http.ResponseWriter, req *http.Request) {
|
||||
"enableActions": h.config.EnableActions,
|
||||
}
|
||||
|
||||
pages, err := content.ReadAll()
|
||||
if err != nil {
|
||||
log.Errorf("error reading content: %v", err)
|
||||
} else if len(pages) > 0 {
|
||||
for i, _ := range pages {
|
||||
pages[i].Content = ""
|
||||
}
|
||||
config["pages"] = pages
|
||||
}
|
||||
|
||||
user := auth.UserFromContext(req.Context())
|
||||
if user != nil {
|
||||
if profile, err := profile.Load(*user); err == nil {
|
||||
|
||||
@@ -112,7 +112,6 @@ func createRouter(h *handler) *chi.Mux {
|
||||
r.Get("/api/releases", h.releases)
|
||||
r.Get("/api/profile/avatar", h.avatar)
|
||||
r.Patch("/api/profile", h.updateProfile)
|
||||
r.Get("/api/content/{id}", h.staticContent)
|
||||
r.Get("/logout", h.clearSession) // TODO remove this
|
||||
r.Get("/version", h.version)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user