Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3eb944a5a5 | ||
|
|
218a5029fb | ||
|
|
13660e0aa4 | ||
|
|
e215b1d3b6 | ||
|
|
a08b30b02f |
+3
-2
@@ -11,8 +11,9 @@ RUN go mod download
|
|||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build statically
|
# Build statically with version
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags='-w -s' -o mdhost .
|
ARG APP_VERSION=dev
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s -X main.version=${APP_VERSION}" -o mdhost .
|
||||||
|
|
||||||
# Final scratch image
|
# Final scratch image
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
A simple, single-binary Go web application for hosting and sharing markdown files.
|
A simple, single-binary Go web application for hosting and sharing markdown files.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Create, view, edit, and delete** markdown files via web interface
|
- **Create, view, edit, and delete** markdown files via web interface
|
||||||
@@ -119,6 +121,8 @@ The creation timestamp is stored in the file's `CreatedAt` field and persists ac
|
|||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
|
A pre-built Docker image is available from `gitea.scu.si/florian.walther/mdhost:latest`.
|
||||||
|
|
||||||
### Build the Image
|
### Build the Image
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -139,7 +143,7 @@ docker run -d \
|
|||||||
-p 8080:8080 \
|
-p 8080:8080 \
|
||||||
-v ~/mdhost-posts:/posts \
|
-v ~/mdhost-posts:/posts \
|
||||||
-v ~/mdhost-data:/data \
|
-v ~/mdhost-data:/data \
|
||||||
mdhost
|
gitea.scu.si/florian.walther/mdhost:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
The application will be available at `http://localhost:8080`.
|
The application will be available at `http://localhost:8080`.
|
||||||
@@ -155,7 +159,8 @@ Create a `docker-compose.yml`:
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
services:
|
services:
|
||||||
mdhost:
|
mdhost:
|
||||||
build: .
|
image: gitea.scu.si/florian.walther/mdhost:latest
|
||||||
|
# build: .
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ var (
|
|||||||
port = ":8080"
|
port = ":8080"
|
||||||
markdown = newMarkdownRenderer()
|
markdown = newMarkdownRenderer()
|
||||||
dataMu sync.RWMutex
|
dataMu sync.RWMutex
|
||||||
|
version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListFormat configures how files are rendered in the index
|
// ListFormat configures how files are rendered in the index
|
||||||
@@ -536,6 +537,9 @@ const css = `<style>
|
|||||||
.edit-link:hover{color:var(--link-color)}
|
.edit-link:hover{color:var(--link-color)}
|
||||||
#theme-toggle{background:none;border:none;cursor:pointer;padding:.25rem .4rem;color:var(--nav-text);font-size:1.1rem;border-radius:4px}
|
#theme-toggle{background:none;border:none;cursor:pointer;padding:.25rem .4rem;color:var(--nav-text);font-size:1.1rem;border-radius:4px}
|
||||||
#theme-toggle:hover{background:rgba(255,255,255,.1)}
|
#theme-toggle:hover{background:rgba(255,255,255,.1)}
|
||||||
|
footer{position:fixed;bottom:0;left:0;width:100%;background:var(--nav-bg);color:var(--nav-text);padding:.5rem 1rem;display:flex;justify-content:space-between;align-items:center;font-size:.85rem;z-index:100}
|
||||||
|
footer .left{font-weight:600}
|
||||||
|
footer .right{font-family:monospace}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded',function(){
|
document.addEventListener('DOMContentLoaded',function(){
|
||||||
@@ -561,7 +565,8 @@ const chromaCSS = `<style>
|
|||||||
</style>`
|
</style>`
|
||||||
|
|
||||||
func renderPage(w http.ResponseWriter, r *http.Request, title, body string) {
|
func renderPage(w http.ResponseWriter, r *http.Request, title, body string) {
|
||||||
fmt.Fprintf(w, "<html><head><title>%s</title>%s%s</head><body>%s<main>%s</main></body></html>", title, chromaCSS, css, getNavBar(r), body)
|
footer := fmt.Sprintf("<footer><span class='left'>mdhost</span><span class='center'></span><span class='right'>%s</span></footer>", version)
|
||||||
|
fmt.Fprintf(w, "<html><head><title>%s</title>%s%s</head><body>%s<main>%s</main>%s</body></html>", title, chromaCSS, css, getNavBar(r), body, footer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func listHandler(w http.ResponseWriter, r *http.Request) {
|
func listHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -1110,5 +1115,6 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use getNavBar which already includes all links
|
// Use getNavBar which already includes all links
|
||||||
fmt.Fprintf(w, "<html><head><title>%s</title>%s%s</head><body>%s<main><div class='markdown-body'>%s</div></main></body></html>", entry.Name, css, chromaCSS, getNavBar(r), buf.String())
|
footer := fmt.Sprintf("<footer><span class='left'>mdhost</span><span class='center'></span><span class='right'>%s</span></footer>", version)
|
||||||
|
fmt.Fprintf(w, "<html><head><title>%s</title>%s%s</head><body>%s<main><div class='markdown-body'>%s</div></main>%s</body></html>", entry.Name, css, chromaCSS, getNavBar(r), buf.String(), footer)
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
Reference in New Issue
Block a user