Skip to content

Commit

Permalink
Merge PR #31: Project and build improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici authored Jan 6, 2019
2 parents bc172cb + 1467c5c commit dd79139
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

# Generated site
/public/
/mumble-www.7z
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
all: public mumble-www
all: public mumble-www package

public: $(shell find hugo/ -type f)
(cd hugo/; hugo)

mumble-www: mumble-www.go githubcache.go snapshotcache.go
mumble-www: src/mumble-www.go src/githubcache.go src/snapshotcache.go
go build -o $@ $^

package: public mumble-www
7z a mumble-www.7z public mumble-www
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The Mumble Website

**This is a work in progress not yet released.**

Source of the Mumble Website available at [mumble.info](https://mumble.info/).

Implemented and served through a combination of a Go webserver for dynamic content and static files generated with [hugo](https://gohugo.io/).

## Webserver

* Cache the `LICENSE` and `AUTHORS` files from github and serve them
* Redirect predefined stable download URLs to download files
* Redirect predefined snapshot download URLs; cached self-updating target URLs
* * Redirect Ubuntu snapshots to the PPA
* Serve static website files

The go source files reside in the `src` folder.

## Website

The website source resides in the `hugo` folder, is buildable with hugo. The target folder is `public`.
21 changes: 21 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
SETLOCAL

PUSHD %~dp0

PUSHD hugo
hugo
IF ERRORLEVEL 1 (PAUSE && EXIT /B 1)
POPD

go build src/mumble-www.go src/githubcache.go src/snapshotcache.go
IF ERRORLEVEL 1 (PAUSE && EXIT /B 1)

SET GOOS=linux
go build src/mumble-www.go src/githubcache.go src/snapshotcache.go
IF ERRORLEVEL 1 (PAUSE && EXIT /B 1)

DEL mumble-www.7z 1>NUL
7z.exe a mumble-www.7z public mumble-www

POPD
63 changes: 0 additions & 63 deletions mumble-www.go

This file was deleted.

File renamed without changes.
7 changes: 7 additions & 0 deletions src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "https: //github.com/mumble-voip/mumble-www"

require (
github.com/PuerkitoBio/goquery v1.5.0
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
)
11 changes: 11 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk=
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o=
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
74 changes: 74 additions & 0 deletions src/mumble-www.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2005-2018 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

package main

import (
"flag"
"log"
"net/http"
"time"
)

func setup(mux *http.ServeMux) {
setupDownloadsStable(mux)
setupDownloadsSnapshot(mux)
setupGithubCache(mux)
setupStaticFiles(mux)
}

func setupDownloadsStable(mux *http.ServeMux) {
stable := map[string]string{
"windows-32": "https://github.com/mumble-voip/mumble/releases/download/1.2.19/mumble-1.2.19.msi",
"osx": "https://github.com/mumble-voip/mumble/releases/download/1.2.19/Mumble-1.2.19.dmg",
"osx-universal": "https://github.com/mumble-voip/mumble/releases/download/1.2.10/Mumble-Universal-1.2.10.dmg",
"ios": "http://itunes.apple.com/us/app/mumble/id443472808?ls=1&mt=8",
"ubuntu": "https://launchpad.net/~mumble/+archive/release",
"linux-static-server": "https://github.com/mumble-voip/mumble/releases/download/1.2.19/murmur-static_x86-1.2.19.tar.bz2",
"osx-static-server": "https://github.com/mumble-voip/mumble/releases/download/1.2.19/Murmur-OSX-Static-1.2.19.tar.bz2",
}

for source, target := range stable {
mux.Handle("/downloads/"+source, http.RedirectHandler(target, http.StatusTemporaryRedirect))
}
}

func setupDownloadsSnapshot(mux *http.ServeMux) {
snapshotCache := NewSnapshotCache(time.Hour)
for source := range snapshotRegexps {
mux.Handle("/downloads/"+source+"/snapshot", snapshotCache.Handle(source))
}
mux.Handle(
"/downloads/ubuntu/snapshot",
http.RedirectHandler("https://launchpad.net/~mumble/+archive/snapshot", http.StatusTemporaryRedirect),
)
}

func setupGithubCache(mux *http.ServeMux) {
githubCache := NewGithubCache(time.Minute * 10)
mux.Handle("/LICENSE", githubCache.Handle("/LICENSE"))
mux.Handle("/AUTHORS", githubCache.Handle("/AUTHORS"))
}

func setupStaticFiles(mux *http.ServeMux) {
public := flag.String("public", "public", "public directory")
fs := http.FileServer(http.Dir(*public))
mux.Handle("/", fs)
}

func main() {
addr := flag.String("addr", "127.0.0.1:8081", "bind address")
flag.Parse()

log.Printf("Starting server on %s\n", *addr)

mux := http.NewServeMux()

setup(mux)

if err := http.ListenAndServe(*addr, mux); err != nil {
log.Fatal(err)
}
}
File renamed without changes.

0 comments on commit dd79139

Please sign in to comment.