月の首都はそれがあるべき場所に戻っています

git-svn-id: file:///srv/svn/repo/toyohime/trunk@115 922d331f-388e-da47-97a9-ad700dc0b8b9
This commit is contained in:
yakumo.izuru 2025-04-17 23:12:28 +00:00
parent 5bcf36ba3a
commit e60a0bf01a
11 changed files with 95 additions and 97 deletions

View File

@ -1,5 +1,5 @@
Copyright (c) 2018, Jon Betti Copyright (c) 2018, Jon Betti
Copyright (c) 2023, Izuru Yakumo Copyright (c) 2023-2025, Izuru Yakumo
Permission to use, copy, modify, and/or distribute this software for any purpose Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice with or without fee is hereby granted, provided that the above copyright notice

View File

@ -1,15 +1,13 @@
GO ?= go GO ?= go
GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=$(VERSION) -X `go list`.Commit=$(COMMIT) -X `go list`.Build=$(BUILD)" -tags "static_build" GOFLAGS ?= -v -ldflags "-w -X `${GO} list`.Version=${VERSION} -X `${GO} list`.Build=${BUILD}"
PREFIX ?= /usr/local PREFIX ?= /usr/local
VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION"`
COMMIT = `git rev-parse --short HEAD || echo "$COMMIT"`
BRANCH = `git rev-parse --abbrev-ref HEAD`
BUILD = `git show -s --pretty=format:%cI`
GOARCH ?= amd64 GOARCH ?= amd64
GOOS ?= linux GOOS ?= linux
VERSION = 0.4.0
BUILD = `date +%Y-%m-%d:%H:%M:%S%z`
all: toyohime all: toyohime
toyohime: toyohime:
@ -17,10 +15,10 @@ toyohime:
clean: clean:
rm toyohime rm toyohime
install: install:
install -m0755 toyohime ${DESTDIR}${PREFIX}/bin/yorihime install -m0755 toyohime ${DESTDIR}${PREFIX}/bin/toyohime
install -Dm0044 toyohime.1 ${DESTDIR}${PREFIX}/share/man/man1/toyohime.1 install -Dm0044 toyohime.1 ${DESTDIR}${PREFIX}/man/man1/toyohime.1
test: test:
${GO} test . ${GO} test .
uninstall: uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/toyohime rm -f ${DESTDIR}${PREFIX}/bin/toyohime
rm -f ${DESTDIR}${PREFIX}/share/man/man1/toyohime.1 rm -f ${DESTDIR}${PREFIX}/man/man1/toyohime.1

View File

@ -14,9 +14,10 @@ BitBucket, etc.). A commonly used vanity import path is
* Redirects pkg.go.dev to browsable files * Redirects pkg.go.dev to browsable files
## Installation ## Installation
Requires Go >=1.16
```bash ```bash
go install marisa.chaotic.ninja/toyohime/cmd/toyohime@latest go install mahou-no-mori.yakumo.dev/toyohime/cmd/toyohime@latest
``` ```
## Specification ## Specification

View File

@ -27,6 +27,7 @@ package main // go.jonnrb.io/vanity
import ( import (
"bufio" "bufio"
"bytes" "bytes"
_ "embed"
"flag" "flag"
"fmt" "fmt"
"html/template" "html/template"
@ -38,7 +39,7 @@ import (
"strings" "strings"
"time" "time"
"marisa.chaotic.ninja/toyohime" "mahou-no-mori.yakumo.dev/toyohime"
) )
var ( var (
@ -53,6 +54,9 @@ var (
reposPath string = "repos" // param 2 reposPath string = "repos" // param 2
) )
//go:embed templates/index.tmpl
var IndexPage string
func serveRepo(mux *http.ServeMux, root string, u *url.URL) { func serveRepo(mux *http.ServeMux, root string, u *url.URL) {
vcsScheme, vcsHost := u.Scheme, u.Host vcsScheme, vcsHost := u.Scheme, u.Host
@ -107,78 +111,8 @@ func addRepoHandlers(mux *http.ServeMux, r io.Reader) error {
} }
var b bytes.Buffer var b bytes.Buffer
err := template.Must(template.New("").Parse(` err := template.Must(template.New("").Parse(IndexPage)).Execute(&b, struct {
<!DOCTYPE html> //err := template.Must(template.New("").Parse(IndexTmpl))).Execute(&b, struct {
<html>
<head>
<title>Import paths hosted at {{ .Host }}</title>
<style type="text/css">
body,td{font-size:11pt; color:#4d4d4d; font-family:ms pgothic, ms gothic, osaka; background-color:#f8dfdf}
a:link{color:#cc9999; text-decoration:none}
a:visited{color:#cc9999; text-decoration:none}
a:active{color:#cc9999; text-decoration:none; position:relative; top:3px; left:3px}
a:hover{color:#cc9999; text-decoration:none; position:relative; top:3px; left:3px}
.yohaku{margin-top:30px}
.dia{line-height:130%}
.star1{font-size:22px; color:#cc9999}
.position1{position:relative; top:7px}
.line{border-top:2px dotted #cc9999}
.waku{border:1px solid #cc9999}
.bg{background-color:#ffffff}
</style>
</head>
<body>
{{ $host := .Host }}
<div align="center">
<p>でホストされているインポート パス {{ html $host }}</p>
</div>
<div align="center">
<table width="470" class="bg waku yohaku" cellspacing="0" style="margin-bottom: 20px">
{{ range $root, $repo := .IndexMap }}
<tr><td class="bg" style="padding-top: 5px; padding-bottom: 5px">
<div class="star1" align="center">
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
</div>
</td></tr>
<tr><td class="bg line dia" style="padding: 15px 10px 10px 10px">
<center>
<h2>{{ html $root }}</h2>
<a href="https://{{ html $host }}/{{ html $root }}">Package</a> <br/>
<a href="{{ html $repo }}">Repository</a></li>
{{ else }}
Nothing here.
{{ end }}
</center>
</table>
<p>から明らかに盗まれた <a href="http://azukifont.com">azukifont.com</a></p>
</div>
</body>
</html>
`)).Execute(&b, struct {
IndexMap map[string]string IndexMap map[string]string
Host string Host string
}{ }{

View File

@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<title>Import paths hosted at {{ .Host }}</title>
<style type="text/css">
body,td{font-size:11pt; color:#4d4d4d; font-family:ms pgothic, ms gothic, osaka; background-color:#f8dfdf}
a:link{color:#cc9999; text-decoration:none}
a:visited{color:#cc9999; text-decoration:none}
a:active{color:#cc9999; text-decoration:none; position:relative; top:3px; left:3px}
a:hover{color:#cc9999; text-decoration:none; position:relative; top:3px; left:3px}
.yohaku{margin-top:30px}
.dia{line-height:130%}
.star1{font-size:22px; color:#cc9999}
.position1{position:relative; top:7px}
.line{border-top:2px dotted #cc9999}
.waku{border:1px solid #cc9999}
.bg{background-color:#ffffff}
</style>
</head>
<body>
{{ $host := .Host }}
<div align="center">
<p>でホストされているインポート パス {{ html $host }}</p>
</div>
<div align="center">
<table width="470" class="bg waku yohaku" cellspacing="0" style="margin-bottom: 20px">
{{ range $root, $repo := .IndexMap }}
<tr><td class="bg" style="padding-top: 5px; padding-bottom: 5px">
<div class="star1" align="center">
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
<span style="position:relative; top:5px">*</span>
<span style="position:relative; top:-5px">*</span>
</div>
</td></tr>
<tr><td class="bg line dia" style="padding: 15px 10px 10px 10px">
<center>
<h2>{{ html $root }}</h2>
<a href="https://{{ html $host }}/{{ html $root }}">Package</a> <br/>
<a href="{{ html $repo }}">Repository</a></li>
{{ else }}
Nothing here.
{{ end }}
</center>
</table>
<p>~から明らかに盗まれた <a href="http://azukifont.com">azukifont.com</a></p>
</div>
</body>
</html>

4
go.mod
View File

@ -1,5 +1,5 @@
module marisa.chaotic.ninja/toyohime module mahou-no-mori.yakumo.dev/toyohime
go 1.14 go 1.16
require github.com/fsnotify/fsnotify v1.4.9 require github.com/fsnotify/fsnotify v1.4.9

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $TheSupernovaDuo$ # $YakumoLabs$
# #
# PROVIDE: toyohime # PROVIDE: toyohime
# REQUIRE: DAEMON NETWORKING # REQUIRE: DAEMON NETWORKING

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $TheSupernovaDuo$ # $YakumoLabs$
# #
# PROVIDE: toyohime # PROVIDE: toyohime
# REQUIRE: DAEMON # REQUIRE: DAEMON

View File

@ -1,5 +1,5 @@
#!/bin/ksh #!/bin/ksh
# $TheSupernovaDuo$ # $YakumoLabs$
. /etc/rc.d/rc.subr . /etc/rc.d/rc.subr

View File

@ -22,4 +22,4 @@ possible.
.Sh AUTHORS .Sh AUTHORS
.An Jon Betti Aq Mt jonbetti@gmail.com .An Jon Betti Aq Mt jonbetti@gmail.com
.Sh MAINTAINERS .Sh MAINTAINERS
.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja .An Izuru Yakumo Aq Mt eternal-servant@yakumo.dev

View File

@ -8,7 +8,6 @@ import (
const ( const (
defaultVersion = "0.0.0" defaultVersion = "0.0.0"
defaultCommit = "HEAD"
defaultBuild = "0000-01-01:00:00+00:00" defaultBuild = "0000-01-01:00:00+00:00"
) )
@ -17,10 +16,6 @@ var (
// following semantic versioning and is overwritten by the build system. // following semantic versioning and is overwritten by the build system.
Version = defaultVersion Version = defaultVersion
// Commit is the commit sha of the build (normally from Git) and is overwritten
// by the build system.
Commit = defaultCommit
// Build is the date and time of the build as an RFC3339 formatted string // Build is the date and time of the build as an RFC3339 formatted string
// and is overwritten by the build system. // and is overwritten by the build system.
Build = defaultBuild Build = defaultBuild
@ -30,10 +25,10 @@ var (
func FullVersion() string { func FullVersion() string {
var sb strings.Builder var sb strings.Builder
isDefault := Version == defaultVersion && Commit == defaultCommit && Build == defaultBuild isDefault := Version == defaultVersion && Build == defaultBuild
if !isDefault { if !isDefault {
sb.WriteString(fmt.Sprintf("%s@%s %s", Version, Commit, Build)) sb.WriteString(fmt.Sprintf("%s@%s", Version, Build))
} }
if info, ok := debug.ReadBuildInfo(); ok { if info, ok := debug.ReadBuildInfo(); ok {