client/home: show top nav after all, improve looks

This commit is contained in:
rr- 2016-06-01 21:31:15 +02:00
parent 446f4d6611
commit fd2df3966d
6 changed files with 47 additions and 68 deletions

View File

@ -1,13 +1,28 @@
#home #home
text-align: center !important text-align: center !important
h1 header
margin-top: 0 h1
margin-bottom: 0.5em margin-top: 0
margin-bottom: 0.2em
aside
opacity: .5
font-size: 80%
margin-bottom: 2em
.message .message
margin-bottom: 2em margin-bottom: 2em
form
margin-bottom: 2em
width: auto
white-space: nowrap
input
width: auto
.separator
display: inline-block
margin: 0 1.5em
.post-container .post-container
display: flex display: flex
align-items: center align-items: center
@ -18,15 +33,11 @@
a a
padding: 0.5em padding: 0.5em
form
width: auto
aside aside
margin-bottom: 0.5em margin-bottom: 1em
font-size: 90% font-size: 90%
footer footer
opacity: .5 margin-top: 1em
margin-top: 2em
line-height: 100% line-height: 100%
font-size: 80% font-size: 80%

View File

@ -2,59 +2,34 @@
<div class='messages'></div> <div class='messages'></div>
<header> <header>
<h1><%= ctx.name %></h1> <h1><%= ctx.name %></h1>
<aside>
Serving <%= ctx.postCount %> posts (<%= ctx.makeFileSize(ctx.diskUsage) %>)
</aside>
</header> </header>
<nav>
<ul>
<% if (ctx.canListPosts) { %>
<li><a href='/posts'><%= ctx.makeAccessKey('Posts', 'P') %></a></li>
<% } %>
<% if (ctx.canListComments) { %>
<li><a href='/comments'><%= ctx.makeAccessKey('Comments', 'C') %></a></li>
<% } %>
<% if (ctx.canListTags) { %>
<li><a href='/tags'><%= ctx.makeAccessKey('Tags', 'T') %></a></li>
<% } %>
<% if (ctx.canListUsers) { %>
<li><a href='/users'><%= ctx.makeAccessKey('Users', 'U') %></a></li>
<% } %>
<li><a href='/help'><%= ctx.makeAccessKey('Help', 'E') %></a></li>
</ul>
</nav>
<% if (ctx.canListPosts) { %> <% if (ctx.canListPosts) { %>
<form class='horizontal'> <form class='horizontal'>
<div class='input'> <div class='input'>
<ul> <%= ctx.makeButton({name: 'all-posts', value: 'Browse all posts'}) %>
<li> <span class='separator'>or</span>
<%= ctx.makeTextInput({id: 'search-text', name: 'search-text'}) %> <%= ctx.makeTextInput({name: 'search-text', placeholder: 'enter some tags'}) %>
</li>
</ul>
</div> </div>
<div class='buttons'> <div class='buttons'>
<input type='submit' value='Search'/> <input type='submit' value='Search'/>
</div> </div>
</form> </form>
<% } %> <% } %>
<div class='post-container'></div>
<% if (ctx.featuredPost) { %> <% if (ctx.featuredPost) { %>
<aside> <aside>
<%= ctx.makePostLink(ctx.featuredPost.id) %> Featured post: <%= ctx.makePostLink(ctx.featuredPost.id) %>,
&bull; posted
Featured
<%= ctx.makeRelativeTime(ctx.featuringTime) %>
by
<%= ctx.makeUserLink(ctx.featuringUser) %>
&bull;
Posted
<%= ctx.makeRelativeTime(ctx.featuredPost.creationTime) %> <%= ctx.makeRelativeTime(ctx.featuredPost.creationTime) %>
by by
<%= ctx.makeUserLink(ctx.featuredPost.user) %> <%= ctx.makeUserLink(ctx.featuredPost.user) %>
</aside> </aside>
<% } %> <% } %>
<div class='post-container'></div>
<footer> <footer>
Serving <%= ctx.postCount %> posts (<%= ctx.makeFileSize(ctx.diskUsage) %>) Build <a class='version' href='https://github.com/rr-/szurubooru/commits/master'><%= ctx.version %></a>
&bull; from <%= ctx.makeRelativeTime(ctx.buildDate) %>
Running <a class='version' href='https://github.com/rr-/szurubooru/commits/master'><%= ctx.version %></a>
&bull;
Built <%= ctx.makeRelativeTime(ctx.buildDate) %>
</footer> </footer>
</div> </div>

