Added support for explicit HTTP permalinks

This commit is contained in:
rr- 2015-07-02 20:24:01 +02:00
parent 3c83f711c9
commit 11648e055c
5 changed files with 22 additions and 1 deletions

View file

@ -31,6 +31,7 @@ secret = change
minPasswordLength = 5
needEmailActivationToRegister = 1
defaultAccessRank = restrictedUser
forceHttpInPermalinks = 0
[security.privileges]
register = anonymous

View file

@ -141,6 +141,7 @@ App.Auth = function(_, jQuery, util, api, appState, promise) {
appState.set('loginToken', response.json.token && response.json.token.name);
appState.set('loggedIn', response.json.user && !!response.json.user.id);
appState.set('loggedInUser', response.json.user);
appState.set('config', response.json.config);
}
function isLoggedIn(userName) {

View file

@ -4,6 +4,7 @@ App.Presenters = App.Presenters || {};
App.Presenters.PostPresenter = function(
_,
jQuery,
appState,
util,
promise,
api,
@ -171,6 +172,7 @@ App.Presenters.PostPresenter = function(
return templates.post({
query: params.query,
post: post,
forceHttpInPermalinks: appState.get('config')['forceHttpInPermalinks'],
ownScore: post.ownScore,
postFavorites: post.favorites,
postHistory: post.history,
@ -334,6 +336,7 @@ App.Presenters.PostPresenter = function(
App.DI.register('postPresenter', [
'_',
'jQuery',
'appState',
'util',
'promise',
'api',

View file

@ -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">

View file

@ -1,5 +1,6 @@
<?php
namespace Szurubooru\Routes;
use Szurubooru\Config;
use Szurubooru\FormData\LoginFormData;
use Szurubooru\Helpers\InputReader;
use Szurubooru\Router;
@ -12,6 +13,7 @@ use Szurubooru\ViewProxies\UserViewProxy;
class Login extends AbstractRoute
{
private $config;
private $authService;
private $userService;
private $tokenService;
@ -21,6 +23,7 @@ class Login extends AbstractRoute
private $tokenViewProxy;
public function __construct(
Config $config,
AuthService $authService,
UserService $userService,
TokenService $tokenService,
@ -29,6 +32,7 @@ class Login extends AbstractRoute
UserViewProxy $userViewProxy,
TokenViewProxy $tokenViewProxy)
{
$this->config = $config;
$this->authService = $authService;
$this->userService = $userService;
$this->tokenService = $tokenService;
@ -79,6 +83,9 @@ class Login extends AbstractRoute
'token' => $this->tokenViewProxy->fromEntity($this->authService->getLoginToken()),
'user' => $this->userViewProxy->fromEntity($user),
'privileges' => $this->privilegeService->getCurrentPrivileges(),
'config' => [
'forceHttpInPermalinks' => $this->config->security->forceHttpInPermalinks,
],
];
}
}