Merge pull request #458 from craigphicks/host-subdir
Allow subdirectory server configuration, e.g. https://example.com/isso
This commit is contained in:
commit
1d9cea8831
@ -1,8 +1,8 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Isso admin</title>
|
<title>Isso admin</title>
|
||||||
<link type="text/css" href="/css/isso.css" rel="stylesheet">
|
<link type="text/css" href="{{isso_host_script}}/css/isso.css" rel="stylesheet">
|
||||||
<link type="text/css" href="/css/admin.css" rel="stylesheet">
|
<link type="text/css" href="{{isso_host_script}}/css/admin.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -32,16 +32,16 @@ function fade(element) {
|
|||||||
op -= op * 0.1;
|
op -= op * 0.1;
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
function moderate(com_id, hash, action) {
|
function moderate(com_id, hash, action, isso_host_script) {
|
||||||
ajax({method: "POST",
|
ajax({method: "POST",
|
||||||
url: "/id/" + com_id + "/" + action + "/" + hash,
|
url: isso_host_script + "/id/" + com_id + "/" + action + "/" + hash,
|
||||||
success: function(){
|
success: function(){
|
||||||
fade(document.getElementById("isso-" + com_id));
|
fade(document.getElementById("isso-" + com_id));
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
function edit(com_id, hash, author, email, website, comment) {
|
function edit(com_id, hash, author, email, website, comment, isso_host_script) {
|
||||||
ajax({method: "POST",
|
ajax({method: "POST",
|
||||||
url: "/id/" + com_id + "/edit/" + hash,
|
url: isso_host_script + "/id/" + com_id + "/edit/" + hash,
|
||||||
data: JSON.stringify({text: comment,
|
data: JSON.stringify({text: comment,
|
||||||
author: author,
|
author: author,
|
||||||
email: email,
|
email: email,
|
||||||
@ -53,11 +53,11 @@ function edit(com_id, hash, author, email, website, comment) {
|
|||||||
console.log("Error: ", ret); // TODO flash msg/notif
|
console.log("Error: ", ret); // TODO flash msg/notif
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
function validate_com(com_id, hash) {
|
function validate_com(com_id, hash, isso_host_script) {
|
||||||
moderate(com_id, hash, "activate");
|
moderate(com_id, hash, "activate", isso_host_script);
|
||||||
}
|
}
|
||||||
function delete_com(com_id, hash) {
|
function delete_com(com_id, hash, isso_host_script) {
|
||||||
moderate(com_id, hash, "delete");
|
moderate(com_id, hash, "delete", isso_host_script);
|
||||||
}
|
}
|
||||||
function unset_editable(elt_id) {
|
function unset_editable(elt_id) {
|
||||||
var elt = document.getElementById(elt_id);
|
var elt = document.getElementById(elt_id);
|
||||||
@ -97,19 +97,19 @@ function stop_edit(com_id) {
|
|||||||
document.getElementById('stop-edit-btn-' + com_id).classList.toggle('hidden');
|
document.getElementById('stop-edit-btn-' + com_id).classList.toggle('hidden');
|
||||||
document.getElementById('send-edit-btn-' + com_id).classList.toggle('hidden');
|
document.getElementById('send-edit-btn-' + com_id).classList.toggle('hidden');
|
||||||
}
|
}
|
||||||
function send_edit(com_id, hash) {
|
function send_edit(com_id, hash, isso_host_script) {
|
||||||
var author = document.getElementById('isso-author-' + com_id).textContent;
|
var author = document.getElementById('isso-author-' + com_id).textContent;
|
||||||
var email = document.getElementById('isso-email-' + com_id).textContent;
|
var email = document.getElementById('isso-email-' + com_id).textContent;
|
||||||
var website = document.getElementById('isso-website-' + com_id).textContent;
|
var website = document.getElementById('isso-website-' + com_id).textContent;
|
||||||
var comment = document.getElementById('isso-text-' + com_id).textContent;
|
var comment = document.getElementById('isso-text-' + com_id).textContent;
|
||||||
edit(com_id, hash, author, email, website, comment);
|
edit(com_id, hash, author, email, website, comment, isso_host_script);
|
||||||
stop_edit(com_id);
|
stop_edit(com_id);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<header>
|
<header>
|
||||||
<img class="logo" src="/img/isso.svg" alt="Wynaut by @veekun"/>
|
<img class="logo" src="{{isso_host_script}}/img/isso.svg" alt="Wynaut by @veekun"/>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<a href="./">
|
<a href="./">
|
||||||
<h1>Isso</h1>
|
<h1>Isso</h1>
|
||||||
@ -232,16 +232,16 @@ function send_edit(com_id, hash) {
|
|||||||
<span class='spacer'></span>
|
<span class='spacer'></span>
|
||||||
<a id="edit-btn-{{comment.id}}" class="edit" onClick="javascript:start_edit({{comment.id}})">Edit</a>
|
<a id="edit-btn-{{comment.id}}" class="edit" onClick="javascript:start_edit({{comment.id}})">Edit</a>
|
||||||
<a id="stop-edit-btn-{{comment.id}}" class="hidden edit" onClick="javascript:stop_edit({{comment.id}})">Cancel</a>
|
<a id="stop-edit-btn-{{comment.id}}" class="hidden edit" onClick="javascript:stop_edit({{comment.id}})">Cancel</a>
|
||||||
<a id="send-edit-btn-{{comment.id}}" class="hidden edit" onClick="javascript:send_edit({{comment.id}}, '{{comment.hash}}')">Send</a>
|
<a id="send-edit-btn-{{comment.id}}" class="hidden edit" onClick="javascript:send_edit({{comment.id}}, '{{comment.hash}}','{{isso_host_script}}')">Send</a>
|
||||||
{% if comment.mode != 4 %}
|
{% if comment.mode != 4 %}
|
||||||
<a class="delete"
|
<a class="delete"
|
||||||
onClick="javascript:delete_com({{comment.id}}, '{{comment.hash}}')">
|
onClick="javascript:delete_com({{comment.id}}, '{{comment.hash}}', '{{isso_host_script}}')">
|
||||||
Delete
|
Delete
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if comment.mode == 2 %}
|
{% if comment.mode == 2 %}
|
||||||
<a class='validate'
|
<a class='validate'
|
||||||
onClick="javascript:validate_com({{comment.id}}, '{{comment.hash}}')">Validate</a>
|
onClick="javascript:validate_com({{comment.id}}, '{{comment.hash}}', '{{isso_host_script}}')">Validate</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Isso admin</title>
|
<title>Isso admin</title>
|
||||||
<link type="text/css" href="/css/isso.css" rel="stylesheet">
|
<link type="text/css" href="{{isso_host_script}}/css/isso.css" rel="stylesheet">
|
||||||
<link type="text/css" href="/css/admin.css" rel="stylesheet">
|
<link type="text/css" href="{{isso_host_script}}/css/admin.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<header>
|
<header>
|
||||||
<img class="logo" src="/img/isso.svg" alt="Wynaut by @veekun"/>
|
<img class="logo" src="{{isso_host_script}}/img/isso.svg" alt="Wynaut by @veekun"/>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<a href="./">
|
<a href="./">
|
||||||
<h1>Isso</h1>
|
<h1>Isso</h1>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
<main>
|
<main>
|
||||||
<div id="login">
|
<div id="login">
|
||||||
Administration secured by password:
|
Administration secured by password:
|
||||||
<form method="POST" action="/login">
|
<form method="POST" action="{{isso_host_script}}/login">
|
||||||
<input type="password" name="password" />
|
<input type="password" name="password" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1082,16 +1082,18 @@ class API(object):
|
|||||||
response.headers.add("X-Set-Cookie", cookie("isso-admin-session"))
|
response.headers.add("X-Set-Cookie", cookie("isso-admin-session"))
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return render_template('login.html')
|
isso_host_script = self.isso.conf.get("server", "public-endpoint") or local.host
|
||||||
|
return render_template('login.html', isso_host_script=isso_host_script)
|
||||||
|
|
||||||
def admin(self, env, req):
|
def admin(self, env, req):
|
||||||
|
isso_host_script = self.isso.conf.get("server", "public-endpoint") or local.host
|
||||||
try:
|
try:
|
||||||
data = self.isso.unsign(req.cookies.get('admin-session', ''),
|
data = self.isso.unsign(req.cookies.get('admin-session', ''),
|
||||||
max_age=60 * 60 * 24)
|
max_age=60 * 60 * 24)
|
||||||
except BadSignature:
|
except BadSignature:
|
||||||
return render_template('login.html')
|
return render_template('login.html',isso_host_script=isso_host_script)
|
||||||
if not data or not data['logged']:
|
if not data or not data['logged']:
|
||||||
return render_template('login.html')
|
return render_template('login.html',isso_host_script=isso_host_script)
|
||||||
page_size = 100
|
page_size = 100
|
||||||
page = int(req.args.get('page', 0))
|
page = int(req.args.get('page', 0))
|
||||||
order_by = req.args.get('order_by', None)
|
order_by = req.args.get('order_by', None)
|
||||||
@ -1111,4 +1113,5 @@ class API(object):
|
|||||||
page=int(page), mode=int(mode),
|
page=int(page), mode=int(mode),
|
||||||
conf=self.conf, max_page=max_page,
|
conf=self.conf, max_page=max_page,
|
||||||
counts=comment_mode_count,
|
counts=comment_mode_count,
|
||||||
order_by=order_by, asc=asc)
|
order_by=order_by, asc=asc,
|
||||||
|
isso_host_script=isso_host_script)
|
||||||
|
Loading…
Reference in New Issue
Block a user