15 Commits

15 changed files with 34 additions and 499 deletions

8
.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
# development
cmd/archive-server/archive-server
cmd/archive-server/config.json
# binaries
_dist/
build/

View File

@@ -1,9 +0,0 @@
mode:regex
# development
^cmd/archive-server/archive-server$
^cmd/archive-server/config.json$
# binaries
^_dist/
^build/

View File

@@ -1,2 +0,0 @@
718fcb17fc0c119591e837d700c752601c392130 release-3.0.0
47147713ae1b5de60d49faeed6e17f962d5deae0 release-3.0.1

View File

@@ -10,7 +10,7 @@ import (
) )
var ( var (
SERVER_VERSION = "archive/0.0.0" SERVER_VERSION = "archive/0.0.0-git"
) )
type ArchiveServer struct { type ArchiveServer struct {

View File

@@ -1,82 +0,0 @@
#
# Makefile for archive
#
VERSION:=3.1.0
SOURCES:=Makefile \
static \
cmd $(wildcard cmd/archive-server/*.go) \
$(wildcard *.go)
GOFLAGS := -ldflags='-s -w -X code.ivysaur.me/archive.SERVER_VERSION=archive/${VERSION}' -gcflags='-trimpath=$(GOPATH)' -asmflags='-trimpath=$(GOPATH)'
#
# Phony targets
#
.PHONY: all dist clean devel
all: build/linux64/archive-server build/win32/archive-server.exe
dist: \
_dist/archive-$(VERSION)-linux64.tar.gz \
_dist/archive-$(VERSION)-win32.7z \
_dist/archive-$(VERSION)-src.zip
clean:
if [ -f ./staticResources.go ] ; then rm ./staticResources.go ; fi
if [ -d ./build ] ; then rm -r ./build ; fi
if [ -f ./archive ] ; then rm ./archive ; fi
devel: staticResources.go
( cd cmd/archive-server && go build && ./archive-server -listen "127.0.0.1:8000" )
#
# Generated files
#
staticResources.go: static/ static/*
go-bindata -o staticResources.go -prefix static -pkg archive static
#
# Release artefacts
#
build/linux64/archive-server: $(SOURCES) staticResources.go
mkdir -p build/linux64
(cd cmd/archive-server ; \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build $(GOFLAGS) -o ../../build/linux64/archive-server \
)
build/win32/archive-server.exe: $(SOURCES) staticResources.go
mkdir -p build/win32
(cd cmd/archive-server ; \
PATH=/usr/lib/mxe/usr/bin:$(PATH) CC=i686-w64-mingw32.static-gcc \
CGO_ENABLED=1 GOOS=windows GOARCH=386 \
go build $(GOFLAGS) -o ../../build/win32/archive-server.exe \
)
build/linux64/config.json.SAMPLE: cmd/archive-server/config.json.SAMPLE
cp cmd/archive-server/config.json.SAMPLE build/linux64/config.json.SAMPLE
build/win32/config.json.SAMPLE: cmd/archive-server/config.json.SAMPLE
cp cmd/archive-server/config.json.SAMPLE build/win32/config.json.SAMPLE
_dist/archive-$(VERSION)-linux64.tar.gz: build/linux64/archive-server build/linux64/config.json.SAMPLE
mkdir -p _dist
tar caf _dist/archive-$(VERSION)-linux64.tar.gz -C build/linux64 archive-server config.json.SAMPLE --owner=0 --group=0
_dist/archive-$(VERSION)-win32.7z: build/win32/archive-server.exe build/win32/config.json.SAMPLE
mkdir -p _dist
( cd build/win32 ; \
if [ -f dist.7z ] ; then rm dist.7z ; fi ; \
7z a dist.7z archive-server.exe config.json.SAMPLE ; \
mv dist.7z ../../_dist/archive-$(VERSION)-win32.7z \
)
_dist/archive-$(VERSION)-src.zip: $(SOURCES)
hg archive --type=zip _dist/archive-$(VERSION)-src.zip

View File

@@ -1,10 +1,19 @@
# archive
![](https://img.shields.io/badge/written%20in-Go-blue.svg)
A web interface for browsing chat logs. A web interface for browsing chat logs.
As of the 3.0 release, `archive` is available as a standalone binary for Linux and Windows. As of the 3.0 release, `archive` is available as a standalone binary for Linux and Windows.
Written in Golang, PHP ## Changelog
=CHANGELOG= 2025-08-20: 3.1.1
- Update dependencies, replace go-bindata with `go:embed`
2018-11-06: (no release tag)
- Convert from hg to git
- Convert to Go Modules
2017-12-10: 3.1.0 2017-12-10: 3.1.0
- Feature: Statistics page - Feature: Statistics page

View File

@@ -2,6 +2,7 @@ package archive
import ( import (
"bytes" "bytes"
"embed"
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
@@ -10,6 +11,11 @@ import (
"time" "time"
) )
// Static assets
//go:embed static/*
var staticAssets embed.FS
func (this *ArchiveServer) lookupSourceByNumericString(slug string) *LogSource { func (this *ArchiveServer) lookupSourceByNumericString(slug string) *LogSource {
intval, err := strconv.Atoi(slug) intval, err := strconv.Atoi(slug)
if err != nil { if err != nil {
@@ -71,7 +77,7 @@ func (this *ArchiveServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Handle static assets // Handle static assets
static, err := Asset(r.URL.Path[1:]) static, err := staticAssets.ReadFile(`static/` + r.URL.Path[1:])
if err == nil { if err == nil {
http.ServeContent(w, r, r.URL.Path[1:], this.startup, bytes.NewReader(static)) http.ServeContent(w, r, r.URL.Path[1:], this.startup, bytes.NewReader(static))
return return

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module code.ivysaur.me/archive
go 1.24.4
require github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag=

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +0,0 @@
Copyright (c) 2012 Jehiah Czebotar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -1,4 +0,0 @@
go-strftime
===========
go implementation of strftime

View File

@@ -1,72 +0,0 @@
// go implementation of strftime
package strftime
import (
"strings"
"time"
)
// taken from time/format.go
var conversion = map[rune]string{
/*stdLongMonth */ 'B': "January",
/*stdMonth */ 'b': "Jan",
// stdNumMonth */ 'm': "1",
/*stdZeroMonth */ 'm': "01",
/*stdLongWeekDay */ 'A': "Monday",
/*stdWeekDay */ 'a': "Mon",
// stdDay */ 'd': "2",
// stdUnderDay */ 'd': "_2",
/*stdZeroDay */ 'd': "02",
/*stdHour */ 'H': "15",
// stdHour12 */ 'I': "3",
/*stdZeroHour12 */ 'I': "03",
// stdMinute */ 'M': "4",
/*stdZeroMinute */ 'M': "04",
// stdSecond */ 'S': "5",
/*stdZeroSecond */ 'S': "05",
/*stdLongYear */ 'Y': "2006",
/*stdYear */ 'y': "06",
/*stdPM */ 'p': "PM",
// stdpm */ 'p': "pm",
/*stdTZ */ 'Z': "MST",
// stdISO8601TZ */ 'z': "Z0700", // prints Z for UTC
// stdISO8601ColonTZ */ 'z': "Z07:00", // prints Z for UTC
/*stdNumTZ */ 'z': "-0700", // always numeric
// stdNumShortTZ */ 'b': "-07", // always numeric
// stdNumColonTZ */ 'b': "-07:00", // always numeric
/* nonStdMilli */ 'L': ".000",
}
// This is an alternative to time.Format because no one knows
// what date 040305 is supposed to create when used as a 'layout' string
// this takes standard strftime format options. For a complete list
// of format options see http://strftime.org/
func Format(format string, t time.Time) string {
retval := make([]byte, 0, len(format))
for i, ni := 0, 0; i < len(format); i = ni + 2 {
ni = strings.IndexByte(format[i:], '%')
if ni < 0 {
ni = len(format)
} else {
ni += i
}
retval = append(retval, []byte(format[i:ni])...)
if ni+1 < len(format) {
c := format[ni+1]
if c == '%' {
retval = append(retval, '%')
} else {
if layoutCmd, ok := conversion[rune(c)]; ok {
retval = append(retval, []byte(t.Format(layoutCmd))...)
} else {
retval = append(retval, '%', c)
}
}
} else {
if ni < len(format) {
retval = append(retval, '%')
}
}
}
return string(retval)
}

View File

@@ -1,49 +0,0 @@
package strftime
import (
"fmt"
"testing"
"time"
)
func ExampleFormat() {
t := time.Unix(1340244776, 0)
utc, _ := time.LoadLocation("UTC")
t = t.In(utc)
fmt.Println(Format("%Y-%m-%d %H:%M:%S", t))
// Output:
// 2012-06-21 02:12:56
}
func TestNoLeadingPercentSign(t *testing.T) {
tm := time.Unix(1340244776, 0)
utc, _ := time.LoadLocation("UTC")
tm = tm.In(utc)
result := Format("aaabbb0123456789%Y", tm)
if result != "aaabbb01234567892012" {
t.Logf("%s != %s", result, "aaabbb01234567892012")
t.Fail()
}
}
func TestUnsupported(t *testing.T) {
tm := time.Unix(1340244776, 0)
utc, _ := time.LoadLocation("UTC")
tm = tm.In(utc)
result := Format("%0%1%%%2", tm)
if result != "%0%1%%2" {
t.Logf("%s != %s", result, "%0%1%%2")
t.Fail()
}
}
func TestRubyStrftime(t *testing.T) {
tm := time.Unix(1340244776, 0)
utc, _ := time.LoadLocation("UTC")
tm = tm.In(utc)
result := Format("%H:%M:%S%L", tm)
if result != "02:12:56.000" {
t.Logf("%s != %s", result, "02:12:56.000")
t.Fail()
}
}