diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/blog/blog.ejs | 35 | ||||
-rw-r--r-- | views/blog/edit.ejs | 42 | ||||
-rw-r--r-- | views/blog/new.ejs | 42 | ||||
-rw-r--r-- | views/blog/show.ejs | 53 | ||||
-rw-r--r-- | views/comments/edit.ejs | 29 | ||||
-rw-r--r-- | views/comments/new.ejs | 29 | ||||
-rw-r--r-- | views/index.ejs | 34 | ||||
-rw-r--r-- | views/login.ejs | 31 | ||||
-rw-r--r-- | views/mbrowsers.ejs | 26 | ||||
-rw-r--r-- | views/partials/footer.ejs | 2 | ||||
-rw-r--r-- | views/partials/header.ejs | 22 | ||||
-rw-r--r-- | views/register.ejs | 33 | ||||
-rw-r--r-- | views/search/all.ejs | 41 | ||||
-rw-r--r-- | views/search/byTag.ejs | 74 | ||||
-rw-r--r-- | views/search/title.ejs | 39 |
15 files changed, 532 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') %> diff --git a/views/comments/edit.ejs b/views/comments/edit.ejs new file mode 100644 index 0000000..2e3f2c5 --- /dev/null +++ b/views/comments/edit.ejs @@ -0,0 +1,29 @@ +<%- include('../partials/header') %> + +<div class='content'> + <div class='leftie'> + <ul> + <% if(!currentUser) { %> + <li><a href='#'>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'>Create a blog post</a></li> + <li><a href='#'>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'> + <p>Edit comment.</p> + <form action="/blog/<%= account %>/<%= post_id %>/comments/<%= comment._id %>?_method=PUT" method='POST' id='newb'> + <label>Comment</label> + <textarea name="cmmnt[text]" id="bod"><%= comment.text %></textarea> + <button class='formBtn' type='submit'>Update</button> + </form> + </div> +</div> + +<%- include('../partials/footer') %>
\ No newline at end of file diff --git a/views/comments/new.ejs b/views/comments/new.ejs new file mode 100644 index 0000000..44dc054 --- /dev/null +++ b/views/comments/new.ejs @@ -0,0 +1,29 @@ +<%- include('../partials/header') %> + +<div class='content'> + <div class='leftie'> + <ul> + <% if(!currentUser) { %> + <li><a href='#'>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'>Create a blog post</a></li> + <li><a href='#'>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'> + <p>New comment.</p> + <form action="/blog/<%= post.author.username %>/<%= post._id %>/comments/" method='POST' id='newb'> + <label>Comment</label> + <textarea name="cmmnt[text]" 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/index.ejs b/views/index.ejs new file mode 100644 index 0000000..c0496ba --- /dev/null +++ b/views/index.ejs @@ -0,0 +1,34 @@ +<%- 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='/'><strong>About</strong></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='/'><strong>About</strong></a></li> + <li><a href='/browsers'>Minimal browsers</a></li> + <% } %> + </ul> + </div> + <div class='rightie'> + <p>Tired of how bloated the web is, so I made this.</p> + <br> + <h3>News</h3> + <p>Find out <a href="#">more</a>.</p> + <h4>2020-02-08</h4> + <p>Sblog app is now live. Some updates will be added later.</p> + <p>ToDo's</p> + <ul> + <li>user warning and success cards</li> + <li>search by tag</li> + </ul> + </div> +</div> + +<%- include('partials/footer') %> diff --git a/views/login.ejs b/views/login.ejs new file mode 100644 index 0000000..3bd5cd1 --- /dev/null +++ b/views/login.ejs @@ -0,0 +1,31 @@ +<%- 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>Log In</h3> + <form action='/login' id='reg' method='POST'> + <label>Username</label> + <input type="text" name='username' placeholder='username'> + <label>Password</label> + <input type="password" name='password' placeholder='password'> + <button class='formBtn' type='submit'>Login</button> + </form> + </div> +</div> + +<%- include('partials/footer') %>
\ No newline at end of file diff --git a/views/mbrowsers.ejs b/views/mbrowsers.ejs new file mode 100644 index 0000000..f7b11ab --- /dev/null +++ b/views/mbrowsers.ejs @@ -0,0 +1,26 @@ +<%- 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'><strong>Minimal browsers</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'><strong>Minimal browsers</strong></a></li> + <% } %> + </ul> + </div> + <div class='rightie'> + <h3>Sblog and minimal browsers</h3> + <p>This app was made with the intention of being used in minimal browsers.</p> + <p><a href="https://luakit.github.io/">Luakit</a> and <a href="https://surf.suckless.org/">surf</a> are my personal favorites. Give it a try for the ultimum minimal experience.</p> + </div> +</div> + +<%- include('partials/footer') %>
\ No newline at end of file diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs new file mode 100644 index 0000000..2ab5c0d --- /dev/null +++ b/views/partials/footer.ejs @@ -0,0 +1,2 @@ + </body> +</html> diff --git a/views/partials/header.ejs b/views/partials/header.ejs new file mode 100644 index 0000000..f6db580 --- /dev/null +++ b/views/partials/header.ejs @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html> + <head> + <title>Suckless Blog</title> + <meta name='viewport' content='width=device-width, initial-scale=1.0'> + <link rel='stylesheet' type='text/css' href="/stylesheets/main.css"> + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> + </head> + <body> + <div class='banner'> + <h2><a href='/'>The Suckless Blog</a></h2> + <h3><em>A blog platform that sucks less</em></h3> + </div> + <div class='nav'> + <h4><a href='/'>Home</a></h4> + <% if(!currentUser) { %> + <h4><a href='/login'>Log In</a></h4> + <h4><a href='/register'>Register</a></h4> + <% } else { %> + <h4><a href='/logout'>Log out</a></h4> + <% } %> + </div> diff --git a/views/register.ejs b/views/register.ejs new file mode 100644 index 0000000..4623fcc --- /dev/null +++ b/views/register.ejs @@ -0,0 +1,33 @@ +<%- 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>Register</h3> + <form action='/register' id='reg' method='POST'> + <label>Username</label> + <input type="text" name='username' placeholder='username'> + <label>Email</label> + <input type="email" name='account[email]' placeholder='name@example.com'> + <label>Password</label> + <input type="password" name='password' placeholder='password'> + <button class='formBtn' type='submit'>Register</button> + </form> + </div> +</div> + +<%- include('partials/footer') %>
\ No newline at end of file diff --git a/views/search/all.ejs b/views/search/all.ejs new file mode 100644 index 0000000..0fca029 --- /dev/null +++ b/views/search/all.ejs @@ -0,0 +1,41 @@ +<%- include('../partials/header') %> + +<div class='content'> + <div class='leftie'> + <ul> + <% if(!currentUser) { %> + <li><a href='/search/all'>Search for blog posts</a></li> + <ul id='sub'> + <li><a href="/search/all"><em><strong>All blog posts</strong></em></a></li> + <!-- <li><a href="/search/tag"><em>By tag</em></a></li> --> + <!-- <li><a href="#"><em>By category</em></a></li> --> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</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> + <ul id='sub'> + <li><a href="/search/all"><em><strong>All blog posts</strong></em></a></li> + <!-- <li><a href="/search/tag">By tag</a></li> --> + <!-- <li><a href="#">By category</a></li> --> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</a></li> + <% } %> + </ul> + </div> + <div class='rightie' id='rev'> + <% posts.map((post) => { %> + <div class='bpost'> + <h4><a href="/blog/<%= post.author.username %>/<%= post._id %>"><%= post.title %></a></h4> + <img src="<%= post.image %>" alt="..."> + <p><%- post.body.substring(0, 300) %>...</p> + </div> + <% }) %> + <h3>All Posts</h3> + </div> +</div> + +<%- include('../partials/footer') %>
\ No newline at end of file diff --git a/views/search/byTag.ejs b/views/search/byTag.ejs new file mode 100644 index 0000000..1566bc6 --- /dev/null +++ b/views/search/byTag.ejs @@ -0,0 +1,74 @@ +<%- include('../partials/header') %> + +<div class='content'> + <div class='leftie'> + <ul> + <% if(!currentUser) { %> + <li><a href='/search/all'>Search for blog posts</a></li> + <ul id='sub'> + <li><a href="/search/all"><em>All blog posts</em></a></li> + <li><a href="/search/tag"><em><strong>By title</strong></em></a></li> + <li><a href="#"><em>By category</em></a></li> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</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> + <ul id='sub'> + <li><a href="/search/all"><em>All blog posts</em></a></li> + <li><a href="/search/tag"><em><strong>By title</strong></em></a></li> + <li><a href="#">By category</a></li> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</a></li> + <% } %> + </ul> + </div> + <div class='rightie' id='rev'> + <% let type = ''; %> + <div id="result"> + <% posts.map((post) => { %> + <% if(post.tag === type) { %> + <div class='bpost'> + <h4><a href="/blog/<%= post.author.username %>/<%= post._id %>"><%= post.title %></a></h4> + <img src="<%= post.image %>" alt="..."> + <p><%- post.body.substring(0, 300) %>...</p> + </div> + <% } else { %> + <div></div> + <% } %> + <% }) %> + </div> + + <form id='fposts' action="/search/tag"> + <select name='tag' value='<%= type %>' onChange='setType()'> + <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> + <button type='submit' onclick="findPosts()">Search</button> + </form> + <h3>Posts by tag</h3> + </div> +</div> + +<script type="text/javascript"> + const setType = (event) => { + type = document.getElementsByName('tag'); + console.log(type); + }; + +</script> + +<script type="text/javascript"> + const findPosts = () => { + event.preventDefault(); + $('#').load(document.URL + ' #'); + }; +</script> + +<%- include('../partials/footer') %>
\ No newline at end of file diff --git a/views/search/title.ejs b/views/search/title.ejs new file mode 100644 index 0000000..a417352 --- /dev/null +++ b/views/search/title.ejs @@ -0,0 +1,39 @@ +<%- include('../partials/header') %> + +<div class='content'> + <div class='leftie'> + <ul> + <% if(!currentUser) { %> + <li><a href='/search/all'>Search for blog posts</a></li> + <ul id='sub'> + <li><a href="/search/all"><em>All blog posts</em></a></li> + <li><a href="/search/title"><strong><em>By title</em></strong></a></li> + <li><a href="#"><em>By category</em></a></li> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</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> + <ul id='sub'> + <li><a href="/search/all"><em><strong>All blog posts</strong></em></a></li> + <li><a href="/search/title">By title</a></li> + <li><a href="#">By category</a></li> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</a></li> + <% } %> + </ul> + </div> + <div class='rightie' id='rev2'> + <form action="/search/title" id='srch'> + <label>Search</label> + <input name='sb' type="text"> + <button class='formBtn' type='submit'><strong>-></strong></button> + </form> + <h3>Search for posts by title</h3> + </div> +</div> + +<%- include('../partials/footer') %>
\ No newline at end of file |