From eb463000a91281f525aa83781e7bcc9dbf8e350f Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 May 2014 03:27:26 -0400 Subject: [PATCH 1/7] Clean files --- README.md | 10 ++--- README_ZH.md | 10 ++--- doc/install_gogs_from_binary_on_ubuntu.md | 26 ------------ doc/install_gogs_from_source_on_ubuntu.md | 48 ----------------------- gogs.go | 2 +- templates/base/footer.tmpl | 2 +- 6 files changed, 12 insertions(+), 86 deletions(-) delete mode 100644 doc/install_gogs_from_binary_on_ubuntu.md delete mode 100644 doc/install_gogs_from_source_on_ubuntu.md diff --git a/README.md b/README.md index 7166daed7..8e00be526 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,10 @@ More importantly, Gogs only needs one binary to setup your own project hosting o ## Overview -- Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, known issues, and change log. +- Please see [Documentation](http://gogs.io/docs/intro/) for project design, known issues, and change log. - See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team. - Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section! -- Having troubles? Get help from [Troubleshooting](https://github.com/gogits/gogs/wiki/Troubleshooting). +- Having troubles? Get help from [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md). ## Features @@ -49,12 +49,12 @@ More importantly, Gogs only needs one binary to setup your own project hosting o ## Installation -Make sure you install [Prerequirements](https://github.com/gogits/gogs/wiki/Prerequirements) first. +Make sure you install [Prerequirements](http://gogs.io/docs/installation/) first. There are 3 ways to install Gogs: -- [Install from binary](https://github.com/gogits/gogs/wiki/Install-from-binary): **STRONGLY RECOMMENDED** -- [Install from source](https://github.com/gogits/gogs/wiki/Install-from-source) +- [Install from binary](http://gogs.io/docs/installation/install_from_binary.md): **STRONGLY RECOMMENDED** +- [Install from source](http://gogs.io/docs/installation/install_from_source.md) - [Ship with Docker](https://github.com/gogits/gogs/tree/master/dockerfiles) ## Acknowledgments diff --git a/README_ZH.md b/README_ZH.md index 177c679a8..e4c92685f 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -15,10 +15,10 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 ## 项目概览 -- 有关项目设计、已知问题和变更日志,请通过 [Wiki](https://github.com/gogits/gogs/wiki) 查看。 +- 有关项目设计、已知问题和变更日志,请通过 [使用手册](http://gogs.io/docs/intro/) 查看。 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。 - 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。 -- 使用过程中遇到问题?尝试从 [故障排查](https://github.com/gogits/gogs/wiki/Troubleshooting) 页面获取帮助。 +- 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.md) 页面获取帮助。 ## 功能特性 @@ -41,12 +41,12 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 ## 安装部署 -在安装 Gogs 之前,您需要先安装 [基本环境](https://github.com/gogits/gogs/wiki/Prerequirements)。 +在安装 Gogs 之前,您需要先安装 [基本环境](http://gogs.io/docs/installation/)。 然后,您可以通过以下 3 种方式来安装 Gogs: -- [二进制安装](https://github.com/gogits/gogs/wiki/Install-from-binary): **强烈推荐** -- [源码安装](https://github.com/gogits/gogs/wiki/Install-from-source) +- [二进制安装](http://gogs.io/docs/installation/install_from_binary.md): **强烈推荐** +- [源码安装](http://gogs.io/docs/installation/install_from_source.md) - [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/dockerfiles) ## 特别鸣谢 diff --git a/doc/install_gogs_from_binary_on_ubuntu.md b/doc/install_gogs_from_binary_on_ubuntu.md deleted file mode 100644 index 3b406b364..000000000 --- a/doc/install_gogs_from_binary_on_ubuntu.md +++ /dev/null @@ -1,26 +0,0 @@ -### Binary install gogs on ubuntu 14.04 LTS - -### create user and install denpendency -- sudo adduser git -- sudo apt-get update -- sudo apt-get upgrade -- sudo apt-get install git -- sudo apt-get install mysql-server - -### create the database -- $mysql -u root -p -- mysql> SET GLOBAL storage_engine = 'InnoDB'; -- mysql> CREATE DATABASE gogs CHARACTER SET utf8 COLLATE utf8_bin; -- mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'root'@'localhost' IDENTIFIED BY 'password'; -- mysql> FLUSH PRIVILEGES; -- mysql> QUIT - -### install the gogs -- mkdir gogs -- cd gogs -- curl -L http://gobuild.io/github.com/gogits/gogs/v0.3.0/linux/amd64 -o v0.3.0.zip -- unzip v0.3.0.zip -- ./start.sh - -> The up-to-date binary could be found at -> http://gobuild.io/download/github.com/gogits/gogs diff --git a/doc/install_gogs_from_source_on_ubuntu.md b/doc/install_gogs_from_source_on_ubuntu.md deleted file mode 100644 index b8ae6fc79..000000000 --- a/doc/install_gogs_from_source_on_ubuntu.md +++ /dev/null @@ -1,48 +0,0 @@ -##Install gogs under ubuntu 14.04 LTS 32bit from source code - -###Requirements -- Go Programming Language: Version >= 1.2 -- git(bash): Version >= 1.6.6(both server and client) -- MySQL: Version >= 5.1 or PostgreSQL or NOTHING. - -### Create the user which will run git -- sudo adduser git -- su git - -### Install git and Mysql-server -- sudo apt-get install git -- sudo apt-get install mysql-server - -### Create database -- $ mysql -u root -p -- mysql> SET GLOBAL storage_engine = 'InnoDB'; -- mysql> CREATE DATABASE gogs CHARACTER SET utf8 COLLATE utf8_bin; -- mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'root'@'localhost' IDENTIFIED BY 'pasword'; -- mysql> FLUSH PRIVILEGES; -- mysql> QUIT - -### install go from source -- sudo apt-get install build-essential -- sudo apt-get install mercurial -- hg clone -r release https://go.googlecode.com/hg/ /home/git/golang/ - - -- echo export GOROOT=/home/git/golang >>.bashrc -- echo export GOARCH=386 >>.bashrc -- echo export GOOS=linux >>.bashrc -- echo export GOBIN= /home/git/golang/bin >>.bashrc -- echo export GOPATH=$HOME/app/Go >>.bashrc -- echo PATH=${PATH}: /$HOME/golang/bin >>.bashrc -- cd $GOROOT/src -- ./make.bash - -### Download and install dependencies -- $ go get -u github.com/gogits/gogs - -### Build main program -- $ cd $GOPATH/src/github.com/gogits/gogs -- $ go build -- $ ./start.sh - -### At present, you could access gogs from http://localhost:3000 - diff --git a/gogs.go b/gogs.go index 7f7267ecd..af707862a 100644 --- a/gogs.go +++ b/gogs.go @@ -19,7 +19,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.3.1.0430 Alpha" +const APP_VER = "0.3.1.0501 Alpha" func init() { base.AppVer = APP_VER diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 23a1173f9..b3e3368b4 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -15,7 +15,7 @@
-

