Commit 4b3f5de0 authored by Van's avatar Van

Merge remote-tracking branch 'origin/3.0.0-dev' into 3.0.0-dev

parents 4b896f67 da03ef56
......@@ -22,11 +22,16 @@ package org.b3log.solo.model;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a>
* @version 1.7.0.1, Feb 8, 2019
* @version 1.7.0.2, Feb 11, 2019
* @since 0.3.1
*/
public final class Common {
/**
* Key of referer.
*/
public static final String REFERER = "referer";
/**
* Key of upload msg.
*/
......@@ -307,11 +312,6 @@ public final class Common {
*/
public static final String UNUSED_TAGS = "unusedTags";
/**
* Key of go to.
*/
public static final String GOTO = "goto";
/**
* Key of online visitor count.
*/
......
......@@ -56,7 +56,7 @@ import java.util.Map;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/DASHU">DASHU</a>
* @version 1.2.4.14, Feb 7, 2019
* @version 1.2.4.15, Feb 11, 2019
* @since 0.3.1
*/
@RequestProcessor
......@@ -147,31 +147,6 @@ public class IndexProcessor {
}
}
/**
* Shows kill browser page with the specified context.
*
* @param context the specified context
*/
@RequestProcessing(value = "/kill-browser", method = HttpMethod.GET)
public void showKillBrowser(final RequestContext context) {
final HttpServletRequest request = context.getRequest();
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "kill-browser.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
try {
final Map<String, String> langs = langPropsService.getAll(Locales.getLocale(request));
dataModel.putAll(langs);
final JSONObject preference = preferenceQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference);
Keys.fillServer(dataModel);
Keys.fillRuntime(dataModel);
dataModelService.fillMinified(dataModel);
} catch (final ServiceException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
/**
* Shows start page.
*
......@@ -179,19 +154,17 @@ public class IndexProcessor {
*/
@RequestProcessing(value = "/start", method = HttpMethod.GET)
public void showStart(final RequestContext context) {
String destinationURL = context.param(Common.GOTO);
if (StringUtils.isBlank(destinationURL)) {
destinationURL = Latkes.getServePath() + Common.ADMIN_INDEX_URI;
} else if (!isInternalLinks(destinationURL)) {
destinationURL = Latkes.getServePath();
}
if (initService.isInited() && null != Solos.getCurrentUser(context.getRequest(), context.getResponse())) {
context.sendRedirect(destinationURL);
context.sendRedirect(Latkes.getServePath());
return;
}
String referer = context.header("referer");
if (StringUtils.isBlank(referer) || !isInternalLinks(referer)) {
referer = Latkes.getServePath();
}
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "start.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final HttpServletRequest request = context.getRequest();
......@@ -200,6 +173,7 @@ public class IndexProcessor {
dataModel.put(Common.VERSION, SoloServletListener.VERSION);
dataModel.put(Common.STATIC_RESOURCE_VERSION, Latkes.getStaticResourceVersion());
dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
dataModel.put(Common.REFERER, referer);
Keys.fillRuntime(dataModel);
dataModelService.fillMinified(dataModel);
......@@ -217,13 +191,33 @@ public class IndexProcessor {
Solos.logout(httpServletRequest, context.getResponse());
String destinationURL = context.param(Common.GOTO);
if (StringUtils.isBlank(destinationURL) || !isInternalLinks(destinationURL)) {
destinationURL = Latkes.getServePath();
}
context.sendRedirect(destinationURL);
Solos.addGoogleNoIndex(context);
context.sendRedirect(Latkes.getServePath());
}
/**
* Shows kill browser page with the specified context.
*
* @param context the specified context
*/
@RequestProcessing(value = "/kill-browser", method = HttpMethod.GET)
public void showKillBrowser(final RequestContext context) {
final HttpServletRequest request = context.getRequest();
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "kill-browser.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
try {
final Map<String, String> langs = langPropsService.getAll(Locales.getLocale(request));
dataModel.putAll(langs);
final JSONObject preference = preferenceQueryService.getPreference();
dataModelService.fillCommon(context, dataModel, preference);
Keys.fillServer(dataModel);
Keys.fillRuntime(dataModel);
dataModelService.fillMinified(dataModel);
} catch (final ServiceException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
context.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
/**
......@@ -233,7 +227,7 @@ public class IndexProcessor {
*
* @return whether the destinationURL is an internal link
*/
private boolean isInternalLinks(String destinationURL) {
private boolean isInternalLinks(final String destinationURL) {
return destinationURL.startsWith(Latkes.getServePath());
}
}
......@@ -121,7 +121,7 @@ public class OAuthGitHubProcessor {
*/
@RequestProcessing(value = "/oauth/github/redirect", method = HttpMethod.GET)
public void redirectGitHub(final RequestContext context) {
String referer = context.header("referer");
String referer = context.param("referer");
if (StringUtils.isBlank(referer)) {
referer = Latkes.getServePath();
}
......
......@@ -215,9 +215,9 @@ public class UserQueryService {
*/
public String getLogoutURL() {
String to = Latkes.getServePath();
to = URLs.encode(to + "/");
to = URLs.encode(to);
return Latkes.getContextPath() + "/logout?goto=" + to;
return Latkes.getContextPath() + "/logout?referer=" + to;
}
/**
......@@ -230,6 +230,6 @@ public class UserQueryService {
String to = Latkes.getServePath();
to = URLs.encode(to + redirectURL);
return Latkes.getContextPath() + "/start?goto=" + to;
return Latkes.getContextPath() + "/start?referer=" + to;
}
}
......@@ -36,7 +36,7 @@ $.extend(Admin.prototype, {
* @description 登出
*/
logout: function () {
window.location.href = latkeConfig.servePath + "/logout?goto=" + latkeConfig.servePath;
window.location.href = latkeConfig.servePath + "/logout";
},
toggleMenu: function () {
if ($('#tabs').css('left') === '-240px') {
......
......@@ -29,11 +29,11 @@
<div id="github">
<div class="github__icon"
onclick="window.location.href = '${servePath}/oauth/github/redirect';$('#github').addClass('github--loading')">
onclick="window.location.href = '${servePath}/oauth/github/redirect?referer=${referer}';$('#github').addClass('github--loading')">
<img src="${staticServePath}/images/github.png"/>
</div>
<button class="hover"
onclick="window.location.href = '${servePath}/oauth/github/redirect';$('#github').addClass('github--loading')">${useGitHubAccountLoginLabel}</button>
onclick="window.location.href = '${servePath}/oauth/github/redirect?referer=${referer}';$('#github').addClass('github--loading')">${useGitHubAccountLoginLabel}</button>
</div>
<script type="text/javascript" src="${staticServePath}/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment