41 Commits

Author SHA1 Message Date
f0e64cbc34 modernise the sample configuration file 2017-11-26 19:56:43 +13:00
e7587dae2d Added tag v1.3.0 for changeset 4dc4a77c8db3 2017-11-26 19:55:50 +13:00
2e264ecaf1 doc: readme 2017-11-26 19:55:45 +13:00
046c6627ec makefile: bump version to 1.3.0 2017-11-26 19:55:39 +13:00
36f49749ad config: hub.port is optional, allow putting full URL in hub.address field 2017-11-26 19:54:03 +13:00
aacebe5c5f compatibility updates for libnmdc 2017-11-26 19:51:10 +13:00
80d230be98 vendor: bump libnmdc 0.15.0 -> 0.16.0 2017-11-26 19:48:53 +13:00
27c9621833 makefile: bump version to 1.2.4 2017-11-14 19:58:00 +13:00
082502c7e6 Added tag v1.2.3 for changeset e7de5d5504b9 2017-11-14 19:57:50 +13:00
f4684673e7 doc: readme 2017-11-14 19:57:44 +13:00
0dc5c2878f hgignore 2017-11-14 19:47:21 +13:00
efdb188aba vendor: bump libnmdc 0.14.0 -> 0.15.0 2017-11-14 19:45:08 +13:00
54e21f2b2d clear owner/group from linux64 release tarball 2017-10-28 14:15:23 +13:00
dd166cf0e9 doc: mention supercedes 2017-10-28 14:00:48 +13:00
92b1c4daa5 doc: fix cosmetic issue with readme generation on code.ivysaur.me 2017-10-28 13:43:02 +13:00
ea4135888d bump all versions to 1.2.3 2017-10-28 13:32:29 +13:00
8e999f5ddb Added tag v1.2.2 for changeset 0c6b957de432 2017-10-28 13:32:16 +13:00
62c03cf9f1 doc: mention download options 2017-10-28 13:30:51 +13:00
6abdc8d2a9 server: use real content length, use system MIME info instead of handrolling it 2017-10-28 13:27:44 +13:00
1a281095f0 regenerate bindata.go 2017-10-28 13:27:19 +13:00
69613d07a5 build: remove timestamps from generated bindata.go file 2017-10-28 13:27:07 +13:00
19b2221ea1 doc: mention unminified development instructions 2017-10-28 13:24:18 +13:00
9840c1024e doc: preliminary changelog update 2017-10-28 13:17:50 +13:00
00cdce5f5a doc: add instructions on setting up a development environment 2017-10-28 13:17:13 +13:00
312cbb7bc1 commit a copy of bindata.go, to allow installation via go get 2017-10-28 13:11:05 +13:00
bea598f7a3 retag in vX.Y.Z format 2017-10-28 12:53:54 +13:00
ef9a61e9cf hgignore vendor directory 2017-10-28 12:49:10 +13:00
0ec079cfd4 use 'dep' for dependency management 2017-10-28 12:48:55 +13:00
54ecffd0d4 build: remove dead code 2017-10-28 11:56:11 +13:00
41e244c255 build: replace minipack shell script with sed commands 2017-10-28 11:51:23 +13:00
a109e2dc29 build: replace IIFEMODE/sed with cat in makefile 2017-10-28 11:40:09 +13:00
0bafa59358 build: remove php, replace with bash script 2017-10-28 11:32:51 +13:00
78ced31e9d further conversion to makefile build 2017-10-28 00:21:20 +13:00
16a4a2556b partial conversion to makefile build 2017-10-28 00:06:45 +13:00
fafca96711 fix not being able to close PM tabs 2017-10-27 23:44:18 +13:00
2eacb06c9e Added tag release-1.2.1 for changeset c8cd84947e45 2017-10-16 18:48:21 +13:00
1f2871b917 doc: preliminary changelog update 2017-10-16 18:47:32 +13:00
855206feed hide (0) from page title 2017-10-16 18:33:43 +13:00
efa195df5b bump scrollback limit from 50->200 2017-10-16 18:30:56 +13:00
89c8cb0dc8 contented: fix upload item disappearing once logged in 2017-10-15 22:55:00 +13:00
c2de4c8d45 Added tag release-1.2.0 for changeset 0eeab5594ba4 2017-10-15 22:54:41 +13:00
13 changed files with 500 additions and 301 deletions

