-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
82 lines (76 loc) · 2.31 KB
/
admin.html
File metadata and controls
82 lines (76 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{% import 'macros.html' as macros %}
<!doctype html>
<head>
<title> Blog Posts </title>
{{ macros.stylesheet(home=True, jquery=True) }}
<style>
.login { margin: auto; text-align: center; }
</style>
</head>
<body>
<script>
var toUpdate = [];
function update(pid, title) {
var url = '/update?id=' + pid;
// window.location.host + '/update?id=' + pid;
$.get(url, function(){
$('#f' + pid).html(title + ' [updated]');
});
}
function publish(pid) {
$.post(
'/publish?id=' + pid,
function(){
$('#p' + pid + ' > span').addClass('published');
setTimeout(function(){ window.location.reload(true); }, 1000);
}
);
return false;
}
function unpublish(pid) {
$.post(
'/unpublish?id=' + pid,
function(){
$('#p' + pid + ' > span').removeClass('published');
setTimeout(function(){ window.location.reload(true); }, 1000);
}
);
return false;
}
</script>
{% if logged_in %}
<div class="page">
{{ macros.create_header(page='admin', logged_in=True) }}
<div class="files"><h4 class="underline">Updating</h4>
{% for file in toupdate %}
<div id="f{{file.id}}">{{file.title}}</div>
<script>toUpdate.push(['{{file.id}}', '{{file.title}}']);</script>
{% endfor %}
</div>
<div id="posts"><h4 class="underline">Unpublished</h4>
{% for post in unpublished %}
<div id='p{{post.postid}}' class='file'>
<span>{{post.title}}</span>
<a href="/post/{{post.small_date}}/{{post.small_name}}">view</a>
<a href="javascript:publish('{{post.postid}}');">publish</a>
</div>
{% endfor %}
</div>
<h4 class="underline">Published</h4>
{% for post in published %}
<div class="post">
<div style="background-image:url({{post.pic}})" class="mainimg"> </div>
<a href="/post/{{post.small_date}}/{{post.small_name}}" class="title">{{post.title}}</a>
<div><a href="javascript:unpublish('{{post.postid}}');">unpublish</a></div>
<div class="snippet">Posted {{post.nice_date}}<br />{{post.snippet}}</div>
</div>
{% endfor %}
<script>for(i in toUpdate){ update.apply(undefined, toUpdate[i]); }</script>
</div>
{% else %}
<div class='login'>
<h3>{{maintitle}}</h3>
<a style='margin:auto;' href="{{url}}" class="btn">Admin Login</a>
</div>
{% endif %}
</body>