View File

@ -25,9 +25,6 @@ class HomeController {
.then(response => { .then(response => {
this._homeView.render({ this._homeView.render({
canListPosts: api.hasPrivilege('posts:list'), canListPosts: api.hasPrivilege('posts:list'),
canListComments: api.hasPrivilege('comments:list'),
canListTags: api.hasPrivilege('tags:list'),
canListUsers: api.hasPrivilege('users:list'),
diskUsage: response.diskUsage, diskUsage: response.diskUsage,
postCount: response.postCount, postCount: response.postCount,
featuredPost: response.featuredPost, featuredPost: response.featuredPost,
@ -38,9 +35,6 @@ class HomeController {
response => { response => {
this._homeView.render({ this._homeView.render({
canListPosts: api.hasPrivilege('posts:list'), canListPosts: api.hasPrivilege('posts:list'),
canListComments: api.hasPrivilege('comments:list'),
canListTags: api.hasPrivilege('tags:list'),
canListUsers: api.hasPrivilege('users:list'),
}); });
events.notify(events.Error, response.description); events.notify(events.Error, response.description);
}); });

View File

@ -108,6 +108,11 @@ function makeInput(options) {
}); });
} }
function makeButton(options) {
options.inputType = 'button';
return makeInput(options);
}
function makeTextInput(options) { function makeTextInput(options) {
options.inputType = 'text'; options.inputType = 'text';
return makeInput(options); return makeInput(options);
@ -159,7 +164,8 @@ function makeTagLink(name) {
function makeUserLink(user) { function makeUserLink(user) {
return makeNonVoidElement('span', {class: 'user'}, return makeNonVoidElement('span', {class: 'user'},
makeThumbnail(user.avatarUrl) + makeThumbnail(user.avatarUrl) +
makeNonVoidElement('a', {'href': '/user/' + user.name}, user.name)); makeNonVoidElement(
'a', {'href': '/user/' + user.name}, '+' + user.name));
} }
function makeFlexboxAlign(options) { function makeFlexboxAlign(options) {
@ -269,6 +275,7 @@ function getTemplate(templatePath) {
makeCheckbox: makeCheckbox, makeCheckbox: makeCheckbox,
makeSelect: makeSelect, makeSelect: makeSelect,
makeInput: makeInput, makeInput: makeInput,
makeButton: makeButton,
makeTextInput: makeTextInput, makeTextInput: makeTextInput,
makePasswordInput: makePasswordInput, makePasswordInput: makePasswordInput,
makeEmailInput: makeEmailInput, makeEmailInput: makeEmailInput,

View File

@ -29,7 +29,14 @@ class HomeView {
const form = source.querySelector('form'); const form = source.querySelector('form');
if (form) { if (form) {
const searchTextInput = form.querySelector('input'); form.querySelector('input[name=all-posts')
.addEventListener('click', e => {
e.preventDefault();
page('/posts/');
});
const searchTextInput = form.querySelector(
'input[name=search-text]');
new TagAutoCompleteControl(searchTextInput); new TagAutoCompleteControl(searchTextInput);
form.addEventListener('submit', e => { form.addEventListener('submit', e => {
e.preventDefault(); e.preventDefault();

View File

@ -16,22 +16,7 @@ class TopNavView {
views.showView(this._navHolder, source); views.showView(this._navHolder, source);
} }
show() {
this._navHolder.style.visibility = 'initial';
this._navHolder.style.position = 'initial';
}
hide() {
this._navHolder.style.visibility = 'hidden';
this._navHolder.style.position = 'fixed';
}
activate(itemName) { activate(itemName) {
if (itemName == 'home') {
this.hide();
} else {
this.show();
}
const allItemsSelector = '#top-nav-holder [data-name]'; const allItemsSelector = '#top-nav-holder [data-name]';
const currentItemSelector = const currentItemSelector =
'#top-nav-holder [data-name="' + itemName + '"]'; '#top-nav-holder [data-name="' + itemName + '"]';