View File

@@ -5,4 +5,8 @@ mode:regex
^clientpack/
^_dist/
^bindata\.go$
^node_modules/
^vendor/
^nmdc-webfrontend$
^nmdc-webfrontend\.exe$

21
.hgtags
View File

@@ -1,8 +1,13 @@
769fad81e3f8db8f7e5f5c164656a382a169d735 release-1.0.0
9ed95938d809a8226aca529e34b655e6d8c8c379 release-1.0.1
46fe533682419c8a519836ac95b5575053aa0fa8 release-1.0.2
a2c92b262f339f82eb01c8d92dda252a27432255 release-1.1.0
d14041daa7bbbd37ea2ff47aa978b9595af67ca3 release-1.1.1
7278eb0d067d8ed2a653de6a1feeeb7f76fb9891 release-1.1.2
6cbd9d59630372c0dff430e3dc6c1fbd7dcee734 release-1.1.3
76c178b8f27ec894e79b8f73649fcb3e45a73729 release-1.1.4
769fad81e3f8db8f7e5f5c164656a382a169d735 v1.0.0
9ed95938d809a8226aca529e34b655e6d8c8c379 v1.0.1
46fe533682419c8a519836ac95b5575053aa0fa8 v1.0.2
a2c92b262f339f82eb01c8d92dda252a27432255 v1.1.0
d14041daa7bbbd37ea2ff47aa978b9595af67ca3 v1.1.1
7278eb0d067d8ed2a653de6a1feeeb7f76fb9891 v1.1.2
6cbd9d59630372c0dff430e3dc6c1fbd7dcee734 v1.1.3
76c178b8f27ec894e79b8f73649fcb3e45a73729 v1.1.4
0eeab5594ba4d683e6a268ef971675c73b226bd0 v1.2.0
c8cd84947e4516215e50639914adfaecf350fe91 v1.2.1
0c6b957de43252f89688ba73c4857f6d912b2912 v1.2.2
e7de5d5504b9a2bf368279d6a691458398a638bf v1.2.3
4dc4a77c8db3170b284e12e33171994ad18ffa29 v1.3.0

View File

@@ -17,7 +17,7 @@ type Config struct {
Hub struct {
Address string `json:"address"`
Port int `json:"port"`
Port int `json:"port,omitempty"`
Tag string `json:"tag"`
}
}

39
Gopkg.lock generated Normal file
View File

@@ -0,0 +1,39 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "code.ivysaur.me/libnmdc"
packages = ["."]
revision = "a23cc9e61d24bb9b16b1126bdddd514e01d64792"
version = "v0.16.0"
[[projects]]
branch = "master"
name = "github.com/cxmcc/tiger"
packages = ["."]
revision = "bde35e2713d7f674987c2ecb21a6b0fc33749516"
[[projects]]
branch = "master"
name = "github.com/googollee/go-engine.io"
packages = [".","message","parser","polling","transport","websocket"]
revision = "80ae0e43aca17b4c5a6834999d0f2eaa16b9afda"
[[projects]]
branch = "master"
name = "github.com/googollee/go-socket.io"
packages = ["."]
revision = "5447e71f36d394766bf855d5714a487596809f0d"
[[projects]]
name = "github.com/gorilla/websocket"
packages = ["."]
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
version = "v1.2.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "7ac2438222289730d49b803fd1c631629921f95fd406c3154a54d34e11fb6947"
solver-name = "gps-cdcl"
solver-version = 1

30
Gopkg.toml Normal file
View File

@@ -0,0 +1,30 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]]
name = "code.ivysaur.me/libnmdc"
version = "0.16.0"
[[constraint]]
branch = "master"
name = "github.com/googollee/go-socket.io"

60
Makefile Normal file
View File

