node tpl and style moved to www

fix ii-node die without tpl dir
pull/1/head
vasyahacker 2023-03-12 12:54:59 +04:00
parent 822bb61a99
commit 52e0d73526
26 changed files with 25 additions and 14 deletions

View File

@ -1,22 +1,20 @@
.PHONY: all clean build
.PHONY: all clean build install
all: build
build-all: build
build:
go build -trimpath -o ii-tool ./ii-tool
go build -trimpath -o ii-node ./ii-node
go build -trimpath -o ii-gemini ./ii-gemini
go build -trimpath -o ii-tool ./cmd/ii-tool
go build -trimpath -o ii-node ./cmd/ii-node
go build -trimpath -o ii-gemini ./cmd/ii-gemini
install-all: install
install:
go install ./ii-tool
go install ./ii-node
go install ./ii-gemini
go install ./cmd/ii-tool
go install ./cmd/ii-node
go install ./cmd/ii-gemini
clean:
cd ii-node && go clean
cd ii-tool && go clean
cd ii-gemini && go clean
rm -f ii-node ii-tool ii-gemini

View File

@ -2,6 +2,7 @@ package main
import (
"git.openbsd.org.ru/vasyahacker/ii-go/ii"
"os"
"bytes"
"encoding/base64"
"errors"
@ -911,7 +912,19 @@ func WebInit(www *WWW) {
return false
},
}
www.tpl = template.Must(template.New("main").Funcs(funcMap).ParseGlob("tpl/*.tpl"))
tpl_path := "tpl"
if _, err := os.Stat(tpl_path); errors.Is(err, os.ErrNotExist) {
fmt.Println("./tpl dir not exist")
tpl_path = "/usr/local/share/ii-go/tpl"
if _, err := os.Stat(tpl_path); errors.Is(err, os.ErrNotExist) {
fmt.Println(tpl_path, "dir not exist")
os.Exit(1)
}
}
www.tpl = template.Must(
template.New("main").Funcs(funcMap).ParseGlob(tpl_path + "/*.tpl"))
}
func handleErr(ctx *WebContext, w http.ResponseWriter, err error) {

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -4,8 +4,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<link rel="icon" href="/lib/icon.png" type="image/png">
<link rel="stylesheet" type="text/css" href="/lib/style.css">
<link rel="icon" href="/style/icon.png" type="image/png">
<link rel="stylesheet" type="text/css" href="/style/style.css">
{{ if eq .Template "query.tpl" }}<link href="{{.PfxPath}}/{{.BasePath}}/rss" type="application/rss+xml" rel="alternate" title="{{.Sysname}} {{.BasePath}} :: RSS feed" />{{ end }}
{{ if eq .Template "blog.tpl" }}<link href="{{.PfxPath}}/{{.BasePath}}+topics/rss" type="application/rss+xml" rel="alternate" title="{{.Sysname}} {{.BasePath}} :: RSS feed" />{{ end }}
@ -16,7 +16,7 @@
<table id="header">
<tr>
<td class="title">
<span class="logo"><a href="/"><img class="logo" src="/lib/icon.png">{{.Sysname}}</a></span>
<span class="logo"><a href="/"><img class="logo" src="/style/icon.png">{{.Sysname}}</a></span>
{{ if eq .BasePath "" }}
<span class="info">II/IDEC networks :: <a href="{{ $.PfxPath }}/echo/all">New posts</a>
{{ else if gt (len .Topics) 0}}