Compare commits
	
		
			136 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f4684673e7 | |||
| 0dc5c2878f | |||
| efdb188aba | |||
| 54e21f2b2d | |||
| dd166cf0e9 | |||
| 92b1c4daa5 | |||
| ea4135888d | |||
| 8e999f5ddb | |||
| 62c03cf9f1 | |||
| 6abdc8d2a9 | |||
| 1a281095f0 | |||
| 69613d07a5 | |||
| 19b2221ea1 | |||
| 9840c1024e | |||
| 00cdce5f5a | |||
| 312cbb7bc1 | |||
| bea598f7a3 | |||
| ef9a61e9cf | |||
| 0ec079cfd4 | |||
| 54ecffd0d4 | |||
| 41e244c255 | |||
| a109e2dc29 | |||
| 0bafa59358 | |||
| 78ced31e9d | |||
| 16a4a2556b | |||
| fafca96711 | |||
| 2eacb06c9e | |||
| 1f2871b917 | |||
| 855206feed | |||
| efa195df5b | |||
| 89c8cb0dc8 | |||
| c2de4c8d45 | |||
| 738e9aed41 | |||
| bdb7b4835d | |||
| 447e8c2591 | |||
| 37014f7f52 | |||
| b8791f6aa2 | |||
| 377131e43d | |||
| 20fa044906 | |||
| 0cb14fb964 | |||
| a60d821e39 | |||
| 15d9ee0023 | |||
| ed0195c4b8 | |||
| a71eb45dd5 | |||
| 086ecfb0a9 | |||
| dff36f6bff | |||
| 7a9b271b90 | |||
| 1c7842c182 | |||
| 9e33e50986 | |||
| 7f618db70a | |||
| 7894355647 | |||
| af324441b7 | |||
| d862a3f703 | |||
| 59c118dc34 | |||
| 42a8298362 | |||
| c4e37bf47d | |||
| 95d56dbca2 | |||
| 761d0bfad5 | |||
| 1d3f16e6c6 | |||
| e5ceadb03a | |||
| 6999069fd7 | |||
| 5da61d5922 | |||
| d33ba5c085 | |||
| a28e5ce9b0 | |||
| 3448cb7eeb | |||
| ba941adfdd | |||
| 48d96f9efe | |||
| 1a1f361e60 | |||
| 3f1f575652 | |||
| e2af839101 | |||
| 659576c7e1 | |||
| 0c5279e254 | |||
| 99cf8ebe49 | |||
| 1189d6fe60 | |||
| 96c3e6ea7d | |||
| 1a64f79394 | |||
| 692537c6f0 | |||
| d2b1d23ba6 | |||
| bc80c94a6f | |||
| fd79d94a20 | |||
| d17ad14914 | |||
| 763f5030d1 | |||
| aa8d89d14b | |||
| d937491545 | |||
| 226e6751c6 | |||
| 9060b87e94 | |||
| 78b7af7fbc | |||
| ff075e2e7e | |||
| ef9057383d | |||
| 0951bf821e | |||
| a60e4bb0c2 | |||
| 7b5dbde7a6 | |||
| 3c2f0c7368 | |||
| 1cc6cd2b90 | |||
| 3f077f15f0 | |||
| ade4439f92 | |||
| edffaac74b | |||
| ceb7420e18 | |||
| 56ced01e97 | |||
| 3c1db1266e | |||
| 4a4e9e694d | |||
| c619be5917 | |||
| afd190b7cc | |||
| a927add8c5 | |||
| 0a5db6a015 | |||
| e15a6afceb | |||
| c19b0fe521 | |||
| 1eaabb099d | |||
| b26b3a695e | |||
| b30beac2b5 | |||
| 39e84f2744 | |||
| 7ceed88dfa | |||
| c7e40ab6c1 | |||
| 35994e81c6 | |||
| 2c94713ba0 | |||
| e9b3fedb17 | |||
| d0219cb16a | |||
| d0d52e931e | |||
| 0ec9ae30b4 | |||
| 490d20b807 | |||
| 299a1c12e1 | |||
| a9dc45f727 | |||
| 5f8544f031 | |||
| ea87419abc | |||
| d5e8e051e3 | |||
| 656125e790 | |||
| 0892666ead | |||
| 6fef5c37cb | |||
| 59abd3c50c | |||
| 610563b35c | |||
| f3ad1fba8a | |||
| 9268c4da4c | |||
| 9361e7ddec | |||
| ee59a4a773 | |||
| 2047762e62 | |||
| 16aa97b6e5 | 
@@ -2,6 +2,11 @@ mode:regex
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
\.exe$
 | 
					\.exe$
 | 
				
			||||||
