From 139a6f80dc258bba1e61aa9584787b86ac4addf3 Mon Sep 17 00:00:00 2001
From: skyblue <ssx205@gmail.com>
Date: Sun, 23 Mar 2014 23:22:35 +0800
Subject: [PATCH 01/26] update my config

---
 conf/app.ini | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/conf/app.ini b/conf/app.ini
index ab9f6dc4bb..b9472b551a 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -2,7 +2,7 @@
 APP_NAME = Gogs: Go Git Service
 APP_LOGO = img/favicon.png
 ; !!MUST CHANGE TO YOUR USER NAME!!
-RUN_USER = lunny
+RUN_USER = skyblue
 ; Either "dev", "prod" or "test", default is "dev"
 RUN_MODE = dev
 
@@ -164,4 +164,4 @@ RECEIVERS =
 [log.database]
 LEVEL = 
 Driver = 
-CONN = 
\ No newline at end of file
+CONN = 

From 7048ea45279cd96f88845d83fe7cef6fbb545fcf Mon Sep 17 00:00:00 2001
From: skyblue <ssx205@gmail.com>
Date: Tue, 25 Mar 2014 18:34:57 +0800
Subject: [PATCH 02/26] update avatar, remove gzip request header

---
 modules/avatar/avatar.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go
index 0ba20294af..3b423a6d15 100644
--- a/modules/avatar/avatar.go
+++ b/modules/avatar/avatar.go
@@ -251,8 +251,8 @@ var client = &http.Client{}
 
 func (this *thunderTask) fetch() error {
 	req, _ := http.NewRequest("GET", this.Url, nil)
-	req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
-	req.Header.Set("Accept-Encoding", "gzip,deflate,sdch")
+	req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8")
+	req.Header.Set("Accept-Encoding", "deflate,sdch")
 	req.Header.Set("Accept-Language", "zh-CN,zh;q=0.8")
 	req.Header.Set("Cache-Control", "no-cache")
 	req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36")

From 2a2f025388b2f47cff4162adc207af2ba68d64d9 Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 18:44:37 +0800
Subject: [PATCH 03/26] change css name style

---
 public/css/gogs.css              | 202 ++++++++++++++++---------------
 public/js/app.js                 |  10 +-
 templates/admin/config.tmpl      |   4 +-
 templates/admin/dashboard.tmpl   |   4 +-
 templates/admin/nav.tmpl         |   2 +-
 templates/admin/repos.tmpl       |   4 +-
 templates/admin/users.tmpl       |   4 +-
 templates/admin/users/edit.tmpl  |   4 +-
 templates/admin/users/new.tmpl   |   4 +-
 templates/base/navbar.tmpl       |  26 ++--
 templates/help.tmpl              |   4 +-
 templates/home.tmpl              |   2 +-
 templates/install.tmpl           |   4 +-
 templates/issue/create.tmpl      |   4 +-
 templates/repo/branches.tmpl     |   4 +-
 templates/repo/commits.tmpl      |   4 +-
 templates/repo/create.tmpl       |   4 +-
 templates/repo/diff.tmpl         |   4 +-
 templates/repo/issues.tmpl       |   4 +-
 templates/repo/list.tmpl         |   2 +-
 templates/repo/nav.tmpl          |   8 +-
 templates/repo/pulls.tmpl        |   4 +-
 templates/repo/setting.tmpl      |   6 +-
 templates/repo/single.tmpl       |   4 +-
 templates/repo/toolbar.tmpl      |   2 +-
 templates/status/200.tmpl        |   2 +-
 templates/status/404.tmpl        |   2 +-
 templates/status/500.tmpl        |   2 +-
 templates/user/active.tmpl       |   4 +-
 templates/user/dashboard.tmpl    |   8 +-
 templates/user/delete.tmpl       |  10 +-
 templates/user/issues.tmpl       |   4 +-
 templates/user/notification.tmpl |   4 +-
 templates/user/password.tmpl     |   8 +-
 templates/user/profile.tmpl      |  12 +-
 templates/user/publickey.tmpl    |  12 +-
 templates/user/pulls.tmpl        |   4 +-
 templates/user/security.tmpl     |   4 +-
 templates/user/setting.tmpl      |   8 +-
 templates/user/setting_nav.tmpl  |   2 +-
 templates/user/signin.tmpl       |   6 +-
 templates/user/signup.tmpl       |   4 +-
 templates/user/stars.tmpl        |   4 +-
 43 files changed, 214 insertions(+), 210 deletions(-)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index 2254ef5a24..c8c5d87b8d 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -52,14 +52,14 @@ html, body {
 }
 
 /* gogits nav header */
-.gogs-masthead {
+.masthead {
     background-color: #428bca;
     box-shadow: inset 0 -2px 5px rgba(0, 0, 0, .1);
     margin: 0;
 }
 
 /* gogits nav item link */
-.gogs-nav-item {
+.nav-item {
     position: relative;
     display: inline-block;
     padding: 10px;
@@ -69,39 +69,39 @@ html, body {
     height: 46px;
 }
 
-#gogs-nav-logo {
+#nav-logo {
     padding-left: 0;
     padding-right: 0;
     margin-right: 10px;
 }
 
-.gogs-nav-item:hover,
-.gogs-nav-item:focus {
+.nav-item:hover,
+.nav-item:focus {
     color: #fff;
     text-decoration: none;
 }
 
-.gogs-nav-item.navbar-right {
+.nav-item.navbar-right {
     margin-top: 3px;
 }
 
-.gogs-nav-item.navbar-btn {
+.nav-item.navbar-btn {
     cursor: pointer;
     margin-top: 8px;
     padding: 5px 15px;
     height: 30px;
 }
 
-.gogs-nav-item.navbar-right .fa {
+.nav-item.navbar-right .fa {
     margin: 0;
 }
 
 /* gogits nav item active status */
-.gogs-nav .active {
+.nav .active {
     color: #fff;
 }
 
-.gogs-nav .active:after {
+.nav .active:after {
     position: absolute;
     bottom: -1px;
     left: 50%;
@@ -115,29 +115,29 @@ html, body {
     border-left: 5px solid transparent;
 }
 
-#gogs-nav-logo:after {
+#nav-logo:after {
     bottom: -4px !important;
 }
 
-#gogs-nav-avatar:after {
+#nav-avatar:after {
     bottom: -4px !important;
 }
 
-.gogs-nav .tooltip {
+.nav .tooltip {
     border: none;
 }
 
 /* gogits logo */
-#gogs-nav-avatar {
+#nav-avatar {
     margin-top: 0;
 }
 
-#gogs-logo, #gogs-nav-avatar img {
+#logo, #nav-avatar img {
     width: 28px;
     height: 28px;
 }
 
-#gogs-nav-out {
+#nav-out {
     margin-top: 10px;
     padding: 5px 0;
     margin-left: 10px;
@@ -145,56 +145,56 @@ html, body {
     float: right;
 }
 
-#gogs-nav-signin, #gogs-nav-signup {
+#nav-signin, #nav-signup {
     float: right;
     margin-left: 1em;
 }
 
-#gogs-nav-out .fa {
+#nav-out .fa {
     vertical-align: -10%;
     margin: 0 .5em;
 }
 
 /* gogits body */
-#gogs-body {
+#body {
     padding-bottom: 60px;
     margin-top: 30px;
 }
 
-#gogs-body .btn-default {
+#body .btn-default {
     background-color: #FFF;
     background-image: linear-gradient(to bottom, #FFF 0, #FAFAFA 100%);
 }
 
-#gogs-body-nav {
+#body-nav {
     background-color: #FFF;
     border-bottom: 1px solid #DDD;
     height: 66px
 }
 
-#gogs-body-nav .nav {
+#body-nav .nav {
     font-size: 14px;
     margin-top: 12px;
 }
 
-#gogs-body-nav .nav-pills li a {
+#body-nav .nav-pills li a {
     color: #444;
 }
 
-#gogs-body-nav .nav-pills li.active a {
+#body-nav .nav-pills li.active a {
     font-weight: bold;
     border-bottom: 2px solid #d26911;
     background-color: transparent;
     color: #444;
 }
 
-#gogs-body-nav .nav-pills li:hover a {
+#body-nav .nav-pills li:hover a {
     background-color: transparent;
     text-decoration: underline;
 }
 
 /* gogits login card */
-.gogs-card {
+.card {
     margin: auto;
     padding: 30px;
     background: #fff;
@@ -203,87 +203,87 @@ html, body {
     box-sizing: border-box;
 }
 
-.gogs-card h3 {
+.card h3 {
     margin-top: 0;
     margin-bottom: 30px;
     padding-bottom: 20px;
     border-bottom: 1px solid #ccc;
 }
 
-#gogs-login-card {
+#login-card {
     width: 600px;
 }
 
-#gogs-login-card .form-control {
+#login-card .form-control {
     padding: 6px 12px;
     box-sizing: content-box;
 }
 
-#gogs-login-card .control-label {
+#login-card .control-label {
     height: 44px;
     line-height: 30px;
 }
 
-#gogs-install-card{
+#install-card {
     width: 800px;
 }
 
-#gogs-install-card .form-group {
+#install-card .form-group {
     margin-left: 0;
     margin-right: 0;
 }
 
-.gogs-card .btn {
+.card .btn {
     cursor: pointer;
     margin-right: 1.2em;
 }
 
-#gogs-social-login {
+#social-login {
     margin-top: 30px;
     padding-top: 20px;
     border-top: 1px solid #ccc;
 }
 
-#gogs-social-login .btn {
+#social-login .btn {
     float: none;
     margin: auto;
 }
 
 /* gogs-user-profile */
 
-#gogs-user-avatar {
+#user-avatar {
     width: 200px;
     height: 200px;
     border-radius: 6px;
 }
 
-#gogs-user-avatar-commit {
+#user-avatar-commit {
     width: 16px;
     height: 16px;
     border-radius: 2px;
 }
 
-#gogs-user-name {
+#user-name {
     margin-top: 20px;
     font-size: 1.6em;
     font-weight: bold;
     margin-bottom: 20px;
 }
 
-#gogs-user-profile .profile-info .list-group-item {
+#user-profile .profile-info .list-group-item {
     background-color: transparent;
     padding-top: 18px;
     color: #666;
 }
 
-#gogs-user-profile .profile-info .list-group-item a {
+#user-profile .profile-info .list-group-item a {
     margin: 0;
     padding: 0;
     display: inline;
     color: #0093c4;
 }
 
-#gogs-user-profile .profile-info .list-group {
+#user-profile .profile-info .list-group {
     border-top: 1px solid #ccc;
     padding-bottom: 18px;
     border-bottom: 1px solid #ccc;
@@ -291,50 +291,50 @@ html, body {
     padding-right: 18px;
 }
 
-#gogs-user-activity .tab-pane {
+#user-activity .tab-pane {
     padding: 20px;
 }
 
-#gogs-user-act-tabs li.active a {
+#user-act-tabs li.active a {
     border-bottom-color: #ddd;
 }
 
 /* gogits repo create */
 
-#gogs-repo-create {
+#repo-create {
     width: 800px;
 }
 
-#gogs-repo-create textarea[name=desc] {
+#repo-create textarea[name=desc] {
     height: 8em;
 }
 
 /* gogits user setting */
 
-#gogs-user-setting-nav > h4, #gogs-user-setting-container > h4, #gogs-user-setting-container > div > h4,
-#gogs-ssh-keys > h4, #gogs-user-delete > h4, #gogs-repo-setting-container .tab-pane > h4 {
+#user-setting-nav > h4, #user-setting-container > h4, #user-setting-container > div > h4,
+#ssh-keys > h4, #user-delete > h4, #repo-setting-container .tab-pane > h4 {
     padding-bottom: 18px;
     margin-bottom: 18px;
     border-bottom: 1px solid #CCC;
 }
 
-#gogs-user-setting-nav .list-group .list-group-item a {
+#user-setting-nav .list-group .list-group-item a {
     margin-left: 0;
     padding: .6em;
     font-size: 14px;
     color: #3B73AF;
 }
 
-#gogs-user-setting-nav .list-group .list-group-item {
+#user-setting-nav .list-group .list-group-item {
     background-color: transparent;
 }
 
-#gogs-user-setting-nav .list-group .list-group-item-success a {
+#user-setting-nav .list-group .list-group-item-success a {
     font-weight: bold;
     color: #444;
 }
 
-.gogs-admin-nav {
+.admin-nav {
     background-color: #FFF;
     padding-top: 10px;
     padding-left: 0;
@@ -342,49 +342,49 @@ html, body {
     border: 1px solid #D8D8D8;
 }
 
-.gogs-admin-nav li {
+.admin-nav li {
     margin-bottom: 8px;
     border-left: 4px solid transparent;
 }
 
-.gogs-admin-nav li:hover {
+.admin-nav li:hover {
     border-left-color: #EEE;
 }
 
-.gogs-admin-nav li.active:hover {
+.admin-nav li.active:hover {
     border-left: 4px solid #DD4B39;
 }
 
-#gogs-repo-setting-container .form-horizontal label {
+#repo-setting-container .form-horizontal label {
     line-height: 30px;
 }
 
 /* gogits user ssh keys */
 
-#gogs-ssh-keys .list-group-item {
+#ssh-keys .list-group-item {
     padding: 15px 0;
     border-bottom: 1px solid #DDD;
 }
 
-#gogs-ssh-keys .list-group-item .delete {
+#ssh-keys .list-group-item .delete {
     margin: -5px 50px 0;
 }
 
-#gogs-ssh-keys .list-group-item:after {
+#ssh-keys .list-group-item:after {
     clear: both;
 }
 
-#gogs-ssh-keys .name {
+#ssh-keys .name {
     font-size: 14px;
     font-weight: bold;
 }
 
-#gogs-ssh-keys .print {
+#ssh-keys .print {
     padding-left: 1em;
     color: #888;
 }
 
-#gogs-ssh-add {
+#ssh-add {
     display: inline-block;
     color: white;
     cursor: pointer;
@@ -392,25 +392,25 @@ html, body {
     border-radius: 3px;
 }
 
-#gogs-ssh-form textarea {
+#ssh-form textarea {
     height: 16em;
 }
 
-/* #gogs-feed */
+/* #feed */
 
-#gogs-feed-right .repo-panel .panel-heading .btn {
+#feed-right .repo-panel .panel-heading .btn {
     margin-top: -4px;
 }
 
-#gogs-feed-right .repo-panel .panel-body {
+#feed-right .repo-panel .panel-body {
     padding: 0;
 }
 
-#gogs-feed-right .repo-panel .list-group {
+#feed-right .repo-panel .list-group {
     margin-bottom: 0;
 }
 
-#gogs-feed-right .repo-panel .list-group-item a {
+#feed-right .repo-panel .list-group-item a {
     display: block;
     margin-left: 0;
     background-color: transparent;
@@ -418,11 +418,11 @@ html, body {
     font-weight: bold;
 }
 
-#gogs-feed-right .repo-panel .list-group-item .fa {
+#feed-right .repo-panel .list-group-item .fa {
     color: #666;
 }
 
-#gogs-feed-right .repo-panel .list-group-item {
+#feed-right .repo-panel .list-group-item {
     font-size: 14px;
     line-height: 32px;
     border-bottom: 1px solid #DDD;
@@ -430,97 +430,101 @@ html, body {
     clear: both;
 }
 
-#gogs-feed-right .repo-panel .list-group-item:last-child {
+#feed-right .repo-panel .list-group-item:last-child {
     border-bottom: none;
 }
 
-#gogs-feed-right .repo-panel .list-group-item:hover {
+#feed-right .repo-panel .list-group-item:hover {
     background-color: #eafffd;
     background-color: rgba(65, 131, 196, 0.1);
 }
 
-#gogs-feed-right .repo-panel span.stars {
+#feed-right .repo-panel span.stars {
     color: #666;
     margin-right: 1em;
 }
 
 /* gogits repo single page */
 
-#gogs-body-nav.gogs-repo-nav {
+#body-nav.repo-nav {
     padding-top: 16px;
     padding-bottom: 30px;
     height: auto;
 }
 
-.gogs-repo-nav .name {
+.repo-nav .name {
     margin-top: 15px;
 }
 
-.gogs-repo-nav .desc {
+.repo-nav .desc {
     color: #888;
     margin-bottom: 0;
 }
 
-.gogs-repo-nav h3 .fa {
+.repo-nav h3 .fa {
     color: #BBB;
     margin-left: 0;
 }
 
-.gogs-repo-nav .actions {
+.repo-nav .actions {
     padding-top: 20px;
 }
 
-.gogs-repo-nav .btn-default {
+.repo-nav .btn-default {
     font-family: Tahoma, Arial, sans-serif;
 }
 
-#gogs-repo-watching .dropdown-menu {
+#repo-watching .dropdown-menu {
     width: 280px;
     padding: 0;
 }
 
-#gogs-repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header, #gogs-repo-watching .dropdown-item .dropdown-header.text-primary {
+#repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header, #repo-watching .dropdown-item .dropdown-header.text-primary {
     color: rgb(65, 131, 196);
     cursor: pointer;
 }
 
-#gogs-repo-watching .dropdown-menu .description {
+#repo-watching .dropdown-menu .description {
     padding: 0 20px;
     color: #888;
 }
 
-#gogs-repo-watching .dropdown-menu .dropdown-header {
+#repo-watching .dropdown-menu .dropdown-header {
     color: #444;
     font-weight: bold;
     font-size: 14px;
     margin-bottom: 4px;
 }
 
-#gogs-repo-toolbar {
+#repo-toolbar {
     border-bottom: 1px solid #DDD;
     background-color: #FFF;
     height: 40px;
     font-size: 14px;
 }
 
-#gogs-repo-toolbar .navbar-default {
+#repo-toolbar .navbar-default {
     border: none;
     height: 39px;
 }
 
-#gogs-repo-toolbar .nav > li > a {
+#repo-toolbar .nav > li > a {
     height: 39px;
 }
 
-#gogs-repo-toolbar .navbar-toolbar.navbar-default .navbar-nav > .active > a:after {
+#repo-toolbar .nav .active {
+    color: #F6F6F6;
+}
+
+#repo-toolbar .nav > .active > a:after {
     border-bottom-color: #999;
 }
 
-#gogs-repo-toolbar .navbar.nav-toolbar {
+#repo-toolbar .navbar.nav-toolbar {
     margin-bottom: 0;
 }
 
-#gogs-repo-toolbar .navbar-collapse {
+#repo-toolbar .navbar-collapse {
     padding: 0;
 }
 
@@ -588,29 +592,29 @@ html, body {
     min-width: 200px;
 }
 
-#gogs-repo-clone .dropdown-menu {
+#repo-clone .dropdown-menu {
     width: 400px;
     padding: 20px;
 }
 
-#gogs-repo-clone .input-group {
+#repo-clone .input-group {
     margin-bottom: 15px;
 }
 
-/* #gogs-source */
-#gogs-source {
+/* #source */
+#source {
     margin-top: -20px;
 }
 
-#gogs-source .source-toolbar:after {
+#source .source-toolbar:after {
     clear: both;
 }
 
-#gogs-source .source-toolbar .branch-switch {
+#source .source-toolbar .branch-switch {
     display: inline-block;
 }
 
