Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Add Build version

Main version can be set in config/default_config.yml
Build version need to be set by build command: go build -ldflags "-X
main.buildversion=$(date -u +.%Y%m%d.%H%M%S)"
Or by using package.sh
Or by using the godep command: godep go build -ldflags "-X
main.buildversion=$(date -u +.%Y%m%d.%H%M%S)"
Cette révision appartient à :
akuma06 2017-05-31 12:20:06 +02:00
Parent e116b30b40
révision 9e0424ec5e
8 fichiers modifiés avec 21 ajouts et 3 suppressions

Voir le fichier

@ -1,6 +1,7 @@
language: go
go:
- 1.x
gobuild_args: -x -ldflags "-X main.buildversion $(date -u +.%Y%m%d.%H%M%S)"
before_install:
- sudo apt-get install gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 binutils-mingw-w64-i686 binutils-mingw-w64-x86-64
- go get -u github.com/tools/godep

Voir le fichier

@ -20,7 +20,10 @@ All tested versions of Ubuntu fail to build, use a different OS or docker
* Install [Golang](https://golang.org/doc/install) (version >=1.8)
* `go get -u github.com/tools/godep`
* `go get github.com/NyaaPantsu/nyaa`
Either use:
* `godep go build`
Or use this to have the build version in index.html:
* `go build -ldflags "-X main.buildversion=$(date -u +.%Y%m%d.%H%M%S)"`
* Download the DB and place it in your root folder named as "nyaa.db" (You want the merged.sqlite3 database, see the dev IRC for more info)
* `./nyaa`
* You can now access your local site over on [localhost:9999](http://localhost:9999)

Voir le fichier

@ -3,6 +3,8 @@
# Host of server
host: localhost
# Version of the app
version: "0.9"
# port of server
port: 9999
# database type

Voir le fichier

@ -13,6 +13,8 @@ type Config struct {
// structure depends on the dialect for each db type
DBParams string `json:"db_params" yaml:"db_params,omitempty"`
DBLogMode string `json:"db_logmode" yaml:"db_logmode,omitempty"`
Version string `json:"version" yaml:"version,omitempty"`
Build string `yaml:"-"`
// tracker scraper config (required)
Scrape ScraperConfig `json:"scraper" yaml:"scraper,flow,omitempty"`
// cache config

Voir le fichier

@ -23,6 +23,8 @@ import (
"github.com/NyaaPantsu/nyaa/util/signals"
)
var buildversion string
// RunServer runs webapp mainloop
func RunServer(conf *config.Config) {
// TODO Use config from cli
@ -112,6 +114,11 @@ func RunMetainfoFetcher(conf *config.Config) {
func main() {
conf := config.Conf
if buildversion != "" {
conf.Build = buildversion
} else {
conf.Build = "unknown"
}
processFlags := conf.BindFlags()
defaults := flag.Bool("print-defaults", false, "print the default configuration file on stdout")
mode := flag.String("mode", "webapp", "which mode to run daemon in, either webapp, scraper or metainfo_fetcher")

Voir le fichier

@ -15,7 +15,7 @@ for i in "${OSes[@]}"; do
cc=${arr[1]}
rm -f nyaa nyaa.exe
echo -e "\nBuilding $os..."
echo GOOS=$os GOARCH=amd64 CC=$cc CGO_ENABLED=1 go build -v
GOOS=$os GOARCH=amd64 CC=$cc CGO_ENABLED=1 go build -v
echo GOOS=$os GOARCH=amd64 CC=$cc CGO_ENABLED=1 go build -v -ldflags="-X main.buildversion=$(date -u +.%Y%m%d.%H%M%S)"
GOOS=$os GOARCH=amd64 CC=$cc CGO_ENABLED=1 go build -v -ldflags="-X main.buildversion=$(date -u +.%Y%m%d.%H%M%S)"
zip -9 -r dist/nyaa-${version}_${os}_amd64.zip os public templates service/user/locale *.md nyaa nyaa.exe
done

Voir le fichier

@ -6,6 +6,7 @@ import (
"net/url"
"github.com/NyaaPantsu/nyaa/common"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/model"
"github.com/NyaaPantsu/nyaa/service/user"
userForms "github.com/NyaaPantsu/nyaa/service/user/form"
@ -106,6 +107,7 @@ type commonTemplateVariables struct {
URL *url.URL // for parsing URL in templates
Route *mux.Route // for getting current route in templates
CsrfField template.HTML
Config *config.Config
}
type navigation struct {
@ -158,5 +160,6 @@ func newCommonVariables(r *http.Request) commonTemplateVariables {
URL: r.URL,
Route: mux.CurrentRoute(r),
CsrfField: csrf.TemplateField(r),
Config: config.Conf,
}
}

Voir le fichier

@ -85,7 +85,7 @@
<div class="footer-opt">
<p><a href="/settings">{{ call $.T "change_settings" }}</a></p>
</div>
<span><i>Powered by <a href="#">NyaaPantsu</a></i></span>
<span><i>Powered by <a href="#">NyaaPantsu</a> v{{ .Config.Version }}{{ .Config.Build }}</i></span>
</div>
</footer>