mirror of
https://github.com/gogs/gogs.git
synced 2026-03-01 01:30:57 +01:00
Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2401e68d7e | ||
|
|
31805e2bbe | ||
|
|
6700257558 | ||
|
|
41b0a7b97c | ||
|
|
62240b6bc1 | ||
|
|
ce05a8d7b6 | ||
|
|
62d23e9154 | ||
|
|
9fdf4bc277 | ||
|
|
8a8f84d245 | ||
|
|
59d0e73c35 | ||
|
|
1badb2bbcc | ||
|
|
89b68bdd45 | ||
|
|
597387ad40 | ||
|
|
cfa0968191 | ||
|
|
9dfb7de371 | ||
|
|
1b734501bd | ||
|
|
861a20f464 | ||
|
|
0da329462e | ||
|
|
3684e70dc4 | ||
|
|
83578cff65 | ||
|
|
3f2f648035 | ||
|
|
d0f887a1ed | ||
|
|
35a86d04c0 | ||
|
|
37cbfc032a | ||
|
|
5898d56205 | ||
|
|
cf7901fe6a | ||
|
|
e5af34a078 | ||
|
|
51550e5b2e | ||
|
|
eb4691cb2f | ||
|
|
912481019f | ||
|
|
184f1ae135 | ||
|
|
efc05ea1de | ||
|
|
521c5f0e10 | ||
|
|
32ae6896fa | ||
|
|
4b58c01603 | ||
|
|
ff690840d4 | ||
|
|
0c5e50a888 | ||
|
|
7ded30ba5b | ||
|
|
683e58878a | ||
|
|
649d0e1681 | ||
|
|
d7956b3fb8 | ||
|
|
2a95bc1395 | ||
|
|
e554e49c16 | ||
|
|
9abb37b45e | ||
|
|
22f8536577 | ||
|
|
8952eb1ce0 | ||
|
|
ee7bfe2ebe | ||
|
|
b270b34c98 | ||
|
|
b01e967a9f | ||
|
|
baacba96ca | ||
|
|
8bc502a1ea | ||
|
|
e5aaf23bb2 | ||
|
|
a90a014033 | ||
|
|
88072a1e9b | ||
|
|
f0cdf30134 | ||
|
|
22bb5104c8 | ||
|
|
1560abe553 | ||
|
|
65ad26feba | ||
|
|
b60d5ecc3e | ||
|
|
8a6119551b | ||
|
|
4b8d72dec2 | ||
|
|
5435b259cc | ||
|
|
dbdaf934e1 | ||
|
|
d6ff275c58 | ||
|
|
b32407456a | ||
|
|
2a9da4b8e5 | ||
|
|
9a5e49cccb | ||
|
|
338fc122fa | ||
|
|
34d18a19a3 | ||
|
|
066d91e113 | ||
|
|
bb84bb8ac3 | ||
|
|
213b366959 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ public/img/avatar/
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
dev
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
|
||||
@@ -19,6 +19,7 @@ github.com/lib/pq =
|
||||
github.com/nfnt/resize =
|
||||
github.com/qiniu/log =
|
||||
github.com/robfig/cron =
|
||||
github.com/juju2013/goldap =
|
||||
|
||||
[res]
|
||||
include = templates|public|conf
|
||||
|
||||
@@ -10,6 +10,8 @@ Want to hack on Gogs? Awesome! Here are instructions to get you started. They ar
|
||||
|
||||
### Pull requests are always welcome
|
||||
|
||||
**ALL PULL REQUESTS MUST SEND TO `DEV` BRANCH**
|
||||
|
||||
We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it.
|
||||
|
||||
If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve.
|
||||
|
||||
@@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language
|
||||
|
||||

