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",
"FontSize": "13px",
"LineHeight": "17px",
"Theme": "wide",
"Theme": "lesser-dark",
"TabSize": "4"
},
"LatestSessionContent": {

16
main.go
View File

@ -194,22 +194,22 @@ func main() {
// indexHandler handles request of Wide index.
func indexHandler(w http.ResponseWriter, r *http.Request) {
if "/" != r.RequestURI {
http.Redirect(w, r, "/", http.StatusFound)
if conf.Wide.Context+"/" != r.RequestURI {
http.Redirect(w, r, conf.Wide.Context+"/", http.StatusFound)
return
}
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound)
http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return
}
username := httpSession.Values["username"].(string)
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
}
@ -224,7 +224,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
if nil == user {
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
}
@ -263,7 +263,7 @@ func serveSingle(pattern string, filename string) {
func startHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound)
http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return
}
@ -303,7 +303,7 @@ func startHandler(w http.ResponseWriter, r *http.Request) {
func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound)
http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return
}
@ -335,7 +335,7 @@ func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) {
func aboutHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew {
http.Redirect(w, r, conf.Wide.Context+"login", http.StatusFound)
http.Redirect(w, r, conf.Wide.Context+"/login", http.StatusFound)
return
}

View File

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

View File

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

View File

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

View File

@ -312,7 +312,7 @@
<span>{{.i18n.team}}</span>
<div class="frame">
<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>{{.i18n.sign_up}}</span>
</li>
@ -340,12 +340,12 @@
{{.i18n.issues}}
</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>
{{.i18n.keyboard_shortcuts}}
</li>
<li class="hr"></li>
<li onclick="window.open('/playground')">
<li onclick="window.open('{{.conf.Context}}/playground')">
<span class="space"></span>
Playground
</li>
@ -375,7 +375,7 @@
<div class="fn-right">
<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"
title="{{.user.Name}}"/>
<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="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" 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>
</div>
</div>
@ -64,7 +64,7 @@
$('#loginForm').submit(function () {
var options = {
url: '/login',
url: '{{.conf.Context}}/login',
type: 'POST',
dataType: 'json',
beforeSubmit: function () {
@ -87,7 +87,7 @@
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"/>
</label>
<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"
title="{{.user.Name}}" class='gravatar'/>
<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="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" 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>
</div>
</div>
@ -93,7 +93,7 @@
};
$.ajax({
type: 'POST',
url: '/signup',
url: '{{.conf.Context}}/signup',
data: JSON.stringify(request),
dataType: "json",
success: function (result) {
@ -102,7 +102,7 @@
return;
}
window.location.href = "/";
window.location.href = "{{.conf.Context}}/";
}
});
};