Official Website

+

Official Website

From dc5546633f391bfc5ca20463baad06919210338d Mon Sep 17 00:00:00 2001 From: Meaglith Ma Date: Thu, 1 May 2014 15:37:24 +0800 Subject: [PATCH 2/7] Remove 'ENV DEBIAN_FRONTEND noninteractive' --- dockerfiles/build.sh.bak | 29 -------------------------- dockerfiles/images/gogits/Dockerfile | 2 -- dockerfiles/images/memcache/Dockerfile | 2 -- dockerfiles/images/mysql/Dockerfile | 2 -- dockerfiles/images/postgres/Dockerfile | 2 -- dockerfiles/images/redis/Dockerfile | 2 -- 6 files changed, 39 deletions(-) delete mode 100755 dockerfiles/build.sh.bak diff --git a/dockerfiles/build.sh.bak b/dockerfiles/build.sh.bak deleted file mode 100755 index 272424c87..000000000 --- a/dockerfiles/build.sh.bak +++ /dev/null @@ -1,29 +0,0 @@ -# Configs of the docker images, you might have specify your own configs here. -# type of database, support 'mysql' and 'postgres' -DB_TYPE="postgres" -DB_PASSWORD="YOUR_DB_PASSWORD" -DB_RUN_NAME="YOUR_DB_RUN_NAME" -HOST_PORT="YOUR_HOST_PORT" - -# Replace the database root password in database image Dockerfile. -sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile -# Replace the database root password in gogits image deploy.sh file. -sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/gogits/deploy.sh -# Replace the database type in gogits image deploy.sh file. -sed -i "s/THE_DB_TYPE/$DB_TYPE/g" images/gogits/deploy.sh - -# Build the database image -cd images/$DB_TYPE -docker build -t gogs/$DB_TYPE . -# -## Build the gogits image -cd ../gogits -docker build -t gogs/gogits . -# -## Run MySQL image with name -docker run -d --name $DB_RUN_NAME gogs/$DB_TYPE -# -## Run gogits image and link it to the database image -echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:" -echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db -p $HOST_PORT:3000 gogs/gogits \033[0m" - diff --git a/dockerfiles/images/gogits/Dockerfile b/dockerfiles/images/gogits/Dockerfile index 7f1514efe..1f67d41ed 100644 --- a/dockerfiles/images/gogits/Dockerfile +++ b/dockerfiles/images/gogits/Dockerfile @@ -1,8 +1,6 @@ FROM stackbrew/ubuntu:13.10 MAINTAINER Meaglith Ma (@genedna) -ENV DEBIAN_FRONTEND noninteractive - #aliyun#RUN echo "deb http://mirrors.aliyun.com/ubuntu/ saucy main restricted" > /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-updates main restricted" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy universe" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-updates universe" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy multiverse" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-updates multiverse" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-backports main restricted universe multiverse" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-security main restricted" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-security universe" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-security multiverse" >> /etc/apt/sources.list #nchc#RUN echo "deb http://free.nchc.org.tw/ubuntu/ saucy main restricted" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy main restricted" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-updates main restricted" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-updates main restricted" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy universe" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy universe" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-updates universe" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-updates universe" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy multiverse" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-updates multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-updates multiverse" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-backports main restricted universe multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-backports main restricted universe multiverse" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-security main restricted" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-security main restricted" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-security universe" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-security universe" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-security multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-security multiverse" >> /etc/apt/source.list && echo "deb http://extras.ubuntu.com/ubuntu saucy main" >> /etc/apt/source.list && echo "deb-src http://extras.ubuntu.com/ubuntu saucy main" >> /etc/apt/source.list diff --git a/dockerfiles/images/memcache/Dockerfile b/dockerfiles/images/memcache/Dockerfile index 2466c1f5b..a1a2b6ee4 100644 --- a/dockerfiles/images/memcache/Dockerfile +++ b/dockerfiles/images/memcache/Dockerfile @@ -3,8 +3,6 @@ FROM ubuntu # Set the file maintainer (your name - the file's author) MAINTAINER Borja Burgos -ENV DEBIAN_FRONTEND noninteractive - # Update the default application repository sources list RUN apt-get update diff --git a/dockerfiles/images/mysql/Dockerfile b/dockerfiles/images/mysql/Dockerfile index 8fff5a194..a9a72e35c 100644 --- a/dockerfiles/images/mysql/Dockerfile +++ b/dockerfiles/images/mysql/Dockerfile @@ -3,8 +3,6 @@ FROM stackbrew/ubuntu:saucy MAINTAINER Meaglith Ma (@genedna) -ENV DEBIAN_FRONTEND noninteractive - RUN apt-get install -y --force-yes software-properties-common RUN add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" RUN apt-get --yes --force-yes update diff --git a/dockerfiles/images/postgres/Dockerfile b/dockerfiles/images/postgres/Dockerfile index 0188dd78f..9d76873c9 100644 --- a/dockerfiles/images/postgres/Dockerfile +++ b/dockerfiles/images/postgres/Dockerfile @@ -1,8 +1,6 @@ FROM ubuntu MAINTAINER SvenDowideit@docker.com -ENV DEBIAN_FRONTEND noninteractive - # Add the PostgreSQL PGP key to verify their Debian packages. # It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 diff --git a/dockerfiles/images/redis/Dockerfile b/dockerfiles/images/redis/Dockerfile index 93260ccaa..a5b948fb1 100644 --- a/dockerfiles/images/redis/Dockerfile +++ b/dockerfiles/images/redis/Dockerfile @@ -1,8 +1,6 @@ FROM stackbrew/ubuntu:saucy MAINTAINER Meaglith Ma (@genedna), Lance Ju (@crystaldust) -ENV DEBIAN_FRONTEND noninteractive - RUN apt-get update && apt-get install -y redis-server # Usually redis doesn't need a password #RUN sed -i "s/# requirepass foobared/requirepass THE_REDIS_PASSWORD/g" /etc/redis/redis.conf From 46af92c57e0d0d71f45d13d0b4bacb91ed2db16b Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 May 2014 06:55:39 -0400 Subject: [PATCH 3/7] Clean files --- conf/app.ini | 4 +--- routers/dev/template.go | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index e7174e225..6dfd198b2 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -15,11 +15,9 @@ LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0| [server] PROTOCOL = http DOMAIN = localhost -ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/ +ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:3000/ ; Disable CDN even in "prod" mode OFFLINE_MODE = false -HTTP_ADDR = -HTTP_PORT = 3000 ; Generate steps: ; $ cd path/to/gogs/custom/https ; $ go run $GOROOT/src/pkg/crypto/tls/generate_cert.go -ca=true -duration=8760h0m0s -host=myhost.example.com diff --git a/routers/dev/template.go b/routers/dev/template.go index 63d5d9a5b..7145bf51f 100644 --- a/routers/dev/template.go +++ b/routers/dev/template.go @@ -21,5 +21,6 @@ func TemplatePreview(ctx *middleware.Context, params martini.Params) { ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374" ctx.Data["ActiveCodeLives"] = base.Service.ActiveCodeLives / 60 ctx.Data["ResetPwdCodeLives"] = base.Service.ResetPwdCodeLives / 60 + ctx.Data["CurDbValue"] = "" ctx.HTML(200, params["_1"]) } From 2a1dc0085b9f7236082f3885fa594ec12d5b0211 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 May 2014 07:35:21 -0400 Subject: [PATCH 4/7] fix #91 --- modules/auth/auth.go | 4 +++- modules/base/base.go | 1 + modules/middleware/binding.go | 12 +++++++++--- templates/base/navbar.tmpl | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/auth/auth.go b/modules/auth/auth.go index e493faefe..85df42d8c 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -21,7 +21,7 @@ type Form interface { } type RegisterForm struct { - UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"` + UserName string `form:"username" binding:"Required;AlphaDashDot;MaxSize(30)"` Email string `form:"email" binding:"Required;Email;MaxSize(50)"` Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"` RetypePasswd string `form:"retypepasswd"` @@ -123,6 +123,8 @@ func validate(errors *base.BindingErrors, data base.TmplData, form Form) { data["ErrorMsg"] = form.Name(field.Name) + " cannot be empty" case base.BindingAlphaDashError: data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) characters" + case base.BindingAlphaDashDotError: + data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) or dot characters" case base.BindingMinSizeError: data["ErrorMsg"] = form.Name(field.Name) + " must contain at least " + getMinMaxSize(field) + " characters" case base.BindingMaxSizeError: diff --git a/modules/base/base.go b/modules/base/base.go index 3e80a436e..e6befb83f 100644 --- a/modules/base/base.go +++ b/modules/base/base.go @@ -45,6 +45,7 @@ func (this *BindingErrors) Combine(other BindingErrors) { const ( BindingRequireError string = "Required" BindingAlphaDashError string = "AlphaDash" + BindingAlphaDashDotError string = "AlphaDashDot" BindingMinSizeError string = "MinSize" BindingMaxSizeError string = "MaxSize" BindingEmailError string = "Email" diff --git a/modules/middleware/binding.go b/modules/middleware/binding.go index cde9ae9cc..bff34ddde 100644 --- a/modules/middleware/binding.go +++ b/modules/middleware/binding.go @@ -180,9 +180,10 @@ func Validate(obj interface{}) martini.Handler { } var ( - alphaDashPattern = regexp.MustCompile("[^\\d\\w-_]") - emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?") - urlPattern = regexp.MustCompile(`(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?`) + alphaDashPattern = regexp.MustCompile("[^\\d\\w-_]") + alphaDashDotPattern = regexp.MustCompile("[^\\d\\w-_\\.]") + emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?") + urlPattern = regexp.MustCompile(`(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?`) ) func validateStruct(errors *base.BindingErrors, obj interface{}) { @@ -227,6 +228,11 @@ func validateStruct(errors *base.BindingErrors, obj interface{}) { errors.Fields[field.Name] = base.BindingAlphaDashError break } + case rule == "AlphaDashDot": + if alphaDashDotPattern.MatchString(fmt.Sprintf("%v", fieldValue)) { + errors.Fields[field.Name] = base.BindingAlphaDashDotError + break + } case strings.HasPrefix(rule, "MinSize("): min, err := strconv.Atoi(rule[8 : len(rule)-1]) if err != nil { diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index da6865b8e..80085d974 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -3,7 +3,7 @@