|
||||
|
||||
##### Current version: 0.3.0 Alpha
|
||||
##### Current version: 0.3.1 Alpha
|
||||
|
||||
### NOTICES
|
||||
|
||||
@@ -42,6 +42,11 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
|
||||
- Supports MySQL, PostgreSQL and SQLite3.
|
||||
- Social account login(GitHub, Google, QQ, Weibo)
|
||||
|
||||
## System Requirements
|
||||
|
||||
- A cheap Raspberry Pi is powerful enough to match the minimal requirement.
|
||||
- 4 CPU Cores and 1GB RAM would be the baseline for teamwork.
|
||||
|
||||
## Installation
|
||||
|
||||
Make sure you install [Prerequirements](https://github.com/gogits/gogs/wiki/Prerequirements) first.
|
||||
@@ -64,7 +69,7 @@ There are 3 ways to install Gogs:
|
||||
|
||||
## Contributors
|
||||
|
||||
This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei), [slene](https://github.com/slene) and [codeskyblue](https://github.com/codeskyblue) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors.
|
||||
This project was launched by [Unknwon](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei), [slene](https://github.com/slene) and [codeskyblue](https://github.com/codeskyblue) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors.
|
||||
|
||||
[][koding]
|
||||
[koding]: https://koding.com/Teamwork?import=https://github.com/gogits/gogs/archive/master.zip&c=git1
|
||||
|
||||
@@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
|
||||
|
||||

|
||||
|
||||
##### 当前版本:0.3.0 Alpha
|
||||
##### 当前版本:0.3.1 Alpha
|
||||
|
||||
## 开发目的
|
||||
|
||||
@@ -33,6 +33,12 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
|
||||
- 支持 MySQL、PostgreSQL 以及 SQLite3 数据库
|
||||
- 社交帐号登录(GitHub、Google、QQ、微博)
|
||||
|
||||
## 系统要求
|
||||
|
||||
- 最低的系统硬件要求为一个廉价的树莓派
|
||||
- 如果用于团队项目,建议使用 4 核 CPU 及 1GB 内存
|
||||
|
||||
|
||||
## 安装部署
|
||||
|
||||
在安装 Gogs 之前,您需要先安装 [基本环境](https://github.com/gogits/gogs/wiki/Prerequirements)。
|
||||
|
||||
@@ -16,6 +16,8 @@ LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0|
|
||||
PROTOCOL = http
|
||||
DOMAIN = localhost
|
||||
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
|
||||
; Disable CDN even in "prod" mode
|
||||
OFFLINE_MODE = false
|
||||
HTTP_ADDR =
|
||||
HTTP_PORT = 3000
|
||||
; Generate steps:
|
||||
@@ -53,7 +55,7 @@ RESET_PASSWD_CODE_LIVE_MINUTES = 180
|
||||
; User need to confirm e-mail for registration
|
||||
REGISTER_EMAIL_CONFIRM = false
|
||||
; Does not allow register and admin create account only
|
||||
DISENABLE_REGISTERATION = false
|
||||
DISABLE_REGISTRATION = false
|
||||
; User must sign in to view anything.
|
||||
REQUIRE_SIGNIN_VIEW = false
|
||||
; Cache avatar as picture
|
||||
|
||||
26
doc/install_gogs_from_binary_on_ubuntu.md
Normal file
26
doc/install_gogs_from_binary_on_ubuntu.md
Normal file
@@ -0,0 +1,26 @@
|
||||
### 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
|
||||
48
doc/install_gogs_from_source_on_ubuntu.md
Normal file
48
doc/install_gogs_from_source_on_ubuntu.md
Normal file
@@ -0,0 +1,48 @@
|
||||
##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
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
### Gogs Install With Docker
|
||||
### Install Gogs With Docker
|
||||
|
||||
|
||||
|
||||
#### Gogs With MySQL
|
||||
|
||||
Deply gogs in [Docker](http://www.docker.io/) is just as easy as eating a pie, what you do is just open the `dockerfiles/build.sh` file, replace the confis:
|
||||
Deploying gogs in [Docker](http://www.docker.io/) is just as easy as eating a pie, what you do is just open the `dockerfiles/build.sh` file, replace the configs:
|
||||
|
||||
```
|
||||
MYSQL_PASSWORD="YOUR_MYSQL_PASSWORD"
|
||||
MYSQL_RUN_NAME="YOUR_MYSQL_RUN_NAME"
|
||||
HOST_PORT="YOUR_HOST_PORT"
|
||||
DB_TYPE="YOUR_DB_TYPE" # type of database, support 'mysql' and 'postgres'
|
||||
MEM_TYPE="YOUR_MEM_TYPE" # type of memory database, support 'redis' and 'memcache'
|
||||
DB_PASSWORD="YOUR_DB_PASSWORD" # The database password.
|
||||
DB_RUN_NAME="YOUR_DB_RUN_NAME" # The --name option value when run the database image.
|
||||
MEM_RUN_NAME="YOUR_MEM_RUN_NAME" # The --name option value when run the mem database image.
|
||||
HOST_PORT="YOUR_HOST_PORT" # The port on host, which will be redirected to the port 3000 inside gogs container.
|
||||
```
|
||||
|
||||
And run:
|
||||
@@ -22,13 +21,13 @@ The build might take some time, just be paient. After it finishes, you will rece
|
||||
|
||||
```
|
||||
Now we have the MySQL image(running) and gogs image, use the follow command to start gogs service( the content might be different, according to your own configs):
|
||||
docker run -i -t --link gogs_mysql:db -p 3333:3000 gogs/gogits
|
||||
docker run -i -t --link YOUR_DB_RUN_NAME:db --link YOUR_MEM_RUN_NAME:mem -p YOUR_HOST_PORT:3000 gogits/gogs
|
||||
```
|
||||
|
||||
Just follow the message, run:
|
||||
|
||||
```
|
||||
docker run -i -t --link gogs_mysql:db -p 3333:3000 gogs/gogits
|
||||
docker run -i -t --link YOUR_DB_RUN_NAME:db --link YOUR_MEM_RUN_NAME:mem -p YOUR_HOST_PORT:3000 gogits/gogs
|
||||
```
|
||||
|
||||
Now we have gogs running! Open the browser and navigate to:
|
||||
@@ -38,22 +37,4 @@ http://YOUR_HOST_IP:YOUR_HOST_PORT
|
||||
```
|
||||
|
||||
Let's 'gogs'!
|
||||
|
||||
#### Gogs With PostgreSQL
|
||||
|
||||
Installing Gogs with PostgreSQL is nearly the same with installing it with MySQL. What you do is just change the DB_TYPE in build.sh to 'postgres'.
|
||||
|
||||
#### Gogs, MySQL With Redis
|
||||
|
||||
|
||||
#### Gogs, MySQL With Memcached
|
||||
|
||||
|
||||
#### Gogs, PostgreSQL With Redis
|
||||
|
||||
|
||||
#### Gogs, PostgreSQL With Memcached
|
||||
|
||||
|
||||
|
||||
|
||||
Ouya~
|
||||
|
||||
@@ -1,29 +1,68 @@
|
||||
# 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"
|
||||
|
||||
DB_TYPE="YOUR_DB_TYPE" # type of database, support 'mysql' and 'postgres'
|
||||
MEM_TYPE="YOUR_MEM_TYPE" # type of memory database, support 'redis' and 'memcache'
|
||||
DB_PASSWORD="YOUR_DB_PASSWORD" # The database password.
|
||||
DB_RUN_NAME="YOUR_DB_RUN_NAME" # The --name option value when run the database image.
|
||||
MEM_RUN_NAME="YOUR_MEM_RUN_NAME" # The --name option value when run the mem database image.
|
||||
HOST_PORT="YOUR_HOST_PORT" # The port on host, which will be redirected to the port 3000 inside gogs container.
|
||||
|
||||
# apt source, you can select 'nchc'(mirror in Taiwan) or 'aliyun'(best for mainlance China users) according to your network, if you could connect to the official unbunt mirror in a fast speed, just leave it to "".
|
||||
APT_SOURCE=""
|
||||
|
||||
# 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 apt source in gogits image Dockerfile.
|
||||
sed -i "s/#$APT_SOURCE#//" images/gogits/Dockerfile
|
||||
# Uncomment the installation of database lib in gogs Dockerfile
|
||||
sed -i "s/#$DB_TYPE#//" images/gogits/Dockerfile
|
||||
# Replace the database type in gogits image deploy.sh file.
|
||||
sed -i "s/THE_DB_TYPE/$DB_TYPE/g" images/gogits/deploy.sh
|
||||
|
||||
if [ $MEM_TYPE != "" ]
|
||||
then
|
||||
# Replace the mem configs in deploy.sh
|
||||
sed -i "s/THE_MEM_TYPE/$MEM_TYPE/g" images/gogits/deploy.sh
|
||||
# Uncomment the installation of go mem lib
|
||||
sed -i "s/#$MEM_TYPE#//" images/gogits/Dockerfile
|
||||
|
||||
# Add the tags when get gogs
|
||||
sed -i "s#RUN go get -u -d github.com/gogits/gogs#RUN go get -u -d -tags $MEM_TYPE github.com/gogits/gogs#g" images/gogits/Dockerfile
|
||||
# Append the tag in gogs build
|
||||
GOGS_BUILD_LINE=`awk '$0 ~ str{print NR}' str="go build" images/gogits/Dockerfile`
|
||||
# Append the build tags
|
||||
sed -i "${GOGS_BUILD_LINE}s/$/ -tags $MEM_TYPE/" images/gogits/Dockerfile
|
||||
|
||||
cd images/$MEM_TYPE
|
||||
docker build -t gogits/$MEM_TYPE .
|
||||
docker run -d --name $MEM_RUN_NAME gogits/$MEM_TYPE
|
||||
MEM_LINK=" --link $MEM_RUN_NAME:mem "
|
||||
cd ../../
|
||||
fi
|
||||
|
||||
# Build the database image
|
||||
cd images/$DB_TYPE
|
||||
docker build -t gogs/$DB_TYPE .
|
||||
docker build -t gogits/$DB_TYPE .
|
||||
#
|
||||
|
||||
|
||||
## Build the gogits image
|
||||
cd ../gogits
|
||||
docker build -t gogs/gogits .
|
||||
|
||||
docker build -t gogits/gogs .
|
||||
|
||||
#sed -i "s#RUN go get -u -tags $MEM_TYPE github.com/gogits/gogs#RUN go get -u github.com/gogits/gogs#g" Dockerfile
|
||||
|
||||
# Remove the appended tags in go build line(if there is any)
|
||||
sed -i "s/ -tags $MEM_TYPE//" Dockerfile
|
||||
|
||||
#
|
||||
## Run MySQL image with name
|
||||
docker run -d --name $DB_RUN_NAME gogs/$DB_TYPE
|
||||
docker run -d --name $DB_RUN_NAME gogits/$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"
|
||||
echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db $MEM_LINK -p $HOST_PORT:3000 gogits/gogs \033[0m"
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ MAINTAINER Meaglith Ma <genedna@gmail.com> (@genedna)
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
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
|
||||
#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
|
||||
|
||||
RUN mkdir -p /go
|
||||
ENV PATH /usr/local/go/bin:/go/bin:$PATH
|
||||
@@ -11,14 +13,13 @@ ENV GOROOT /usr/local/go
|
||||
ENV GOPATH /go
|
||||
|
||||
RUN apt-get update && apt-get install --yes --force-yes curl git mercurial zip wget ca-certificates build-essential
|
||||
RUN apt-get install -yq vim sudo
|
||||
|
||||
RUN curl -s http://docker.u.qiniudn.com/go1.2.1.src.tar.gz | tar -v -C /usr/local -xz
|
||||
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1
|
||||
|
||||
# You may need a proxy, if github is very slow.
|
||||
#RUN http_proxy=106.187.38.45:3128 go get -u github.com/gogits/gogs
|
||||
RUN go get -u github.com/gogits/gogs
|
||||
RUN cd $GOPATH/src/github.com/gogits/gogs && go build
|
||||
RUN go get -u -d github.com/gogits/gogs
|
||||
RUN cd $GOPATH/src/github.com/gogits/gogs && git checkout dev && git pull origin dev && go install && go build -tags redis
|
||||
|
||||
# Clean all the unused packages
|
||||
RUN apt-get autoremove -y
|
||||
|
||||
@@ -4,22 +4,47 @@
|
||||
DB_TYPE=THE_DB_TYPE
|
||||
DB_PASSWORD=THE_DB_PASSWORD
|
||||
DB_ALIAS=DB
|
||||
MEM_TYPE=THE_MEM_TYPE
|
||||
|
||||
DB_TYPE_LINE=`awk '$0 ~ str{print NR}' str="DB_TYPE = mysql" $GOPATH/src/github.com/gogits/gogs/conf/app.ini`
|
||||
DB_PASSWORD_LINE=`awk '$0 ~ str{print NR+1}' str="USER = root" $GOPATH/src/github.com/gogits/gogs/conf/app.ini`
|
||||
|
||||
sed -i "${DB_TYPE_LINE}s/.*$/DB_TYPE = $DB_TYPE/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
sed -i "${DB_PASSWORD_LINE}s/.*$/PASSWD = $DB_PASSWORD/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
|
||||
if [ $DB_TYPE = "postgres" ]
|
||||
|
||||
|
||||
if [ $MEM_TYPE != "" ]
|
||||
then
|
||||
# Add the postgres in gogs image.
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||
apt-get update
|
||||
apt-get -y -q install python-software-properties software-properties-common
|
||||
apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
|
||||
MEM_HOST_LINE=`awk '$0 ~ str{print NR+6}' str="ADAPTER = memory" $GOPATH/src/github.com/gogits/gogs/conf/app.ini`
|
||||
|
||||
_MEM_ADDR=`echo $MEM_PORT | cut -d '/' -f 3 | cut -d ':' -f 1`
|
||||
_MEM_PORT=`echo $MEM_PORT | cut -d '/' -f 3 | cut -d ':' -f 2`
|
||||
|
||||
# take advantage of memory db for adapter and provider
|
||||
sed -i "s/ADAPTER = memory/ADAPTER = $MEM_TYPE/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
# Comment the memory interval since we don't use 'memory' as adapter
|
||||
sed -i "s/INTERVAL = 60/;INTERVAL = 60/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
|
||||
|
||||
case $MEM_TYPE in
|
||||
"redis")
|
||||
# Modify the adapter host
|
||||
sed -i "${MEM_HOST_LINE}s/.*/HOST = $_MEM_ADDR:$_MEM_PORT/" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
sed -i "s/PROVIDER = file/PROVIDER = $MEM_TYPE/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
# Modify the provider config
|
||||
sed -i "s#PROVIDER_CONFIG = data/sessions#PROVIDER_CONFIG = $_MEM_ADDR:$_MEM_PORT#g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
;;
|
||||
|
||||
"memcache")
|
||||
# Modify the adapter host
|
||||
sed -i "${MEM_HOST_LINE}s/.*/HOST = $_MEM_ADDR:$_MEM_PORT/" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
|
||||
## Replace the database address and port
|
||||
# When using --link in docker run, the database image's info looks like this:
|
||||
# DB_PORT=tcp://172.17.0.2:3306
|
||||
|
||||
26
dockerfiles/images/memcache/Dockerfile
Normal file
26
dockerfiles/images/memcache/Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
||||
FROM ubuntu
|
||||
|
||||
# Set the file maintainer (your name - the file's author)
|
||||
MAINTAINER Borja Burgos <borja@tutum.co>
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# Update the default application repository sources list
|
||||
RUN apt-get update
|
||||
|
||||
# Install Memcached
|
||||
RUN apt-get install -y memcached
|
||||
|
||||
# Port to expose (default: 11211)
|
||||
EXPOSE 11211
|
||||
|
||||
# Default Memcached run command arguments
|
||||
# Change to limit memory when creating container in Tutum
|
||||
CMD ["-m", "64"]
|
||||
|
||||
# Set the user to run Memcached daemon
|
||||
USER daemon
|
||||
|
||||
# Set the entrypoint to memcached binary
|
||||
ENTRYPOINT memcached
|
||||
|
||||
@@ -10,7 +10,7 @@ RUN add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -s
|
||||
RUN apt-get --yes --force-yes update
|
||||
RUN apt-get --yes --force-yes upgrade
|
||||
|
||||
ENV MYSQL_PASSWORD THE_MYSQL_PASSWORD
|
||||
ENV MYSQL_PASSWORD THE_DB_PASSWORD
|
||||
|
||||
RUN echo "mysql-server mysql-server/root_password password $MYSQL_PASSWORD" | debconf-set-selections
|
||||
RUN echo "mysql-server mysql-server/root_password_again password $MYSQL_PASSWORD" | debconf-set-selections
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
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
|
||||
|
||||
# Add PostgreSQL's repository. It contains the most recent stable release
|
||||
# of PostgreSQL, ``9.3``.
|
||||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||
# See http://apt.postgresql.org/pub/repos/apt/README
|
||||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||
|
||||
# Update the Ubuntu and PostgreSQL repository indexes
|
||||
RUN apt-get update
|
||||
|
||||
12
dockerfiles/images/redis/Dockerfile
Normal file
12
dockerfiles/images/redis/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM stackbrew/ubuntu:saucy
|
||||
MAINTAINER Meaglith Ma <genedna@gmail.com> (@genedna), Lance Ju <juzhenatpku@gmail.com> (@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
|
||||
EXPOSE 6379
|
||||
ENTRYPOINT ["/usr/bin/redis-server"]
|
||||
CMD ["--bind", "0.0.0.0"]
|
||||
|
||||
2
gogs.go
2
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.0.0421 Alpha"
|
||||
const APP_VER = "0.3.1.0427 Alpha"
|
||||
|
||||
func init() {
|
||||
base.AppVer = APP_VER
|
||||
|
||||
38
models/ldap.go
Normal file
38
models/ldap.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright github.com/juju2013. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gogits/gogs/modules/auth/ldap"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
||||
// Query if name/passwd can login against the LDAP direcotry pool
|
||||
// Create a local user if success
|
||||
// Return the same LoginUserPlain semantic
|
||||
func LoginUserLdap(name, passwd string) (*User, error) {
|
||||
mail, logged := ldap.LoginUser(name, passwd)
|
||||
if !logged {
|
||||
// user not in LDAP, do nothing
|
||||
return nil, ErrUserNotExist
|
||||
}
|
||||
// fake a local user creation
|
||||
user := User{
|
||||
LowerName: strings.ToLower(name),
|
||||
Name: strings.ToLower(name),
|
||||
LoginType: 389,
|
||||
IsActive: true,
|
||||
Passwd: passwd,
|
||||
Email: mail}
|
||||
_, err := RegisterUser(&user)
|
||||
if err != nil {
|
||||
log.Debug("LDAP local user %s fond (%s) ", name, err)
|
||||
}
|
||||
// simulate local user login
|
||||
localUser, err2 := GetUserByName(user.Name)
|
||||
return localUser, err2
|
||||
}
|
||||
@@ -77,12 +77,12 @@ func init() {
|
||||
// PublicKey represents a SSH key of user.
|
||||
type PublicKey struct {
|
||||
Id int64
|
||||
OwnerId int64 `xorm:"unique(s) index not null"`
|
||||
Name string `xorm:"unique(s) not null"`
|
||||
OwnerId int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
|
||||
Name string `xorm:"UNIQUE(s) NOT NULL"`
|
||||
Fingerprint string
|
||||
Content string `xorm:"TEXT not null"`
|
||||
Created time.Time `xorm:"created"`
|
||||
Updated time.Time `xorm:"updated"`
|
||||
Content string `xorm:"TEXT NOT NULL"`
|
||||
Created time.Time `xorm:"CREATED"`
|
||||
Updated time.Time `xorm:"UPDATED"`
|
||||
}
|
||||
|
||||
// GenAuthorizedKey returns formatted public key string.
|
||||
@@ -107,9 +107,9 @@ func AddPublicKey(key *PublicKey) (err error) {
|
||||
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
stdout, _, err := com.ExecCmd("ssh-keygen", "-l", "-f", tmpPath)
|
||||
stdout, stderr, err := com.ExecCmd("ssh-keygen", "-l", "-f", tmpPath)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.New("ssh-keygen -l -f: " + stderr)
|
||||
} else if len(stdout) < 2 {
|
||||
return errors.New("Not enough output for calculating fingerprint")
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ func NewRepoContext() {
|
||||
zip.Verbose = false
|
||||
|
||||
// Check if server has basic git setting.
|
||||
stdout, _, err := com.ExecCmd("git", "config", "--get", "user.name")
|
||||
if err != nil {
|
||||
fmt.Printf("repo.init(fail to get git user.name): %v", err)
|
||||
stdout, stderr, err := com.ExecCmd("git", "config", "--get", "user.name")
|
||||
if strings.Contains(stderr, "fatal:") {
|
||||
fmt.Printf("repo.NewRepoContext(fail to get git user.name): %s", stderr)
|
||||
os.Exit(2)
|
||||
} else if len(stdout) == 0 {
|
||||
if _, _, err = com.ExecCmd("git", "config", "--global", "user.email", "gogitservice@gmail.com"); err != nil {
|
||||
fmt.Printf("repo.init(fail to set git user.email): %v", err)
|
||||
} else if err != nil || len(strings.TrimSpace(stdout)) == 0 {
|
||||
if _, stderr, err = com.ExecCmd("git", "config", "--global", "user.email", "gogitservice@gmail.com"); err != nil {
|
||||
fmt.Printf("repo.NewRepoContext(fail to set git user.email): %s", stderr)
|
||||
os.Exit(2)
|
||||
} else if _, _, err = com.ExecCmd("git", "config", "--global", "user.name", "Gogs"); err != nil {
|
||||
fmt.Printf("repo.init(fail to set git user.name): %v", err)
|
||||
} else if _, stderr, err = com.ExecCmd("git", "config", "--global", "user.name", "Gogs"); err != nil {
|
||||
fmt.Printf("repo.NewRepoContext(fail to set git user.name): %s", stderr)
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
@@ -159,9 +159,7 @@ func MirrorUpdate() {
|
||||
repoPath := filepath.Join(base.RepoRootPath, m.RepoName+".git")
|
||||
_, stderr, err := com.ExecCmdDir(repoPath, "git", "remote", "update")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return errors.New(stderr)
|
||||
return errors.New("git remote update: " + stderr)
|
||||
} else if err = git.UnpackRefs(repoPath); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -177,9 +175,7 @@ func MirrorUpdate() {
|
||||
func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error {
|
||||
_, stderr, err := com.ExecCmd("git", "clone", "--mirror", url, repoPath)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return errors.New(stderr)
|
||||
return errors.New("git clone --mirror: " + stderr)
|
||||
}
|
||||
|
||||
if _, err = orm.InsertOne(&Mirror{
|
||||
@@ -219,23 +215,17 @@ func MigrateRepository(user *User, name, desc string, private, mirror bool, url
|
||||
// Clone from local repository.
|
||||
_, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir)
|
||||
if err != nil {
|
||||
return repo, err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return repo, errors.New("git clone: " + stderr)
|
||||
}
|
||||
|
||||
// Pull data from source.
|
||||
_, stderr, err = com.ExecCmdDir(tmpDir, "git", "pull", url)
|
||||
if err != nil {
|
||||
return repo, err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return repo, errors.New("git pull: " + stderr)
|
||||
}
|
||||
|
||||
// Push data to local repository.
|
||||
if _, stderr, err = com.ExecCmdDir(tmpDir, "git", "push", "origin", "master"); err != nil {
|
||||
return repo, err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return repo, errors.New("git push: " + stderr)
|
||||
}
|
||||
|
||||
@@ -352,7 +342,6 @@ func CreateRepository(user *User, name, desc, lang, license string, private, mir
|
||||
func extractGitBareZip(repoPath string) error {
|
||||
z, err := zip.Open("conf/content/git-bare.zip")
|
||||
if err != nil {
|
||||
fmt.Println("shi?")
|
||||
return err
|
||||
}
|
||||
defer z.Close()
|
||||
@@ -364,21 +353,14 @@ func extractGitBareZip(repoPath string) error {
|
||||
func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
|
||||
var stderr string
|
||||
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil {
|
||||
return err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return errors.New("git add: " + stderr)
|
||||
}
|
||||
|
||||
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
|
||||
"-m", "Init commit"); err != nil {
|
||||
return err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return errors.New("git commit: " + stderr)
|
||||
}
|
||||
|
||||
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil {
|
||||
return err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return errors.New("git push: " + stderr)
|
||||
}
|
||||
return nil
|
||||
@@ -411,10 +393,11 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
||||
return err
|
||||
}
|
||||
|
||||
rp := strings.NewReplacer("\\", "/", " ", "\\ ")
|
||||
// hook/post-update
|
||||
if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n%s update $1 $2 $3\n", base.ScriptType,
|
||||
strings.Replace(appPath, "\\", "/", -1))); err != nil {
|
||||
rp.Replace(appPath))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -436,8 +419,6 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
||||
|
||||
_, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if strings.Contains(stderr, "fatal:") {
|
||||
return errors.New("git clone: " + stderr)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
@@ -5,9 +9,11 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/gogits/git"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
qlog "github.com/qiniu/log"
|
||||
|
||||
"github.com/gogits/git"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
)
|
||||
|
||||
func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId int64) {
|
||||
|
||||
@@ -125,6 +125,7 @@ func GetUserSalt() string {
|
||||
|
||||
// RegisterUser creates record of a new user.
|
||||
func RegisterUser(user *User) (*User, error) {
|
||||
|
||||
if !IsLegalName(user.Name) {
|
||||
return nil, ErrUserNameIllegal
|
||||
}
|
||||
@@ -409,21 +410,27 @@ func GetUserByEmail(email string) (*User, error) {
|
||||
}
|
||||
|
||||
// LoginUserPlain validates user by raw user name and password.
|
||||
func LoginUserPlain(name, passwd string) (*User, error) {
|
||||
user := User{LowerName: strings.ToLower(name)}
|
||||
has, err := orm.Get(&user)
|
||||
func LoginUserPlain(uname, passwd string) (*User, error) {
|
||||
var u *User
|
||||
if strings.Contains(uname, "@") {
|
||||
u = &User{Email: uname}
|
||||
} else {
|
||||
u = &User{LowerName: strings.ToLower(uname)}
|
||||
}
|
||||
|
||||
has, err := orm.Get(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, ErrUserNotExist
|
||||
}
|
||||
|
||||
newUser := &User{Passwd: passwd, Salt: user.Salt}
|
||||
newUser := &User{Passwd: passwd, Salt: u.Salt}
|
||||
newUser.EncodePasswd()
|
||||
if user.Passwd != newUser.Passwd {
|
||||
if u.Passwd != newUser.Passwd {
|
||||
return nil, ErrUserNotExist
|
||||
}
|
||||
return &user, nil
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// Follow is connection request for receiving user notifycation.
|
||||
|
||||
@@ -57,7 +57,7 @@ func (f *RegisterForm) Validate(errors *base.BindingErrors, req *http.Request, c
|
||||
}
|
||||
|
||||
type LogInForm struct {
|
||||
UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
|
||||
UserName string `form:"username" binding:"Required;MaxSize(35)"`
|
||||
Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"`
|
||||
Remember string `form:"remember"`
|
||||
}
|
||||
|
||||
43
modules/auth/ldap/README.md
Normal file
43
modules/auth/ldap/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
LDAP authentication
|
||||
===================
|
||||
|
||||
## Goal
|
||||
|
||||
Authenticat user against LDAP directories
|
||||
|
||||
It will bind with the user's login/pasword and query attributs ("mail" for instance) in a pool of directory servers
|
||||
|
||||
The first OK wins.
|
||||
|
||||
If there's connection error, the server will be disabled and won't be checked again
|
||||
|
||||
## Usage
|
||||
|
||||
In the [security] section, set
|
||||
> LDAP_AUTH = true
|
||||
|
||||
then for each LDAP source, set
|
||||
|
||||
> [LdapSource-someuniquename]
|
||||
> name=canonicalName
|
||||
> host=hostname-or-ip
|
||||
> port=3268 # or regular LDAP port
|
||||
> # the following settings depend highly how you've configured your AD
|
||||
> basedn=dc=ACME,dc=COM
|
||||
> MSADSAFORMAT=%s@ACME.COM
|
||||
> filter=(&(objectClass=user)(sAMAccountName=%s))
|
||||
|
||||
### Limitation
|
||||
|
||||
Only tested on an MS 2008R2 DC, using global catalog (TCP/3268)
|
||||
|
||||
This MSAD is a mess.
|
||||
|
||||
The way how one checks the directory (CN, DN etc...) may be highly depending local custom configuration
|
||||
|
||||
### Todo
|
||||
* Define a timeout per server
|
||||
* Check servers marked as "Disabled" when they'll come back online
|
||||
* Find a more flexible way to define filter/MSADSAFORMAT/Attributes etc... maybe text/template ?
|
||||
* Check OpenLDAP server
|
||||
* SSL support ?
|
||||
86
modules/auth/ldap/ldap.go
Normal file
86
modules/auth/ldap/ldap.go
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright github.com/juju2013. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// package ldap provide functions & structure to query a LDAP ldap directory
|
||||
// For now, it's mainly tested again an MS Active Directory service, see README.md for more information
|
||||
package ldap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
goldap "github.com/juju2013/goldap"
|
||||
)
|
||||
|
||||
// Basic LDAP authentication service
|
||||
type ldapsource struct {
|
||||
Name string // canonical name (ie. corporate.ad)
|
||||
Host string // LDAP host
|
||||
Port int // port number
|
||||
BaseDN string // Base DN
|
||||
Attributes string // Attribut to search
|
||||
Filter string // Query filter to validate entry
|
||||
MsAdSAFormat string // in the case of MS AD Simple Authen, the format to use (see: http://msdn.microsoft.com/en-us/library/cc223499.aspx)
|
||||
Enabled bool // if this source is disabled
|
||||
}
|
||||
|
||||
//Global LDAP directory pool
|
||||
var (
|
||||
Authensource []ldapsource
|
||||
)
|
||||
|
||||
// Add a new source (LDAP directory) to the global pool
|
||||
func AddSource(name string, host string, port int, basedn string, attributes string, filter string, msadsaformat string) {
|
||||
ldaphost := ldapsource{name, host, port, basedn, attributes, filter, msadsaformat, true}
|
||||
Authensource = append(Authensource, ldaphost)
|
||||
}
|
||||
|
||||
//LoginUser : try to login an user to LDAP sources, return requested (attribut,true) if ok, ("",false) other wise
|
||||
//First match wins
|
||||
//Returns first attribute if exists
|
||||
func LoginUser(name, passwd string) (a string, r bool) {
|
||||
r = false
|
||||
for _, ls := range Authensource {
|
||||
a, r = ls.searchEntry(name, passwd)
|
||||
if r {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// searchEntry : search an LDAP source if an entry (name, passwd) is valide and in the specific filter
|
||||
func (ls ldapsource) searchEntry(name, passwd string) (string, bool) {
|
||||
l, err := goldap.Dial("tcp", fmt.Sprintf("%s:%d", ls.Host, ls.Port))
|
||||
if err != nil {
|
||||
log.Debug("LDAP Connect error, disabled source %s", ls.Host)
|
||||
ls.Enabled = false
|
||||
return "", false
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
nx := fmt.Sprintf(ls.MsAdSAFormat, name)
|
||||
err = l.Bind(nx, passwd)
|
||||
if err != nil {
|
||||
log.Debug("LDAP Authan failed for %s, reason: %s", nx, err.Error())
|
||||
return "", false
|
||||
}
|
||||
|
||||
search := goldap.NewSearchRequest(
|
||||
ls.BaseDN,
|
||||
goldap.ScopeWholeSubtree, goldap.NeverDerefAliases, 0, 0, false,
|
||||
fmt.Sprintf(ls.Filter, name),
|
||||
[]string{ls.Attributes},
|
||||
nil)
|
||||
sr, err := l.Search(search)
|
||||
if err != nil {
|
||||
log.Debug("LDAP Authen OK but not in filter %s", name)
|
||||
return "", false
|
||||
}
|
||||
log.Debug("LDAP Authen OK: %s", name)
|
||||
if len(sr.Entries) > 0 {
|
||||
r := sr.Entries[0].GetAttributeValue(ls.Attributes)
|
||||
return r, true
|
||||
}
|
||||
return "", true
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package base
|
||||
|
||||
import (
|
||||
_ "github.com/gogits/cache/redis"
|
||||
_ "github.com/gogits/session/redis"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
"github.com/gogits/cache"
|
||||
"github.com/gogits/session"
|
||||
|
||||
"github.com/gogits/gogs/modules/auth/ldap"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
||||
@@ -43,14 +45,15 @@ type Oauther struct {
|
||||
}
|
||||
|
||||
var (
|
||||
AppVer string
|
||||
AppName string
|
||||
AppLogo string
|
||||
AppUrl string
|
||||
IsProdMode bool
|
||||
Domain string
|
||||
SecretKey string
|
||||
RunUser string
|
||||
AppVer string
|
||||
AppName string
|
||||
AppLogo string
|
||||
AppUrl string
|
||||
OfflineMode bool
|
||||
ProdMode bool
|
||||
Domain string
|
||||
SecretKey string
|
||||
RunUser string
|
||||
|
||||
RepoRootPath string
|
||||
ScriptType string
|
||||
@@ -83,13 +86,14 @@ var (
|
||||
)
|
||||
|
||||
var Service struct {
|
||||
RegisterEmailConfirm bool
|
||||
DisenableRegisteration bool
|
||||
RequireSignInView bool
|
||||
EnableCacheAvatar bool
|
||||
NotifyMail bool
|
||||
ActiveCodeLives int
|
||||
ResetPwdCodeLives int
|
||||
RegisterEmailConfirm bool
|
||||
DisableRegistration bool
|
||||
RequireSignInView bool
|
||||
EnableCacheAvatar bool
|
||||
NotifyMail bool
|
||||
ActiveCodeLives int
|
||||
ResetPwdCodeLives int
|
||||
LdapAuth bool
|
||||
}
|
||||
|
||||
func ExecDir() (string, error) {
|
||||
@@ -116,7 +120,7 @@ var logLevels = map[string]string{
|
||||
func newService() {
|
||||
Service.ActiveCodeLives = Cfg.MustInt("service", "ACTIVE_CODE_LIVE_MINUTES", 180)
|
||||
Service.ResetPwdCodeLives = Cfg.MustInt("service", "RESET_PASSWD_CODE_LIVE_MINUTES", 180)
|
||||
Service.DisenableRegisteration = Cfg.MustBool("service", "DISENABLE_REGISTERATION", false)
|
||||
Service.DisableRegistration = Cfg.MustBool("service", "DISABLE_REGISTRATION", false)
|
||||
Service.RequireSignInView = Cfg.MustBool("service", "REQUIRE_SIGNIN_VIEW", false)
|
||||
Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR", false)
|
||||
}
|
||||
@@ -175,6 +179,36 @@ func newLogService() {
|
||||
log.Info("Log Mode: %s(%s)", strings.Title(LogMode), levelName)
|
||||
}
|
||||
|
||||
func newLdapService() {
|
||||
Service.LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false)
|
||||
if !Service.LdapAuth {
|
||||
return
|
||||
}
|
||||
|
||||
nbsrc := 0
|
||||
for _, v := range Cfg.GetSectionList() {
|
||||
if matched, _ := regexp.MatchString("(?i)^LDAPSOURCE.*", v); matched {
|
||||
ldapname := Cfg.MustValue(v, "name", v)
|
||||
ldaphost := Cfg.MustValue(v, "host")
|
||||
ldapport := Cfg.MustInt(v, "port", 389)
|
||||
ldapbasedn := Cfg.MustValue(v, "basedn", "dc=*,dc=*")
|
||||
ldapattribute := Cfg.MustValue(v, "attribute", "mail")
|
||||
ldapfilter := Cfg.MustValue(v, "filter", "(*)")
|
||||
ldapmsadsaformat := Cfg.MustValue(v, "MSADSAFORMAT", "%s")
|
||||
ldap.AddSource(ldapname, ldaphost, ldapport, ldapbasedn, ldapattribute, ldapfilter, ldapmsadsaformat)
|
||||
nbsrc++
|
||||
log.Debug("%s added as LDAP source", ldapname)
|
||||
}
|
||||
}
|
||||
if nbsrc == 0 {
|
||||
log.Warn("No valide LDAP found, LDAP Authentication NOT enabled")
|
||||
Service.LdapAuth = false
|
||||
return
|
||||
}
|
||||
|
||||
log.Info("LDAP Authentication Enabled")
|
||||
}
|
||||
|
||||
func newCacheService() {
|
||||
CacheAdapter = Cfg.MustValue("cache", "ADAPTER", "memory")
|
||||
if EnableRedis {
|
||||
@@ -292,6 +326,7 @@ func NewConfigContext() {
|
||||
AppLogo = Cfg.MustValue("", "APP_LOGO", "img/favicon.png")
|
||||
AppUrl = Cfg.MustValue("server", "ROOT_URL")
|
||||
Domain = Cfg.MustValue("server", "DOMAIN")
|
||||
OfflineMode = Cfg.MustBool("server", "OFFLINE_MODE", false)
|
||||
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
|
||||
|
||||
InstallLock = Cfg.MustBool("security", "INSTALL_LOCK", false)
|
||||
@@ -309,7 +344,6 @@ func NewConfigContext() {
|
||||
LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS")
|
||||
CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME")
|
||||
CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME")
|
||||
|
||||
PictureService = Cfg.MustValue("picture", "SERVICE")
|
||||
|
||||
// Determine and create root git reposiroty path.
|
||||
@@ -327,6 +361,7 @@ func NewConfigContext() {
|
||||
func NewBaseServices() {
|
||||
newService()
|
||||
newLogService()
|
||||
newLdapService()
|
||||
newCacheService()
|
||||
newSessionService()
|
||||
newMailService()
|
||||
|
||||
@@ -56,8 +56,8 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
|
||||
"AppDomain": func() string {
|
||||
return Domain
|
||||
},
|
||||
"IsProdMode": func() bool {
|
||||
return IsProdMode
|
||||
"CdnMode": func() bool {
|
||||
return ProdMode && !OfflineMode
|
||||
},
|
||||
"LoadTimes": func(startTime time.Time) string {
|
||||
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
|
||||
@@ -124,11 +124,11 @@ func ActionIcon(opType int) string {
|
||||
const (
|
||||
TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s">%s</a>`
|
||||
TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>%s`
|
||||
TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s">%s</a> %s</div>`
|
||||
TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s" rel="nofollow">%s</a> %s</div>`
|
||||
TPL_CREATE_ISSUE = `<a href="/user/%s">%s</a> opened issue <a href="/%s/issues/%s">%s#%s</a>
|
||||
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
|
||||
TPL_TRANSFER_REPO = `<a href="/user/%s">%s</a> transfered repository <code>%s</code> to <a href="/%s">%s</a>`
|
||||
TPL_PUSH_TAG = `<a href="/user/%s">%s</a> pushed tag <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>`
|
||||
TPL_PUSH_TAG = `<a href="/user/%s">%s</a> pushed tag <a href="/%s/src/%s" rel="nofollow">%s</a> at <a href="/%s">%s</a>`
|
||||
)
|
||||
|
||||
type PushCommit struct {
|
||||
@@ -165,7 +165,7 @@ func ActionDesc(act Actioner) string {
|
||||
buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
|
||||
}
|
||||
if push.Len > 3 {
|
||||
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
|
||||
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s" rel="nofollow">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
|
||||
}
|
||||
return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink,
|
||||
buf.String())
|
||||
|
||||
@@ -26,11 +26,14 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
|
||||
var displayBare bool
|
||||
|
||||
if len(args) >= 1 {
|
||||
validBranch = args[0]
|
||||
// Note: argument has wrong value in Go1.3 martini.
|
||||
// validBranch = args[0]
|
||||
validBranch = true
|
||||
}
|
||||
|
||||
if len(args) >= 2 {
|
||||
displayBare = args[1]
|
||||
// displayBare = args[1]
|
||||
displayBare = true
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
BIN
public/img/favicon.bak.png
Normal file
BIN
public/img/favicon.bak.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 11 KiB |
@@ -470,10 +470,10 @@ function initInstall() {
|
||||
(function () {
|
||||
$('#install-database').on("change", function () {
|
||||
var val = $(this).val();
|
||||
if (val != "sqlite") {
|
||||
if (val != "SQLite3") {
|
||||
$('.server-sql').show();
|
||||
$('.sqlite-setting').addClass("hide");
|
||||
if (val == "pgsql") {
|
||||
if (val == "PostgreSQL") {
|
||||
$('.pgsql-setting').removeClass("hide");
|
||||
} else {
|
||||
$('.pgsql-setting').addClass("hide");
|
||||
|
||||
@@ -139,9 +139,11 @@ func Config(ctx *middleware.Context) {
|
||||
|
||||
ctx.Data["AppUrl"] = base.AppUrl
|
||||
ctx.Data["Domain"] = base.Domain
|
||||
ctx.Data["OfflineMode"] = base.OfflineMode
|
||||
ctx.Data["RunUser"] = base.RunUser
|
||||
ctx.Data["RunMode"] = strings.Title(martini.Env)
|
||||
ctx.Data["RepoRootPath"] = base.RepoRootPath
|
||||
ctx.Data["ScriptType"] = base.ScriptType
|
||||
|
||||
ctx.Data["Service"] = base.Service
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func checkRunMode() {
|
||||
switch base.Cfg.MustValue("", "RUN_MODE") {
|
||||
case "prod":
|
||||
martini.Env = martini.Prod
|
||||
base.IsProdMode = true
|
||||
base.ProdMode = true
|
||||
case "test":
|
||||
martini.Env = martini.Test
|
||||
}
|
||||
@@ -65,6 +65,10 @@ func GlobalInit() {
|
||||
checkRunMode()
|
||||
}
|
||||
|
||||
func renderDbOption(ctx *middleware.Context) {
|
||||
ctx.Data["DbOptions"] = []string{"MySQL", "PostgreSQL", "SQLite3"}
|
||||
}
|
||||
|
||||
func Install(ctx *middleware.Context, form auth.InstallForm) {
|
||||
if base.InstallLock {
|
||||
ctx.Handle(404, "install.Install", errors.New("Installation is prohibited"))
|
||||
@@ -104,6 +108,13 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
|
||||
form.AppUrl = base.AppUrl
|
||||
}
|
||||
|
||||
renderDbOption(ctx)
|
||||
curDbValue := ""
|
||||
if models.EnableSQLite3 {
|
||||
curDbValue = "SQLite3" // Default when enabled.
|
||||
}
|
||||
ctx.Data["CurDbValue"] = curDbValue
|
||||
|
||||
auth.AssignForm(form, ctx.Data)
|
||||
ctx.HTML(200, "install")
|
||||
}
|
||||
@@ -117,6 +128,9 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
|
||||
ctx.Data["Title"] = "Install"
|
||||
ctx.Data["PageIsInstall"] = true
|
||||
|
||||
renderDbOption(ctx)
|
||||
ctx.Data["CurDbValue"] = form.Database
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "install")
|
||||
return
|
||||
@@ -129,7 +143,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
|
||||
|
||||
// Pass basic check, now test configuration.
|
||||
// Test database setting.
|
||||
dbTypes := map[string]string{"mysql": "mysql", "pgsql": "postgres", "sqlite": "sqlite3"}
|
||||
dbTypes := map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "SQLite3": "sqlite3"}
|
||||
models.DbCfg.Type = dbTypes[form.Database]
|
||||
models.DbCfg.Host = form.Host
|
||||
models.DbCfg.User = form.User
|
||||
|
||||
@@ -91,10 +91,23 @@ func Diff(ctx *middleware.Context, params martini.Params) {
|
||||
return isImage
|
||||
}
|
||||
|
||||
parents := make([]string, commit.ParentCount())
|
||||
for i := 0; i < commit.ParentCount(); i++ {
|
||||
sha, err := commit.ParentId(i)
|
||||
parents[i] = sha.String()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "repo.Diff", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["IsImageFile"] = isImageFile
|
||||
ctx.Data["Title"] = commit.Message() + " · " + base.ShortSha(commitId)
|
||||
ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId)
|
||||
ctx.Data["Commit"] = commit
|
||||
ctx.Data["Diff"] = diff
|
||||
ctx.Data["Parents"] = parents
|
||||
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)
|
||||
|
||||
@@ -87,7 +87,6 @@ func Releases(ctx *middleware.Context) {
|
||||
return
|
||||
}
|
||||
tags.rels[i].NumCommitsBehind = commitsCount - tags.rels[i].NumCommits
|
||||
tags.rels[i].Created = commit.Author.When
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,6 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
||||
}
|
||||
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treename)
|
||||
|
||||
if err != nil && err != git.ErrNotExist {
|
||||
ctx.Handle(404, "repo.Single(GetTreeEntryByPath)", err)
|
||||
return
|
||||
|
||||
@@ -66,7 +66,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)
|
||||
|
||||
ctx.Flash.Success("Your profile has been successfully updated.")
|
||||
ctx.Redirect("/user/setting")
|
||||
ctx.Redirect("/user/settings")
|
||||
}
|
||||
|
||||
func SettingSocial(ctx *middleware.Context) {
|
||||
@@ -122,7 +122,7 @@ func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
||||
ctx.Flash.Success("Password is changed successfully. You can now sign in via new password.")
|
||||
}
|
||||
|
||||
ctx.Redirect("/user/setting/password")
|
||||
ctx.Redirect("/user/settings/password")
|
||||
}
|
||||
|
||||
func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
@@ -166,7 +166,8 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
return
|
||||
}
|
||||
|
||||
k := &models.PublicKey{OwnerId: ctx.User.Id,
|
||||
k := &models.PublicKey{
|
||||
OwnerId: ctx.User.Id,
|
||||
Name: form.KeyName,
|
||||
Content: form.KeyContent,
|
||||
}
|
||||
@@ -181,7 +182,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
} else {
|
||||
log.Trace("%s User SSH key added: %s", ctx.Req.RequestURI, ctx.User.LowerName)
|
||||
ctx.Flash.Success("New SSH Key has been added!")
|
||||
ctx.Redirect("/user/setting/ssh")
|
||||
ctx.Redirect("/user/settings/ssh")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,18 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := models.LoginUserPlain(form.UserName, form.Password)
|
||||
var user *models.User
|
||||
var err error
|
||||
if base.Service.LdapAuth {
|
||||
user, err = models.LoginUserLdap(form.UserName, form.Password)
|
||||
if err != nil {
|
||||
log.Error("Fail to login through LDAP: %v", err)
|
||||
}
|
||||
}
|
||||
// try local if not LDAP or it's failed
|
||||
if !base.Service.LdapAuth || err != nil {
|
||||
user, err = models.LoginUserPlain(form.UserName, form.Password)
|
||||
}
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
log.Trace("%s Log in failed: %s/%s", ctx.Req.RequestURI, form.UserName, form.Password)
|
||||
@@ -133,27 +144,6 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||
ctx.Redirect("/")
|
||||
}
|
||||
|
||||
func oauthSignInPost(ctx *middleware.Context, sid int64) {
|
||||
ctx.Data["Title"] = "OAuth Sign Up"
|
||||
ctx.Data["PageIsSignUp"] = true
|
||||
|
||||
if _, err := models.GetOauth2ById(sid); err != nil {
|
||||
if err == models.ErrOauth2RecordNotExist {
|
||||
ctx.Handle(404, "user.oauthSignUp(GetOauth2ById)", err)
|
||||
} else {
|
||||
ctx.Handle(500, "user.oauthSignUp(GetOauth2ById)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsSocialLogin"] = true
|
||||
ctx.Data["username"] = ctx.Session.Get("socialName")
|
||||
ctx.Data["email"] = ctx.Session.Get("socialEmail")
|
||||
log.Trace("user.oauthSignUp(social ID): %v", ctx.Session.Get("socialId"))
|
||||
|
||||
ctx.HTML(200, "user/signup")
|
||||
}
|
||||
|
||||
func SignOut(ctx *middleware.Context) {
|
||||
ctx.Session.Delete("userId")
|
||||
ctx.Session.Delete("userName")
|
||||
@@ -169,8 +159,8 @@ func SignUp(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Sign Up"
|
||||
ctx.Data["PageIsSignUp"] = true
|
||||
|
||||
if base.Service.DisenableRegisteration {
|
||||
ctx.Data["DisenableRegisteration"] = true
|
||||
if base.Service.DisableRegistration {
|
||||
ctx.Data["DisableRegistration"] = true
|
||||
ctx.HTML(200, "user/signup")
|
||||
return
|
||||
}
|
||||
@@ -208,7 +198,7 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||
ctx.Data["Title"] = "Sign Up"
|
||||
ctx.Data["PageIsSignUp"] = true
|
||||
|
||||
if base.Service.DisenableRegisteration {
|
||||
if base.Service.DisableRegistration {
|
||||
ctx.Handle(403, "user.SignUpPost", nil)
|
||||
return
|
||||
}
|
||||
|
||||
13
serve.go
13
serve.go
@@ -53,6 +53,7 @@ func newLogger(execDir string) {
|
||||
}
|
||||
|
||||
qlog.SetOutput(f)
|
||||
//qlog.SetOutputLevel(qlog.Ldebug)
|
||||
qlog.Info("Start logging serv...")
|
||||
}
|
||||
|
||||
@@ -116,8 +117,8 @@ func runServ(k *cli.Context) {
|
||||
repoPath := strings.Trim(args, "'")
|
||||
rr := strings.SplitN(repoPath, "/", 2)
|
||||
if len(rr) != 2 {
|
||||
println("Unavilable repository", args)
|
||||
qlog.Fatalf("Unavilable repository %v", args)
|
||||
println("Unavailable repository", args)
|
||||
qlog.Fatalf("Unavailable repository %v", args)
|
||||
}
|
||||
repoUserName := rr[0]
|
||||
repoName := strings.TrimSuffix(rr[1], ".git")
|
||||
@@ -136,7 +137,7 @@ func runServ(k *cli.Context) {
|
||||
case isWrite:
|
||||
has, err := models.HasAccess(user.LowerName, path.Join(repoUserName, repoName), models.AU_WRITABLE)
|
||||
if err != nil {
|
||||
println("Inernel error:", err)
|
||||
println("Internal error:", err)
|
||||
qlog.Fatal(err)
|
||||
} else if !has {
|
||||
println("You have no right to write this repository")
|
||||
@@ -155,13 +156,13 @@ func runServ(k *cli.Context) {
|
||||
|
||||
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.AU_READABLE)
|
||||
if err != nil {
|
||||
println("Inernel error")
|
||||
println("Internal error")
|
||||
qlog.Fatal(err)
|
||||
}
|
||||
if !has {
|
||||
has, err = models.HasAccess(user.Name, repoPath, models.AU_WRITABLE)
|
||||
has, err = models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.AU_WRITABLE)
|
||||
if err != nil {
|
||||
println("Inernel error")
|
||||
println("Internal error")
|
||||
qlog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<dd>{{.AppUrl}}</dd>
|
||||
<dt>Domain</dt>
|
||||
<dd>{{.Domain}}</dd>
|
||||
<dt>Offline Mode</dt>
|
||||
<dd><i class="fa fa{{if .OfflineMode}}-check{{end}}-square-o"></i></dd>
|
||||
<hr/>
|
||||
<dt>Run User</dt>
|
||||
<dd>{{.RunUser}}</dd>
|
||||
@@ -26,6 +28,8 @@
|
||||
<hr/>
|
||||
<dt>Repository Root Path</dt>
|
||||
<dd>{{.RepoRootPath}}</dd>
|
||||
<dt>Script Type</dt>
|
||||
<dd>{{.ScriptType}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,8 +66,8 @@
|
||||
<dl class="dl-horizontal admin-dl-horizontal">
|
||||
<dt>Register Email Confirmation</dt>
|
||||
<dd><i class="fa fa{{if .Service.RegisterEmailConfirm}}-check{{end}}-square-o"></i></dd>
|
||||
<dt>Disenable Registeration</dt>
|
||||
<dd><i class="fa fa{{if .Service.DisenableRegisteration}}-check{{end}}-square-o"></i></dd>
|
||||
<dt>Disable Registration</dt>
|
||||
<dd><i class="fa fa{{if .Service.DisableRegistration}}-check{{end}}-square-o"></i></dd>
|
||||
<dt>Require Sign In View</dt>
|
||||
<dd><i class="fa fa{{if .Service.RequireSignInView}}-check{{end}}-square-o"></i></dd>
|
||||
<dt>Mail Notification</dt>
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
<div class="col-md-1" style="margin: -5px;">
|
||||
<a target="_blank" href="https://github.com/gogits/gogs"><i class="fa fa-github fa-2x"></i></a>
|
||||
</div>
|
||||
<p class="desc"></p>
|
||||
|
||||
<div class="col-md-5">
|
||||
<p class="desc"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{if .Repository.IsGoget}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}}
|
||||
|
||||
<!-- Stylesheets -->
|
||||
{{if IsProdMode}}
|
||||
{{if CdnMode}}
|
||||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
|
||||
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<nav class="nav">
|
||||
<a id="nav-logo" class="nav-item pull-left{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a>
|
||||
<a class="nav-item pull-left{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a>
|
||||
<a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}}
|
||||
<a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}}
|
||||
{{if .HasAccess}}<!-- <form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form">
|
||||
<div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
@@ -21,7 +21,7 @@
|
||||
<a id="nav-avatar" class="nav-item navbar-right{{if .PageIsUserProfile}} active{{end}}" href="{{.SignedUser.HomeLink}}" data-toggle="tooltip" data-placement="bottom" title="{{.SignedUserName}}">
|
||||
<img src="{{.SignedUser.AvatarLink}}?s=28" alt="user-avatar" title="username"/>
|
||||
</a>
|
||||
<a class="navbar-right nav-item{{if .PageIsUserSetting}} active{{end}}" href="/user/setting" data-toggle="tooltip" data-placement="bottom" title="Setting"><i class="fa fa-cogs fa-lg"></i></a>
|
||||
<a class="navbar-right nav-item{{if .PageIsUserSetting}} active{{end}}" href="/user/settings" data-toggle="tooltip" data-placement="bottom" title="Settings"><i class="fa fa-cogs fa-lg"></i></a>
|
||||
{{if .IsAdmin}}<a class="navbar-right nav-item{{if .PageIsAdmin}} active{{end}}" href="/admin" data-toggle="tooltip" data-placement="bottom" title="Admin"><i class="fa fa-gear fa-lg"></i></a>{{end}}
|
||||
<div class="navbar-right nav-item pull-right{{if .PageIsNewRepo}} active{{end}}" id="nav-repo-new" data-toggle="tooltip" data-placement="bottom" title="New Repo">
|
||||
<button type="button" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus-square fa-lg"></i></button>
|
||||
@@ -33,8 +33,8 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}<a id="nav-signin" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign In</a>
|
||||
<a id="nav-signup" class="nav-item navbar-right" href="/user/sign_up/">Sign Up</a>{{end}}
|
||||
{{else}}<a id="nav-signin" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/" rel="nofollow">Sign In</a>
|
||||
<a id="nav-signup" class="nav-item navbar-right" href="/user/sign_up/" rel="nofollow">Sign Up</a>{{end}}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
<label class="col-md-3 control-label">Database Type: </label>
|
||||
<div class="col-md-8">
|
||||
<select name="database" id="install-database" class="form-control">
|
||||
<option value="mysql">MySQL</option>
|
||||
<option value="pgsql">PostgreSQL</option>
|
||||
<option value="sqlite">SQLite3</option>
|
||||
{{if .CurDbValue}}<option value="{{.CurDbValue}}">{{.CurDbValue}}</option>{{end}}
|
||||
{{range .DbOptions}}
|
||||
{{if not (eq $.CurDbValue .)}}<option value="{{.}}">{{.}}</option>{{end}}
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="server-sql">
|
||||
<div class="server-sql {{if eq .CurDbValue "SQLite3"}}hide{{end}}">
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Host: </label>
|
||||
<div class="col-md-8">
|
||||
@@ -49,7 +50,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group pgsql-setting hide">
|
||||
<div class="form-group pgsql-setting {{if not (eq .CurDbValue "PostgreSQL")}}hide{{end}}">
|
||||
<label class="col-md-3 control-label">SSL Mode: </label>
|
||||
<div class="col-md-8">
|
||||
<select name="ssl_mode" class="form-control">
|
||||
@@ -61,7 +62,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sqlite-setting hide">
|
||||
<div class="sqlite-setting {{if not (eq .CurDbValue "SQLite3")}}hide{{end}}">
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Path: </label>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="filter-option">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-default issue-open{{if not .IsShowClosed}} active{{end}}" href="/issues?type={{.ViewType}}&repoid={{.RepoId}}">{{.OpenIssueCount}} Open</a>
|
||||
<a class="btn btn-default issue-close{{if .IsShowClosed}} active{{end}}" href="/issues?state=closed&type={{.ViewType}}&repoid={{.RepoId}}">{{.ClosedIssueCount}} Close</a>
|
||||
<a class="btn btn-default issue-close{{if .IsShowClosed}} active{{end}}" href="/issues?state=closed&type={{.ViewType}}&repoid={{.RepoId}}">{{.ClosedIssueCount}} Closed</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="issues list-group">
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
{{if .PublisherId}}
|
||||
<div class="col-md-2 text-right">
|
||||
{{if .IsPrerelease}}<span class="btn btn-warning status pre-release">Pre-Release</span>{{else}}<span class="btn btn-success status stable">Stable</span>{{end}}
|
||||
<a class="tag" href="{{$.RepoLink}}/src/{{.TagName}}"><i class="fa fa-tag"></i>{{.TagName}}</a>
|
||||
<a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a>
|
||||
<a class="tag" href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow"><i class="fa fa-tag"></i>{{.TagName}}</a>
|
||||
<a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<h4 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}">{{.Title}}</a></h4>
|
||||
@@ -30,19 +30,19 @@
|
||||
{{str2html .Note}}
|
||||
</div>
|
||||
<p class="download">
|
||||
<a class="btn btn-default" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip"><i class="fa fa-download"></i>Source Code (ZIP)</a>
|
||||
<a class="btn btn-default" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip" rel="nofollow"><i class="fa fa-download"></i>Source Code (ZIP)</a>
|
||||
<!-- <a class="btn btn-default" href="{release_download_link}"><i class="fa fa-download"></i>Source Code (TAR.GZ)</a> -->
|
||||
</p>
|
||||
<span class="dot"> </span>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="col-md-2 text-right">
|
||||
<a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a>
|
||||
<a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<h5 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}">{{.TagName}}</a><i class="fa fa-tag"></i></h5>
|
||||
<h5 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow">{{.TagName}}</a><i class="fa fa-tag"></i></h5>
|
||||
<p class="download">
|
||||
<a class="download-link" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip"><i class="fa fa-download"></i>zip</a>
|
||||
<a class="download-link" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip" rel="nofollow"><i class="fa fa-download"></i>zip</a>
|
||||
<!-- <a class="download-link" href="{release_download_link}"><i class="fa fa-download"></i>tar.gz</a> -->
|
||||
</p>
|
||||
<span class="dot"> </span>
|
||||
@@ -50,30 +50,6 @@
|
||||
{{end}}
|
||||
</li>
|
||||
{{end}}
|
||||
<!-- <li class="release-item clearfix" id="release-{release_id}">
|
||||
<div class="col-md-2 text-right">
|
||||
<span class="btn btn-warning status pre-release">Pre-Release</span>
|
||||
<a class="tag" href="{commit_link}"><i class="fa fa-tag"></i>release tag</a>
|
||||
<a class="commit" href="{commit_link}"><i class="fa fa-code"></i>commit-sha</a>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<h4 class="title"><a href="{release_single_link}">Release Title</a></h4>
|
||||
<p class="info">
|
||||
<span class="author"><img class="avatar" src="http://1.gravatar.com/avatar/f72f7454ce9d710baa506394f68f4132" alt="" width="20">
|
||||
<a href="/user/fuxiaohei">fuxiaohei</a></span>
|
||||
<span class="time">1 week ago</span>
|
||||
<span class="ahead"><strong>0</strong> commits since this tag</span>
|
||||
</p>
|
||||
<div class="markdown desc">
|
||||
release descriptions, support markdown content
|
||||
</div>
|
||||
<p class="download">
|
||||
<a class="btn btn-default" href="{release_download_link}"><i class="fa fa-download"></i>Source Code (ZIP)</a>
|
||||
<a class="btn btn-default" href="{release_download_link}"><i class="fa fa-download"></i>Source Code (TAR.GZ)</a>
|
||||
</p>
|
||||
<span class="dot"> </span>
|
||||
</div>
|
||||
</li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<tr>
|
||||
<td class="author"><img class="avatar" src="{{AvatarLink .Author.Email}}" alt=""/><a href="/user/email2user?email={{.Author.Email}}">{{.Author.Name}}</a></td>
|
||||
<td class="sha"><a rel="nofollow" class="label label-success" href="/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||
<td class="message">{{.Message}} </td>
|
||||
<td class="message">{{.Summary}} </td>
|
||||
<td class="date">{{TimeSince .Author.When}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
@@ -41,8 +41,8 @@
|
||||
</table>
|
||||
</div>
|
||||
{{if not .IsSearchPage}}<ul class="pagination" id="commits-pager">
|
||||
{{if .LastPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.LastPageNum}}">« Newer</a></li>{{end}}
|
||||
{{if .NextPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.NextPageNum}}">» Older</a></li>{{end}}
|
||||
{{if .LastPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.LastPageNum}}" rel="nofollow">« Newer</a></li>{{end}}
|
||||
{{if .NextPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.NextPageNum}}" rel="nofollow">» Older</a></li>{{end}}
|
||||
</ul>{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,12 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<span class="pull-right">
|
||||
commit <span class="label label-default sha">{{ShortSha .CommitId}}</span>
|
||||
<ul class="list-unstyled">
|
||||
{{range .Parents}}
|
||||
<li>parent <a href="{{$.RepoLink}}/commit/{{.}}"><span class="label label-default sha">{{ShortSha .}}</span></a></li>
|
||||
{{end}}
|
||||
<li>commit <span class="label label-default sha">{{ShortSha .CommitId}}</span></li>
|
||||
</ul>
|
||||
</span>
|
||||
<p class="author">
|
||||
<img class="avatar" src="{{AvatarLink .Commit.Author.Email}}" alt=""/>
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
<button class="btn btn-default" type="button" data-toggle="tooltip" title="copy to clipboard" data-placement="top" data-init="copy" data-copy-val="val" data-copy-from="#repo-clone-ipt"><i class="fa fa-copy"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p>
|
||||
<p class="help-block text-center">Need help cloning? Visit <a target="_blank" href="https://help.github.com/articles/fork-a-repo">Help</a>!</p>
|
||||
<hr/>
|
||||
<div class="clone-zip text-center">
|
||||
<a class="btn btn-success btn-lg" href="{{.RepoLink}}/archive/{{.BranchName}}/{{.Repository.Name}}.zip"><i class="fa fa-suitcase"></i>Download ZIP</a>
|
||||
<a class="btn btn-success btn-lg" href="{{.RepoLink}}/archive/{{.BranchName}}/{{.Repository.Name}}.zip" rel="nofollow"><i class="fa fa-suitcase"></i>Download ZIP</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,37 +14,38 @@
|
||||
{{if not .ReadmeInSingle}}
|
||||
<div class="btn-group pull-right">
|
||||
<a class="btn btn-default hidden" href="#">Edit</a>
|
||||
<a class="btn btn-default" href="{{.FileLink}}">Raw</a>
|
||||
<a class="btn btn-default" href="{{.FileLink}}" rel="nofollow">Raw</a>
|
||||
<a class="btn btn-default hidden" href="#">Blame</a>
|
||||
<a class="btn btn-default hidden" href="#">History</a>
|
||||
<a class="btn btn-danger hidden" href="#">Delete</a>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{if not .FileIsText}}
|
||||
<div class="panel-footer text-center">
|
||||
{{if .IsImageFile}}
|
||||
<img src="{{.FileLink}}">
|
||||
{{else}}
|
||||
<a href="{{.FileLink}}" class="btn btn-default">View Raw</a>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{if .ReadmeExist}}
|
||||
<div class="panel-body file-body markdown">
|
||||
{{.FileContent|str2html}}
|
||||
</div>
|
||||
<div class="panel-body file-body file-code code-view">
|
||||
{{if .IsImageFile}}
|
||||
<img src="{{.FileLink}}">
|
||||
{{else}}
|
||||
<div class="panel-body file-body file-code code-view">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="lines-num"></td>
|
||||
<td class="lines-code markdown"><pre class="prettyprint linenums{{if .FileExt}} lang-{{.FileExt}}{{end}}">{{.FileContent}}</pre></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<a href="{{.FileLink}}" rel="nofollow" class="btn btn-default">View Raw</a>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{if .ReadmeExist}}
|
||||
<div class="panel-body file-body markdown">
|
||||
{{.FileContent|str2html}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="panel-body file-body file-code code-view">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="lines-num"></td>
|
||||
<td class="lines-code markdown"><pre class="prettyprint linenums{{if .FileExt}} lang-{{.FileExt}}{{end}}">{{.FileContent}}</pre></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="panel panel-default info-box">
|
||||
<div class="panel-heading info-head">
|
||||
<a href="/{{.Username}}/{{.Reponame}}/commit/{{.LastCommit.Id}}">{{.LastCommit.Message}}</a>
|
||||
<a href="/{{.Username}}/{{.Reponame}}/commit/{{.LastCommit.Id}}" rel="nofollow">{{.LastCommit.Summary}}</a>
|
||||
</div>
|
||||
<div class="panel-body info-content">
|
||||
<a href="/user/{{.LastCommit.Author.Name}}">{{.LastCommit.Author.Name}}</a> <span class="text-muted">{{TimeSince .LastCommit.Author.When}}</span>
|
||||
@@ -36,7 +36,7 @@
|
||||
</span>
|
||||
</td>
|
||||
<td class="text">
|
||||
<span class="wrap"><a rel="nofollow" href="/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}">{{$commit.Message}}</a></span>
|
||||
<span class="wrap"><a rel="nofollow" href="/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}">{{$commit.Summary}}</a></span>
|
||||
</td>
|
||||
<td class="date">
|
||||
<span class="wrap">{{TimeSince $commit.Committer.When}}</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div id="user-setting-container" class="col-md-9">
|
||||
<div id="setting-pwd">
|
||||
<h4>Password</h4>
|
||||
<form class="form-horizontal" id="password-form" method="post" action="/user/setting/password">
|
||||
<form class="form-horizontal" id="password-form" method="post" action="/user/settings/password">
|
||||
{{.CsrfTokenHtml}}
|
||||
{{template "base/alert" .}}
|
||||
<div class="form-group">
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
<div class="profile-info">
|
||||
<ul class="list-group">
|
||||
{{if .Owner.Location}}
|
||||
<li class="list-group-item"><i class="fa fa-thumb-tack"></i>{{.Owner.Location}}</li>
|
||||
<li class="list-group-item"><i class="fa fa-thumb-tack"></i>{{.Owner.Location}}</li>
|
||||
{{end}}
|
||||
{{if .Owner.Email}}
|
||||
<li class="list-group-item"><i class="fa fa-envelope"></i><a href="mailto:{{.Owner.Email}}">{{.Owner.Email}}</a></li>
|
||||
<li class="list-group-item"><i class="fa fa-envelope"></i><a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a></li>
|
||||
{{end}}
|
||||
{{if .Owner.Website}}
|
||||
<li class="list-group-item"><i class="fa fa-link"></i><a target="_blank" href="{{.Owner.Website}}">{{.Owner.Website}}</a></li>
|
||||
<li class="list-group-item"><i class="fa fa-link"></i><a target="_blank" href="{{.Owner.Website}}">{{.Owner.Website}}</a></li>
|
||||
{{end}}
|
||||
<li class="list-group-item"><i class="fa fa-clock-o"></i>Joined on {{DateFormat .Owner.Created "M d, Y"}}</li>
|
||||
<!-- <hr> -->
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ul>
|
||||
<div class="modal fade" id="ssh-add-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form class="modal-content form-horizontal" id="ssh-form" method="post" action="/user/setting/ssh/">
|
||||
<form class="modal-content form-horizontal" id="ssh-form" method="post" action="/user/settings/ssh/">
|
||||
{{.CsrfTokenHtml}}
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div id="user-setting-container" class="col-md-9">
|
||||
<div id="setting-pwd">
|
||||
<h4>Account Profile</h4>
|
||||
<form class="form-horizontal" id="password-form" method="post" action="/user/setting">
|
||||
<form class="form-horizontal" id="password-form" method="post" action="/user/settings">
|
||||
{{.CsrfTokenHtml}}
|
||||
{{template "base/alert" .}}
|
||||
<p>Your Email address is public and will be used for any account related notifications, and any web based operations made via the site.</p>
|
||||
@@ -13,7 +13,7 @@
|
||||
<label class="col-md-2 control-label" for="user-setting-username">Username<strong class="text-danger">*</strong></label>
|
||||
<div class="col-md-8">
|
||||
<input name="username" class="form-control" placeholder="Type your user name" required="required" value="{{.SignedUser.Name}}" title="{{.SignedUser.Name}}" id="user-setting-username">
|
||||
<p class="help-block hidden"><span class="text-danger">Cautious : </span>your username is changing !</p>
|
||||
<p class="help-block hidden"><span class="text-danger">Caution : </span>your username is changing !</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<div id="user-setting-nav" class="col-md-3">
|
||||
<h4>Account Setting</h4>
|
||||
<h4>Account Settings</h4>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item{{if .IsUserPageSetting}} list-group-item-success{{end}}"><a href="/user/setting">Account Profile</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingSocial}} list-group-item-success{{end}}"><a href="/user/setting/social">Social Account</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingPasswd}} list-group-item-success{{end}}"><a href="/user/setting/password">Password</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSetting}} list-group-item-success{{end}}"><a href="/user/settings">Account Profile</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingSocial}} list-group-item-success{{end}}"><a href="/user/settings/social">Social Account</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingPasswd}} list-group-item-success{{end}}"><a href="/user/settings/password">Password</a></li>
|
||||
<!-- <li class="list-group-item{{if .IsUserPageSettingNotify}} list-group-item-success{{end}}"><a href="/user/setting/notification">Notifications</a></li> -->
|
||||
<li class="list-group-item{{if .IsUserPageSettingSSH}} list-group-item-success{{end}}"><a href="/user/setting/ssh/">SSH Keys</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingSSH}} list-group-item-success{{end}}"><a href="/user/settings/ssh/">SSH Keys</a></li>
|
||||
<!-- <li class="list-group-item{{if .IsUserPageSettingSecurity}} list-group-item-success{{end}}"><a href="/user/setting/security">Security</a></li> -->
|
||||
<li class="list-group-item{{if .IsUserPageSettingDelete}} list-group-item-success{{end}}"><a href="/user/delete">Delete Account</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
{{end}}
|
||||
{{template "base/alert" .}}
|
||||
<div class="form-group {{if .Err_UserName}}has-error has-feedback{{end}}">
|
||||
<label class="col-md-4 control-label">Username: </label>
|
||||
<label class="col-md-4 control-label">Username or e-mail: </label>
|
||||
<div class="col-md-6">
|
||||
<input name="username" class="form-control" placeholder="Type your username" value="{{.username}}" required="required">
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="container" id="body">
|
||||
<form action="/user/sign_up" method="post" class="form-horizontal card" id="login-card">
|
||||
{{.CsrfTokenHtml}}
|
||||
{{if .DisenableRegisteration}}
|
||||
{{if .DisableRegistration}}
|
||||
Sorry, registration has been disabled. Please contact the site administrator.
|
||||
{{else}}
|
||||
{{if .IsSocialLogin}}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
command: go test -v {}
|
||||
include: ^.+_test\.go$
|
||||
path: ./
|
||||
depth: 1
|
||||
verbose: true
|
||||
timeout: 1m
|
||||
reload: false
|
||||
html: test.html
|
||||
notify: []
|
||||
@@ -1,13 +0,0 @@
|
||||
## Gogs Test
|
||||
|
||||
This is for developers.
|
||||
|
||||
## Prepare Environment
|
||||
|
||||
go get -u github.com/shxsun/travelexec
|
||||
# start gogs server
|
||||
gogs web
|
||||
|
||||
## Start Testing
|
||||
|
||||
travelexec
|
||||
@@ -1,17 +0,0 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
r, err := http.Get("http://localhost:3000/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer r.Body.Close()
|
||||
if r.StatusCode != http.StatusOK {
|
||||
t.Error(r.StatusCode)
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ var CmdUpdate = cli.Command{
|
||||
Name: "update",
|
||||
Usage: "This command just should be called by ssh shell",
|
||||
Description: `
|
||||
gogs serv provide access auth for repositories`,
|
||||
gogs update get pushed info and insert into database`,
|
||||
Action: runUpdate,
|
||||
Flags: []cli.Flag{},
|
||||
}
|
||||
|
||||
6
web.go
6
web.go
@@ -94,8 +94,8 @@ func runWeb(*cli.Context) {
|
||||
m.Group("/user", func(r martini.Router) {
|
||||
r.Get("/delete", user.Delete)
|
||||
r.Post("/delete", user.DeletePost)
|
||||
r.Get("/setting", user.Setting)
|
||||
r.Post("/setting", bindIgnErr(auth.UpdateProfileForm{}), user.SettingPost)
|
||||
r.Get("/settings", user.Setting)
|
||||
r.Post("/settings", bindIgnErr(auth.UpdateProfileForm{}), user.SettingPost)
|
||||
}, reqSignIn)
|
||||
m.Group("/user", func(r martini.Router) {
|
||||
r.Get("/feeds", middleware.Bind(auth.FeedsForm{}), user.Feeds)
|
||||
@@ -105,7 +105,7 @@ func runWeb(*cli.Context) {
|
||||
r.Post("/forget_password", user.ForgotPasswdPost)
|
||||
r.Get("/logout", user.SignOut)
|
||||
})
|
||||
m.Group("/user/setting", func(r martini.Router) {
|
||||
m.Group("/user/settings", func(r martini.Router) {
|
||||
r.Get("/social", user.SettingSocial)
|
||||
r.Get("/password", user.SettingPassword)
|
||||
r.Post("/password", bindIgnErr(auth.UpdatePasswdForm{}), user.SettingPasswordPost)
|
||||
|
||||
Reference in New Issue
Block a user