summaryrefslogtreecommitdiff
path: root/views/blog
diff options
context:
space:
mode:
Diffstat (limited to 'views/blog')
-rw-r--r--views/blog/blog.ejs35
-rw-r--r--views/blog/edit.ejs42
-rw-r--r--views/blog/new.ejs42
-rw-r--r--views/blog/show.ejs53
4 files changed, 172 insertions, 0 deletions
diff --git a/views/blog/blog.ejs b/views/blog/blog.ejs
new file mode 100644
index 0000000..2afe769
--- /dev/null
+++ b/views/blog/blog.ejs
@@ -0,0 +1,35 @@
+<%- include('../partials/header') %>
+
+<div class='content'>
+ <div class='leftie'>
+ <ul>
+ <% if(!currentUser) { %>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } else { %>
+ <% if(currentUser.username === account.username) { %>
+ <li><a href='/blog/<%= currentUser.username %>'><strong>My Blog</strong></a></li>
+ <% } else { %>
+ <li><a href='/blog/<%= currentUser.username %>'>My Blog</a></li>
+ <% } %>
+ <li><a href='/blog/<%= currentUser.username %>/new'>Create a blog post</a></li>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } %>
+ </ul>
+ </div>
+ <div class='rightie' id='rev'>
+ <% posts.map((post) => { %>
+ <div class='bpost'>
+ <h4><a href="/blog/<%= account.username %>/<%= post._id %>"><%= post.title %></a></h4>
+ <img src="<%= post.image %>" alt="...">
+ <p><%- post.body.substring(0, 300) %>...</p>
+ </div>
+ <% }) %>
+ <h3><a id='bname' href="/blog/<%= account.username %>"><%= account.username.toUpperCase() %></a></h3>
+ </div>
+</div>
+
+<%- include('../partials/footer') %> \ No newline at end of file
diff --git a/views/blog/edit.ejs b/views/blog/edit.ejs
new file mode 100644
index 0000000..00d9b57
--- /dev/null
+++ b/views/blog/edit.ejs
@@ -0,0 +1,42 @@
+<%- include('../partials/header') %>
+
+<div class='content'>
+ <div class='leftie'>
+ <ul>
+ <% if(!currentUser) { %>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } else { %>
+ <li><a href='/blog/<%= currentUser.username %>'>My Blog</a></li>
+ <li><a href='/blog/<%= currentUser %>/new'><strong>Create a blog post</strong></a></li>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } %>
+ </ul>
+ </div>
+ <div class='rightie'>
+ <h3><%= currentUser.username.toUpperCase() %></h3>
+ <p>New blog post.</p>
+ <form action="/blog/<%= currentUser.username %>/<%= post._id %>?_method=PUT" method='POST' id='newb'>
+ <label>Title</label>
+ <input type="text" name='post[title]' placeholder='title' value='<%= post.title %>'>
+ <label>Image</label>
+ <input type="text" name='post[image]' placeholder='iamge url' value='<%= post.image %>'>
+ <label>Choose a tag:</label>
+ <select name="post[tag]" value='<%= post.tag %>'>
+ <option value="life">Life</option>
+ <option value="science">Science</option>
+ <option value="music">Music</option>
+ <option value="cinema">Cinema</option>
+ <option value="travel">Travel</option>
+ </select>
+ <label>Body</label>
+ <textarea name="post[body]" id="bod"><%= post.body %></textarea>
+ <button class='formBtn' type='submit'>Post</button>
+ </form>
+ </div>
+</div>
+
+<%- include('../partials/footer') %> \ No newline at end of file
diff --git a/views/blog/new.ejs b/views/blog/new.ejs
new file mode 100644
index 0000000..2800c6f
--- /dev/null
+++ b/views/blog/new.ejs
@@ -0,0 +1,42 @@
+<%- include('../partials/header') %>
+
+<div class='content'>
+ <div class='leftie'>
+ <ul>
+ <% if(!currentUser) { %>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } else { %>
+ <li><a href='/blog/<%= currentUser.username %>'>My Blog</a></li>
+ <li><a href='/blog/<%= currentUser %>/new'><strong>Create a blog post</strong></a></li>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } %>
+ </ul>
+ </div>
+ <div class='rightie'>
+ <h3><%= currentUser.username.toUpperCase() %></h3>
+ <p>New blog post.</p>
+ <form action="/blog" method='POST' id='newb'>
+ <label>Title</label>
+ <input type="text" name='post[title]' placeholder='title'>
+ <label>Image</label>
+ <input type="text" name='post[image]' placeholder='image url'>
+ <label>Choose a tag:</label>
+ <select name="post[tag]">
+ <option value="life">Life</option>
+ <option value="science">Science</option>
+ <option value="music">Music</option>
+ <option value="cinema">Cinema</option>
+ <option value="travel">Travel</option>
+ </select>
+ <label>Body</label>
+ <textarea name="post[body]" id="bod"></textarea>
+ <button class='formBtn' type='submit'>Post</button>
+ </form>
+ </div>
+</div>
+
+<%- include('../partials/footer') %> \ No newline at end of file
diff --git a/views/blog/show.ejs b/views/blog/show.ejs
new file mode 100644
index 0000000..0133499
--- /dev/null
+++ b/views/blog/show.ejs
@@ -0,0 +1,53 @@
+<%- include('../partials/header') %>
+
+<div class='content'>
+ <div class='leftie'>
+ <ul>
+ <% if(!currentUser) { %>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } else { %>
+ <li><a href='/blog/<%= currentUser.username %>'>My Blog</a></li>
+ <li><a href='/blog/<%= currentUser.username %>/new'>Create a blog post</a></li>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } %>
+ </ul>
+ </div>
+ <div class='rightie'>
+ <h3><a id='pbname' href="/blog/<%= account %>"><%= account.toUpperCase() %></a></h3>
+ <div class='showPost'>
+ <h4><%= post.title %></h4>
+ <img src="<%= post.image %>" alt="...">
+ <span><button><%= post.tag %></button></span>
+ <p><%- post.body %></p>
+ <% if(currentUser && post.author.id.equals(currentUser._id)) { %>
+ <a id='edit' href="/blog/<%= currentUser.username %>/<%= post._id %>/edit">Edit</a>
+ <form id="deleteForm" action="/blog/<%= currentUser.username %>/<%= post._id %>?_method=DELETE" method="POST">
+ <button class='deleteBtn' type='submit'>Delete</button>
+ </form>
+ <% } %>
+ <% post.comments.map((comment) => { %>
+ <div class='comment'>
+ <h5><%= comment.author.username.toUpperCase() %>: </h5>
+ <p><%- comment.text %></p>
+ <% if(currentUser && comment.author.id.equals(currentUser._id)) { %>
+ <div class='cmmntOps'>
+ <a id="edCmmnt" href="/blog/<%= account %>/<%= post._id %>/comments/<%= comment._id %>/edit">
+ Edit
+ </a>
+ <form id="deleteForm" action='/blog/<%= account %>/<%= post._id %>/comments/<%= comment._id %>?_method=DELETE' method="POST">
+ <button class='deleteBtn' type='submit'>Delete</button>
+ </form>
+ </div>
+ <% } %>
+ </div>
+ <% }) %>
+ <a id='edit' href="/blog/<%= account %>/<%= post._id %>/comments/new">Add a comment</a>
+ </div>
+ </div>
+</div>
+
+<%- include('../partials/footer') %>