Added support for explicit HTTP permalinks
This commit is contained in:
parent
3c83f711c9
commit
11648e055c
5 changed files with 22 additions and 1 deletions
|
@ -31,6 +31,7 @@ secret = change
|
||||||
minPasswordLength = 5
|
minPasswordLength = 5
|
||||||
needEmailActivationToRegister = 1
|
needEmailActivationToRegister = 1
|
||||||
defaultAccessRank = restrictedUser
|
defaultAccessRank = restrictedUser
|
||||||
|
forceHttpInPermalinks = 0
|
||||||
|
|
||||||
[security.privileges]
|
[security.privileges]
|
||||||
register = anonymous
|
register = anonymous
|
||||||
|
|
|
@ -141,6 +141,7 @@ App.Auth = function(_, jQuery, util, api, appState, promise) {
|
||||||
appState.set('loginToken', response.json.token && response.json.token.name);
|
appState.set('loginToken', response.json.token && response.json.token.name);
|
||||||
appState.set('loggedIn', response.json.user && !!response.json.user.id);
|
appState.set('loggedIn', response.json.user && !!response.json.user.id);
|
||||||
appState.set('loggedInUser', response.json.user);
|
appState.set('loggedInUser', response.json.user);
|
||||||
|
appState.set('config', response.json.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLoggedIn(userName) {
|
function isLoggedIn(userName) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ App.Presenters = App.Presenters || {};
|
||||||
App.Presenters.PostPresenter = function(
|
App.Presenters.PostPresenter = function(
|
||||||
_,
|
_,
|
||||||
jQuery,
|
jQuery,
|
||||||
|
appState,
|
||||||
util,
|
util,
|
||||||
promise,
|
promise,
|
||||||
api,
|
api,
|
||||||
|
@ -171,6 +172,7 @@ App.Presenters.PostPresenter = function(
|
||||||
return templates.post({
|
return templates.post({
|
||||||
query: params.query,
|
query: params.query,
|
||||||
post: post,
|
post: post,
|
||||||
|
forceHttpInPermalinks: appState.get('config')['forceHttpInPermalinks'],
|
||||||
ownScore: post.ownScore,
|
ownScore: post.ownScore,
|
||||||
postFavorites: post.favorites,
|
postFavorites: post.favorites,
|
||||||
postHistory: post.history,
|
postHistory: post.history,
|
||||||
|
@ -334,6 +336,7 @@ App.Presenters.PostPresenter = function(
|
||||||
App.DI.register('postPresenter', [
|
App.DI.register('postPresenter', [
|
||||||
'_',
|
'_',
|
||||||
'jQuery',
|
'jQuery',
|
||||||
|
'appState',
|
||||||
'util',
|
'util',
|
||||||
'promise',
|
'promise',
|
||||||
'api',
|
'api',
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
<% var permaLink = (window.location.origin + '/' + window.location.pathname + '/data/posts/' + post.name).replace(/([^:])\/+/g, '$1/') %>
|
<%
|
||||||
|
var permaLink = '';
|
||||||
|
permaLink += window.location.origin + '/';
|
||||||
|
permaLink += window.location.pathname + '/';
|
||||||
|
permaLink += 'data/posts/' + post.name;
|
||||||
|
permaLink = permaLink.replace(/([^:])\/+/g, '$1/');
|
||||||
|
if (forceHttpInPermalinks > 0) {
|
||||||
|
permaLink = permaLink.replace('https', 'http');
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
<div id="post-current-search-wrapper">
|
<div id="post-current-search-wrapper">
|
||||||
<div id="post-current-search">
|
<div id="post-current-search">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Szurubooru\Routes;
|
namespace Szurubooru\Routes;
|
||||||
|
use Szurubooru\Config;
|
||||||
use Szurubooru\FormData\LoginFormData;
|
use Szurubooru\FormData\LoginFormData;
|
||||||
use Szurubooru\Helpers\InputReader;
|
use Szurubooru\Helpers\InputReader;
|
||||||
use Szurubooru\Router;
|
use Szurubooru\Router;
|
||||||
|
@ -12,6 +13,7 @@ use Szurubooru\ViewProxies\UserViewProxy;
|
||||||
|
|
||||||
class Login extends AbstractRoute
|
class Login extends AbstractRoute
|
||||||
{
|
{
|
||||||
|
private $config;
|
||||||
private $authService;
|
private $authService;
|
||||||
private $userService;
|
private $userService;
|
||||||
private $tokenService;
|
private $tokenService;
|
||||||
|
@ -21,6 +23,7 @@ class Login extends AbstractRoute
|
||||||
private $tokenViewProxy;
|
private $tokenViewProxy;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
Config $config,
|
||||||
AuthService $authService,
|
AuthService $authService,
|
||||||
UserService $userService,
|
UserService $userService,
|
||||||
TokenService $tokenService,
|
TokenService $tokenService,
|
||||||
|
@ -29,6 +32,7 @@ class Login extends AbstractRoute
|
||||||
UserViewProxy $userViewProxy,
|
UserViewProxy $userViewProxy,
|
||||||
TokenViewProxy $tokenViewProxy)
|
TokenViewProxy $tokenViewProxy)
|
||||||
{
|
{
|
||||||
|
$this->config = $config;
|
||||||
$this->authService = $authService;
|
$this->authService = $authService;
|
||||||
$this->userService = $userService;
|
$this->userService = $userService;
|
||||||
$this->tokenService = $tokenService;
|
$this->tokenService = $tokenService;
|
||||||
|
@ -79,6 +83,9 @@ class Login extends AbstractRoute
|
||||||
'token' => $this->tokenViewProxy->fromEntity($this->authService->getLoginToken()),
|
'token' => $this->tokenViewProxy->fromEntity($this->authService->getLoginToken()),
|
||||||
'user' => $this->userViewProxy->fromEntity($user),
|
'user' => $this->userViewProxy->fromEntity($user),
|
||||||
'privileges' => $this->privilegeService->getCurrentPrivileges(),
|
'privileges' => $this->privilegeService->getCurrentPrivileges(),
|
||||||
|
'config' => [
|
||||||
|
'forceHttpInPermalinks' => $this->config->security->forceHttpInPermalinks,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue