Repository navigation
Expand file tree
/
Copy pathstringquery.js
More file actions
203 lines (140 loc) · 4.09 KB
/
Copy pathstringquery.js
File metadata and controls
203 lines (140 loc) · 4.09 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// for string=> :phone and at ejs =write ejs
// for query =>
// <a href="/delete-contact/?id=<%=i._id%>"></a> for db delete.
//<ul>
// <% if(locals.user){ %>
// <li> <%= user.name %> </li>
// <li>
// <a href= "/new/sign-out">Sign out</a>
// </li>
//
// <%} else{ %>
// <li>
// <a href="/new/sign-in">Sign in</a>
// </li>
// <li>
// <a href= "/new/sign-up">Sign up</a>
// </li>
// <% } %>
// </ul>
// check if the user is authenticated
//passport.checkAuthentication = function(req, res, next){
// if the user is signed in, then pass on the request to the next function(controller's action)
// if (req.isAuthenticated()){
// return next();
// }
// if the user is not signed in
// return res.redirect('/users/sign-in');
// }
//passport.setAuthenticatedUser = function(req, res, next){
// if (req.isAuthenticated()){
// // req.user contains the current signed in user from the session cookie and we are just sending this to the locals for the views
// res.locals.user = req.user;
// }
// next();
// }
//<!--<link rel ="stylesheet" href="/css/layout.css">
//<html>
// <head>
// <title>
// <%= title %>
</title>
</head>
<body>
<%- include('_header'); -%>
<h1>Codeial/xcvcx</h1>
<%- include('_footer'); -%>
</body>
</html> ---->
// for home.ejs
<!----
<div id="posts-list-container">
<ul>
<% for(post of posts){ %>
<%- include('_post') -%>
<%}%>
</ul>
</div>
</section>
<section id="user-friends">
<h4>Friends</h4>
<% for(u of all_users){%>
<p>
<a href="new/profile/<%= u.id %>"><%= u.name %></a>
</p>
<%}%>
</section>
</div>
<script src="../assets/js/home_posts.js"></script>
// for flash
<!---- <% if(flash.success && flash.success.length >0) { %>
<h5>
<%=flash.success%>
</h5>
<% } %> --->
//for noty
<!----- <script>
<% if(flash.success && flash.success.length >0){ %>
new Noty({
type:'success',
layout:'topRight',
text:"<%- flash.success -%>",
timeout: 1500
}).show();
<% } %>
</script> --->
<div id="posts-list-container">
<ul>
<% for(post of posts){ %>
<li>
<%= post.content %>
</li>
<small>
<%= post.user %>
</small>
<%}%>
</ul>
</div>
<div id="posts-list-container">
<ul>
<% for(post of posts){ %>
<li>
<p>
<% if(locals.user && locals.user.id == post.user.id){ %>
<small>
<a class="delete-post-button" href="/posts/destroy/<%=post.id%>">delete me!!!!</a>
</small>
<%}%>
<%= post.content %>
<br>
<small>
<%= post.user.name %>
</small>
</p>
<div class ="post-comments">
<% if(locals.user){%>
<form action="/posts/create" method="POST">
<input type="text" name="content" placeholder="add comment">
<input type="hidden" name="post" value="<%= post._id %>">
<input type="submit" value="Add comment">
</form>
<%}%>
<div class ="post-comments-list">
<ul id = "post-comments-<%= post._id %>">
<% for(comment of post.comments) { %>
<p>
<%= comment.content %>
<br>
<small>
<%= comment.user.name %>
</small>
</p>
<%}%>
</ul>
</div>
</div>
</li>
<%}%>
</ul>
</div>
</section>