-#gogs-source .source-toolbar .breadcrumb {
+#source .source-toolbar .breadcrumb {
     margin: 0 .5em;
     padding: 6px 15px;
     font-size: 16px;
@@ -619,9 +623,9 @@ html, body {
     background-color: transparent;
 }
 
-#gogs-source .source-toolbar,
-#gogs-source .info-box,
-#gogs-source .file-content {
+#source .source-toolbar,
+#source .info-box,
+#source .file-content {
     margin: 0 0 10px;
 }
 
@@ -941,7 +945,7 @@ html, body {
     color: #888;
 }
 
-#gogs-source .file-content.diff-file-box {
+#source .file-content.diff-file-box {
     margin-bottom: 20px;
 }
 
diff --git a/public/js/app.js b/public/js/app.js
index f98fd03f82..0973398a50 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -243,7 +243,7 @@ function initCore() {
 
 function initRegister() {
     $.getScript("/js/jquery.validate.min.js", function () {
-        Gogits.validateForm("#gogs-login-card", {
+        Gogits.validateForm("#login-card", {
             rules: {
                 "username": {
                     required: true,
@@ -268,7 +268,7 @@ function initRegister() {
 }
 
 function initUserSetting() {
-    $('#gogs-ssh-keys .delete').confirmation({
+    $('#ssh-keys .delete').confirmation({
         singleton: true,
         onConfirm: function (e, $this) {
             Gogits.ajaxDelete("", {"id": $this.data("del")}, function (json) {
@@ -303,7 +303,7 @@ function initRepository() {
 
     // watching script
     (function () {
-        var $watch = $('#gogs-repo-watching'),
+        var $watch = $('#repo-watching'),
             watchLink = $watch.data("watch"),
             unwatchLink = $watch.data("unwatch");
         $watch.on('click', '.to-watch',function () {
@@ -354,14 +354,14 @@ function initRepository() {
 (function ($) {
     $(function () {
         initCore();
-        var body = $("#gogs-body");
+        var body = $("#body");
         if (body.data("page") == "user-signup") {
             initRegister();
         }
         if (body.data("page") == "user") {
             initUserSetting();
         }
-        if ($('.gogs-repo-nav').length) {
+        if ($('.repo-nav').length) {
             initRepository();
         }
     });
diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl
index 1e26304602..39895aa311 100644
--- a/templates/admin/config.tmpl
+++ b/templates/admin/config.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="admin">
+<div id="body" class="container" data-page="admin">
     {{template "admin/nav" .}}
-    <div id="gogs-admin-container" class="col-md-9">
+    <div id="admin-container" class="col-md-9">
         <div class="panel panel-default">
             <div class="panel-heading">
                 Server Configuration
diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl
index 2a5a161e03..e0b31817aa 100644
--- a/templates/admin/dashboard.tmpl
+++ b/templates/admin/dashboard.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="admin">
+<div id="body" class="container" data-page="admin">
     {{template "admin/nav" .}}
-    <div id="gogs-admin-container" class="col-md-9">
+    <div id="admin-container" class="col-md-9">
         <div class="panel panel-default">
             <div class="panel-heading">
                 Statistic
diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl
index 72f008acc7..8c2e33888e 100644
--- a/templates/admin/nav.tmpl
+++ b/templates/admin/nav.tmpl
@@ -1,4 +1,4 @@
-<div id="gogs-user-setting-nav" class="col-md-3 gogs-admin-nav">
+<div id="user-setting-nav" class="col-md-3 admin-nav">
     <ul class="list-group" data-init="tabs">
         <li class="list-group-item{{if .PageIsDashboard}} active{{end}}"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
         <li class="list-group-item{{if .PageIsUsers}} active{{end}}"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li>
diff --git a/templates/admin/repos.tmpl b/templates/admin/repos.tmpl
index 2c91ccc096..8cc424db68 100644
--- a/templates/admin/repos.tmpl
+++ b/templates/admin/repos.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="admin">
+<div id="body" class="container" data-page="admin">
     {{template "admin/nav" .}}
-    <div id="gogs-admin-container" class="col-md-9">
+    <div id="admin-container" class="col-md-9">
         <div class="panel panel-default">
             <div class="panel-heading">
                 Repository Management
diff --git a/templates/admin/users.tmpl b/templates/admin/users.tmpl
index dec5c18954..63da451743 100644
--- a/templates/admin/users.tmpl
+++ b/templates/admin/users.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="admin">
+<div id="body" class="container" data-page="admin">
     {{template "admin/nav" .}}
-    <div id="gogs-admin-container" class="col-md-9">
+    <div id="admin-container" class="col-md-9">
         <div class="panel panel-default">
             <div class="panel-heading">
                 User Management
diff --git a/templates/admin/users/edit.tmpl b/templates/admin/users/edit.tmpl
index 08f11fcb12..5db2c7a95e 100644
--- a/templates/admin/users/edit.tmpl
+++ b/templates/admin/users/edit.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="admin">
+<div id="body" class="container" data-page="admin">
     {{template "admin/nav" .}}
-    <div id="gogs-admin-container" class="col-md-9">
+    <div id="admin-container" class="col-md-9">
         <div class="panel panel-default">
             <div class="panel-heading">
                 Edit Account
diff --git a/templates/admin/users/new.tmpl b/templates/admin/users/new.tmpl
index 7b41ae43a7..7f441f32b3 100644
--- a/templates/admin/users/new.tmpl
+++ b/templates/admin/users/new.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="admin">
+<div id="body" class="container" data-page="admin">
     {{template "admin/nav" .}}
-    <div id="gogs-admin-container" class="col-md-9">
+    <div id="admin-container" class="col-md-9">
         <div class="panel panel-default">
             <div class="panel-heading">
                 New Account
diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl
index 90e90f296f..829ecba62b 100644
--- a/templates/base/navbar.tmpl
+++ b/templates/base/navbar.tmpl
@@ -1,25 +1,25 @@
-<div class="gogs-masthead navbar" id="masthead">
+<div class="masthead navbar" id="masthead">
     <div class="container">
-        <nav class="gogs-nav">
-            <a id="gogs-nav-logo" class="gogs-nav-item{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="gogs-logo"></a>
-            <a class="gogs-nav-item{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a>
-            <a class="gogs-nav-item{{if .PageIsHelp}} active{{end}}" href="/help">Help</a>{{if .IsSigned}}
-            <a id="gogs-nav-out" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/logout/"><i class="fa fa-power-off fa-lg"></i></a>
-            <a id="gogs-nav-avatar" class="gogs-nav-item navbar-right{{if .PageIsUserProfile}} active{{end}}" href="{{.SignedUser.HomeLink}}" data-toggle="tooltip" data-placement="bottom" title="{{.SignedUserName}}">
+        <nav class="nav">
+            <a id="nav-logo" class="nav-item{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a>
+            <a class="nav-item{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a>
+            <a class="nav-item{{if .PageIsHelp}} active{{end}}" href="/help">Help</a>{{if .IsSigned}}
+            <a id="nav-out" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/logout/"><i class="fa fa-power-off fa-lg"></i></a>
+            <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 gogs-nav-item{{if .PageIsNewRepo}} active{{end}}" href="/repo/create" data-toggle="tooltip" data-placement="bottom" title="New Repository"><i class="fa fa-plus fa-lg"></i></a>
-            <a class="navbar-right gogs-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>
-            {{if .IsAdmin}}<a class="navbar-right gogs-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}}
-            {{else}}<a id="gogs-nav-signin" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign In</a>
-            <a id="gogs-nav-signup" class="gogs-nav-item navbar-right" href="/user/sign_up/">Sign Up</a>{{end}}
+            <a class="navbar-right nav-item{{if .PageIsNewRepo}} active{{end}}" href="/repo/create" data-toggle="tooltip" data-placement="bottom" title="New Repository"><i class="fa fa-plus fa-lg"></i></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>
+            {{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}}
+            {{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}}
         </nav>
     </div>
 </div>
 <!--<nav class="navbar navbar-inverse navbar-fixed-top">
 	<div class="container">
 		<div class="navbar-header">
-			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#gogs-navbar-collapse">
+			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
 				<i class="fa fa-bars"></i>
 			</button>
 			<a class="navbar-brand" href="/"><img src="/img/favicon.png" alt="Gogs Logo"></a>
diff --git a/templates/help.tmpl b/templates/help.tmpl
index b4d5d2a97e..e835c2981e 100644
--- a/templates/help.tmpl
+++ b/templates/help.tmpl
@@ -1,11 +1,11 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body-nav">
+<div id="body-nav">
     <div class="container">
         <h3>Help</h3>
     </div>
 </div>
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/home.tmpl b/templates/home.tmpl
index e077624323..381b6f1e8e 100644
--- a/templates/home.tmpl
+++ b/templates/home.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container">
+<div id="body" class="container">
 	Welcome to the land of Gogs! There will be some indroduction!
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/install.tmpl b/templates/install.tmpl
index a13f219088..849491f898 100644
--- a/templates/install.tmpl
+++ b/templates/install.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
-<div id="gogs-body" class="container">
-    <form action="/install" method="post" class="form-horizontal gogs-card" id="gogs-install-card">
+<div id="body" class="container">
+    <form action="/install" method="post" class="form-horizontal card" id="install-card">
         {{.CsrfTokenHtml}}
         <h3>Install Steps</h3>
         <div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div>
diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl
index e71843e6f0..2fb29d1b8b 100644
--- a/templates/issue/create.tmpl
+++ b/templates/issue/create.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-source">
+<div id="body" class="container">
+    <div id="source">
         new-issues
     </div>
 </div>
diff --git a/templates/repo/branches.tmpl b/templates/repo/branches.tmpl
index 63e77ab924..8d2d59d7fd 100644
--- a/templates/repo/branches.tmpl
+++ b/templates/repo/branches.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-source">
+<div id="body" class="container">
+    <div id="source">
         <div class="panel panel-default branch-box info-box">
             <div class="panel-heading info-head">
                 <h4>Branches</h4>
diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl
index 2e67a1200a..2f308a108d 100644
--- a/templates/repo/commits.tmpl
+++ b/templates/repo/commits.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-commits">
+<div id="body" class="container">
+    <div id="commits">
         <div class="panel panel-default commit-box info-box">
             <div class="panel-heading info-head">
                 <div class="search pull-right form">
diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl
index a43f510484..dc509fc1cc 100644
--- a/templates/repo/create.tmpl
+++ b/templates/repo/create.tmpl
@@ -1,7 +1,7 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div class="container" id="gogs-body">
-    <form action="/repo/create" method="post" class="form-horizontal gogs-card" id="gogs-repo-create">
+<div class="container" id="body">
+    <form action="/repo/create" method="post" class="form-horizontal card" id="repo-create">
         {{.CsrfTokenHtml}}
         <h3>Create New Repository</h3>
         <div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div>
diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl
index b0836127ff..6a3c5fb308 100644
--- a/templates/repo/diff.tmpl
+++ b/templates/repo/diff.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container" data-page="repo">
-    <div id="gogs-source">
+<div id="body" class="container" data-page="repo">
+    <div id="source">
         <div class="panel panel-info diff-box diff-head-box">
             <div class="panel-heading">
                 <a class="pull-right btn btn-primary btn-sm" href="#commit-source">Browse Source</a>
diff --git a/templates/repo/issues.tmpl b/templates/repo/issues.tmpl
index bf23ff83ff..df53197c36 100644
--- a/templates/repo/issues.tmpl
+++ b/templates/repo/issues.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-source">
+<div id="body" class="container">
+    <div id="source">
         issues
     </div>
 </div>
diff --git a/templates/repo/list.tmpl b/templates/repo/list.tmpl
index 2c5432a174..403c62d62c 100644
--- a/templates/repo/list.tmpl
+++ b/templates/repo/list.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div class="container" id="gogs-body">
+<div class="container" id="body">
 	<ul>
 	{{range .Repos}}
 		<li>{{.Name}} stars: {{.NumStars}} forks: {{.NumForks}} watches:{{.NumWatchs}}</li>
diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl
index 2770328cb1..e1b22b1c93 100644
--- a/templates/repo/nav.tmpl
+++ b/templates/repo/nav.tmpl
@@ -1,4 +1,4 @@
-<div id="gogs-body-nav" class="gogs-repo-nav">
+<div id="body-nav" class="repo-nav">
     <div class="container">
         <div class="row">
             <div class="col-md-7">
@@ -7,13 +7,13 @@
             </div>
             <div class="col-md-5 actions text-right clone-group-btn">
                 {{if not .IsBareRepo}}
-                <!--<div class="btn-group" id="gogs-repo-clone">
+                <!--<div class="btn-group" id="repo-clone">
                     <button type="button" class="btn btn-default"><i class="fa fa-download fa-lg fa-m"></i></button>
                     <button type="button" class="btn btn-default dropdown-toggle" data-container="body" data-toggle="popover" data-placement="bottom" data-content="<label>SSH:</label><div class='input-group'><input type='text' class='form-control' value='{{.CloneLink.SSH}}'></div>" data-html="1">
                         <span class="caret"></span>
                     </button>
                 </div>-->
-                <div class="btn-group" id="gogs-repo-clone">
+                <div class="btn-group" id="repo-clone">
                     <button type="button" class="btn btn-default"><i class="fa fa-download fa-lg fa-m"></i></button>
                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                         <span class="caret"></span>
@@ -36,7 +36,7 @@
                         </div>
                     </div>
                 </div>
-                <div class="btn-group {{if .IsRepositoryWatching}}watching{{else}}no-watching{{end}}" id="gogs-repo-watching" data-watch="/{{.Owner.Name}}/{{.Repository.Name}}/action/watch" data-unwatch="/{{.Owner.Name}}/{{.Repository.Name}}/action/unwatch">
+                <div class="btn-group {{if .IsRepositoryWatching}}watching{{else}}no-watching{{end}}" id="repo-watching" data-watch="/{{.Owner.Name}}/{{.Repository.Name}}/action/watch" data-unwatch="/{{.Owner.Name}}/{{.Repository.Name}}/action/unwatch">
                     {{if .IsRepositoryWatching}}
                     <button type="button" class="btn btn-default"><i class="fa fa-eye fa-lg fa-m"></i></button>
                     {{else}}
diff --git a/templates/repo/pulls.tmpl b/templates/repo/pulls.tmpl
index daacc089c3..8c5d9376c8 100644
--- a/templates/repo/pulls.tmpl
+++ b/templates/repo/pulls.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-source">
+<div id="body" class="container">
+    <div id="source">
     </div>
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/repo/setting.tmpl b/templates/repo/setting.tmpl
index c826e55a77..d527dac3bc 100644
--- a/templates/repo/setting.tmpl
+++ b/templates/repo/setting.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-user-setting-nav" class="col-md-3">
+<div id="body" class="container">
+    <div id="user-setting-nav" class="col-md-3">
         <ul class="list-group" data-init="tabs">
             <li class="list-group-item active"><a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings">Options</a></li>
             <!--<li class="list-group-item"><a href="#">Collaborators</a></li>
@@ -11,7 +11,7 @@
         </ul>
     </div>
 
-    <div id="gogs-repo-setting-container" class="col-md-9">
+    <div id="repo-setting-container" class="col-md-9">
         {{if .IsSuccess}}<p class="alert alert-success">Repository option has been successfully updated.</p>{{else if .HasError}}<p class="alert alert-danger form-error">{{.ErrorMsg}}</p>{{end}}
         <div class="panel panel-default">
             <div class="panel-heading">
diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl
index 56e6746c76..ed04be0779 100644
--- a/templates/repo/single.tmpl
+++ b/templates/repo/single.tmpl
@@ -2,8 +2,8 @@
 {{template "base/navbar" .}}
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
-<div id="gogs-body" class="container">
-    <div id="gogs-source">
+<div id="body" class="container">
+    <div id="source">
         {{if .IsBareRepo}}
         {{template "repo/single_bare" .}}
         {{else}}
diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl
index 415023d17f..1f8a70984c 100644
--- a/templates/repo/toolbar.tmpl
+++ b/templates/repo/toolbar.tmpl
@@ -1,4 +1,4 @@
-<div id="gogs-repo-toolbar">
+<div id="repo-toolbar">
     <div class="container">
         <nav class="navbar navbar-toolbar navbar-default" role="navigation">
             <div class="collapse navbar-collapse">
diff --git a/templates/status/200.tmpl b/templates/status/200.tmpl
index 8f64494201..0846ad7951 100644
--- a/templates/status/200.tmpl
+++ b/templates/status/200.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container">
+<div id="body" class="container">
 	<p>An error is occurred : {{.ErrorMsg}}</p>
 	<p>Application Version: {{AppVer}}</p>
 </div>
diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl
index b971f279a8..f68676fe23 100644
--- a/templates/status/404.tmpl
+++ b/templates/status/404.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container text-center">
+<div id="body" class="container text-center">
     <p style="margin-top: 80px"><img src="/img/404.png" alt="404"/></p>
     <hr/>
     <p>Application Version: {{AppVer}}</p>
diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl
index f3cd24d696..dd7358115d 100644
--- a/templates/status/500.tmpl
+++ b/templates/status/500.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container text-center">
+<div id="body" class="container text-center">
     <p style="margin-top: 80px"><img src="/img/500.png" alt="404"/></p>
     <hr/>
     <p>An error is occurred : {{.ErrorMsg}}</p>
diff --git a/templates/user/active.tmpl b/templates/user/active.tmpl
index 0df116cb40..9cac069dce 100644
--- a/templates/user/active.tmpl
+++ b/templates/user/active.tmpl
@@ -1,7 +1,7 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container">
-    <form action="/user/activate" method="post" class="form-horizontal gogs-card" id="gogs-login-card">
+<div id="body" class="container">
+    <form action="/user/activate" method="post" class="form-horizontal card" id="login-card">
         {{.CsrfTokenHtml}}
         <h3>Activate Your Account</h3>
         {{if .IsActivatePage}}
diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl
index ca5fecf268..bc0853fb0d 100644
--- a/templates/user/dashboard.tmpl
+++ b/templates/user/dashboard.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body-nav">
+<div id="body-nav">
     <div class="container">
         <ul class="nav nav-pills pull-right">
             <li class="active"><a href="/">Feed</a></li>
@@ -11,9 +11,9 @@
         <h3>News Feed</h3>
     </div>
 </div>
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
-    <div id="gogs-feed-left" class="col-md-8">
+    <div id="feed-left" class="col-md-8">
         <ul class="list-unstyled activity-list">
         {{range .Feeds}}
             <li>
@@ -26,7 +26,7 @@
         {{end}}
         </ul>
     </div>
-    <div id="gogs-feed-right" class="col-md-4">
+    <div id="feed-right" class="col-md-4">
         <div class="panel panel-default repo-panel">
             <div class="panel-heading">Your Repositories
                 <a class="btn btn-success pull-right btn-sm" href="/repo/create"><i class="fa fa-plus-square"></i>New Repo</a>
diff --git a/templates/user/delete.tmpl b/templates/user/delete.tmpl
index 46376672d4..a0f20fa2ca 100644
--- a/templates/user/delete.tmpl
+++ b/templates/user/delete.tmpl
@@ -1,7 +1,7 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
-    <div id="gogs-user-setting-nav" class="col-md-3">
+<div id="body" class="container" data-page="user">
+    <div id="user-setting-nav" class="col-md-3">
         <h4>Account Setting</h4>
         <ul class="list-group">
             <li class="list-group-item"><a href="/user/setting">Account Profile</a></li>
@@ -12,16 +12,16 @@
             <li class="list-group-item list-group-item-success"><a href="/user/delete">Delete Account</a></li>
         </ul>
     </div>
-    <div id="gogs-user-setting-container" class="col-md-9">
+    <div id="user-setting-container" class="col-md-9">
         <h4>Delete Account</h4>
         <p class="alert alert-danger">{{if not .HasError}}The operation will delete your account permanently. Sorry to see you go, but we know you'll back soon.{{else}}{{.ErrorMsg}}{{end}}</p>
         <div class="form-group">
-            <button type="submit" class="btn btn-danger btn-lg" href="#delete-account-modal" id="gogs-delete-account" data-toggle="modal">Delete Account</button>
+            <button type="submit" class="btn btn-danger btn-lg" href="#delete-account-modal" id="delete-account" data-toggle="modal">Delete Account</button>
         </div>
     </div>
     <div class="modal fade" id="delete-account-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
         <div class="modal-dialog">
-            <form action="/user/delete" method="post" class="modal-content" id="gogs-user-delete">
+            <form action="/user/delete" method="post" class="modal-content" id="user-delete">
                 {{.CsrfTokenHtml}}
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
diff --git a/templates/user/issues.tmpl b/templates/user/issues.tmpl
index e28af5bec6..dd17b667d1 100644
--- a/templates/user/issues.tmpl
+++ b/templates/user/issues.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body-nav">
+<div id="body-nav">
     <div class="container">
         <ul class="nav nav-pills pull-right">
             <li><a href="/">Feed</a></li>
@@ -11,7 +11,7 @@
         <h3>Issues</h3>
     </div>
 </div>
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/user/notification.tmpl b/templates/user/notification.tmpl
index 7911c0fd5f..7c2e8425d4 100644
--- a/templates/user/notification.tmpl
+++ b/templates/user/notification.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{template "user/setting_nav" .}}
-    <div id="gogs-user-setting-container" class="col-md-9">
+    <div id="user-setting-container" class="col-md-9">
         <h4>Notification</h4>
     </div>
 </div>
diff --git a/templates/user/password.tmpl b/templates/user/password.tmpl
index 936ec4b124..b2cdc72d9e 100644
--- a/templates/user/password.tmpl
+++ b/templates/user/password.tmpl
@@ -1,11 +1,11 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{template "user/setting_nav" .}}
-    <div id="gogs-user-setting-container" class="col-md-9">
-        <div id="gogs-setting-pwd">
+    <div id="user-setting-container" class="col-md-9">
+        <div id="setting-pwd">
             <h4>Password</h4>
-            <form class="form-horizontal" id="gogs-password-form" method="post" action="/user/setting/password">
+            <form class="form-horizontal" id="password-form" method="post" action="/user/setting/password">
             {{.CsrfTokenHtml}}
             {{if .IsSuccess}}
                 <p class="alert alert-success">Password is changed successfully. You can now sign in via new password.</p>{{else if .HasError}}<p class="alert alert-danger form-error">{{.ErrorMsg}}</p>{{end}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 3422361474..7762ad2c6c 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -1,12 +1,12 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
-    <div id="gogs-user-profile" class="col-md-3">
+<div id="body" class="container" data-page="user">
+    <div id="user-profile" class="col-md-3">
         <div class="profile-avatar text-center">
             <a href="http://gravatar.com/emails/" class="center-block" data-toggle="tooltip" data-placement="bottom" title="Change your avatar at gravatar.com">
-                <img id="gogs-user-avatar" src="{{.Owner.AvatarLink}}?s=200" alt="user-avatar" title="{{.Owner.Name}}"/>
+                <img id="user-avatar" src="{{.Owner.AvatarLink}}?s=200" alt="user-avatar" title="{{.Owner.Name}}"/>
             </a>
-            <span id="gogs-user-name" class="center-block">{{.Owner.Name}}</span>
+            <span id="user-name" class="center-block">{{.Owner.Name}}</span>
         </div>
         <div class="profile-info">
             <ul class="list-group">
@@ -23,8 +23,8 @@
             </ul>
         </div>
     </div>
-    <div id="gogs-user-activity" class="col-md-9">
-        <ul class="nav nav-tabs" id="gogs-user-act-tabs" data-init="tabs">
+    <div id="user-activity" class="col-md-9">
+        <ul class="nav nav-tabs" id="user-act-tabs" data-init="tabs">
             <li{{if not .TabName}} class="active"{{end}}><a href="{{.Owner.HomeLink}}"><i class="fa fa-gittip"></i>Repositories</a></li>
             <li{{if eq .TabName "activity"}} class="active"{{end}}><a href="{{.Owner.HomeLink}}?tab=activity"><i class="fa fa-rss"></i>Public Activity</a></li>
         </ul>
diff --git a/templates/user/publickey.tmpl b/templates/user/publickey.tmpl
index e645e1a84b..ecdeb035d2 100644
--- a/templates/user/publickey.tmpl
+++ b/templates/user/publickey.tmpl
@@ -1,12 +1,12 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{template "user/setting_nav" .}}
-    <div id="gogs-user-setting-container" class="col-md-9">
-        <div id="gogs-ssh-keys">
+    <div id="user-setting-container" class="col-md-9">
+        <div id="ssh-keys">
             <h4>SSH Keys</h4>{{if .AddSSHKeySuccess}}
             <p class="alert alert-success">New SSH Key has been added !</p>{{else if .HasError}}<p class="alert alert-danger">{{.ErrorMsg}}</p>{{end}}
-            <ul id="gogs-ssh-keys-list" class="list-group">
+            <ul id="ssh-keys-list" class="list-group">
                 <li class="list-group-item"><span class="name">SSH Key's name</span></li>
                 {{range .Keys}}
                 <li class="list-group-item">
@@ -16,12 +16,12 @@
                 </li>
                 {{end}}
                 <li class="list-group-item">
-                    <a class="btn btn-link btn-primary" href="#ssh-add-modal" id="gogs-ssh-add" data-toggle="modal">Add SSH Key</a>
+                    <a class="btn btn-link btn-primary" href="#ssh-add-modal" id="ssh-add" data-toggle="modal">Add SSH Key</a>
                 </li>
             </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="gogs-ssh-form" method="post" action="/user/setting/ssh/">
+                    <form class="modal-content form-horizontal" id="ssh-form" method="post" action="/user/setting/ssh/">
                         {{.CsrfTokenHtml}}
                         <div class="modal-header">
                             <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
diff --git a/templates/user/pulls.tmpl b/templates/user/pulls.tmpl
index 0891f5e850..47462a9be6 100644
--- a/templates/user/pulls.tmpl
+++ b/templates/user/pulls.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body-nav">
+<div id="body-nav">
     <div class="container">
         <ul class="nav nav-pills pull-right">
             <li><a href="/">Feed</a></li>
@@ -11,7 +11,7 @@
         <h3>Pull Requests</h3>
     </div>
 </div>
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/user/security.tmpl b/templates/user/security.tmpl
index a7506b5086..7de41ebd35 100644
--- a/templates/user/security.tmpl
+++ b/templates/user/security.tmpl
@@ -1,8 +1,8 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{template "user/setting_nav" .}}
-    <div id="gogs-user-setting-container" class="col-md-9">
+    <div id="user-setting-container" class="col-md-9">
         <h4>Security</h4>
     </div>
 </div>
diff --git a/templates/user/setting.tmpl b/templates/user/setting.tmpl
index 30c9529b12..283a8df8bf 100644
--- a/templates/user/setting.tmpl
+++ b/templates/user/setting.tmpl
@@ -1,11 +1,11 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{template "user/setting_nav" .}}
-    <div id="gogs-user-setting-container" class="col-md-9">
-        <div id="gogs-setting-pwd">
+    <div id="user-setting-container" class="col-md-9">
+        <div id="setting-pwd">
             <h4>Account Profile</h4>
-            <form class="form-horizontal" id="gogs-password-form" method="post" action="/user/setting">
+            <form class="form-horizontal" id="password-form" method="post" action="/user/setting">
                 {{.CsrfTokenHtml}}
                 {{if .IsSuccess}}<p class="alert alert-success">Your profile has been successfully updated.</p>{{else if .HasError}}<p class="alert alert-danger form-error">{{.ErrorMsg}}</p>{{end}}
                 <p>Your Email will be public and used for Account related notifications and any web based operations made via the web.</p>
diff --git a/templates/user/setting_nav.tmpl b/templates/user/setting_nav.tmpl
index 2905f2825c..c0f2ae03dd 100644
--- a/templates/user/setting_nav.tmpl
+++ b/templates/user/setting_nav.tmpl
@@ -1,4 +1,4 @@
-<div id="gogs-user-setting-nav" class="col-md-3">
+<div id="user-setting-nav" class="col-md-3">
     <h4>Account Setting</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>
diff --git a/templates/user/signin.tmpl b/templates/user/signin.tmpl
index 1cd3275cce..49a2262633 100644
--- a/templates/user/signin.tmpl
+++ b/templates/user/signin.tmpl
@@ -1,7 +1,7 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div class="container" id="gogs-body" data-page="user-signin">
-    <form action="/user/login" method="post" class="form-horizontal gogs-card" id="gogs-login-card">
+<div class="container" id="body" data-page="user-signin">
+    <form action="/user/login" method="post" class="form-horizontal card" id="login-card">
         {{.CsrfTokenHtml}}
         <h3>Log in</h3>
         <div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div>
@@ -43,7 +43,7 @@
             </div>
         </div>
 
-        <div class="form-group text-center" id="gogs-social-login">
+        <div class="form-group text-center" id="social-login">
             <a class="btn btn-danger btn-lg">Register new account</a>
         </div>
     </form>
diff --git a/templates/user/signup.tmpl b/templates/user/signup.tmpl
index fbfc4cadcc..6ed595a350 100644
--- a/templates/user/signup.tmpl
+++ b/templates/user/signup.tmpl
@@ -1,7 +1,7 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div class="container" id="gogs-body" data-page="user-signup">
-	<form action="/user/sign_up" method="post" class="form-horizontal gogs-card" id="gogs-login-card">
+<div class="container" id="body" data-page="user-signup">
+	<form action="/user/sign_up" method="post" class="form-horizontal card" id="login-card">
 		{{.CsrfTokenHtml}}
 		{{if .DisenableRegisteration}}
 		Sorry, registeration has been disenabled, you can only get account from administrator.
diff --git a/templates/user/stars.tmpl b/templates/user/stars.tmpl
index 4e6f0c92fc..253efd6eec 100644
--- a/templates/user/stars.tmpl
+++ b/templates/user/stars.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
-<div id="gogs-body-nav">
+<div id="body-nav">
     <div class="container">
         <ul class="nav nav-pills pull-right">
             <li><a href="/">Feed</a></li>
@@ -11,7 +11,7 @@
         <h3>Stars</h3>
     </div>
 </div>
-<div id="gogs-body" class="container" data-page="user">
+<div id="body" class="container" data-page="user">
     {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
 </div>
 {{template "base/footer" .}}
\ No newline at end of file

From eeb793524f2da4afdca017b585d9cfb6e9628e85 Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 06:52:56 -0400
Subject: [PATCH 04/26] Check run user

---
 conf/app.ini               |  4 ++--
 gogs.go                    | 15 ---------------
 modules/base/conf.go       | 21 +++++++++++----------
 templates/user/delete.tmpl |  4 ++--
 4 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/conf/app.ini b/conf/app.ini
index 809ea61c07..4c2398dd68 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -1,8 +1,8 @@
 ; App name that shows on every page title
 APP_NAME = Gogs: Go Git Service
 APP_LOGO = img/favicon.png
-; !!MUST CHANGE TO YOUR USER NAME!!
-RUN_USER = lunny
+; Check it if you run locally
+RUN_USER = git
 ; Either "dev", "prod" or "test", default is "dev"
 RUN_MODE = dev
 
diff --git a/gogs.go b/gogs.go
index 93b7231b77..7ac699cc69 100644
--- a/gogs.go
+++ b/gogs.go
@@ -7,7 +7,6 @@ package main
 
 import (
 	"os"
-	// "os/user"
 	"runtime"
 
 	"github.com/codegangsta/cli"
@@ -27,21 +26,7 @@ func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())
 }
 
-// func checkRunUser() bool {
-// 	u, err := user.Current()
-// 	if err != nil {
-// 		// TODO: log
-// 		return false
-// 	}
-// 	return u.Username == base.Cfg.MustValue("", "RUN_USER")
-// }
-
 func main() {
-	/*if !checkRunUser() {
-		println("The command should be run as", base.Cfg.MustValue("", "RUN_USER"))
-		return
-	}*/
-
 	app := cli.NewApp()
 	app.Name = "Gogs"
 	app.Usage = "Go Git Service"
diff --git a/modules/base/conf.go b/modules/base/conf.go
index d3122a5339..c692ddc23f 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -259,16 +259,11 @@ func NewConfigContext() {
 	Cfg.BlockMode = false
 
 	cfgPath = filepath.Join(workDir, "custom/conf/app.ini")
-	if !com.IsFile(cfgPath) {
-		fmt.Println("Custom configuration not found(custom/conf/app.ini)\n" +
-			"Please create it and make your own configuration!")
-		os.Exit(2)
-
-	}
-
-	if err = Cfg.AppendFiles(cfgPath); err != nil {
-		fmt.Printf("Cannot load config file '%s'\n", cfgPath)
-		os.Exit(2)
+	if com.IsFile(cfgPath) {
+		if err = Cfg.AppendFiles(cfgPath); err != nil {
+			fmt.Printf("Cannot load config file '%s'\n", cfgPath)
+			os.Exit(2)
+		}
 	}
 
 	AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service")
@@ -276,7 +271,13 @@ func NewConfigContext() {
 	AppUrl = Cfg.MustValue("server", "ROOT_URL")
 	Domain = Cfg.MustValue("server", "DOMAIN")
 	SecretKey = Cfg.MustValue("security", "SECRET_KEY")
+
 	RunUser = Cfg.MustValue("", "RUN_USER")
+	curUser := os.Getenv("USERNAME")
+	if RunUser != curUser {
+		fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser)
+		os.Exit(2)
+	}
 
 	EnableHttpsClone = Cfg.MustBool("security", "ENABLE_HTTPS_CLONE", false)
 
diff --git a/templates/user/delete.tmpl b/templates/user/delete.tmpl
index 46376672d4..04c713eb65 100644
--- a/templates/user/delete.tmpl
+++ b/templates/user/delete.tmpl
@@ -6,9 +6,9 @@
         <ul class="list-group">
             <li class="list-group-item"><a href="/user/setting">Account Profile</a></li>
             <li class="list-group-item"><a href="/user/setting/password">Password</a></li>
-            <li class="list-group-item"><a href="/user/setting/notification">Notifications</a></li>
+            <!-- <li class="list-group-item"><a href="/user/setting/notification">Notifications</a></li> -->
             <li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li>
-            <li class="list-group-item"><a href="/user/setting/security">Security</a></li>
+            <!-- <li class="list-group-item"><a href="/user/setting/security">Security</a></li> -->
             <li class="list-group-item list-group-item-success"><a href="/user/delete">Delete Account</a></li>
         </ul>
     </div>

From be69e74bc05b62deb6a5f9ae360af220cd5d5226 Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 07:06:56 -0400
Subject: [PATCH 05/26] Mirror fix

---
 modules/base/conf.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/base/conf.go b/modules/base/conf.go
index d0f8ae2cc8..3eb01bdd56 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -274,6 +274,9 @@ func NewConfigContext() {
 
 	RunUser = Cfg.MustValue("", "RUN_USER")
 	curUser := os.Getenv("USERNAME")
+	if len(curUser) == 0 {
+		curUser = os.Getenv("whoami")
+	}
 	if RunUser != curUser {
 		fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser)
 		os.Exit(2)

From 7aa0a97d10a6810ab0b6fb482c7f8f179431104f Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 07:10:23 -0400
Subject: [PATCH 06/26] Mirror fix

---
 modules/base/conf.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/base/conf.go b/modules/base/conf.go
index 3eb01bdd56..1661681e7e 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -275,7 +275,7 @@ func NewConfigContext() {
 	RunUser = Cfg.MustValue("", "RUN_USER")
 	curUser := os.Getenv("USERNAME")
 	if len(curUser) == 0 {
-		curUser = os.Getenv("whoami")
+		curUser = os.Getenv("USER")
 	}
 	if RunUser != curUser {
 		fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser)

From c3953a62fd874f035adf3c16a59dfd97f655c078 Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 07:30:18 -0400
Subject: [PATCH 07/26] Add more log to locate issue

---
 serve.go | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/serve.go b/serve.go
index acdcb877ff..962f877745 100644
--- a/serve.go
+++ b/serve.go
@@ -49,7 +49,7 @@ func init() {
 	level := "0"
 	os.MkdirAll("log", os.ModePerm)
 	log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log"))
-	log.Info("start logging...")
+	log.Trace("start logging...")
 }
 
 func parseCmd(cmd string) (string, string) {
@@ -80,17 +80,20 @@ func runServ(k *cli.Context) {
 	keys := strings.Split(os.Args[2], "-")
 	if len(keys) != 2 {
 		fmt.Println("auth file format error")
+		log.Error("auth file format error")
 		return
 	}
 
 	keyId, err := strconv.ParseInt(keys[1], 10, 64)
 	if err != nil {
 		fmt.Println("auth file format error")
+		log.Error("auth file format error")
 		return
 	}
 	user, err := models.GetUserByKeyId(keyId)
 	if err != nil {
 		fmt.Println("You have no right to access")
+		log.Error("You have no right to access")
 		return
 	}
 
@@ -105,6 +108,7 @@ func runServ(k *cli.Context) {
 	rr := strings.SplitN(rRepo, "/", 2)
 	if len(rr) != 2 {
 		println("Unavilable repository", args)
+		log.Error("Unavilable repository %v", args)
 		return
 	}
 	repoName := rr[1]
@@ -122,11 +126,12 @@ func runServ(k *cli.Context) {
 			isExist = false
 			if isRead {
 				println("Repository", user.Name+"/"+repoName, "is not exist")
+				log.Error("Repository " + user.Name + "/" + repoName + " is not exist")
 				return
 			}
 		} else {
 			println("Get repository error:", err)
-			log.Error(err.Error())
+			log.Error("Get repository error: " + err.Error())
 			return
 		}
 	}
@@ -142,6 +147,7 @@ func runServ(k *cli.Context) {
 		}
 		if !has {
 			println("You have no right to write this repository")
+			log.Error("You have no right to access this repository")
 			return
 		}
 	case isRead:
@@ -161,10 +167,12 @@ func runServ(k *cli.Context) {
 		}
 		if !has {
 			println("You have no right to access this repository")
+			log.Error("You have no right to access this repository")
 			return
 		}
 	default:
 		println("Unknown command")
+		log.Error("Unknown command")
 		return
 	}
 
@@ -175,23 +183,23 @@ func runServ(k *cli.Context) {
 			_, err = models.CreateRepository(user, repoName, "", "", "", false, true)
 			if err != nil {
 				println("Create repository failed")
-				log.Error(err.Error())
+				log.Error("Create repository failed: " + err.Error())
 				return
 			}
 		}
 	}
 
-		rep, err = git.OpenRepository(repoPath)
-		if err != nil {
-			println("OpenRepository failed:", err.Error())
-			log.Error(err.Error())
-			return
-		}
+	rep, err = git.OpenRepository(repoPath)
+	if err != nil {
+		println("OpenRepository failed:", err.Error())
+		log.Error("OpenRepository failed: " + err.Error())
+		return
+	}
 
 	refs, err := rep.AllReferencesMap()
 	if err != nil {
 		println("Get All References failed:", err.Error())
-		log.Error(err.Error())
+		log.Error("Get All References failed: " + err.Error())
 		return
 	}
 
@@ -208,7 +216,7 @@ func runServ(k *cli.Context) {
 
 	if err = gitcmd.Run(); err != nil {
 		println("execute command error:", err.Error())
-		log.Error(err.Error())
+		log.Error("execute command error: " + err.Error())
 		return
 	}
 
@@ -236,6 +244,7 @@ func runServ(k *cli.Context) {
 	}
 	if refname == "" {
 		println("No find any reference name:", b.String())
+		log.Error("No find any reference name: " + b.String())
 		return
 	}
 
@@ -248,17 +257,18 @@ func runServ(k *cli.Context) {
 		refs, err = rep.AllReferencesMap()
 		if err != nil {
 			println("Get All References failed:", err.Error())
-			log.Error(err.Error())
+			log.Error("Get All References failed: " + err.Error())
 			return
 		}
 		if ref, ok = refs[refname]; !ok {
+			log.Error("unknow reference name -", refname, "-", b.String())
 			log.Error("unknow reference name -", refname, "-", b.String())
 			return
 		}
 		l, err = ref.AllCommits()
 		if err != nil {
 			println("Get All Commits failed:", err.Error())
-			log.Error(err.Error())
+			log.Error("Get All Commits failed: " + err.Error())
 			return
 		}
 	} else {
@@ -268,14 +278,14 @@ func runServ(k *cli.Context) {
 		last, err = ref.LastCommit()
 		if err != nil {
 			println("Get last commit failed:", err.Error())
-			log.Error(err.Error())
+			log.Error("Get last commit failed: " + err.Error())
 			return
 		}
 
 		ref2, err := rep.LookupReference(ref.Name)
 		if err != nil {
 			println("look up reference failed:", err.Error())
-			log.Error(err.Error())
+			log.Error("look up reference failed: " + err.Error())
 			return
 		}
 
@@ -283,7 +293,7 @@ func runServ(k *cli.Context) {
 		before, err := ref2.LastCommit()
 		if err != nil {
 			println("Get last commit failed:", err.Error())
-			log.Error(err.Error())
+			log.Error("Get last commit failed: " + err.Error())
 			return
 		}
 		//log.Info("----", before.Id(), "-----", last.Id())

From 5d67960b1e812c2b455c93ec9c86d72c9c9a7f5b Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 19:38:07 +0800
Subject: [PATCH 08/26] fix style

---
 public/css/gogs.css | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index c8c5d87b8d..74dce472e2 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -97,11 +97,11 @@ html, body {
 }
 
 /* gogits nav item active status */
-.nav .active {
+#masthead .nav .active {
     color: #fff;
 }
 
-.nav .active:after {
+#masthead .nav .active:after {
     position: absolute;
     bottom: -1px;
     left: 50%;

From ca49acfe67cee4b5d4be40519b83d9107833e60d Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 07:38:48 -0400
Subject: [PATCH 09/26] Add more log to locate issue

---
 serve.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/serve.go b/serve.go
index 962f877745..a4d5a727d8 100644
--- a/serve.go
+++ b/serve.go
@@ -73,6 +73,8 @@ func In(b string, sl map[string]int) bool {
 }
 
 func runServ(k *cli.Context) {
+	log.Trace("new serv request")
+
 	base.NewConfigContext()
 	models.LoadModelsConfig()
 	models.NewEngine()

From 4f6889bef2bea9992330860e8605d5d0d06df23f Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 07:47:04 -0400
Subject: [PATCH 10/26] Add more log to locate issue

---
 modules/log/log.go | 6 +++++-
 serve.go           | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/modules/log/log.go b/modules/log/log.go
index 0c07c7c62a..e1bab8ae4a 100644
--- a/modules/log/log.go
+++ b/modules/log/log.go
@@ -9,7 +9,10 @@ import (
 	"github.com/gogits/logs"
 )
 
-var logger *logs.BeeLogger
+var (
+	logger       *logs.BeeLogger
+	Mode, Config string
+)
 
 func init() {
 	logger = logs.NewLogger(10000)
@@ -17,6 +20,7 @@ func init() {
 }
 
 func NewLogger(bufLen int64, mode, config string) {
+	Mode, Config = mode, config
 	logger = logs.NewLogger(bufLen)
 	logger.SetLogger(mode, config)
 }
diff --git a/serve.go b/serve.go
index a4d5a727d8..35adcaca34 100644
--- a/serve.go
+++ b/serve.go
@@ -73,6 +73,7 @@ func In(b string, sl map[string]int) bool {
 }
 
 func runServ(k *cli.Context) {
+	fmt.Println("new serv request", log.Mode, log.Config)
 	log.Trace("new serv request")
 
 	base.NewConfigContext()

From 09e7e76204c694278972f3225040726d2ec687cd Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 07:56:06 -0400
Subject: [PATCH 11/26] Add more log to locate issue

---
 serve.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/serve.go b/serve.go
index 35adcaca34..89ef0d848f 100644
--- a/serve.go
+++ b/serve.go
@@ -73,8 +73,7 @@ func In(b string, sl map[string]int) bool {
 }
 
 func runServ(k *cli.Context) {
-	fmt.Println("new serv request", log.Mode, log.Config)
-	log.Trace("new serv request")
+	log.Trace("new serv request " + log.Mode + ":" + log.Config)
 
 	base.NewConfigContext()
 	models.LoadModelsConfig()

From 197c4d4a5ba8a9540c49879324194f5f6be4689c Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 08:53:11 -0400
Subject: [PATCH 12/26] Fix wrong serve command log location and commit repo
 action

---
 models/action.go           | 6 ++++--
 modules/base/conf.go       | 4 ++--
 modules/middleware/repo.go | 2 +-
 serve.go                   | 6 ++++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/models/action.go b/models/action.go
index 44d7aea8ca..dffc0e537e 100644
--- a/models/action.go
+++ b/models/action.go
@@ -59,7 +59,7 @@ func (a Action) GetContent() string {
 // CommitRepoAction records action for commit repository.
 func CommitRepoAction(userId int64, userName string,
 	repoId int64, repoName string, refName string, commits *base.PushCommits) error {
-	log.Trace("action.CommitRepoAction: %d/%s", userId, repoName)
+	log.Trace("action.CommitRepoAction(start): %d/%s", userId, repoName)
 
 	bs, err := json.Marshal(commits)
 	if err != nil {
@@ -92,8 +92,8 @@ func CommitRepoAction(userId int64, userName string,
 		})
 		if err != nil {
 			log.Error("action.CommitRepoAction(notify watches): %d/%s", userId, repoName)
+			return err
 		}
-		return err
 	}
 
 	// Update repository last update time.
@@ -107,6 +107,8 @@ func CommitRepoAction(userId int64, userName string,
 		log.Error("action.CommitRepoAction(UpdateRepository): %d/%s", userId, repoName)
 		return err
 	}
+
+	log.Trace("action.CommitRepoAction(end): %d/%s", userId, repoName)
 	return nil
 }
 
diff --git a/modules/base/conf.go b/modules/base/conf.go
index 1661681e7e..0fb1ccdcf6 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -71,7 +71,7 @@ var Service struct {
 	ResetPwdCodeLives      int
 }
 
-func exeDir() (string, error) {
+func ExecDir() (string, error) {
 	file, err := exec.LookPath(os.Args[0])
 	if err != nil {
 		return "", err
@@ -244,7 +244,7 @@ func newNotifyMailService() {
 
 func NewConfigContext() {
 	//var err error
-	workDir, err := exeDir()
+	workDir, err := ExecDir()
 	if err != nil {
 		fmt.Printf("Fail to get work directory: %s\n", err)
 		os.Exit(2)
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index eea2570ca6..b23bccb104 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -73,7 +73,7 @@ func RepoAssignment(redirect bool) martini.Handler {
 		if base.EnableHttpsClone {
 			scheme = "https"
 		}
-		ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName)
+		ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", base.RunUser, base.Domain, user.LowerName, repo.LowerName)
 		ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s://%s/%s/%s.git", scheme, base.Domain, user.LowerName, repo.LowerName)
 
 		ctx.Data["IsRepositoryValid"] = true
diff --git a/serve.go b/serve.go
index 89ef0d848f..7e21fcae3a 100644
--- a/serve.go
+++ b/serve.go
@@ -45,10 +45,10 @@ gogs serv provide access auth for repositories`,
 	Flags:  []cli.Flag{},
 }
 
-func init() {
+func newLogger(execDir string) {
 	level := "0"
 	os.MkdirAll("log", os.ModePerm)
-	log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log"))
+	log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, execDir+"/log/serv.log"))
 	log.Trace("start logging...")
 }
 
@@ -73,6 +73,8 @@ func In(b string, sl map[string]int) bool {
 }
 
 func runServ(k *cli.Context) {
+	execDir, _ := base.ExecDir()
+	newLogger(execDir)
 	log.Trace("new serv request " + log.Mode + ":" + log.Config)
 
 	base.NewConfigContext()

From 9aba29dd8f067338025593b7c409b494d4b0ce32 Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 08:56:01 -0400
Subject: [PATCH 13/26] Fix wrong serve command log location and commit repo
 action

---
 serve.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/serve.go b/serve.go
index 7e21fcae3a..bfd2663fc6 100644
--- a/serve.go
+++ b/serve.go
@@ -11,6 +11,7 @@ import (
 	"io"
 	"os"
 	"os/exec"
+	"path"
 	"strconv"
 	"strings"
 	"time"
@@ -47,8 +48,9 @@ gogs serv provide access auth for repositories`,
 
 func newLogger(execDir string) {
 	level := "0"
-	os.MkdirAll("log", os.ModePerm)
-	log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, execDir+"/log/serv.log"))
+	logPath := execDir + "/log/serv.log"
+	os.MkdirAll(path.Dir(logPath), os.ModePerm)
+	log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, logPath))
 	log.Trace("start logging...")
 }
 

From e5d8fe41c4fd8331352c77d8a17d5c035f0787a2 Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 21:14:05 +0800
Subject: [PATCH 14/26] issue create page ui

---
 public/css/gogs.css         | 30 ++++++++++++++++++++++++++++--
 public/js/app.js            |  1 +
 templates/issue/create.tmpl | 36 ++++++++++++++++++++++++++++++++++--
 templates/repo/toolbar.tmpl |  5 +++++
 4 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index 74dce472e2..eeead844ae 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -512,6 +512,14 @@ html, body {
     height: 39px;
 }
 
+#repo-toolbar .nav .tmp a:hover {
+    text-decoration: none;
+}
+
+#repo-toolbar .nav .tmp .btn {
+    margin-top: -2px;
+}
+
 #repo-toolbar .nav .active {
     color: #F6F6F6;
 }
@@ -602,7 +610,7 @@ html, body {
 }
 
 /* #source */
-#source {
+#source, #commits {
     margin-top: -20px;
 }
 
@@ -857,7 +865,7 @@ html, body {
 }
 
 .guide-box, .diff-head-box {
-    margin-top: 20px;
+    margin-top: 4px;
 }
 
 .diff-head-box h4 {
@@ -991,6 +999,24 @@ html, body {
     color: #AAA;
 }
 
+/* issue */
+
+#issue-create-form .panel-body {
+    padding: 15px 0 0 0;
+}
+
+#issue-create-form .panel-body.form-group, #issue-create-form .tab-pane .form-group {
+    margin-bottom: 0;
+}
+
+#issue-create-form .nav-tabs {
+    margin-bottom: 10px;
+}
+
+#issue-create-form .md-help{
+    margin-top: 6px;
+}
+
 /* wrapper and footer */
 
 #wrapper {
diff --git a/public/js/app.js b/public/js/app.js
index 0973398a50..8b0e5cd62c 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -111,6 +111,7 @@ var Gogits = {
     };
     Gogits.initTabs = function () {
         var $tabs = $('[data-init=tabs]');
+        $tabs.tab("show");
         $tabs.find("li:eq(0) a").tab("show");
     };
     // fix dropdown inside click
diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl
index 2fb29d1b8b..34c7f40aa3 100644
--- a/templates/issue/create.tmpl
+++ b/templates/issue/create.tmpl
@@ -3,8 +3,40 @@
 {{template "repo/nav" .}}
 {{template "repo/toolbar" .}}
 <div id="body" class="container">
-    <div id="source">
-        new-issues
+    <div id="issue">
+        <form class="form" action="#" method="post" id="issue-create-form">
+            <div class="col-md-1">
+                <img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt=""/>
+            </div>
+            <div class="col-md-8 panel panel-default">
+                <div class="form-group panel-body">
+                    <input class="form-control input-lg" type="text" name="title" required="required" placeholder="Title"/>
+                </div>
+                <div class="form-group panel-body">
+                    <div class="md-help pull-right"><!-- todo help link -->
+                        Content with <a href="#">Markdown</a>
+                    </div>
+                    <ul class="nav nav-tabs" data-init="tabs">
+                        <li class="active"><a href="#issue-textarea" data-toggle="tab">Write</a></li>
+                        <li><a href="#issue-preview" data-toggle="tab">Preview</a></li>
+                    </ul>
+                    <div class="tab-content">
+                        <div class="tab-pane" id="issue-textarea">
+                            <div class="form-group">
+                                <textarea class="form-control" name="content" id="issue-content" rows="10" placeholder="Write some content"></textarea>
+                            </div>
+                        </div>
+                        <div class="tab-pane" id="issue-preview">preview</div>
+                    </div>
+                </div>
+                <div class="text-right panel-body">
+                    <div class="form-group">
+                        <input type="hidden" value="id" name="repo-id"/>
+                        <button class="btn-success btn">Create new issue</button>
+                    </div>
+                </div>
+            </div>
+        </form>
     </div>
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl
index 1f8a70984c..17d4e5b1ad 100644
--- a/templates/repo/toolbar.tmpl
+++ b/templates/repo/toolbar.tmpl
@@ -9,6 +9,11 @@
                     <!-- <li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="/{{.RepositoryLink}}/branches">Branches</a></li> -->
                     <!-- <li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li> -->
                     <li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="/{{.RepositoryLink}}/issues">Issues <!--<span class="badge">42</span>--></a></li>
+                    {{if .IsRepoToolbarIssues}}
+                    <li class="tmp"><a href="/{{.RepositoryLink}}/issues/new">
+                        <button class="btn btn-primary btn-sm">New Issue</button>
+                    </a></li>
+                    {{end}}
                     <!-- <li class="dropdown">
                         <a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
                         <ul class="dropdown-menu">

From 124c4d72bfd911b7966cfd513d469b3aff8ac086 Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 22:42:45 +0800
Subject: [PATCH 15/26] issue list in repo

---
 public/css/gogs.css   | 66 ++++++++++++++++++++++++++++++++++++++++++-
 routers/repo/issue.go |  2 +-
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index eeead844ae..ae970b4799 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -1013,10 +1013,74 @@ html, body {
     margin-bottom: 10px;
 }
 
-#issue-create-form .md-help{
+#issue-create-form .md-help {
     margin-top: 6px;
 }
 
+#issue .filter-list a {
+    padding: 6px 10px;
+    font-size: 14px;
+    display: block;
+    margin-bottom: 6px;
+    border-radius: 3px;
+    color: #444;
+}
+
+#issue .filter-list a:hover {
+    background-color: #DDD;
+    text-decoration: none;
+}
+
+#issue .filter-list a.active {
+    background-color: #4183c4;
+    color: #FFF;
+}
+
+#issue .filter-option {
+    margin-bottom: 12px;
+}
+
+#issue .list-group .list-group-item {
+    background-color: #FFF;
+}
+
+#issue .list-group .list-group-item.unread {
+    border-left: 2px solid #DD4B39;
+}
+
+#issue .issue-item .title {
+    margin-bottom: 16px;
+}
+
+#issue .issue-item h5.title a {
+    color: #444;
+}
+
+#issue .issue-item.unread h5 {
+    font-weight: bold;
+}
+
+#issue .issue-item .info span {
+    margin-right: 12px;
+    color: #888;
+    line-height: 20px;
+}
+
+#issue .issue-item .info a, #issue .issue-item .number {
+    color: #888;
+}
+
+#issue .issue-item .number {
+    margin-top: 8px;
+}
+
+#issue .issue-item .avatar {
+    margin-right: 8px;
+    width: 20px;
+    height: 20px;
+    vertical-align: top;
+}
+
 /* wrapper and footer */
 
 #wrapper {
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index d54582a2a0..ab070d724c 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -35,7 +35,7 @@ func Issues(ctx *middleware.Context, params martini.Params) {
 		params["branchname"] = "master"
 	}
 	ctx.Data["Branchname"] = params["branchname"]
-	ctx.HTML(200, "repo/issues")
+	ctx.HTML(200, "issue/repo")
 }
 
 func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {

From 23d103c72163cdb4ea65c9756edf22c597060a7e Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 23:00:26 +0800
Subject: [PATCH 16/26] issue list in user

---
 public/css/gogs.css        | 12 +++++++
 routers/user/user.go       |  3 +-
 templates/issue/repo.tmpl  | 56 ++++++++++++++++++++++++++++++
 templates/issue/user.tmpl  | 70 ++++++++++++++++++++++++++++++++++++++
 templates/repo/issues.tmpl | 10 ------
 templates/user/issues.tmpl | 17 ---------
 6 files changed, 140 insertions(+), 28 deletions(-)
 create mode 100644 templates/issue/repo.tmpl
 create mode 100644 templates/issue/user.tmpl
 delete mode 100644 templates/repo/issues.tmpl
 delete mode 100644 templates/user/issues.tmpl

diff --git a/public/css/gogs.css b/public/css/gogs.css
index ae970b4799..06f5931916 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -1026,6 +1026,14 @@ html, body {
     color: #444;
 }
 
+#issue .filter-list a.sm{
+    font-size: 13px;
+}
+
+#issue .filter-list hr{
+    border-color: #CCC;
+}
+
 #issue .filter-list a:hover {
     background-color: #DDD;
     text-decoration: none;
@@ -1044,6 +1052,10 @@ html, body {
     background-color: #FFF;
 }
 
+#issue .issue-item:hover{
+    background-color: rgba(19, 95, 215, 0.03);
+}
+
 #issue .list-group .list-group-item.unread {
     border-left: 2px solid #DD4B39;
 }
diff --git a/routers/user/user.go b/routers/user/user.go
index a0321f187b..d3ef96211e 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -285,7 +285,8 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
 }
 
 func Issues(ctx *middleware.Context) {
-	ctx.HTML(200, "user/issues")
+	ctx.Data["Title"] = "Your Issues"
+	ctx.HTML(200, "issue/user")
 }
 
 func Pulls(ctx *middleware.Context) {
diff --git a/templates/issue/repo.tmpl b/templates/issue/repo.tmpl
new file mode 100644
index 0000000000..c348f27ff6
--- /dev/null
+++ b/templates/issue/repo.tmpl
@@ -0,0 +1,56 @@
+{{template "base/head" .}}
+{{template "base/navbar" .}}
+{{template "repo/nav" .}}
+{{template "repo/toolbar" .}}
+<div id="body" class="container">
+    <div id="issue">
+        <div class="col-md-3 filter-list">
+            <ul class="list-unstyled">
+                <li><a href="#" class="active">All Issues <strong class="pull-right">10</strong></a></li>
+                <li><a href="#">My Issues</a></li>
+                <li><a href="#">Mentioned</a></li>
+            </ul>
+        </div>
+        <div class="col-md-9">
+            <div class="filter-option">
+                <div class="btn-group">
+                    <a class="btn btn-default active issue-open" href="#">27 Open</a>
+                    <a class="btn btn-default issue-close" href="#">Close 128</a>
+                </div>
+            </div>
+            <div class="issues list-group">
+                <div class="list-group-item unread issue-item" id="issue-id">
+                    <span class="number pull-right">#123</span>
+                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
+                        <a href="#">Obama</a></span>
+                        <span class="time">3 days ago</span>
+                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
+                    </p>
+                </div>
+                <div class="list-group-item issue-item" id="issue-id2">
+                    <span class="number pull-right">#123</span>
+                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
+                        <a href="#">Obama</a></span>
+                        <span class="time">3 days ago</span>
+                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
+                    </p>
+                </div>
+                <div class="list-group-item issue-item" id="issue-id3">
+                    <span class="number pull-right">#123</span>
+                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
+                        <a href="#">Obama</a></span>
+                        <span class="time">3 days ago</span>
+                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
+                    </p>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/issue/user.tmpl b/templates/issue/user.tmpl
new file mode 100644
index 0000000000..2cf9571306
--- /dev/null
+++ b/templates/issue/user.tmpl
@@ -0,0 +1,70 @@
+{{template "base/head" .}}
+{{template "base/navbar" .}}
+<div id="body-nav">
+    <div class="container">
+        <ul class="nav nav-pills pull-right">
+            <li><a href="/">Feed</a></li>
+            <li class="active"><a href="/issues">Issues</a></li>
+            <!-- <li><a href="/pulls">Pull Requests</a></li>
+            <li><a href="/stars">Stars</a></li> -->
+        </ul>
+        <h3>Your Issues</h3>
+    </div>
+</div>
+<div id="body" class="container" data-page="user">
+    {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
+    <div id="issue">
+        <div class="col-md-3 filter-list">
+            <ul class="list-unstyled">
+                <li><a href="#" class="active">In your repositories <strong class="pull-right">10</strong></a></li>
+                <li><a href="#">Created by you</a></li>
+                <li><a href="#">Assigned to you</a></li>
+                <li><hr/></li>
+                <li><a href="" class="sm">gogits/gogs <strong class="pull-right">12</strong></a></li>
+                <li><a href="" class="sm">gogits/session <strong class="pull-right">8</strong></a></li>
+                <li><a href="" class="sm">gogits/git <strong class="pull-right">2</strong></a></li>
+            </ul>
+        </div>
+        <div class="col-md-9">
+            <div class="filter-option">
+                <div class="btn-group">
+                    <a class="btn btn-default active issue-open" href="#">27 Open</a>
+                    <a class="btn btn-default issue-close" href="#">Close 128</a>
+                </div>
+            </div>
+            <div class="issues list-group">
+                <div class="list-group-item unread issue-item" id="issue-id">
+                    <span class="number pull-right">#123</span>
+                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
+                        <a href="#">Obama</a></span>
+                        <span class="time">3 days ago</span>
+                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
+                    </p>
+                </div>
+                <div class="list-group-item issue-item" id="issue-id2">
+                    <span class="number pull-right">#123</span>
+                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
+                        <a href="#">Obama</a></span>
+                        <span class="time">3 days ago</span>
+                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
+                    </p>
+                </div>
+                <div class="list-group-item issue-item" id="issue-id3">
+                    <span class="number pull-right">#123</span>
+                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
+                        <a href="#">Obama</a></span>
+                        <span class="time">3 days ago</span>
+                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
+                    </p>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/repo/issues.tmpl b/templates/repo/issues.tmpl
deleted file mode 100644
index df53197c36..0000000000
--- a/templates/repo/issues.tmpl
+++ /dev/null
@@ -1,10 +0,0 @@
-{{template "base/head" .}}
-{{template "base/navbar" .}}
-{{template "repo/nav" .}}
-{{template "repo/toolbar" .}}
-<div id="body" class="container">
-    <div id="source">
-        issues
-    </div>
-</div>
-{{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/user/issues.tmpl b/templates/user/issues.tmpl
deleted file mode 100644
index dd17b667d1..0000000000
--- a/templates/user/issues.tmpl
+++ /dev/null
@@ -1,17 +0,0 @@
-{{template "base/head" .}}
-{{template "base/navbar" .}}
-<div id="body-nav">
-    <div class="container">
-        <ul class="nav nav-pills pull-right">
-            <li><a href="/">Feed</a></li>
-            <li class="active"><a href="/issues">Issues</a></li>
-            <!-- <li><a href="/pulls">Pull Requests</a></li>
-            <li><a href="/stars">Stars</a></li> -->
-        </ul>
-        <h3>Issues</h3>
-    </div>
-</div>
-<div id="body" class="container" data-page="user">
-    {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
-</div>
-{{template "base/footer" .}}
\ No newline at end of file

From 8ce9458d654c38d7e815d78a14b9f3daf599e284 Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 23:58:23 +0800
Subject: [PATCH 17/26] issue style change

---
 public/css/gogs.css | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index 06f5931916..69d8f7f49f 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -1026,11 +1026,11 @@ html, body {
     color: #444;
 }
 
-#issue .filter-list a.sm{
+#issue .filter-list a.sm {
     font-size: 13px;
 }
 
-#issue .filter-list hr{
+#issue .filter-list hr {
     border-color: #CCC;
 }
 
@@ -1052,7 +1052,7 @@ html, body {
     background-color: #FFF;
 }
 
-#issue .issue-item:hover{
+#issue .issue-item:hover {
     background-color: rgba(19, 95, 215, 0.03);
 }
 
@@ -1062,16 +1062,13 @@ html, body {
 
 #issue .issue-item .title {
     margin-bottom: 16px;
+    font-weight: bold;
 }
 
 #issue .issue-item h5.title a {
     color: #444;
 }
 
-#issue .issue-item.unread h5 {
-    font-weight: bold;
-}
-
 #issue .issue-item .info span {
     margin-right: 12px;
     color: #888;

From 84bec2842f6b926e5d287d6201560364771cd64c Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 25 Mar 2014 23:59:50 +0800
Subject: [PATCH 18/26] issue style change

---
 public/css/gogs.css | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index 69d8f7f49f..6bf698e8b1 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -1001,6 +1001,11 @@ html, body {
 
 /* issue */
 
+#issue-create-form .avatar {
+    width: 50px;
+    height: 50px;
+}
+
 #issue-create-form .panel-body {
     padding: 15px 0 0 0;
 }

From 2fa8d0c8dd43f95e1659a266e84c7713cc8f2fcf Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 12:12:27 -0400
Subject: [PATCH 19/26] Added create issue

---
 gogs.go                                  |  2 +-
 modules/auth/issue.go                    |  9 +++------
 modules/avatar/avatar.go                 |  3 ++-
 modules/base/tool.go                     |  5 ++++-
 modules/middleware/repo.go               |  5 +++++
 routers/repo/branch.go                   |  5 -----
 routers/repo/issue.go                    | 11 +++--------
 routers/repo/pull.go                     |  5 -----
 routers/repo/repo.go                     | 14 --------------
 serve.go                                 |  5 ++---
 templates/issue/create.tmpl              |  9 +++++----
 templates/issue/{repo.tmpl => list.tmpl} |  5 +++++
 templates/repo/nav.tmpl                  |  2 +-
 web.go                                   |  6 +++---
 14 files changed, 34 insertions(+), 52 deletions(-)
 rename templates/issue/{repo.tmpl => list.tmpl} (93%)

diff --git a/gogs.go b/gogs.go
index 7ac699cc69..b62580f8fd 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.1.7.0324"
+const APP_VER = "0.1.7.0325"
 
 func init() {
 	base.AppVer = APP_VER
diff --git a/modules/auth/issue.go b/modules/auth/issue.go
index e2b1f9f2a7..8bf49684c6 100644
--- a/modules/auth/issue.go
+++ b/modules/auth/issue.go
@@ -17,9 +17,8 @@ import (
 )
 
 type CreateIssueForm struct {
-	IssueName   string `form:"name" binding:"Required;MaxSize(50)"`
-	RepoId      int64  `form:"repoid" binding:"Required"`
-	MilestoneId int64  `form:"milestoneid" binding:"Required"`
+	IssueName   string `form:"title" binding:"Required;MaxSize(50)"`
+	MilestoneId int64  `form:"milestoneid"`
 	AssigneeId  int64  `form:"assigneeid"`
 	Labels      string `form:"labels"`
 	Content     string `form:"content"`
@@ -27,9 +26,7 @@ type CreateIssueForm struct {
 
 func (f *CreateIssueForm) Name(field string) string {
 	names := map[string]string{
-		"IssueName":   "Issue name",
-		"RepoId":      "Repository ID",
-		"MilestoneId": "Milestone ID",
+		"IssueName": "Issue name",
 	}
 	return names[field]
 }
diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go
index 3b423a6d15..449c9656dc 100644
--- a/modules/avatar/avatar.go
+++ b/modules/avatar/avatar.go
@@ -30,8 +30,9 @@ import (
 	"sync"
 	"time"
 
-	"github.com/gogits/gogs/modules/log"
 	"github.com/nfnt/resize"
+
+	"github.com/gogits/gogs/modules/log"
 )
 
 var (
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 0dec7aa8dd..c23f5de6cc 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -102,7 +102,10 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
 
 // AvatarLink returns avatar link by given e-mail.
 func AvatarLink(email string) string {
-	return "/avatar/" + EncodeMd5(email)
+	if Service.EnableCacheAvatar {
+		return "/avatar/" + EncodeMd5(email)
+	}
+	return "http://1.gravatar.com/avatar/" + EncodeMd5(email)
 }
 
 // Seconds-based time units
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index b23bccb104..bc90c05cc7 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -76,6 +76,11 @@ func RepoAssignment(redirect bool) martini.Handler {
 		ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", base.RunUser, base.Domain, user.LowerName, repo.LowerName)
 		ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s://%s/%s/%s.git", scheme, base.Domain, user.LowerName, repo.LowerName)
 
+		if len(params["branchname"]) == 0 {
+			params["branchname"] = "master"
+		}
+		ctx.Data["Branchname"] = params["branchname"]
+
 		ctx.Data["IsRepositoryValid"] = true
 		ctx.Data["Repository"] = repo
 		ctx.Data["Owner"] = user
diff --git a/routers/repo/branch.go b/routers/repo/branch.go
index 8c953f2ede..aed77cfaa5 100644
--- a/routers/repo/branch.go
+++ b/routers/repo/branch.go
@@ -26,11 +26,6 @@ func Branches(ctx *middleware.Context, params martini.Params) {
 
 	ctx.Data["Username"] = params["username"]
 	ctx.Data["Reponame"] = params["reponame"]
-
-	if len(params["branchname"]) == 0 {
-		params["branchname"] = "master"
-	}
-	ctx.Data["Branchname"] = params["branchname"]
 	ctx.Data["Branches"] = brs
 	ctx.Data["IsRepoToolbarBranches"] = true
 
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index ab070d724c..4e8324605c 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -30,12 +30,7 @@ func Issues(ctx *middleware.Context, params martini.Params) {
 		ctx.Handle(200, "issue.Issues: %v", err)
 		return
 	}
-
-	if len(params["branchname"]) == 0 {
-		params["branchname"] = "master"
-	}
-	ctx.Data["Branchname"] = params["branchname"]
-	ctx.HTML(200, "issue/repo")
+	ctx.HTML(200, "issue/list")
 }
 
 func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
@@ -57,10 +52,10 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
 		return
 	}
 
-	issue, err := models.CreateIssue(ctx.User.Id, form.RepoId, form.MilestoneId, form.AssigneeId,
+	issue, err := models.CreateIssue(ctx.User.Id, ctx.Repo.Repository.Id, form.MilestoneId, form.AssigneeId,
 		form.IssueName, form.Labels, form.Content, false)
 	if err == nil {
-		log.Trace("%s Issue created: %d", form.RepoId, issue.Id)
+		log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id)
 		ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index))
 		return
 	}
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 16c60389da..93b6a9f7cc 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -12,10 +12,5 @@ import (
 
 func Pulls(ctx *middleware.Context, params martini.Params) {
 	ctx.Data["IsRepoToolbarPulls"] = true
-	if len(params["branchname"]) == 0 {
-		params["branchname"] = "master"
-	}
-
-	ctx.Data["Branchname"] = params["branchname"]
 	ctx.HTML(200, "repo/pulls")
 }
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index cd28d52caa..acf025a284 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -57,10 +57,6 @@ func Single(ctx *middleware.Context, params martini.Params) {
 		return
 	}
 
-	if len(params["branchname"]) == 0 {
-		params["branchname"] = "master"
-	}
-
 	// Get tree path
 	treename := params["_1"]
 
@@ -177,7 +173,6 @@ func Single(ctx *middleware.Context, params martini.Params) {
 
 	ctx.Data["Username"] = params["username"]
 	ctx.Data["Reponame"] = params["reponame"]
-	ctx.Data["Branchname"] = params["branchname"]
 
 	var treenames []string
 	Paths := make([]string, 0)
@@ -216,10 +211,6 @@ func SingleDownload(ctx *middleware.Context, params martini.Params) {
 		return
 	}
 
-	if len(params["branchname"]) == 0 {
-		params["branchname"] = "master"
-	}
-
 	// Get tree path
 	treename := params["_1"]
 
@@ -290,11 +281,6 @@ func Setting(ctx *middleware.Context, params martini.Params) {
 		title = t
 	}
 
-	if len(params["branchname"]) == 0 {
-		params["branchname"] = "master"
-	}
-
-	ctx.Data["Branchname"] = params["branchname"]
 	ctx.Data["Title"] = title + " - settings"
 	ctx.HTML(200, "repo/setting")
 }
diff --git a/serve.go b/serve.go
index bfd2663fc6..25a34efbaf 100644
--- a/serve.go
+++ b/serve.go
@@ -249,8 +249,8 @@ func runServ(k *cli.Context) {
 		}
 	}
 	if refname == "" {
-		println("No find any reference name:", b.String())
-		log.Error("No find any reference name: " + b.String())
+		println("Not found any reference name:", b.String())
+		log.Error("Not found any reference name: " + b.String())
 		return
 	}
 
@@ -267,7 +267,6 @@ func runServ(k *cli.Context) {
 			return
 		}
 		if ref, ok = refs[refname]; !ok {
-			log.Error("unknow reference name -", refname, "-", b.String())
 			log.Error("unknow reference name -", refname, "-", b.String())
 			return
 		}
diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl
index 34c7f40aa3..cbc21f6ce0 100644
--- a/templates/issue/create.tmpl
+++ b/templates/issue/create.tmpl
@@ -4,13 +4,14 @@
 {{template "repo/toolbar" .}}
 <div id="body" class="container">
     <div id="issue">
-        <form class="form" action="#" method="post" id="issue-create-form">
+        <form class="form" action="/{{.RepositoryLink}}/issues/new" method="post" id="issue-create-form">
+            {{.CsrfTokenHtml}}
             <div class="col-md-1">
-                <img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt=""/>
+                <img class="avatar" src="{{.SignedUser.AvatarLink}}" alt=""/>
             </div>
             <div class="col-md-8 panel panel-default">
                 <div class="form-group panel-body">
-                    <input class="form-control input-lg" type="text" name="title" required="required" placeholder="Title"/>
+                    <input class="form-control input-lg" type="text" name="title" required="required" placeholder="Title" value="{{.title}}" />
                 </div>
                 <div class="form-group panel-body">
                     <div class="md-help pull-right"><!-- todo help link -->
@@ -23,7 +24,7 @@
                     <div class="tab-content">
                         <div class="tab-pane" id="issue-textarea">
                             <div class="form-group">
-                                <textarea class="form-control" name="content" id="issue-content" rows="10" placeholder="Write some content"></textarea>
+                                <textarea class="form-control" name="content" id="issue-content" rows="10" placeholder="Write some content">{{.content}}</textarea>
                             </div>
                         </div>
                         <div class="tab-pane" id="issue-preview">preview</div>
diff --git a/templates/issue/repo.tmpl b/templates/issue/list.tmpl
similarity index 93%
rename from templates/issue/repo.tmpl
rename to templates/issue/list.tmpl
index c348f27ff6..685eaeeb96 100644
--- a/templates/issue/repo.tmpl
+++ b/templates/issue/list.tmpl
@@ -18,6 +18,11 @@
                     <a class="btn btn-default issue-close" href="#">Close 128</a>
                 </div>
             </div>
+            <div class="issues list-group">
+                {{range .Issues}}
+                <div class="list-group-item issue-item" id="{{.Id}}"></div>
+                {{end}}
+            </div>
             <div class="issues list-group">
                 <div class="list-group-item unread issue-item" id="issue-id">
                     <span class="number pull-right">#123</span>
diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl
index e1b22b1c93..02096c34c1 100644
--- a/templates/repo/nav.tmpl
+++ b/templates/repo/nav.tmpl
@@ -2,7 +2,7 @@
     <div class="container">
         <div class="row">
             <div class="col-md-7">
-                <h3 class="name"><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / {{.Repository.Name}}</h3>
+                <h3 class="name"><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="/{{.Owner.Name}}/{{.Repository.Name}}">{{.Repository.Name}}</a></h3>
                 <p class="desc">{{.Repository.Description}}{{if .Repository.Website}} <a href="{{.Repository.Website}}">{{.Repository.Website}}</a>{{end}}</p>
             </div>
             <div class="col-md-5 actions text-right clone-group-btn">
diff --git a/web.go b/web.go
index 6538c61f19..9b7b21639a 100644
--- a/web.go
+++ b/web.go
@@ -90,7 +90,7 @@ func runWeb(*cli.Context) {
 
 	// Routers.
 	m.Get("/", ignSignIn, routers.Home)
-	m.Get("/install",routers.Install)
+	m.Get("/install", routers.Install)
 	m.Get("/issues", reqSignIn, user.Issues)
 	m.Get("/pulls", reqSignIn, user.Pulls)
 	m.Get("/stars", reqSignIn, user.Stars)
@@ -142,13 +142,13 @@ func runWeb(*cli.Context) {
 		r.Post("/settings", repo.SettingPost)
 		r.Get("/settings", repo.Setting)
 		r.Get("/action/:action", repo.Action)
+		r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue)
+		r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue)
 	}, reqSignIn, middleware.RepoAssignment(true))
 	m.Group("/:username/:reponame", func(r martini.Router) {
 		r.Get("/commits/:branchname", repo.Commits)
 		r.Get("/issues", repo.Issues)
-		r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue)
 		r.Get("/issues/:index", repo.ViewIssue)
-		r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue)
 		r.Get("/pulls", repo.Pulls)
 		r.Get("/branches", repo.Branches)
 		r.Get("/src/:branchname", repo.Single)

From d3b8e9daa1a22501c03564f2739f9fa8198fbdf1 Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 14:04:57 -0400
Subject: [PATCH 20/26] Add notify watcher action

---
 README.md                 |  2 +-
 README_ZH.md              |  2 +-
 models/action.go          | 29 ++--------------
 models/issue.go           |  1 +
 models/repo.go            | 71 ++++++++++++++++++++++++++++-----------
 modules/base/tool.go      | 21 ++++++++----
 routers/repo/issue.go     | 40 ++++++++++++++++++----
 templates/issue/list.tmpl | 48 +++++++-------------------
 8 files changed, 119 insertions(+), 95 deletions(-)

diff --git a/README.md b/README.md
index a39a92a322..d99031c687 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
 - Create/delete/watch public repository.
 - User profile page.
 - Repository viewer.
-- Gravatar support.
+- Gravatar and cache support.
 - Mail service(register).
 - Administration panel.
 - Supports MySQL, PostgreSQL and SQLite3(binary release only).
diff --git a/README_ZH.md b/README_ZH.md
index 440f952f86..0a4d3bdc16 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -28,7 +28,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
 - 创建/删除/关注公开仓库
 - 用户个人信息页面
 - 仓库浏览器
-- Gravatar 支持
+- Gravatar 以及缓存支持
 - 邮件服务(注册)
 - 管理员面板
 - 支持 MySQL、PostgreSQL 以及 SQLite3(仅限二进制版本)
diff --git a/models/action.go b/models/action.go
index dffc0e537e..edf1bf58f9 100644
--- a/models/action.go
+++ b/models/action.go
@@ -19,6 +19,7 @@ const (
 	OP_STAR_REPO
 	OP_FOLLOW_REPO
 	OP_COMMIT_REPO
+	OP_CREATE_ISSUE
 	OP_PULL_REQUEST
 )
 
@@ -67,34 +68,10 @@ func CommitRepoAction(userId int64, userName string,
 		return err
 	}
 
-	// Add feeds for user self and all watchers.
-	watches, err := GetWatches(repoId)
-	if err != nil {
-		log.Error("action.CommitRepoAction(get watches): %d/%s", userId, repoName)
+	if err = NotifyWatchers(userId, repoId, OP_COMMIT_REPO, userName, repoName, refName, string(bs)); err != nil {
+		log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
 		return err
 	}
-	watches = append(watches, Watch{UserId: userId})
-
-	for i := range watches {
-		if userId == watches[i].UserId && i > 0 {
-			continue // Do not add twice in case author watches his/her repository.
-		}
-
-		_, err = orm.InsertOne(&Action{
-			UserId:      watches[i].UserId,
-			ActUserId:   userId,
-			ActUserName: userName,
-			OpType:      OP_COMMIT_REPO,
-			Content:     string(bs),
-			RepoId:      repoId,
-			RepoName:    repoName,
-			RefName:     refName,
-		})
-		if err != nil {
-			log.Error("action.CommitRepoAction(notify watches): %d/%s", userId, repoName)
-			return err
-		}
-	}
 
 	// Update repository last update time.
 	repo, err := GetRepositoryByName(userId, repoName)
diff --git a/models/issue.go b/models/issue.go
index fe43a94b59..2bdd083d90 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -23,6 +23,7 @@ type Issue struct {
 	Name        string
 	RepoId      int64 `xorm:"index"`
 	PosterId    int64
+	Poster      *User `xorm:"-"`
 	MilestoneId int64
 	AssigneeId  int64
 	IsPull      bool // Indicates whether is a pull request or not.
diff --git a/models/repo.go b/models/repo.go
index d5f9be72ac..824d5ba0ca 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -262,27 +262,27 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
 	}
 
 	/*
-	// hook/post-update
-	pu, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-update"), os.O_CREATE|os.O_WRONLY, 0777)
-	if err != nil {
-		return err
-	}
-	defer pu.Close()
-	// TODO: Windows .bat
-	if _, err = pu.WriteString(fmt.Sprintf("#!/usr/bin/env bash\n%s update\n", appPath)); err != nil {
-		return err
-	}
+		// hook/post-update
+		pu, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-update"), os.O_CREATE|os.O_WRONLY, 0777)
+		if err != nil {
+			return err
+		}
+		defer pu.Close()
+		// TODO: Windows .bat
+		if _, err = pu.WriteString(fmt.Sprintf("#!/usr/bin/env bash\n%s update\n", appPath)); err != nil {
+			return err
+		}
 
-	// hook/post-update
-	pu2, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-receive"), os.O_CREATE|os.O_WRONLY, 0777)
-	if err != nil {
-		return err
-	}
-	defer pu2.Close()
-	// TODO: Windows .bat
-	if _, err = pu2.WriteString("#!/usr/bin/env bash\ngit update-server-info\n"); err != nil {
-		return err
-	}
+		// hook/post-update
+		pu2, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-receive"), os.O_CREATE|os.O_WRONLY, 0777)
+		if err != nil {
+			return err
+		}
+		defer pu2.Close()
+		// TODO: Windows .bat
+		if _, err = pu2.WriteString("#!/usr/bin/env bash\ngit update-server-info\n"); err != nil {
+			return err
+		}
 	*/
 
 	// Initialize repository according to user's choice.
@@ -506,6 +506,37 @@ func GetWatches(repoId int64) ([]Watch, error) {
 	return watches, err
 }
 
+// NotifyWatchers creates batch of actions for every watcher.
+func NotifyWatchers(userId, repoId int64, opType int, userName, repoName, refName, content string) error {
+	// Add feeds for user self and all watchers.
+	watches, err := GetWatches(repoId)
+	if err != nil {
+		return errors.New("repo.NotifyWatchers(get watches): " + err.Error())
+	}
+	watches = append(watches, Watch{UserId: userId})
+
+	for i := range watches {
+		if userId == watches[i].UserId && i > 0 {
+			continue // Do not add twice in case author watches his/her repository.
+		}
+
+		_, err = orm.InsertOne(&Action{
+			UserId:      watches[i].UserId,
+			ActUserId:   userId,
+			ActUserName: userName,
+			OpType:      opType,
+			Content:     content,
+			RepoId:      repoId,
+			RepoName:    repoName,
+			RefName:     refName,
+		})
+		if err != nil {
+			return errors.New("repo.NotifyWatchers(create action): " + err.Error())
+		}
+	}
+	return nil
+}
+
 // IsWatching checks if user has watched given repository.
 func IsWatching(userId, repoId int64) bool {
 	has, _ := orm.Get(&Watch{0, repoId, userId})
diff --git a/modules/base/tool.go b/modules/base/tool.go
index c23f5de6cc..8f38d492a5 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -486,15 +486,19 @@ func ActionIcon(opType int) string {
 		return "plus-circle"
 	case 5: // Commit repository.
 		return "arrow-circle-o-right"
+	case 6: // Create issue.
+		return "exclamation-circle"
 	default:
 		return "invalid type"
 	}
 }
 
 const (
-	TPL_CREATE_REPO    = `<a href="/user/%s">%s</a> created repository <a href="/%s/%s">%s</a>`
-	TPL_COMMIT_REPO    = `<a href="/user/%s">%s</a> pushed to <a href="/%s/%s/tree/%s">%s</a> at <a href="/%s/%s">%s/%s</a>%s`
-	TPL_COMMIT_REPO_LI = `<div><img id="gogs-user-avatar-commit" src="%s?s=16" alt="user-avatar" title="username"/> <a href="/%s/%s/commit/%s">%s</a> %s</div>`
+	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_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>`
 )
 
 type PushCommits struct {
@@ -507,11 +511,12 @@ type PushCommits struct {
 func ActionDesc(act Actioner, avatarLink string) string {
 	actUserName := act.GetActUserName()
 	repoName := act.GetRepoName()
+	repoLink := actUserName + "/" + repoName
 	branch := act.GetBranch()
 	content := act.GetContent()
 	switch act.GetOpType() {
 	case 1: // Create repository.
-		return fmt.Sprintf(TPL_CREATE_REPO, actUserName, actUserName, actUserName, repoName, repoName)
+		return fmt.Sprintf(TPL_CREATE_REPO, actUserName, actUserName, repoLink, repoName)
 	case 5: // Commit repository.
 		var push *PushCommits
 		if err := json.Unmarshal([]byte(content), &push); err != nil {
@@ -519,13 +524,17 @@ func ActionDesc(act Actioner, avatarLink string) string {
 		}
 		buf := bytes.NewBuffer([]byte("\n"))
 		for _, commit := range push.Commits {
-			buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n")
+			buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit[0], commit[0][:7], commit[1]) + "\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))
 		}
-		return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, branch, branch, actUserName, repoName, actUserName, repoName,
+		return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink,
 			buf.String())
+	case 6: // Create issue.
+		infos := strings.SplitN(content, "|", 2)
+		return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
+			avatarLink, infos[1])
 	default:
 		return "invalid type"
 	}
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 4e8324605c..fc5bb98643 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -23,13 +23,33 @@ func Issues(ctx *middleware.Context, params martini.Params) {
 	milestoneId, _ := base.StrTo(params["milestone"]).Int()
 	page, _ := base.StrTo(params["page"]).Int()
 
-	var err error
-	ctx.Data["Issues"], err = models.GetIssues(0, ctx.Repo.Repository.Id, 0,
+	// Get issues.
+	issues, err := models.GetIssues(0, ctx.Repo.Repository.Id, 0,
 		int64(milestoneId), page, params["state"] == "closed", false, params["labels"], params["sortType"])
 	if err != nil {
 		ctx.Handle(200, "issue.Issues: %v", err)
 		return
 	}
+
+	var closedCount int
+	// Get posters.
+	for i := range issues {
+		u, err := models.GetUserById(issues[i].PosterId)
+		if err != nil {
+			ctx.Handle(200, "issue.Issues(get poster): %v", err)
+			return
+		}
+
+		if issues[i].IsClosed {
+			closedCount++
+		}
+		issues[i].Poster = u
+	}
+
+	ctx.Data["Issues"] = issues
+	ctx.Data["IssueCount"] = len(issues)
+	ctx.Data["OpenCount"] = len(issues) - closedCount
+	ctx.Data["ClosedCount"] = closedCount
 	ctx.HTML(200, "issue/list")
 }
 
@@ -54,12 +74,20 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
 
 	issue, err := models.CreateIssue(ctx.User.Id, ctx.Repo.Repository.Id, form.MilestoneId, form.AssigneeId,
 		form.IssueName, form.Labels, form.Content, false)
-	if err == nil {
-		log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id)
-		ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index))
+	if err != nil {
+		ctx.Handle(200, "issue.CreateIssue", err)
 		return
 	}
-	ctx.Handle(200, "issue.CreateIssue", err)
+
+	// Notify watchers.
+	if err = models.NotifyWatchers(ctx.User.Id, ctx.Repo.Repository.Id, models.OP_CREATE_ISSUE,
+		ctx.User.Name, ctx.Repo.Repository.Name, "", fmt.Sprintf("%d|%s", issue.Index, issue.Name)); err != nil {
+		ctx.Handle(200, "issue.CreateIssue", err)
+		return
+	}
+
+	log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id)
+	ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index))
 }
 
 func ViewIssue(ctx *middleware.Context, params martini.Params) {
diff --git a/templates/issue/list.tmpl b/templates/issue/list.tmpl
index 685eaeeb96..0df6883867 100644
--- a/templates/issue/list.tmpl
+++ b/templates/issue/list.tmpl
@@ -6,7 +6,7 @@
     <div id="issue">
         <div class="col-md-3 filter-list">
             <ul class="list-unstyled">
-                <li><a href="#" class="active">All Issues <strong class="pull-right">10</strong></a></li>
+                <li><a href="#" class="active">All Issues <strong class="pull-right">{{.IssueCount}}</strong></a></li>
                 <li><a href="#">My Issues</a></li>
                 <li><a href="#">Mentioned</a></li>
             </ul>
@@ -14,46 +14,24 @@
         <div class="col-md-9">
             <div class="filter-option">
                 <div class="btn-group">
-                    <a class="btn btn-default active issue-open" href="#">27 Open</a>
-                    <a class="btn btn-default issue-close" href="#">Close 128</a>
+                    <a class="btn btn-default active issue-open" href="#">{{.OpenCount}} Open</a>
+                    <a class="btn btn-default issue-close" href="#">{{.ClosedCount}} Closed</a>
                 </div>
             </div>
             <div class="issues list-group">
                 {{range .Issues}}
-                <div class="list-group-item issue-item" id="{{.Id}}"></div>
+                <div class="list-group-item issue-item" id="{{.Id}}">
+                    <span class="number pull-right">#{{.Index}}</span>
+                    <h5 class="title"><a href="/{{$.RepositoryLink}}/issues/{{.Index}}">{{.Name}}</a></h5>
+                    <p class="info">
+                        <span class="author"><img class="avatar" src="{{.Poster.AvatarLink}}" alt="" width="20"/>
+                        <a href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a></span>
+                        <span class="time">{{TimeSince .Created}}</span>
+                        <span class="comment"><i class="fa fa-comments"></i> {{.NumComments}}</span>
+                    </p>
+                </div>
                 {{end}}
             </div>
-            <div class="issues list-group">
-                <div class="list-group-item unread issue-item" id="issue-id">
-                    <span class="number pull-right">#123</span>
-                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
-                    <p class="info">
-                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
-                        <a href="#">Obama</a></span>
-                        <span class="time">3 days ago</span>
-                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
-                    </p>
-                </div>
-                <div class="list-group-item issue-item" id="issue-id2">
-                    <span class="number pull-right">#123</span>
-                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
-                    <p class="info">
-                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
-                        <a href="#">Obama</a></span>
-                        <span class="time">3 days ago</span>
-                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
-                    </p>
-                </div>
-                <div class="list-group-item issue-item" id="issue-id3">
-                    <span class="number pull-right">#123</span>
-                    <h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
-                    <p class="info">
-                        <span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
-                        <a href="#">Obama</a></span>
-                        <span class="time">3 days ago</span>
-                        <span class="comment"><i class="fa fa-comments"></i> 3</span>
-                    </p>
-                </div>
             </div>
         </div>
     </div>

From 588a700257e982fda3fee66d38672e9598d350a7 Mon Sep 17 00:00:00 2001
From: Matthew Baird <mattbaird@gmail.com>
Date: Tue, 25 Mar 2014 12:12:23 -0700
Subject: [PATCH 21/26] fix typo s/Broad/Board

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index d99031c687..5a57eb5f99 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ 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, develop specification, change log and road map.
-- See [Trello Broad](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
+- 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).
 
@@ -57,4 +57,4 @@ There are two 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) and [slene](https://github.com/slene) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors.
\ No newline at end of file
+This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei) and [slene](https://github.com/slene) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors.

From 60b83ce0c670e2b96c19ff694301684500392838 Mon Sep 17 00:00:00 2001
From: Jake Scott <jake.net@gmail.com>
Date: Wed, 26 Mar 2014 08:54:46 +1300
Subject: [PATCH 22/26] Fix up the spelling on the intro :)

---
 templates/home.tmpl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/home.tmpl b/templates/home.tmpl
index 381b6f1e8e..8121a4e8c9 100644
--- a/templates/home.tmpl
+++ b/templates/home.tmpl
@@ -1,6 +1,6 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
 <div id="body" class="container">
-	Welcome to the land of Gogs! There will be some indroduction!
+	Welcome to the land of Gogs! We will add an introduction soon!
 </div>
-{{template "base/footer" .}}
\ No newline at end of file
+{{template "base/footer" .}}

From c1a3d4fefbbbf332cd1cedda66e93bf40cc9713d Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 21:37:18 -0400
Subject: [PATCH 23/26] Add mail notify for creating issue

---
 gogs.go                  |  2 +-
 models/issue.go          |  1 -
 modules/mailer/mail.go   | 40 ++++++++++++++++++++++++++++++++++++++--
 modules/mailer/mailer.go |  2 +-
 routers/repo/issue.go    |  9 +++++++++
 5 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/gogs.go b/gogs.go
index b62580f8fd..f5a328add9 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.1.7.0325"
+const APP_VER = "0.1.8.0325"
 
 func init() {
 	base.AppVer = APP_VER
diff --git a/models/issue.go b/models/issue.go
index 2bdd083d90..2de6568589 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -59,7 +59,6 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co
 		Content:     content,
 	}
 	_, err = orm.Insert(issue)
-	// TODO: newIssueAction
 	return issue, err
 }
 
diff --git a/modules/mailer/mail.go b/modules/mailer/mail.go
index 92acd20efb..d0decbe068 100644
--- a/modules/mailer/mail.go
+++ b/modules/mailer/mail.go
@@ -6,6 +6,7 @@ package mailer
 
 import (
 	"encoding/hex"
+	"errors"
 	"fmt"
 
 	"github.com/gogits/gogs/models"
@@ -15,12 +16,17 @@ import (
 )
 
 // Create New mail message use MailFrom and MailUser
-func NewMailMessage(To []string, subject, body string) Message {
-	msg := NewHtmlMessage(To, base.MailService.User, subject, body)
+func NewMailMessageFrom(To []string, from, subject, body string) Message {
+	msg := NewHtmlMessage(To, from, subject, body)
 	msg.User = base.MailService.User
 	return msg
 }
 
+// Create New mail message use MailFrom and MailUser
+func NewMailMessage(To []string, subject, body string) Message {
+	return NewMailMessageFrom(To, base.MailService.User, subject, body)
+}
+
 func GetMailTmplData(user *models.User) map[interface{}]interface{} {
 	data := make(map[interface{}]interface{}, 10)
 	data["AppName"] = base.AppName
@@ -84,3 +90,33 @@ func SendActiveMail(r *middleware.Render, user *models.User) {
 
 	SendAsync(&msg)
 }
+
+// SendNotifyMail sends mail notification of all watchers.
+func SendNotifyMail(userId, repoId int64, userName, repoName, subject, content string) error {
+	watches, err := models.GetWatches(repoId)
+	if err != nil {
+		return errors.New("mail.NotifyWatchers(get watches): " + err.Error())
+	}
+
+	tos := make([]string, 0, len(watches))
+	for i := range watches {
+		uid := watches[i].UserId
+		if userId == uid {
+			continue
+		}
+		u, err := models.GetUserById(uid)
+		if err != nil {
+			return errors.New("mail.NotifyWatchers(get user): " + err.Error())
+		}
+		tos = append(tos, u.Email)
+	}
+
+	if len(tos) == 0 {
+		return nil
+	}
+
+	msg := NewMailMessageFrom(tos, userName, subject, content)
+	msg.Info = fmt.Sprintf("Subject: %s, send notify emails", subject)
+	SendAsync(&msg)
+	return nil
+}
diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go
index da63e01d2a..63861d870e 100644
--- a/modules/mailer/mailer.go
+++ b/modules/mailer/mailer.go
@@ -33,7 +33,7 @@ func (m Message) Content() string {
 	}
 
 	// create mail content
-	content := "From: " + m.User + "<" + m.From +
+	content := "From: " + m.From + "<" + m.User +
 		">\r\nSubject: " + m.Subject + "\r\nContent-Type: " + contentType + "\r\n\r\n" + m.Body
 	return content
 }
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index fc5bb98643..242593ff29 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -13,6 +13,7 @@ import (
 	"github.com/gogits/gogs/modules/auth"
 	"github.com/gogits/gogs/modules/base"
 	"github.com/gogits/gogs/modules/log"
+	"github.com/gogits/gogs/modules/mailer"
 	"github.com/gogits/gogs/modules/middleware"
 )
 
@@ -86,6 +87,14 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
 		return
 	}
 
+	// Mail watchers.
+	if base.Service.NotifyMail {
+		if err = mailer.SendNotifyMail(ctx.User.Id, ctx.Repo.Repository.Id, ctx.User.Name, ctx.Repo.Repository.Name, issue.Name, issue.Content); err != nil {
+			ctx.Handle(200, "issue.CreateIssue", err)
+			return
+		}
+	}
+
 	log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id)
 	ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index))
 }

From a8623ec104c3759b53e39a41d0a571013677cea3 Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Wed, 26 Mar 2014 10:49:18 +0800
Subject: [PATCH 24/26] fix init-tabs bug

---
 templates/admin/nav.tmpl    | 2 +-
 templates/repo/setting.tmpl | 2 +-
 templates/user/profile.tmpl | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl
index 8c2e33888e..2ac6462571 100644
--- a/templates/admin/nav.tmpl
+++ b/templates/admin/nav.tmpl
@@ -1,5 +1,5 @@
 <div id="user-setting-nav" class="col-md-3 admin-nav">
-    <ul class="list-group" data-init="tabs">
+    <ul class="list-group">
         <li class="list-group-item{{if .PageIsDashboard}} active{{end}}"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
         <li class="list-group-item{{if .PageIsUsers}} active{{end}}"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li>
         <li class="list-group-item{{if .PageIsRepos}} active{{end}}"><a href="/admin/repos"><i class="fa fa-book fa-lg"></i> Repositories</a></li>
diff --git a/templates/repo/setting.tmpl b/templates/repo/setting.tmpl
index d527dac3bc..ea7a5ddb61 100644
--- a/templates/repo/setting.tmpl
+++ b/templates/repo/setting.tmpl
@@ -4,7 +4,7 @@
 {{template "repo/toolbar" .}}
 <div id="body" class="container">
     <div id="user-setting-nav" class="col-md-3">
-        <ul class="list-group" data-init="tabs">
+        <ul class="list-group">
             <li class="list-group-item active"><a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings">Options</a></li>
             <!--<li class="list-group-item"><a href="#">Collaborators</a></li>
             <li class="list-group-item"><a href="#">Notifications</a></li>-->
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 7762ad2c6c..3733736dde 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -24,7 +24,7 @@
         </div>
     </div>
     <div id="user-activity" class="col-md-9">
-        <ul class="nav nav-tabs" id="user-act-tabs" data-init="tabs">
+        <ul class="nav nav-tabs" id="user-act-tabs">
             <li{{if not .TabName}} class="active"{{end}}><a href="{{.Owner.HomeLink}}"><i class="fa fa-gittip"></i>Repositories</a></li>
             <li{{if eq .TabName "activity"}} class="active"{{end}}><a href="{{.Owner.HomeLink}}?tab=activity"><i class="fa fa-rss"></i>Public Activity</a></li>
         </ul>

From 87de66561c0ecc14f42a24242d850b586f143080 Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Tue, 25 Mar 2014 23:53:01 -0400
Subject: [PATCH 25/26] Start working on diff page

---
 README.md                |   2 +-
 README_ZH.md             |   4 +-
 diff.txt                 | 137 ++++++++++++++++
 models/git.go            | 272 +++++++++++++++++++++++++++++++
 models/repo.go           | 242 +--------------------------
 routers/repo/commit.go   |  22 ++-
 templates/repo/diff.tmpl | 342 ++++++++++++++++++---------------------
 7 files changed, 591 insertions(+), 430 deletions(-)
 create mode 100644 diff.txt
 create mode 100644 models/git.go

diff --git a/README.md b/README.md
index 5a57eb5f99..debe834b30 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language
 
 ![Demo](http://gowalker.org/public/gogs_demo.gif)
 
-##### Current version: 0.1.7 Alpha
+##### Current version: 0.1.8 Alpha
 
 #### Other language version
 
diff --git a/README_ZH.md b/README_ZH.md
index 0a4d3bdc16..ee9c3b7c42 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
 
 ![Demo](http://gowalker.org/public/gogs_demo.gif)
 
-##### 当前版本:0.1.7 Alpha
+##### 当前版本:0.1.8 Alpha
 
 ## 开发目的
 
@@ -16,7 +16,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
 ## 项目概览
 
 - 有关项目设计、开发说明、变更日志和路线图,请通过  [Wiki](https://github.com/gogits/gogs/wiki) 查看。
-- 您可以到 [Trello Broad](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
+- 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
 - 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。
 - 使用过程中遇到问题?尝试从 [故障排查](https://github.com/gogits/gogs/wiki/Troubleshooting) 页面获取帮助。
 
diff --git a/diff.txt b/diff.txt
new file mode 100644
index 0000000000..7b2522f89e
--- /dev/null
+++ b/diff.txt
@@ -0,0 +1,137 @@
+commit c1a3d4fefbbbf332cd1cedda66e93bf40cc9713d
+Author: Unknown <joe2010xtmf@163.com>
+Date:   Tue Mar 25 21:37:18 2014 -0400
+
+    Add mail notify for creating issue
+
+diff --git a/gogs.go b/gogs.go
+index b62580f..f5a328a 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.1.7.0325"
++const APP_VER = "0.1.8.0325"
+ 
+ func init() {
+ 	base.AppVer = APP_VER
+diff --git a/models/issue.go b/models/issue.go
+index 2bdd083..2de6568 100644
+--- a/models/issue.go
++++ b/models/issue.go
+@@ -59,7 +59,6 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co
+ 		Content:     content,
+ 	}
+ 	_, err = orm.Insert(issue)
+-	// TODO: newIssueAction
+ 	return issue, err
+ }
+ 
+diff --git a/modules/mailer/mail.go b/modules/mailer/mail.go
+index 92acd20..d0decbe 100644
+--- a/modules/mailer/mail.go
++++ b/modules/mailer/mail.go
+@@ -6,6 +6,7 @@ package mailer
+ 
+ import (
+ 	"encoding/hex"
++	"errors"
+ 	"fmt"
+ 
+ 	"github.com/gogits/gogs/models"
+@@ -15,12 +16,17 @@ import (
+ )
+ 
+ // Create New mail message use MailFrom and MailUser
+-func NewMailMessage(To []string, subject, body string) Message {
+-	msg := NewHtmlMessage(To, base.MailService.User, subject, body)
++func NewMailMessageFrom(To []string, from, subject, body string) Message {
++	msg := NewHtmlMessage(To, from, subject, body)
+ 	msg.User = base.MailService.User
+ 	return msg
+ }
+ 
++// Create New mail message use MailFrom and MailUser
++func NewMailMessage(To []string, subject, body string) Message {
++	return NewMailMessageFrom(To, base.MailService.User, subject, body)
++}
++
+ func GetMailTmplData(user *models.User) map[interface{}]interface{} {
+ 	data := make(map[interface{}]interface{}, 10)
+ 	data["AppName"] = base.AppName
+@@ -84,3 +90,33 @@ func SendActiveMail(r *middleware.Render, user *models.User) {
+ 
+ 	SendAsync(&msg)
+ }
++
++// SendNotifyMail sends mail notification of all watchers.
++func SendNotifyMail(userId, repoId int64, userName, repoName, subject, content string) error {
++	watches, err := models.GetWatches(repoId)
++	if err != nil {
++		return errors.New("mail.NotifyWatchers(get watches): " + err.Error())
++	}
++
++	tos := make([]string, 0, len(watches))
++	for i := range watches {
++		uid := watches[i].UserId
++		if userId == uid {
++			continue
++		}
++		u, err := models.GetUserById(uid)
++		if err != nil {
++			return errors.New("mail.NotifyWatchers(get user): " + err.Error())
++		}
++		tos = append(tos, u.Email)
++	}
++
++	if len(tos) == 0 {
++		return nil
++	}
++
++	msg := NewMailMessageFrom(tos, userName, subject, content)
++	msg.Info = fmt.Sprintf("Subject: %s, send notify emails", subject)
++	SendAsync(&msg)
++	return nil
++}
+diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go
+index da63e01..63861d8 100644
+--- a/modules/mailer/mailer.go
++++ b/modules/mailer/mailer.go
+@@ -33,7 +33,7 @@ func (m Message) Content() string {
+ 	}
+ 
+ 	// create mail content
+-	content := "From: " + m.User + "<" + m.From +
++	content := "From: " + m.From + "<" + m.User +
+ 		">\r\nSubject: " + m.Subject + "\r\nContent-Type: " + contentType + "\r\n\r\n" + m.Body
+ 	return content
+ }
+diff --git a/routers/repo/issue.go b/routers/repo/issue.go
+index fc5bb98..242593f 100644
+--- a/routers/repo/issue.go
++++ b/routers/repo/issue.go
+@@ -13,6 +13,7 @@ import (
+ 	"github.com/gogits/gogs/modules/auth"
+ 	"github.com/gogits/gogs/modules/base"
+ 	"github.com/gogits/gogs/modules/log"
++	"github.com/gogits/gogs/modules/mailer"
+ 	"github.com/gogits/gogs/modules/middleware"
+ )
+ 
+@@ -86,6 +87,14 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
+ 		return
+ 	}
+ 
++	// Mail watchers.
++	if base.Service.NotifyMail {
++		if err = mailer.SendNotifyMail(ctx.User.Id, ctx.Repo.Repository.Id, ctx.User.Name, ctx.Repo.Repository.Name, issue.Name, issue.Content); err != nil {
++			ctx.Handle(200, "issue.CreateIssue", err)
++			return
++		}
++	}
++
+ 	log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id)
+ 	ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index))
+ }
diff --git a/models/git.go b/models/git.go
new file mode 100644
index 0000000000..6a4bd61064
--- /dev/null
+++ b/models/git.go
@@ -0,0 +1,272 @@
+// 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 (
+	"container/list"
+	"fmt"
+	"path"
+	"strings"
+
+	"github.com/Unknwon/com"
+
+	"github.com/gogits/git"
+)
+
+// RepoFile represents a file object in git repository.
+type RepoFile struct {
+	*git.TreeEntry
+	Path   string
+	Size   int64
+	Repo   *git.Repository
+	Commit *git.Commit
+}
+
+// LookupBlob returns the content of an object.
+func (file *RepoFile) LookupBlob() (*git.Blob, error) {
+	if file.Repo == nil {
+		return nil, ErrRepoFileNotLoaded
+	}
+
+	return file.Repo.LookupBlob(file.Id)
+}
+
+// GetBranches returns all branches of given repository.
+func GetBranches(userName, reposName string) ([]string, error) {
+	repo, err := git.OpenRepository(RepoPath(userName, reposName))
+	if err != nil {
+		return nil, err
+	}
+
+	refs, err := repo.AllReferences()
+	if err != nil {
+		return nil, err
+	}
+
+	brs := make([]string, len(refs))
+	for i, ref := range refs {
+		brs[i] = ref.Name
+	}
+	return brs, nil
+}
+
+func GetTargetFile(userName, reposName, branchName, commitId, rpath string) (*RepoFile, error) {
+	repo, err := git.OpenRepository(RepoPath(userName, reposName))
+	if err != nil {
+		return nil, err
+	}
+
+	commit, err := repo.GetCommit(branchName, commitId)
+	if err != nil {
+		return nil, err
+	}
+
+	parts := strings.Split(path.Clean(rpath), "/")
+
+	var entry *git.TreeEntry
+	tree := commit.Tree
+	for i, part := range parts {
+		if i == len(parts)-1 {
+			entry = tree.EntryByName(part)
+			if entry == nil {
+				return nil, ErrRepoFileNotExist
+			}
+		} else {
+			tree, err = repo.SubTree(tree, part)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	size, err := repo.ObjectSize(entry.Id)
+	if err != nil {
+		return nil, err
+	}
+
+	repoFile := &RepoFile{
+		entry,
+		rpath,
+		size,
+		repo,
+		commit,
+	}
+
+	return repoFile, nil
+}
+
+// GetReposFiles returns a list of file object in given directory of repository.
+func GetReposFiles(userName, reposName, branchName, commitId, rpath string) ([]*RepoFile, error) {
+	repo, err := git.OpenRepository(RepoPath(userName, reposName))
+	if err != nil {
+		return nil, err
+	}
+
+	commit, err := repo.GetCommit(branchName, commitId)
+	if err != nil {
+		return nil, err
+	}
+
+	var repodirs []*RepoFile
+	var repofiles []*RepoFile
+	commit.Tree.Walk(func(dirname string, entry *git.TreeEntry) int {
+		if dirname == rpath {
+			// TODO: size get method shoule be improved
+			size, err := repo.ObjectSize(entry.Id)
+			if err != nil {
+				return 0
+			}
+
+			var cm = commit
+			var i int
+			for {
+				i = i + 1
+				//fmt.Println(".....", i, cm.Id(), cm.ParentCount())
+				if cm.ParentCount() == 0 {
+					break
+				} else if cm.ParentCount() == 1 {
+					pt, _ := repo.SubTree(cm.Parent(0).Tree, dirname)
+					if pt == nil {
+						break
+					}
+					pEntry := pt.EntryByName(entry.Name)
+					if pEntry == nil || !pEntry.Id.Equal(entry.Id) {
+						break
+					} else {
+						cm = cm.Parent(0)
+					}
+				} else {
+					var emptyCnt = 0
+					var sameIdcnt = 0
+					var lastSameCm *git.Commit
+					//fmt.Println(".....", cm.ParentCount())
+					for i := 0; i < cm.ParentCount(); i++ {
+						//fmt.Println("parent", i, cm.Parent(i).Id())
+						p := cm.Parent(i)
+						pt, _ := repo.SubTree(p.Tree, dirname)
+						var pEntry *git.TreeEntry
+						if pt != nil {
+							pEntry = pt.EntryByName(entry.Name)
+						}
+
+						//fmt.Println("pEntry", pEntry)
+
+						if pEntry == nil {
+							emptyCnt = emptyCnt + 1
+							if emptyCnt+sameIdcnt == cm.ParentCount() {
+								if lastSameCm == nil {
+									goto loop
+								} else {
+									cm = lastSameCm
+									break
+								}
+							}
+						} else {
+							//fmt.Println(i, "pEntry", pEntry.Id, "entry", entry.Id)
+							if !pEntry.Id.Equal(entry.Id) {
+								goto loop
+							} else {
+								lastSameCm = cm.Parent(i)
+								sameIdcnt = sameIdcnt + 1
+								if emptyCnt+sameIdcnt == cm.ParentCount() {
+									// TODO: now follow the first parent commit?
+									cm = lastSameCm
+									//fmt.Println("sameId...")
+									break
+								}
+							}
+						}
+					}
+				}
+			}
+
+		loop:
+
+			rp := &RepoFile{
+				entry,
+				path.Join(dirname, entry.Name),
+				size,
+				repo,
+				cm,
+			}
+
+			if entry.IsFile() {
+				repofiles = append(repofiles, rp)
+			} else if entry.IsDir() {
+				repodirs = append(repodirs, rp)
+			}
+		}
+		return 0
+	})
+
+	return append(repodirs, repofiles...), nil
+}
+
+func GetCommit(userName, repoName, branchname, commitid string) (*git.Commit, error) {
+	repo, err := git.OpenRepository(RepoPath(userName, repoName))
+	if err != nil {
+		return nil, err
+	}
+
+	return repo.GetCommit(branchname, commitid)
+}
+
+// GetCommits returns all commits of given branch of repository.
+func GetCommits(userName, reposName, branchname string) (*list.List, error) {
+	repo, err := git.OpenRepository(RepoPath(userName, reposName))
+	if err != nil {
+		return nil, err
+	}
+	r, err := repo.LookupReference(fmt.Sprintf("refs/heads/%s", branchname))
+	if err != nil {
+		return nil, err
+	}
+	return r.AllCommits()
+}
+
+type DiffFile struct {
+	Name               string
+	Addition, Deletion int
+	Type               string
+	Content            []string
+}
+
+type Diff struct {
+	NumFiles                     int // Number of file has been changed.
+	TotalAddition, TotalDeletion int
+	Files                        []*DiffFile
+}
+
+func GetDiff(repoPath, commitid string) (*Diff, error) {
+	stdout, _, err := com.ExecCmdDir(repoPath, "git", "show", commitid)
+	if err != nil {
+		return nil, err
+	}
+
+	// Sperate parts by file.
+	parts := strings.Split(stdout, "diff --git ")
+
+	// First part is commit information.
+	// Check if it's a merge.
+	mergeIndex := strings.Index(parts[0], "merge")
+	if mergeIndex > -1 {
+		mergeCommit := strings.SplitN(strings.Split(parts[0], "\n")[1], "", 3)[2]
+		return GetDiff(repoPath, mergeCommit)
+	}
+
+	diff := &Diff{NumFiles: len(parts[1:])}
+	diff.Files = make([]*DiffFile, 0, diff.NumFiles)
+	for _, part := range parts[1:] {
+		infos := strings.SplitN(part, "\n", 6)
+		infos[5] = strings.TrimSuffix(strings.TrimSuffix(infos[5], "\n"), "\n\\ No newline at end of file")
+
+		file := &DiffFile{
+			Name:    strings.TrimPrefix(strings.Split(infos[0], " ")[0], "a/"),
+			Content: strings.Split(infos[5], "\n"),
+		}
+		diff.Files = append(diff.Files, file)
+	}
+	return diff, nil
+}
diff --git a/models/repo.go b/models/repo.go
index 824d5ba0ca..868a5dc2be 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -5,17 +5,14 @@
 package models
 
 import (
-	"container/list"
 	"errors"
 	"fmt"
 	"io/ioutil"
 	"os"
 	"os/exec"
-	"path"
 	"path/filepath"
 	"regexp"
 	"strings"
-	"sync"
 	"time"
 	"unicode/utf8"
 
@@ -36,8 +33,6 @@ var (
 	ErrRepoFileNotLoaded = fmt.Errorf("repo file not loaded")
 )
 
-var gitInitLocker = sync.Mutex{}
-
 var (
 	LanguageIgns, Licenses []string
 )
@@ -222,33 +217,21 @@ func extractGitBareZip(repoPath string) error {
 }
 
 // initRepoCommit temporarily changes with work directory.
-func initRepoCommit(tmpPath string, sig *git.Signature) error {
-	gitInitLocker.Lock()
-	defer gitInitLocker.Unlock()
-
-	// Change work directory.
-	curPath, err := os.Getwd()
-	if err != nil {
-		return err
-	} else if err = os.Chdir(tmpPath); err != nil {
-		return err
-	}
-	defer os.Chdir(curPath)
-
+func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
 	var stderr string
-	if _, stderr, err = com.ExecCmd("git", "add", "--all"); err != nil {
+	if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil {
 		return err
 	}
-	log.Info("stderr(1): %s", stderr)
-	if _, stderr, err = com.ExecCmd("git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
+	log.Trace("stderr(1): %s", 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
 	}
-	log.Info("stderr(2): %s", stderr)
-	if _, stderr, err = com.ExecCmd("git", "push", "origin", "master"); err != nil {
+	log.Trace("stderr(2): %s", stderr)
+	if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil {
 		return err
 	}
-	log.Info("stderr(3): %s", stderr)
+	log.Trace("stderr(3): %s", stderr)
 	return nil
 }
 
@@ -562,214 +545,3 @@ func UnWatchRepository() {
 func ForkRepository(reposName string, userId int64) {
 
 }
-
-// RepoFile represents a file object in git repository.
-type RepoFile struct {
-	*git.TreeEntry
-	Path   string
-	Size   int64
-	Repo   *git.Repository
-	Commit *git.Commit
-}
-
-// LookupBlob returns the content of an object.
-func (file *RepoFile) LookupBlob() (*git.Blob, error) {
-	if file.Repo == nil {
-		return nil, ErrRepoFileNotLoaded
-	}
-
-	return file.Repo.LookupBlob(file.Id)
-}
-
-// GetBranches returns all branches of given repository.
-func GetBranches(userName, reposName string) ([]string, error) {
-	repo, err := git.OpenRepository(RepoPath(userName, reposName))
-	if err != nil {
-		return nil, err
-	}
-
-	refs, err := repo.AllReferences()
-	if err != nil {
-		return nil, err
-	}
-
-	brs := make([]string, len(refs))
-	for i, ref := range refs {
-		brs[i] = ref.Name
-	}
-	return brs, nil
-}
-
-func GetTargetFile(userName, reposName, branchName, commitId, rpath string) (*RepoFile, error) {
-	repo, err := git.OpenRepository(RepoPath(userName, reposName))
-	if err != nil {
-		return nil, err
-	}
-
-	commit, err := repo.GetCommit(branchName, commitId)
-	if err != nil {
-		return nil, err
-	}
-
-	parts := strings.Split(path.Clean(rpath), "/")
-
-	var entry *git.TreeEntry
-	tree := commit.Tree
-	for i, part := range parts {
-		if i == len(parts)-1 {
-			entry = tree.EntryByName(part)
-			if entry == nil {
-				return nil, ErrRepoFileNotExist
-			}
-		} else {
-			tree, err = repo.SubTree(tree, part)
-			if err != nil {
-				return nil, err
-			}
-		}
-	}
-
-	size, err := repo.ObjectSize(entry.Id)
-	if err != nil {
-		return nil, err
-	}
-
-	repoFile := &RepoFile{
-		entry,
-		rpath,
-		size,
-		repo,
-		commit,
-	}
-
-	return repoFile, nil
-}
-
-// GetReposFiles returns a list of file object in given directory of repository.
-func GetReposFiles(userName, reposName, branchName, commitId, rpath string) ([]*RepoFile, error) {
-	repo, err := git.OpenRepository(RepoPath(userName, reposName))
-	if err != nil {
-		return nil, err
-	}
-
-	commit, err := repo.GetCommit(branchName, commitId)
-	if err != nil {
-		return nil, err
-	}
-
-	var repodirs []*RepoFile
-	var repofiles []*RepoFile
-	commit.Tree.Walk(func(dirname string, entry *git.TreeEntry) int {
-		if dirname == rpath {
-			// TODO: size get method shoule be improved
-			size, err := repo.ObjectSize(entry.Id)
-			if err != nil {
-				return 0
-			}
-
-			var cm = commit
-			var i int
-			for {
-				i = i + 1
-				//fmt.Println(".....", i, cm.Id(), cm.ParentCount())
-				if cm.ParentCount() == 0 {
-					break
-				} else if cm.ParentCount() == 1 {
-					pt, _ := repo.SubTree(cm.Parent(0).Tree, dirname)
-					if pt == nil {
-						break
-					}
-					pEntry := pt.EntryByName(entry.Name)
-					if pEntry == nil || !pEntry.Id.Equal(entry.Id) {
-						break
-					} else {
-						cm = cm.Parent(0)
-					}
-				} else {
-					var emptyCnt = 0
-					var sameIdcnt = 0
-					var lastSameCm *git.Commit
-					//fmt.Println(".....", cm.ParentCount())
-					for i := 0; i < cm.ParentCount(); i++ {
-						//fmt.Println("parent", i, cm.Parent(i).Id())
-						p := cm.Parent(i)
-						pt, _ := repo.SubTree(p.Tree, dirname)
-						var pEntry *git.TreeEntry
-						if pt != nil {
-							pEntry = pt.EntryByName(entry.Name)
-						}
-
-						//fmt.Println("pEntry", pEntry)
-
-						if pEntry == nil {
-							emptyCnt = emptyCnt + 1
-							if emptyCnt+sameIdcnt == cm.ParentCount() {
-								if lastSameCm == nil {
-									goto loop
-								} else {
-									cm = lastSameCm
-									break
-								}
-							}
-						} else {
-							//fmt.Println(i, "pEntry", pEntry.Id, "entry", entry.Id)
-							if !pEntry.Id.Equal(entry.Id) {
-								goto loop
-							} else {
-								lastSameCm = cm.Parent(i)
-								sameIdcnt = sameIdcnt + 1
-								if emptyCnt+sameIdcnt == cm.ParentCount() {
-									// TODO: now follow the first parent commit?
-									cm = lastSameCm
-									//fmt.Println("sameId...")
-									break
-								}
-							}
-						}
-					}
-				}
-			}
-
-		loop:
-
-			rp := &RepoFile{
-				entry,
-				path.Join(dirname, entry.Name),
-				size,
-				repo,
-				cm,
-			}
-
-			if entry.IsFile() {
-				repofiles = append(repofiles, rp)
-			} else if entry.IsDir() {
-				repodirs = append(repodirs, rp)
-			}
-		}
-		return 0
-	})
-
-	return append(repodirs, repofiles...), nil
-}
-
-func GetCommit(userName, repoName, branchname, commitid string) (*git.Commit, error) {
-	repo, err := git.OpenRepository(RepoPath(userName, repoName))
-	if err != nil {
-		return nil, err
-	}
-
-	return repo.GetCommit(branchname, commitid)
-}
-
-// GetCommits returns all commits of given branch of repository.
-func GetCommits(userName, reposName, branchname string) (*list.List, error) {
-	repo, err := git.OpenRepository(RepoPath(userName, reposName))
-	if err != nil {
-		return nil, err
-	}
-	r, err := repo.LookupReference(fmt.Sprintf("refs/heads/%s", branchname))
-	if err != nil {
-		return nil, err
-	}
-	return r.AllCommits()
-}
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index e038998f94..3d00f8d747 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -34,8 +34,24 @@ func Commits(ctx *middleware.Context, params martini.Params) {
 	ctx.HTML(200, "repo/commits")
 }
 
-func Diff(ctx *middleware.Context,params martini.Params){
-	ctx.Data["Title"] = "commit-sha"
+func Diff(ctx *middleware.Context, params martini.Params) {
+	commit, err := models.GetCommit(params["username"], params["reponame"], params["branchname"], params["commitid"])
+	if err != nil {
+		ctx.Handle(404, "repo.Diff", err)
+		return
+	}
+
+	diff, err := models.GetDiff(models.RepoPath(params["username"], params["reponame"]), params["commitid"])
+	if err != nil {
+		ctx.Handle(404, "repo.Diff", err)
+		return
+	}
+
+	shortSha := params["commitid"][:7]
+	ctx.Data["Title"] = commit.Message() + " · " + shortSha
+	ctx.Data["Commit"] = commit
+	ctx.Data["ShortSha"] = shortSha
+	ctx.Data["Diff"] = diff
 	ctx.Data["IsRepoToolbarCommits"] = true
-	ctx.HTML(200,"repo/diff")
+	ctx.HTML(200, "repo/diff")
 }
diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl
index 6a3c5fb308..2627c9e1aa 100644
--- a/templates/repo/diff.tmpl
+++ b/templates/repo/diff.tmpl
@@ -7,239 +7,203 @@
         <div class="panel panel-info diff-box diff-head-box">
             <div class="panel-heading">
                 <a class="pull-right btn btn-primary btn-sm" href="#commit-source">Browse Source</a>
-                <h4>bsongen: support for custom tags</h4>
+                <h4>{{.Commit.Message}}</h4>
             </div>
             <div class="panel-body">
                 <span class="pull-right">
-                    commit <span class="label label-default sha">commit-sha</span>
+                    commit <span class="label label-default sha">{{.ShortSha}}</span>
                 </span>
                 <p class="author">
-                    <img class="avatar" src="#" alt=""/>
-                    <a class="name" href="#"><strong>author-name</strong></a>
-                    <span class="time">times-ago</span>
+                    <img class="avatar" src="{{AvatarLink .Commit.Author.Email}}" alt=""/>
+                    <a class="name" href="#"><strong>{{.Commit.Author.Name}}</strong></a>
+                    <span class="time">{{TimeSince .Commit.Author.When}}</span>
                 </p>
             </div>
         </div>
 
         <div class="diff-detail-box diff-box">
-            <a class="pull-right btn btn-default" data-toggle="collapse" data-target="#diff-files">Show Diff Files</a>
+            <a class="pull-right btn btn-default" data-toggle="collapse" data-target="#diff-files">Show Diff Stats</a>
             <p class="showing">
                 <i class="fa fa-retweet"></i>
-                <strong> 5 changed files</strong> with <strong>25 additions</strong> and <strong>9 deletions</strong>.
+                <strong> {{.Diff.NumFiles}} changed files</strong> with <strong>{{.Diff.TotalAddition}} additions</strong> and <strong>{{.Diff.TotalDeletion}} deletions</strong>.
             </p>
             <ol class="detail-files collapse" id="diff-files">
+                {{range .Diff.Files}}
                 <li>
                     <div class="diff-counter count pull-right">
-                        <span class="add" data-line="2">2</span>
+                        <span class="add" data-line="{{.Addition}}">{{.Addition}}</span>
                         <span class="bar">
                             <span class="pull-left add"></span>
                             <span class="pull-left del"></span>
                         </span>
-                        <span class="del" data-line="4">4</span>
+                        <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
                     </div>
                     <!-- todo finish all file status, now modify, add, delete and rename -->
                     <span class="status modify" data-toggle="tooltip" data-placement="right" title="modify">&nbsp;</span>
-                    <a class="file" href="#diff-1">gopmweb.go</a>
-                </li>
-                <li>
-                    <div class="diff-counter count pull-right">
-                        <span class="add" data-line="666">666</span>
-                        <span class="bar">
-                            <span class="pull-left add"></span>
-                            <span class="pull-left del"></span>
-                        </span>
-                        <span class="del" data-line="44">44</span>
-                    </div>
-                    <span class="status add" data-toggle="tooltip" data-placement="right" title="add">&nbsp;</span>
-                    <a class="file" href="#diff-2">static/img/favicon.png</a>
-                </li>
-                <li>
-                    <span class="status del" data-toggle="tooltip" data-placement="right" title="delete">&nbsp;</span>
-                    <a class="file" href="#diff-2">static/img/favicon.png</a>
-                </li>
-                <li>
-                    <span class="status rename" data-toggle="tooltip" data-placement="right" title="rename">&nbsp;</span>
-                    <a class="file" href="#diff-2">static/img/favicon.png</a>
+                    <a class="file" href="#diff-1">{{.Name}}</a>
                 </li>
+                {{end}}
             </ol>
         </div>
 
-        <div class="panel panel-default diff-file-box diff-box file-content" id="diff-1">
-            <div class="panel-heading">
-                <div class="diff-counter count pull-left">
-                    <span class="add" data-line="1">BIN</span>
-                    <span class="bar">
-                        <span class="pull-left add"></span>
-                        <span class="pull-left del"></span>
-                    </span>
-                    <span class="del" data-line="0"></span>
-                </div>
-                <a class="btn btn-default btn-sm pull-right" href="#">View File</a>
-               <span class="file">data/test/bson_test/simple_type.png</span>
-            </div>
-            <div class="panel-body file-body file-code code-view code-bin">
-                <table>
-                    <tbody>
-                        <tr class="text-center"><td><img src="http://1.gravatar.com/avatar/f72f7454ce9d710baa506394f68f4132?s=200" alt=""/></td></tr>
-                    </tbody>
-                </table>
-            </div>
-        </div>
-
+        {{range .Diff.Files}}
         <div class="panel panel-default diff-file-box diff-box file-content" id="diff-2">
             <div class="panel-heading">
                 <div class="diff-counter count pull-left">
-                    <span class="add" data-line="30">+ 30</span>
+                    <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
                     <span class="bar">
                         <span class="pull-left add"></span>
                         <span class="pull-left del"></span>
                     </span>
-                    <span class="del" data-line="4">- 4</span>
+                    <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
                 </div>
                 <a class="btn btn-default btn-sm pull-right" href="#">View File</a>
-                <span class="file">data/test/bson_test/simple_type.go</span>
+                <span class="file">{{.Name}}</span>
             </div>
             <div class="panel-body file-body file-code code-view code-diff">
                 <table>
                     <tbody>
-                    <tr class="same-code nl-1 ol-1">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L1">1</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L1">1</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="same-code nl-2 ol-2">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L1">2</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L1">2</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="same-code nl-3 ol-3">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L3">3</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L3">3</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="add-code nl-4 ol-0">
-                        <td class="lines-num lines-num-old">
-                            <span rel="add">+</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L4">4</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="add-code nl-5 ol-0">
-                        <td class="lines-num lines-num-old">
-                            <span rel="add">+</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L5">5</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="del-code nl-0 ol-4">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L4">4</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="del">-</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="del-code nl-0 ol-5">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L5">5</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="del">-</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="del-code nl-0 ol-6">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L6">6</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="del">-</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="del-code nl-0 ol-7">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L7">7</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="del">-</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="same-code nl-6 ol-8">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L8">8</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L6">6</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="same-code nl-7 ol-9">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L1">9</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L1">7</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
-                    <tr class="same-code nl-8 ol-10">
-                        <td class="lines-num lines-num-old">
-                            <span rel="L1">10</span>
-                        </td>
-                        <td class="lines-num lines-num-new">
-                            <span rel="L1">8</span>
-                        </td>
-                        <td class="lines-code">
-                            <pre>	"github.com/youtube/vitess/go/bson"</pre>
-                        </td>
-                    </tr>
+                        {{range .Content}}
+                        <tr class="same-code nl-1 ol-1">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L1"></span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L1"></span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>{{.}}</pre>
+                            </td>
+                        </tr>
+                        {{end}}
+                       <!--  <tr class="same-code nl-2 ol-2">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L1">2</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L1">2</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="same-code nl-3 ol-3">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L3">3</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L3">3</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="add-code nl-4 ol-0">
+                            <td class="lines-num lines-num-old">
+                                <span rel="add">+</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L4">4</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="add-code nl-5 ol-0">
+                            <td class="lines-num lines-num-old">
+                                <span rel="add">+</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L5">5</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="del-code nl-0 ol-4">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L4">4</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="del">-</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="del-code nl-0 ol-5">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L5">5</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="del">-</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="del-code nl-0 ol-6">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L6">6</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="del">-</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="del-code nl-0 ol-7">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L7">7</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="del">-</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="same-code nl-6 ol-8">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L8">8</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L6">6</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="same-code nl-7 ol-9">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L1">9</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L1">7</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr>
+                        <tr class="same-code nl-8 ol-10">
+                            <td class="lines-num lines-num-old">
+                                <span rel="L1">10</span>
+                            </td>
+                            <td class="lines-num lines-num-new">
+                                <span rel="L1">8</span>
+                            </td>
+                            <td class="lines-code">
+                                <pre>	"github.com/youtube/vitess/go/bson"</pre>
+                            </td>
+                        </tr> -->
                     </tbody>
                 </table>
             </div>
         </div>
+        {{end}}
 
-        <div class="panel panel-default diff-file-box diff-box file-content">
+        <!-- <div class="panel panel-default diff-file-box diff-box file-content">
             <div class="panel-heading">
                 <div class="diff-counter count pull-left">
                     <span class="add" data-line="2">+ 2</span>
@@ -442,7 +406,7 @@
                     </tbody>
                 </table>
             </div>
-        </div>
+        </div> -->
     </div>
 </div>
 {{template "base/footer" .}}
\ No newline at end of file

From 06cf878471af02376dfcd02b9781982a89c27a2a Mon Sep 17 00:00:00 2001
From: Unknown <joe2010xtmf@163.com>
Date: Wed, 26 Mar 2014 00:13:01 -0400
Subject: [PATCH 26/26] More on diff page

---
 models/git.go | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/models/git.go b/models/git.go
index 6a4bd61064..b0b0dd2f84 100644
--- a/models/git.go
+++ b/models/git.go
@@ -246,25 +246,27 @@ func GetDiff(repoPath, commitid string) (*Diff, error) {
 	}
 
 	// Sperate parts by file.
-	parts := strings.Split(stdout, "diff --git ")
+	startIndex := strings.Index(stdout, "diff --git ") + 12
 
 	// First part is commit information.
 	// Check if it's a merge.
-	mergeIndex := strings.Index(parts[0], "merge")
+	mergeIndex := strings.Index(stdout[:startIndex], "merge")
 	if mergeIndex > -1 {
-		mergeCommit := strings.SplitN(strings.Split(parts[0], "\n")[1], "", 3)[2]
+		mergeCommit := strings.SplitN(strings.Split(stdout[:startIndex], "\n")[1], "", 3)[2]
 		return GetDiff(repoPath, mergeCommit)
 	}
 
-	diff := &Diff{NumFiles: len(parts[1:])}
+	parts := strings.Split(stdout[startIndex:], "diff --git ")
+	diff := &Diff{NumFiles: len(parts)}
 	diff.Files = make([]*DiffFile, 0, diff.NumFiles)
-	for _, part := range parts[1:] {
+	for _, part := range parts {
 		infos := strings.SplitN(part, "\n", 6)
-		infos[5] = strings.TrimSuffix(strings.TrimSuffix(infos[5], "\n"), "\n\\ No newline at end of file")
+		maxIndex := len(infos) - 1
+		infos[maxIndex] = strings.TrimSuffix(strings.TrimSuffix(infos[maxIndex], "\n"), "\n\\ No newline at end of file")
 
 		file := &DiffFile{
 			Name:    strings.TrimPrefix(strings.Split(infos[0], " ")[0], "a/"),
-			Content: strings.Split(infos[5], "\n"),
+			Content: strings.Split(infos[maxIndex], "\n"),
 		}
 		diff.Files = append(diff.Files, file)
 	}