This commit is contained in:
Liang Ding 2016-02-26 13:45:54 +08:00
parent ada7da92c9
commit be04f26b0d
9 changed files with 23 additions and 23 deletions

View File

@ -18,7 +18,7 @@
"FontFamily": "Consolas, 'Courier New', monospace", "FontFamily": "Consolas, 'Courier New', monospace",
"FontSize": "13px", "FontSize": "13px",
"LineHeight": "17px", "LineHeight": "17px",
"Theme": "wide", "Theme": "lesser-dark",
"TabSize": "4" "TabSize": "4"
}, },
"LatestSessionContent": { "LatestSessionContent": {

16
main.go
View File

@ -194,22 +194,22 @@ func main() {
// indexHandler handles request of Wide index. // indexHandler handles request of Wide index.
func indexHandler(w http.ResponseWriter, r *http.Request) { func indexHandler(w http.ResponseWriter, r *http.Request) {
if "/" != r.RequestURI { if conf.Wide.Context+"/" != r.RequestURI {
http.Redirect(w, r, "/", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/", http.StatusFound)
return return
} }
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }
username := httpSession.Values["username"].(string) username := httpSession.Values["username"].(string)
if "playground" == username { // reserved user for Playground if "playground" == username { // reserved user for Playground
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }
@ -224,7 +224,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
if nil == user { if nil == user {
logger.Warnf("Not found user [%s]", username) logger.Warnf("Not found user [%s]", username)
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }
@ -263,7 +263,7 @@ func serveSingle(pattern string, filename string) {
func startHandler(w http.ResponseWriter, r *http.Request) { func startHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }
@ -303,7 +303,7 @@ func startHandler(w http.ResponseWriter, r *http.Request) {
func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) { func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }
@ -335,7 +335,7 @@ func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) {
func aboutHandler(w http.ResponseWriter, r *http.Request) { func aboutHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }

View File

@ -52,7 +52,7 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := HTTPSession.Get(r, "wide-session") httpSession, _ := HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }

View File

@ -44,7 +44,7 @@ var logger = log.NewLogger(os.Stdout)
func IndexHandler(w http.ResponseWriter, r *http.Request) { func IndexHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound) http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return return
} }

View File

@ -165,7 +165,7 @@ var menu = {
dataType: "json", dataType: "json",
success: function (result) { success: function (result) {
if (result.succ) { if (result.succ) {
window.location.href = "/login"; window.location.href = config.context + "/login";
} }
} }
}); });

View File

@ -312,7 +312,7 @@
<span>{{.i18n.team}}</span> <span>{{.i18n.team}}</span>
<div class="frame"> <div class="frame">
<ul> <ul>
<li class="signup" onclick="window.open('/signup')"> <li class="signup" onclick="window.open('{{.conf.Context}}/signup')">
<span class="ico-signup font-ico"></span> <span class="ico-signup font-ico"></span>
<span>{{.i18n.sign_up}}</span> <span>{{.i18n.sign_up}}</span>
</li> </li>
@ -340,12 +340,12 @@
{{.i18n.issues}} {{.i18n.issues}}
</li> </li>
<li class="hr"></li> <li class="hr"></li>
<li onclick="window.open('/keyboard_shortcuts')"> <li onclick="window.open('{{.conf.Context}}/keyboard_shortcuts')">
<span class="ico-keyboard font-ico"></span> <span class="ico-keyboard font-ico"></span>
{{.i18n.keyboard_shortcuts}} {{.i18n.keyboard_shortcuts}}
</li> </li>
<li class="hr"></li> <li class="hr"></li>
<li onclick="window.open('/playground')"> <li onclick="window.open('{{.conf.Context}}/playground')">
<span class="space"></span> <span class="space"></span>
Playground Playground
</li> </li>
@ -375,7 +375,7 @@
<div class="fn-right"> <div class="fn-right">
<img class="gravatar" <img class="gravatar"
onerror="this.src='/static/images/user-thumbnail.png'" onerror="this.src='{{.conf.StaticServer}}/static/images/user-thumbnail.png'"
src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=17&d=https://hacpai.com/images/user-thumbnail.png" src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=17&d=https://hacpai.com/images/user-thumbnail.png"
title="{{.user.Name}}"/> title="{{.user.Name}}"/>
<span class="font-ico ico-share"></span> &nbsp; <span class="font-ico ico-share"></span> &nbsp;

View File

@ -25,7 +25,7 @@
<li><a rel="help" href="https://www.gitbook.com/book/88250/wide-user-guide" target="_blank">{{.i18n.help}}</a></li> <li><a rel="help" href="https://www.gitbook.com/book/88250/wide-user-guide" target="_blank">{{.i18n.help}}</a></li>
<li><a rel="bookmark" href="https://github.com/b3log/wide/issues/new" target="_blank">{{.i18n.issues}}</a></li> <li><a rel="bookmark" href="https://github.com/b3log/wide/issues/new" target="_blank">{{.i18n.issues}}</a></li>
<!--<li><button class="btn btn-red" onclick="window.open('http://b3log.org/services')">{{.i18n.pricing}}</button></li>--> <!--<li><button class="btn btn-red" onclick="window.open('http://b3log.org/services')">{{.i18n.pricing}}</button></li>-->
<li><button class="btn" onclick="window.location.href = '/signup'">{{.i18n.sign_up}}</button></li> <li><button class="btn" onclick="window.location.href = '{{.conf.Context}}/signup'">{{.i18n.sign_up}}</button></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -64,7 +64,7 @@
$('#loginForm').submit(function () { $('#loginForm').submit(function () {
var options = { var options = {
url: '/login', url: '{{.conf.Context}}/login',
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
beforeSubmit: function () { beforeSubmit: function () {
@ -87,7 +87,7 @@
return; return;
} }
window.location.href = "/"; window.location.href = "{{.conf.Context}}/";
} }
}; };

View File

@ -103,7 +103,7 @@
<input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password" type="password"/> <input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password" type="password"/>
</label> </label>
<label class="fn-clear"> <label class="fn-clear">
<img onerror="this.src='/static/images/user-thumbnail.png'" <img onerror="this.src='{{.conf.StaticServer}}/static/images/user-thumbnail.png'"
src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=48&d=https://hacpai.com/images/user-thumbnail.png" src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=48&d=https://hacpai.com/images/user-thumbnail.png"
title="{{.user.Name}}" class='gravatar'/> title="{{.user.Name}}" class='gravatar'/>
<a href="http://gravatar.com/" target="_blank">{{.i18n.change_avatar}} Gravatar.com</a> <a href="http://gravatar.com/" target="_blank">{{.i18n.change_avatar}} Gravatar.com</a>

View File

@ -25,7 +25,7 @@
<li><a rel="help" href="https://www.gitbook.com/book/88250/wide-user-guide" target="_blank">{{.i18n.help}}</a></li> <li><a rel="help" href="https://www.gitbook.com/book/88250/wide-user-guide" target="_blank">{{.i18n.help}}</a></li>
<li><a rel="bookmark" href="https://github.com/b3log/wide/issues/new" target="_blank">{{.i18n.issues}}</a></li> <li><a rel="bookmark" href="https://github.com/b3log/wide/issues/new" target="_blank">{{.i18n.issues}}</a></li>
<!--<li><button class="btn btn-red" onclick="window.open('http://b3log.org/services')">{{.i18n.pricing}}</button></li>--> <!--<li><button class="btn btn-red" onclick="window.open('http://b3log.org/services')">{{.i18n.pricing}}</button></li>-->
<li><button class="btn" onclick="window.location.href = '/login'">{{.i18n.login}}</button></li> <li><button class="btn" onclick="window.location.href = '{{.conf.Context}}/login'">{{.i18n.login}}</button></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -93,7 +93,7 @@
}; };
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/signup', url: '{{.conf.Context}}/signup',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function (result) { success: function (result) {
@ -102,7 +102,7 @@
return; return;
} }
window.location.href = "/"; window.location.href = "{{.conf.Context}}/";
} }
}); });
}; };