index.ejs
2.53 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
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<div>
<h2 class="mb-3" style="font-weight: bold; font-style:italic; float:left;">Memory</h2>
<div style="float:right">
<% if(isAuthenticated){ %>
<a class="btn btn-outline-primary" href="/posts/new">Write Memory</a>
<% } %>
</div>
<!-- <table class="board-table table table-sm border-bottom"> -->
<table class="table table-hover table-light">
<thead>
<tr class="table-dark">
<th scope="col">Title</th>
<th scope="col" class="author">Author</th>
<th scope="col" class="date">Date</th>
</tr>
</thead>
<tbody>
<% if(posts == null || posts.length == 0){ %>
<tr>
<td colspan=2> EMPTY </td>
</tr>
<% } %>
<% posts.forEach(function(post) { %>
<tr>
<td>
<a href="/posts/<%= post._id %>" style="color:black; font-weight: bold;"><div class="ellipsis"><%= post.title %></div></a>
</td>
<td class="author">
<div class="ellipsis"><%= post.author ? post.author.username : "" %></div>
</td>
<td class="date">
<span data-date="<%= post.createdAt %>"><%= post.createdAt %></span>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
</div>
<form action="/posts" method="get" class="post-index-tool"> <!-- 1 -->
<div class="form-row">
<div class="form-group col-9"> <!-- 2 -->
<label>Search</label>
<div class="input-group">
<select name="searchType" class="custom-select">
<option value="title,body" <% searchType=='title,body'?'selected':'' %>>Title, Body</option>
<option value="title" <%= searchType=='title'?'selected':'' %>>Title</option>
<option value="body" <%= searchType=='body'?'selected':''' %>>Body</option>
</select>
<input minLength="3" type="text" name="searchText" value="<%= searchText %>">
<div class="input-group-append">
<button class="btn btn-outline-primary" type="submit">search</button>
</div>
</div>
</div>
</div>
</form>
</body>
</html>