^nmdc-webfrontend\.conf$
 | 
					^nmdc-webfrontend\.conf$
 | 
				
			||||||
 | 
					^clientpack/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
^_dist/
 | 
					^_dist/
 | 
				
			||||||
^bindata\.go$
 | 
					^node_modules/
 | 
				
			||||||
 | 
					^vendor/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					^nmdc-webfrontend$
 | 
				
			||||||
 | 
					^nmdc-webfrontend\.exe$
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								.hgtags
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								.hgtags
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
							
								
								
									
										22
									
								
								Config.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								Config.go
									
									
									
									
									
								
							@@ -2,22 +2,22 @@ package main
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type Config struct {
 | 
					type Config struct {
 | 
				
			||||||
	App struct {
 | 
						App struct {
 | 
				
			||||||
		Name     string
 | 
							MotdHTML        string `json:"motd"`
 | 
				
			||||||
		Version  string
 | 
							ContentedServer string `json:"contented_server"`
 | 
				
			||||||
		MotdHTML string
 | 
					 | 
				
			||||||
		Debug    bool
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Web struct {
 | 
						Web struct {
 | 
				
			||||||
		Port   int
 | 
							Port          int    `json:"port"`
 | 
				
			||||||
		BindTo string
 | 
							BindTo        string `json:"bind_to"`
 | 
				
			||||||
		Extern string
 | 
							Title         string `json:"title"`
 | 
				
			||||||
		Title  string
 | 
							CustomFavicon bool   `json:"custom_favicon"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ExternalWebroot bool `json:"external_webroot,omitempty"`
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Hub struct {
 | 
						Hub struct {
 | 
				
			||||||
		Address string
 | 
							Address string `json:"address"`
 | 
				
			||||||
		Port    int
 | 
							Port    int    `json:"port"`
 | 
				
			||||||
		Tag     string
 | 
							Tag     string `json:"tag"`
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										33
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[projects]]
 | 
				
			||||||
 | 
					  name = "code.ivysaur.me/libnmdc"
 | 
				
			||||||
 | 
					  packages = ["."]
 | 
				
			||||||
 | 
					  revision = "4ea6cbb6f1a2d91a1e64c4b028b1c0ffe1bdd88d"
 | 
				
			||||||
 | 
					  version = "v0.15.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[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 = "383f1855bfd5d5845dcfa88d2dab2599d9fdee6ddd849d9cb1e1a5ae35fd41ac"
 | 
				
			||||||
 | 
					  solver-name = "gps-cdcl"
 | 
				
			||||||
 | 
					  solver-version = 1
 | 
				
			||||||
							
								
								
									
										30
									
								
								Gopkg.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Gopkg.toml
									
									
									
									
									
										Normal 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.15.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[constraint]]
 | 
				
			||||||
 | 
					  branch = "master"
 | 
				
			||||||
 | 
					  name = "github.com/googollee/go-socket.io"
 | 
				
			||||||
							
								
								
									
										60
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					# Makefile for nmdc-webfrontend
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BINNAME=nmdc-webfrontend
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					VERSION=1.2.3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
@@ -4,12 +4,104 @@ Chat in real-time on your NMDC hub using a web browser. This project forks and d
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Written in Golang
 | 
					Written in Golang
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Tags: nmdc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This project supercedes [entry=dcwebui]dcwebui[/entry], [entry=flexdc]flexdc[/entry], and [entry=dcwebui2]dcwebui2[/entry].
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=UPGRADING FROM DCWEBUI2=
 | 
					=UPGRADING FROM DCWEBUI2=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- The configuration file format is identical, but please now ensure it's valid json instead of just a .js file. This means no assignment, use double-quoted strings, and no comments.
 | 
					- 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=
 | 
					=CHANGELOG=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2017-02-11 1.1.4
 | 
				
			||||||
 | 
					- Update libnmdc to 0.14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2017-02-11 1.1.3
 | 
				
			||||||
 | 
					- Feature: Display user IP address on hover, if available
 | 
				
			||||||
 | 
					- Enhancement: Allow clicking on popup notifications
 | 
				
			||||||
 | 
					- Enhancement: Only show 'popups enabled' notification when enabling for the first time, not persistent page load
 | 
				
			||||||
 | 
					- Update libnmdc to 0.13
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with not displaying non-zero user share sizes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2017-02-06 1.1.2
 | 
				
			||||||
 | 
					- Autodetect 'extern', no need to include it in config files
 | 
				
			||||||
 | 
					- Enhancement: Remove redundant request, for a faster page load
 | 
				
			||||||
 | 
					- Display server version number in log file and in response headers
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with spacing around user count in page title
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2017-02-06 1.1.1
 | 
				
			||||||
 | 
					- Fix an issue with malformed content in minified build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2017-02-06 1.1.0
 | 
				
			||||||
 | 
					- Feature: Remember last username/password for login; remember last "show joins/parts" status
 | 
				
			||||||
 | 
					- Feature: Display user details on hover (description, email, client tag, share size)
 | 
				
			||||||
 | 
					- Feature: Optional desktop notifications for background PMs (not possible in incognito)
 | 
				
			||||||
 | 
					- Feature: Automatically reconnect with the same username/password if connection was lost
 | 
				
			||||||
 | 
					- Feature: Re-enter last message (Ctrl+Up, Ctrl+Down)
 | 
				
			||||||
 | 
					- Feature: Set custom date/time format (Minutes, Seconds, Full), remembered for next session
 | 
				
			||||||
 | 
					- Feature: Clickable magnet links
 | 
				
			||||||
 | 
					- Feature: Display unread main-chat message count in the page title if the window is inactive
 | 
				
			||||||
 | 
					- Feature: Add warning message when closing tab while still connected (optional preference, disabled by default, will be remembered).
 | 
				
			||||||
 | 
					- Feature: Admin option to load a custom favicon (set `web.custom_favicon=true` and place a `favicon.ico` in the current directory)
 | 
				
			||||||
 | 
					- Feature: Admin option to use external web resources (set `web.external_webroot=true` and use the /client/ directory)
 | 
				
			||||||
 | 
					- Enhancement: Higher resolution favicon
 | 
				
			||||||
 | 
					- Enhancement: Display operators in green in the user list
 | 
				
			||||||
 | 
					- Enhancement: Enable spellcheck for text input once logged in
 | 
				
			||||||
 | 
					- Enhancement: Prevent sending referrer to remote URLs
 | 
				
			||||||
 | 
					- Enhancement: Display joins/parts and connection/disconnection messages in PM tabs
 | 
				
			||||||
 | 
					- Enhancement: Support Shift+Tab to autocomplete backward
 | 
				
			||||||
 | 
					- Enhancement: Support unread status for the main tab
 | 
				
			||||||
 | 
					- Enhancement: Improve page load time via minification
 | 
				
			||||||
 | 
					- Remove unused options from the config file
 | 
				
			||||||
 | 
					- Update socket.io to 1.7.2
 | 
				
			||||||
 | 
					- Update libnmdc to 0.12
 | 
				
			||||||
 | 
					- Add margin between bottom of the text area and the text input box
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with collapsing consecutive spaces in posted messages
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with text size adjustment on mobile devices
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with clearing the screen on reconnection
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with not clearing the userlist on certain types of network error
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with closed PM tabs reappearing in some cases
 | 
				
			||||||
 | 
					- Fix a cosmetic issue with marking all PM tabs as read when switching to a single one
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2016-11-29 1.0.2
 | 
				
			||||||
 | 
					- Rebuild with libnmdc 0.11
 | 
				
			||||||
 | 
					- Fix an issue with not setting a version in the client tag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2016-10-08 1.0.1
 | 
				
			||||||
 | 
					- Fix an issue with backward compatibility with `dcwebui2` configuration file format
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2016-10-08 1.0.0
 | 
					2016-10-08 1.0.0
 | 
				
			||||||
- Port `dcwebui2` from Node.js (Javascript) to Go
 | 
					- Port `dcwebui2` from Node.js (Javascript) to Go
 | 
				
			||||||
- Fix a cosmetic issue with not clearing userlist on disconnection
 | 
					- Fix a cosmetic issue with not clearing userlist on disconnection
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										281
									
								
								bindata.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										281
									
								
								bindata.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										171
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										171
									
								
								build.sh
									
									
									
									
									
								
							@@ -1,171 +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
 | 
					 | 
				
			||||||
	go build \
 | 
					 | 
				
			||||||
		-a \
 | 
					 | 
				
			||||||
		-ldflags '-s -w' \
 | 
					 | 
				
			||||||
		-gcflags "-trimpath=${GOPATH}" \
 | 
					 | 
				
			||||||
		-asmflags "-trimpath=${GOPATH}" \
 | 
					 | 
				
			||||||
		-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
 | 
					 | 
				
			||||||
	go-bindata -nomemcopy -prefix client client
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	GOARCH=amd64 GOOS=windows single_build "$version"
 | 
					 | 
				
			||||||
	GOARCH=386   GOOS=windows single_build "$version"
 | 
					 | 
				
			||||||
	GOARCH=amd64 GOOS=linux   single_build "$version"
 | 
					 | 
				
			||||||
	GOARCH=386   GOOS=linux   single_build "$version"
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	echo "[INFO] Build complete."
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
main "$@"
 | 
					 | 
				
			||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
/* dcwebui.css */
 | 
					/* dcwebui.css */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* {
 | 
					* {
 | 
				
			||||||
	-webkit-text-size-adjust:100%
 | 
						-webkit-text-size-adjust:100%;
 | 
				
			||||||
	   -moz-text-size-adjust:100%
 | 
						   -moz-text-size-adjust:100%;
 | 
				
			||||||
	    -ms-text-size-adjust:100%
 | 
						    -ms-text-size-adjust:100%;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
html,body {
 | 
					html,body {
 | 
				
			||||||
@@ -71,10 +71,15 @@ html,body {
 | 
				
			|||||||
	color:black;
 | 
						color:black;
 | 
				
			||||||
	font-weight:bold;
 | 
						font-weight:bold;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	line-height:18px;
 | 
						line-height:0;
 | 
				
			||||||
 | 
						height:18px;
 | 
				
			||||||
	width:18px;
 | 
						width:18px;
 | 
				
			||||||
	text-align:center;
 | 
						text-align:center;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					.menubutton svg {
 | 
				
			||||||
 | 
						width: 18px;
 | 
				
			||||||
 | 
						height: 18px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
.menubutton:hover {
 | 
					.menubutton:hover {
 | 
				
			||||||
	background:white;
 | 
						background:white;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -180,13 +185,13 @@ html,body {
 | 
				
			|||||||
	overflow-y:auto;
 | 
						overflow-y:auto;
 | 
				
			||||||
	-webkit-transition: all 0.25s ease-in-out;
 | 
						-webkit-transition: all 0.25s ease-in-out;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	padding:0; /*4px;*/
 | 
						padding:0;
 | 
				
			||||||
	margin:0;
 | 
						margin:0;
 | 
				
			||||||
	box-sizing:border-box;
 | 
						box-sizing:border-box;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	position:absolute;
 | 
						position:absolute;
 | 
				
			||||||
	top:4px;
 | 
						top:4px;
 | 
				
			||||||
	bottom:0;
 | 
						bottom:4px;
 | 
				
			||||||
	left:4px;
 | 
						left:4px;
 | 
				
			||||||
	right:0;
 | 
						right:0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -300,6 +305,9 @@ html,body {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Text */
 | 
					/* Text */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tx-sys, .tx-user, .tx-chat {	
 | 
				
			||||||
 | 
						white-space:pre-wrap;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
.tx-time {
 | 
					.tx-time {
 | 
				
			||||||
	color:grey;
 | 
						color:grey;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -314,10 +322,6 @@ html,body {
 | 
				
			|||||||
.tx-chat {
 | 
					.tx-chat {
 | 
				
			||||||
	color: black;
 | 
						color: black;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.tx-private {
 | 
					 | 
				
			||||||
	color: red;
 | 
					 | 
				
			||||||
	font-style: italic;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* webkit scrollbars */
 | 
					/* webkit scrollbars */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -354,6 +358,11 @@ html,body {
 | 
				
			|||||||
	overflow-y: auto;
 | 
						overflow-y: auto;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.user-is-operator {
 | 
				
			||||||
 | 
						color:darkgreen;
 | 
				
			||||||
 | 
						font-weight:bold;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* User sprite */
 | 
					/* User sprite */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.ul-mini {
 | 
					.ul-mini {
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 17 KiB  | 
@@ -11,8 +11,12 @@
 | 
				
			|||||||
	</head>
 | 
						</head>
 | 
				
			||||||
	<body>
 | 
						<body>
 | 
				
			||||||
		<div class="tabbar placement-top" id="bar">
 | 
							<div class="tabbar placement-top" id="bar">
 | 
				
			||||||
			<div class="menubutton" id="menubutton">☰</div>
 | 
								<div class="menubutton" id="menubutton">
 | 
				
			||||||
			<div class="tabitem selected" data-tab="tab-main">
 | 
									<svg viewBox="0 0 24 24">
 | 
				
			||||||
 | 
										<path fill="#000000" d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
 | 
				
			||||||
 | 
									</svg>
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
								<div class="tabitem selected" data-tab="tab-main" id="tabitem-tab-main">
 | 
				
			||||||
				<span class="tab-label">
 | 
									<span class="tab-label">
 | 
				
			||||||
					Main
 | 
										Main
 | 
				
			||||||
				</span>
 | 
									</span>
 | 
				
			||||||
@@ -52,8 +56,7 @@
 | 
				
			|||||||
			</form>
 | 
								</form>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		<script type="text/javascript" src="/socket.io-1.4.5.js"></script>
 | 
							<script type="text/javascript" src="/socket.io-1.7.2.js"></script>
 | 
				
			||||||
		<script type="text/javascript" src="/conf"></script>
 | 
					 | 
				
			||||||
		<script type="text/javascript" src="/dcwebui.js"></script>
 | 
							<script type="text/javascript" src="/dcwebui.js"></script>
 | 
				
			||||||
	</body>
 | 
						</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										4
									
								
								client/socket.io-1.7.2.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								client/socket.io-1.7.2.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										125
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										125
									
								
								main.go
									
									
									
									
									
								
							@@ -5,18 +5,15 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"log"
 | 
						"log"
 | 
				
			||||||
 | 
						"mime"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"strings"
 | 
						"path/filepath"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"code.ivysaur.me/libnmdc"
 | 
				
			||||||
	"github.com/googollee/go-socket.io"
 | 
						"github.com/googollee/go-socket.io"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	"libnmdc"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ActiveConnection struct {
 | 
					var VERSION string = `nmdc-webfrontend/devel-unreleased`
 | 
				
			||||||
	s *socketio.Socket
 | 
					 | 
				
			||||||
	h *libnmdc.HubConnection
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
type App struct {
 | 
					type App struct {
 | 
				
			||||||
	cfg *Config
 | 
						cfg *Config
 | 
				
			||||||
@@ -49,6 +46,7 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	selfUser := libnmdc.NewUserInfo(Nick)
 | 
						selfUser := libnmdc.NewUserInfo(Nick)
 | 
				
			||||||
	selfUser.ClientTag = this.cfg.Hub.Tag
 | 
						selfUser.ClientTag = this.cfg.Hub.Tag
 | 
				
			||||||
 | 
						selfUser.ClientVersion = libnmdc.DEFAULT_CLIENT_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hco := libnmdc.HubConnectionOptions{
 | 
						hco := libnmdc.HubConnectionOptions{
 | 
				
			||||||
		Address:           libnmdc.HubAddress(fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)),
 | 
							Address:           libnmdc.HubAddress(fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)),
 | 
				
			||||||
@@ -81,6 +79,29 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Loop hub connection
 | 
						// Loop hub connection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						serveUserInfo := func(nick string) {
 | 
				
			||||||
 | 
							props := ""
 | 
				
			||||||
 | 
							hub.Users(func(users *map[string]libnmdc.UserInfo) error {
 | 
				
			||||||
 | 
								uinfo, ok := (*users)[nick]
 | 
				
			||||||
 | 
								if !ok {
 | 
				
			||||||
 | 
									return nil // just skip
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								bProps, err := json.Marshal(uinfo)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return nil // just skip
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								props = string(bProps)
 | 
				
			||||||
 | 
								return nil
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 'Message' is a json-encoded param with user properties
 | 
				
			||||||
 | 
							if len(props) > 0 {
 | 
				
			||||||
 | 
								so.Emit("info", UserMessageStruct{User: nick, Message: props})
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
		select {
 | 
							select {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -100,19 +121,24 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
 | 
				
			|||||||
			case libnmdc.EVENT_PRIVATE:
 | 
								case libnmdc.EVENT_PRIVATE:
 | 
				
			||||||
				so.Emit("priv", UserMessageStruct{User: hev.Nick, Message: hev.Message})
 | 
									so.Emit("priv", UserMessageStruct{User: hev.Nick, Message: hev.Message})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								case libnmdc.EVENT_USER_UPDATED_INFO:
 | 
				
			||||||
 | 
									serveUserInfo(hev.Nick)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case libnmdc.EVENT_USER_JOINED:
 | 
								case libnmdc.EVENT_USER_JOINED:
 | 
				
			||||||
				so.Emit("join", UserMessageStruct{User: hev.Nick})
 | 
									so.Emit("join", UserMessageStruct{User: hev.Nick})
 | 
				
			||||||
 | 
									serveUserInfo(hev.Nick)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case libnmdc.EVENT_USER_PART:
 | 
								case libnmdc.EVENT_USER_PART:
 | 
				
			||||||
				so.Emit("part", UserMessageStruct{User: hev.Nick})
 | 
									so.Emit("part", UserMessageStruct{User: hev.Nick})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
 | 
								case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
 | 
				
			||||||
				if hev.StateChange == libnmdc.CONNECTIONSTATE_CONNECTED {
 | 
									if hev.StateChange == libnmdc.CONNECTIONSTATE_CONNECTED {
 | 
				
			||||||
 | 
										log.Printf("[%s] Connected to hub\n", so.Id())
 | 
				
			||||||
					so.Emit("hello")
 | 
										so.Emit("hello")
 | 
				
			||||||
				} else if hev.StateChange == libnmdc.CONNECTIONSTATE_DISCONNECTED {
 | 
									} else if hev.StateChange == libnmdc.CONNECTIONSTATE_DISCONNECTED {
 | 
				
			||||||
					so.Emit("close")
 | 
										so.Emit("close")
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					so.Emit("sys", hev.StateChange.Format())
 | 
										so.Emit("sys", hev.StateChange.String())
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case libnmdc.EVENT_HUBNAME_CHANGED:
 | 
								case libnmdc.EVENT_HUBNAME_CHANGED:
 | 
				
			||||||
@@ -126,11 +152,6 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
 | 
				
			|||||||
					"raw":     hev.UserCommand.Command,
 | 
										"raw":     hev.UserCommand.Command,
 | 
				
			||||||
				})
 | 
									})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				if this.cfg.App.Debug {
 | 
					 | 
				
			||||||
					log.Printf("[%s] %v\n", so.Id(), hev)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case <-done:
 | 
							case <-done:
 | 
				
			||||||
@@ -146,9 +167,14 @@ func (this *App) SocketIOServer(so socketio.Socket) {
 | 
				
			|||||||
	log.Printf("[%s] Client connected", so.Id())
 | 
						log.Printf("[%s] Client connected", so.Id())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	so.Emit("cls")
 | 
						so.Emit("cls")
 | 
				
			||||||
 | 
						so.Emit("hubname", this.cfg.Web.Title)
 | 
				
			||||||
	so.Emit("raw", this.cfg.App.MotdHTML+"<br>")
 | 
						so.Emit("raw", this.cfg.App.MotdHTML+"<br>")
 | 
				
			||||||
	so.Emit("sys", "Enter a name to connect as (or name:pass for a registered nick)")
 | 
						so.Emit("sys", "Enter a name to connect as (or name:pass for a registered nick)")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if len(this.cfg.App.ContentedServer) > 0 {
 | 
				
			||||||
 | 
							so.Emit("contented", this.cfg.App.ContentedServer)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	doneChan := make(chan struct{}, 0)
 | 
						doneChan := make(chan struct{}, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	so.On("hello", func(data map[string]string) {
 | 
						so.On("hello", func(data map[string]string) {
 | 
				
			||||||
@@ -163,22 +189,8 @@ func (this *App) SocketIOServer(so socketio.Socket) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *App) ConfigRequestHandler(w http.ResponseWriter, r *http.Request) {
 | 
					func (this *App) customFaviconHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
						http.ServeFile(w, r, "favicon.ico")
 | 
				
			||||||
	confStruct := struct {
 | 
					 | 
				
			||||||
		Extern string `json:"extern"`
 | 
					 | 
				
			||||||
		Title  string `json:"title"`
 | 
					 | 
				
			||||||
	}{
 | 
					 | 
				
			||||||
		Extern: this.cfg.Web.Extern,
 | 
					 | 
				
			||||||
		Title:  this.cfg.Web.Title,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	confBytes, _ := json.Marshal(confStruct)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	w.Header().Set("Content-Type", "text/javascript")
 | 
					 | 
				
			||||||
	w.WriteHeader(200)
 | 
					 | 
				
			||||||
	fmt.Fprintf(w, "var DCWEBUI_CONF = %s;\n", string(confBytes))
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) {
 | 
					func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
@@ -193,32 +205,16 @@ func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	knownContentTypes := map[string]string{
 | 
						w.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(fileName)))
 | 
				
			||||||
		".htm": "text/html",
 | 
						w.Header().Set("Content-Length", fmt.Sprintf("%d", len(data)))
 | 
				
			||||||
		".css": "text/css",
 | 
					 | 
				
			||||||
		".js":  "application/javascript",
 | 
					 | 
				
			||||||
		".png": "image/png",
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	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.Write(data)
 | 
						w.Write(data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *App) RunServer() {
 | 
					func (this *App) RunServer() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Inner mux {{
 | 
				
			||||||
 | 
						innerMux := http.NewServeMux()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Socket.io handler
 | 
						// Socket.io handler
 | 
				
			||||||
	server, err := socketio.NewServer(nil)
 | 
						server, err := socketio.NewServer(nil)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@@ -228,22 +224,39 @@ func (this *App) RunServer() {
 | 
				
			|||||||
	server.On("error", func(so socketio.Socket, err error) {
 | 
						server.On("error", func(so socketio.Socket, err error) {
 | 
				
			||||||
		log.Println("error:", err)
 | 
							log.Println("error:", err)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	http.Handle("/socket.io/", server)
 | 
						innerMux.Handle("/socket.io/", server)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Configuration handler
 | 
						// Custom favicon handler
 | 
				
			||||||
	http.HandleFunc("/conf", this.ConfigRequestHandler)
 | 
						if this.cfg.Web.CustomFavicon {
 | 
				
			||||||
 | 
							innerMux.HandleFunc("/favicon.ico", this.customFaviconHandler)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Other files: asset handler
 | 
						// Asset handler
 | 
				
			||||||
	http.HandleFunc("/", this.StaticRequestHandler)
 | 
						if this.cfg.Web.ExternalWebroot {
 | 
				
			||||||
 | 
							innerMux.Handle("/", http.FileServer(http.Dir("client")))
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							innerMux.HandleFunc("/", this.StaticRequestHandler)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Wrapper mux {{
 | 
				
			||||||
 | 
						outerMux := http.NewServeMux()
 | 
				
			||||||
 | 
						outerMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
							w.Header().Set("Server", VERSION)
 | 
				
			||||||
 | 
							innerMux.ServeHTTP(w, r)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						// }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Listen and serve
 | 
						// Listen and serve
 | 
				
			||||||
	bindAddr := fmt.Sprintf("%s:%d", this.cfg.Web.BindTo, this.cfg.Web.Port)
 | 
						bindAddr := fmt.Sprintf("%s:%d", this.cfg.Web.BindTo, this.cfg.Web.Port)
 | 
				
			||||||
	log.Printf("Serving at %s...", bindAddr)
 | 
						log.Printf("Serving at %s...", bindAddr)
 | 
				
			||||||
	log.Fatal(http.ListenAndServe(bindAddr, nil))
 | 
						log.Fatal(http.ListenAndServe(bindAddr, outerMux))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						log.Println(VERSION)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	a, err := NewApp("nmdc-webfrontend.conf")
 | 
						a, err := NewApp("nmdc-webfrontend.conf")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Fatal(err.Error())
 | 
							log.Fatal(err.Error())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,23 +1,20 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	"app": {
 | 
						"app": {
 | 
				
			||||||
		"name"   : "DCWebUI2",
 | 
							"motd": "Welcome!<br>"
 | 
				
			||||||
		"version": "1.3.0",
 | 
					 | 
				
			||||||
		"motd"   : "Welcome!<br>",
 | 
					 | 
				
			||||||
		"debug"  : true
 | 
					 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	"web": {
 | 
						"web": {
 | 
				
			||||||
		"port"   : 8082,
 | 
							"port": 8082,
 | 
				
			||||||
		"bind_to": "127.0.0.1",
 | 
							"bind_to": "127.0.0.1",
 | 
				
			||||||
		"extern" : "http://127.0.0.1:8082",
 | 
							"title": "NMDC Web Frontend",
 | 
				
			||||||
		"title"  : "DCWebUI"
 | 
							"custom_favicon": false
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	"hub": {
 | 
						"hub": {
 | 
				
			||||||
		"address": "127.0.0.1",
 | 
							"address": "127.0.0.1",
 | 
				
			||||||
		"port"   : 411,
 | 
							"port": 411,
 | 
				
			||||||
		"tag"    : "nmdc-webfrontend"
 | 
							"tag": "nmdc-webfrontend"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user