@@ -0,0 +1,60 @@
# Makefile for nmdc-webfrontend
BINNAME=nmdc-webfrontend
VERSION=1.3.0
GOFLAGS=-a \
-ldflags "-s -w -X main.VERSION=$(BINNAME)/$(VERSION)" \
-gcflags "-trimpath ${GOPATH}" \
-asmflags "-trimpath ${GOPATH}"
SOURCES=client/ Gopkg.lock Gopkg.toml Makefile Config.go main.go nmdc-webfrontend.conf.SAMPLE
.PHONY: all deps clean
all: $(BINNAME)-$(VERSION)-win32.7z $(BINNAME)-$(VERSION)-linux64.tar.xz $(BINNAME)-$(VERSION)-src.tar.xz
deps:
npm install -g less uglify-js less-plugin-clean-css html-minifier
go get -u github.com/jteeuwen/go-bindata/...
go get -u github.com/golang/dep/cmd/dep
dep ensure
clean:
rm -f ./$(BINNAME)
rm -f ./$(BINNAME).exe
rm -fr ./clientpack
rm -f ./bindata.go
bindata.go: client client/*
rm -fr ./clientpack
cp -r ./client ./clientpack
( echo ';(function() {' ; cat clientpack/dcwebui.js ; echo '})();' ) | uglifyjs -o clientpack/dcwebui.min.js -c -m --ie8
lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css
cat clientpack/index.htm \
| sed -e '/dcwebui.css/{i <style>' -e 'r clientpack/dcwebui.min.css' -e 'a </style>' -e 'd}' \
| sed -e '/dcwebui.js/{i <script>' -e 'r clientpack/dcwebui.min.js' -e 'a </script>' -e 'd}' \
| sed -e '/socket.io-1.7.2.js/{i <script>' -e 'r clientpack/socket.io-1.7.2.js' -e 'a </script>' -e 'd}' \
> clientpack/index.packed.htm
mv clientpack/index.packed.htm clientpack/index.htm
html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm
mv clientpack/index.min.htm clientpack/index.htm
rm ./clientpack/*.js
rm ./clientpack/*.css
go-bindata -nomemcopy -nometadata -prefix clientpack clientpack
$(BINNAME).exe: bindata.go *.go
GOARCH=386 GOOS=windows go build $(GOFLAGS) -o $(BINNAME).exe
$(BINNAME): bindata.go *.go
GOARCH=amd64 GOOS=linux go build $(GOFLAGS) -o $(BINNAME)
$(BINNAME)-$(VERSION)-win32.7z: $(BINNAME).exe nmdc-webfrontend.conf.SAMPLE
7z a -mx9 "$(BINNAME)-$(VERSION)-win32.7z" $(BINNAME).exe nmdc-webfrontend.conf.SAMPLE
$(BINNAME)-$(VERSION)-linux64.tar.xz: $(BINNAME) nmdc-webfrontend.conf.SAMPLE
XZ_OPT='-9' tar caf "$(BINNAME)-$(VERSION)-linux64.tar.xz" $(BINNAME) nmdc-webfrontend.conf.SAMPLE --owner=0 --group=0
$(BINNAME)-$(VERSION)-src.tar.xz: $(SOURCES)
XZ_OPT='-9' tar caf "$(BINNAME)-$(VERSION)-src.tar.xz" $(SOURCES) --owner=0 --group=0

View File

@@ -1,18 +1,50 @@
A web interface to an NMDC hub.
A web interface to an NMDC/ADC hub.
Chat in real-time on your NMDC hub using a web browser. This project forks and deprecates my earlier `dcwebui2` project since Go seems to use less memory than node.
Chat in real-time on your NMDC/ADC hub using a web browser. This project forks and deprecates my earlier `dcwebui2` project since Go seems to use less memory than node.
Written in Golang
Tags: nmdc
This project supercedes [entry=dcwebui]dcwebui[/entry], [entry=flexdc]flexdc[/entry], and [entry=dcwebui2]dcwebui2[/entry].
=UPGRADING FROM DCWEBUI2=
- The configuration file content is identical between nmdc-webfrontend 1.0.0 and dcwebui2 1.3.0, but please now ensure it's valid JSON instead of arbitrary javascript. This means no assignment, use double-quoted strings, and no comments.
- Future changes to the configuration file since nmdc-webfrontend 1.0.0 are backward compatible (see the changelog for more details).
=DEVELOPING=
[go-get]code.ivysaur.me/nmdc-webfrontend git https://git.ivysaur.me/code.ivysaur.me/nmdc-webfrontend.git[/go-get]
1. Install Go, Node.js, NPM, and 7-Zip (`p7zip-full` on Debian)
2. Set up your `$GOPATH`
3. Download the source code
    - `git clone https://git.ivysaur.me/code.ivysaur.me/nmdc-webfrontend.git `; or
    - `go get code.ivysaur.me/nmdc-webfrontend` ; or
    - download and extract a source archive
4. Install dependencies: `sudo make deps`
5. Build: `make`
6. Optional: Set `web.external_webroot: true` in the config file for unminified development
=CHANGELOG=
2017-11-26 1.3.0
- Update libnmdc to 0.16 (adds ADC hub support)
- Configuration: The `hub.port` property is now optional. You can specify a full URI in the `hub.address` property instead.
2017-11-14 1.2.3
- Update libnmdc to 0.15
2017-10-28 1.2.2
- Enhancement: Simplify build process
- Fix an issue with closing PM tabs
2017-10-16 1.2.1
- Enhancement: Increase scrollback buffer size
- Fix an issue with missing `contented` upload link once logged in
- Fix a cosmetic issue with `(0)` appearing in page title
2017-10-15 1.2.0
- Feature: Add `contented` integration (set `app.contented_server` in config file)
- Fix a cosmetic issue with the menu icon on devices without unicode font coverage

281
bindata.go Normal file

File diff suppressed because one or more lines are too long

184
build.sh
View File

@@ -1,184 +0,0 @@
#!/bin/bash
# godist.sh is a template build script for golang applications.
#
# Copyright (c) 2016, The godist.sh Author(s)
#
# 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 and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
set -eu
DIST_DIR=./_dist
EXTRA_FILES=(
nmdc-webfrontend.conf.SAMPLE
)
get_package_name() {
# Binaries are named after the containing folder.
pwd | tr / $'\n' | tail -n1
}
check_dependencies() {
# `set -e` will take care of killing the application if the dependency
# goes unresolved.
which 7z > /dev/null
which php > /dev/null
}
get_platform_description() {
if [[ $GOOS == windows ]] ; then
echo -n "win"
else
echo -n "${GOOS}"
fi
if [[ $GOARCH == 386 ]] ; then
echo -n 32
elif [[ $GOARCH == amd64 ]] ; then
echo -n 64
else
echo -n "-${GOARCH}"
if [[ -v $GOARM ]] ; then
echo -n "v${GOARM}"
fi
fi
}
pathfix() {
if [[ $(uname -o) == Cygwin ]] ; then
cygpath -w "$1"
else
echo "$1"
fi
}
single_build() {
local version="$1"
# Determine build output name
local bin_name=''
if [[ $GOOS == windows ]] ; then
local_bin_name="$(get_package_name).exe"
else
local_bin_name="$(get_package_name)"
fi
if [[ -f ./$local_bin_name ]] ; then
rm -f "./$local_bin_name"
fi
local tmpdir=$(mktemp -d)
# Platform identifier
local platform="$(get_platform_description)"
echo "[INFO] Building ${version} for ${platform}..."
# Build.
# GOARCH/GOOS supplied in function env
local gofwdpath=$(echo -n $GOPATH | sed 's/[\\/]$//')
go build \
-a \
-ldflags "-s -w -X main.VERSION=nmdc-webfrontend/${version}" \
-gcflags "-trimpath ${gofwdpath}" \
-asmflags "-trimpath ${gofwdpath}" \
-o "$(pathfix "${tmpdir}/${local_bin_name}")"
# Archive.
if [[ ! -d $DIST_DIR ]] ; then
mkdir "$DIST_DIR"
fi
local archive_name="${DIST_DIR}/$(get_package_name)-${version}-${platform}"
if [[ $GOOS == windows ]] ; then
archive_name="${archive_name}.7z"
7z a -mx9 "$archive_name" "${tmpdir}/${local_bin_name}" "${EXTRA_FILES[@]}" >/dev/null
else
archive_name="${archive_name}.tar.xz"
XZ_OPT='-9' tar caf "$archive_name" -C "${tmpdir}" "${local_bin_name}" -C "$(pwd)" "${EXTRA_FILES[@]}" --owner=0 --group=0 >/dev/null
fi
# Cleanup
rm -f "${tmpdir}/${local_bin_name}"
rmdir "$tmpdir"
}
datestamp() {
( TZ=UTC date +%Y%m%d%H%M%SZ )
}
usage() {
cat <<EOD
Usage: ./godist.sh [-v VERSION]
EOD
exit 0
}
main() {
check_dependencies
if [[ ! -v GOPATH ]] ; then
echo "Please set GOPATH." >&2
exit 1
fi
if [[ ! -d $GOPATH ]] ; then
echo "Invalid GOPATH set." >&2
exit 1
fi
local version=""
while getopts ':v:' flag ; do
case "$flag" in
v)
version="$OPTARG"
;;
*)
usage
;;
esac
done
if [[ $version == "" ]] ; then
read -p "Enter version string (blank for timestamp)> " version
if [[ $version == "" ]] ; then
version=$(datestamp)
fi
fi
if [[ -f ./bindata.go ]] ; then
rm ./bindata.go
fi
php clientpack.php
go-bindata -nomemcopy -prefix clientpack clientpack
GOARCH=386 GOOS=windows single_build "$version"
GOARCH=amd64 GOOS=linux single_build "$version"
# Also make source tarball
local SOURCE_FILES=(
client/
build.sh
clientpack.php
Config.go
main.go
nmdc-webfrontend.conf.SAMPLE
)
XZ_OPT='-9' tar caf "_dist/$(get_package_name)-${version}-src.tar.xz" "${SOURCE_FILES[@]}" --owner=0 --group=0 >/dev/null
echo "[INFO] Build complete."
}
main "$@"

View File

@@ -1,10 +1,9 @@
/* dcwebui.js */
//IIFEMODE:;(function() {
"use strict";
var SENTINEL_PASSWORD = "************";
var CHAT_SCROLLBACK_LIMIT = 50; // Once over 2x $limit, the first $limit will be trimmed off the list
var CHAT_SCROLLBACK_LIMIT = 200; // Once over 2x $limit, the first $limit will be trimmed off the list
var EXTERN_ROOT = window.location.protocol + "//" + window.location.host + "/";
var el = function(s) {
@@ -509,11 +508,11 @@ var tab_free = function(id) {
if (id === "tab-main") return;
// remove tab item and body
var el = el("#tabitem-"+id);
el.parentNode.removeChild(el);
var $el = el("#tabitem-"+id);
$el.parentNode.removeChild($el);
var el = el("#"+id);
el.parentNode.removeChild(el);
$el = el("#"+id);
$el.parentNode.removeChild($el);
// clear from PM tabs
for (var i in pm_tabs) {
@@ -690,6 +689,13 @@ var menu = new MenuList(el("#menubutton"));
menu.reset = function() {
this.clear();
if (contented_url.length > 0) {
menu.add("Upload", function() {
contented_load();
});
}
this.add(joinparts_getstr(), toggle_joinparts);
this.add(desktop_notifications_fmtstr(), desktop_notifications_toggle);
this.add(warnonclose_fmtstr(), warnonclose_toggle);
@@ -789,7 +795,11 @@ var updateTitle = function() {
prefix = "[NEW PM] "
}
document.title = prefix + hub_hubname + " ("+userlist.count()+")"
var suffix = "";
if (userlist.count() > 0) {
suffix = " ("+userlist.count()+")";
}
document.title = prefix + hub_hubname + suffix;
};
var sock = {};
@@ -1176,10 +1186,6 @@ window.onload = function() {
});
sock.on('contented', function(url) {
contented_url = url;
menu.add("Upload", function() {
contented_load();
});
menu.reset(); // sent before login
});
};
//IIFEMODE:})();

View File

@@ -1,60 +0,0 @@
#!/usr/bin/php
<?php
# Dependencies:
# - PHP
# - Uglifyjs (`npm install -g uglify-js`)
# - Lessc (`npm install -g less`)
# - Lessc minifier (`npm install -g less-plugin-clean-css`)
# - HTML minifier (`npm install -g html-minifier`)
echo "Compressing/minifying web resources...\n";
if (is_dir('clientpack')) {
`rm -r clientpack`;
}
`cp -r client clientpack`;
// Toggle IIFE on
`sed -i -re 's~//IIFEMODE:~~g' clientpack/dcwebui.js`;
// Minify JS
`uglifyjs clientpack/dcwebui.js -o clientpack/dcwebui.min.js -c -m`;
// Minify CSS
`lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css`;
// Embed css into HTML file
$html_content = file_get_contents('clientpack/index.htm');
$html_content = preg_replace_callback('~<link[^>]+dcwebui.css[^>]*>~', function() { return '<style type="text/css">'.file_get_contents('clientpack/dcwebui.min.css').'</style>'; }, $html_content);
// Embed JS into HTML file
$html_content = preg_replace_callback('~<script[^>]+dcwebui.js[^>]*>~', function() { return '<script type="text/javascript">'.file_get_contents('clientpack/dcwebui.min.js').'</script>'; }, $html_content);
// Embed socketio into HTML file
define('SIO_NAME', 'socket.io-1.7.2.js');
$html_content = preg_replace_callback('~<script[^>]+'.SIO_NAME.'[^>]*>~', function() { return '<script type="text/javascript">'.file_get_contents('clientpack/'.SIO_NAME).'</script>'; }, $html_content);
// Minify the combined file
file_put_contents('clientpack/index.htm', $html_content);
`html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm`;
// Clean up files
unlink('clientpack/index.htm');
unlink('clientpack/dcwebui.js');
unlink('clientpack/dcwebui.min.js');
unlink('clientpack/dcwebui.css');
unlink('clientpack/dcwebui.min.css');
unlink('clientpack/'.SIO_NAME);
rename('clientpack/index.min.htm', 'clientpack/index.htm');

45
main.go
View File

@@ -5,8 +5,9 @@ import (
"fmt"
"io/ioutil"
"log"
"mime"
"net/http"
"strings"
"path/filepath"
"code.ivysaur.me/libnmdc"
"github.com/googollee/go-socket.io"
@@ -47,14 +48,19 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
selfUser.ClientTag = this.cfg.Hub.Tag
selfUser.ClientVersion = libnmdc.DEFAULT_CLIENT_VERSION
hco := libnmdc.HubConnectionOptions{
Address: libnmdc.HubAddress(fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)),
Self: *selfUser,
NickPassword: Pass,
NumEventsToBuffer: 0,
url := this.cfg.Hub.Address
if this.cfg.Hub.Port == 0 {
url = fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)
}
hub := hco.Connect()
hco := libnmdc.HubConnectionOptions{
Address: libnmdc.HubAddress(url),
Self: selfUser,
NickPassword: Pass,
}
hubEvents := make(chan libnmdc.HubEvent, 10)
hub := libnmdc.ConnectAsync(&hco, hubEvents)
defer func() {
hub.Disconnect()
@@ -104,7 +110,7 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
for {
select {
case hev, ok := <-hub.OnEvent:
case hev, ok := <-hubEvents:
if !ok {
log.Printf("[%s] hub chan closed\n", so.Id())
return // abandon
@@ -204,27 +210,8 @@ func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) {
return
}
knownContentTypes := map[string]string{
".htm": "text/html",
".png": "image/png",
".ico": "image/x-icon",
// No CSS/JS since they're embedded in the HTML
}
foundMime := false
for ext, mimeType := range knownContentTypes {
if strings.HasSuffix(fileName, ext) {
w.Header().Set("Content-Type", mimeType)
foundMime = true
break
}
}
if !foundMime {
w.Header().Set("Content-Type", "application/x-octet-stream")
}
dataInfo, _ := AssetInfo(fileName)
w.Header().Set("Content-Length", fmt.Sprintf("%d", dataInfo.Size()))
w.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(fileName)))
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(data)))
w.Write(data)
}

View File

@@ -12,9 +12,8 @@
},
"hub": {
"address": "127.0.0.1",
"port": 411,
"address": "nmdc://127.0.0.1:411",
"tag": "nmdc-webfrontend"
}
}
}