legacy site updates

This commit is contained in:
scoliono 2020-09-07 15:56:53 -07:00
parent bb69cf9321
commit d23281ea83
5 changed files with 121 additions and 20 deletions

View File

@ -4,10 +4,12 @@ import Article from '../models/article.js';
const app = express.Router();
app.get('/', async function (req, res) {
let page = Number.isInteger(req.query.page) && req.query.page > 0 ? req.query.page : 1;
let intPage = +req.query.page;
let page = Number.isInteger(intPage) && intPage > 0 ? intPage : 1;
let offset = (page - 1) * 4;
let articles = await Article.find().sort('-created_at').limit(4).skip(offset);
res.render('index', { articles, offset });
let hasNextPage = (await Article.countDocuments()) > offset + 4;
res.render('index', { articles, offset, hasNextPage, page });
});
app.use(function (req, res) {

View File

@ -1,10 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<title>HOWFEED.biz</title>
</head>
<body>
<h1>Error 404</h1>
<p>Looks like you're barking up the wrong tree!</p>
</body>
</html>
<%- include('header') -%>
<tr height="64" style="background: url('/background.png');" align="center">
<td colspan="6"><h1 style="line-height: 64px;font-size: 48px; margin:0;">ERROR 404</h1></td>
</tr>
<tr height="40" bgcolor="#96C8EA">
<td colspan="6" align="center">
<p style="line-height: 40px; margin: 0; display: inline;">
<span style="font-weight: bold">OOPS!</span> Looks like you're barking up the wrong tree!
</p>
</td>
</tr>
<tr height="280" bgcolor="#96C8EA" style="overflow: scroll">
<td colspan="6" align="center">
<img src="http://howfeed.biz/sally.png" alt="Sally the dog">
</td>
</tr>
<tr height="40" bgcolor="#96C8EA">
<td colspan="6" align="center">
<p style="margin: 0; font-size: 16px; line-height: 40px;">The file was not found. Check that the URL was spelled correctly and try again.</p>
</td>
</tr>
<%- include('footer') -%>

View File

@ -0,0 +1,53 @@
<div class="content">
<div class="article-image">
<img alt={article.title} src={`/a/${article.image}`}>
</div>
<div class="article-meta">
<h1 class="article-title">{article.title}</h1>
<blockquote>
<p>Author: <img class="avatar" alt={article.author.realname} src={`/u/${article.author.avatar || 'default.jpg'}`}> <strong>{article.author.realname}</strong></p>
<p>Category: <strong><a href={`/c/${article.category.slug}`}>{article.category.name}</a></strong></p>
<p>Published: <strong>{new Date(article.created_at).toLocaleString()}</strong></p>
{#if article.updated_at}
<p>Last Updated: <strong>{new Date(article.updated_at).toLocaleString()}</strong></p>
{/if}
<p>Views: <strong>{article.views}</strong></p>
</blockquote>
</div>
<div class="article-content">
{@html article.html}
</div>
<hr>
<h3>Comments</h3>
<div class="comments">
{#each comments as comment}
<div class="comment">
{#if comment.author_user}
<img class="avatar" alt={comment.author_user.realname} src={`/u/${comment.author_user.avatar || 'default.jpg'}`}>
{/if}
<p class="comment-meta">
{#if comment.author_user}
<span class="comment-username">{comment.author_user.realname}</span> <span class="comment-verified">(verified)</span> - {new Date(comment.created_at).toLocaleString()}
{:else}
<span class="comment-username">{comment.author}</span> - {new Date(comment.created_at).toLocaleString()}
{/if}
</p>
<div class="comment-content">{comment.content}</div>
</div>
{:else}
<p>No comments.</p>
{/each}
</div>
<h3>Add a Comment</h3>
<form method="POST" action={`/a/${article.slug}/comments`}>
<p>Name:
{#if $session.user}
<input type="text" disabled value={$session.user.realname}>
{:else}
<input type="text" bind:value={author} name="author" maxlength="100" placeholder="Anonymous">
{/if}
</p>
<p><textarea name="content" bind:value={content} maxlength="5000"></textarea></p>
<p><button type="submit" on:click|preventDefault={postComment}>Submit</button></p>
</form>
</div>

View File

@ -29,6 +29,9 @@
color: #000;
font-weight: bold;
}
a img {
border: 0;
}
-->
</style>
</head>
@ -36,7 +39,11 @@
<table width="640" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr align="center" height="36">
<td colspan="2"><img src="/logo.png" height="26" width="150"></td>
<td colspan="2">
<a href="/">
<img src="/logo.png" height="26" width="150">
</a>
</td>
<td colspan="2">
<form method="GET" action="/search" style="display: inline;">
<input style="border: 4px solid #000;font-family: Tahoma;" type="text" name="query" value="Search" onclick="hidePlaceholder(this);" onblur="showPlaceholder(this);">

View File

@ -2,13 +2,40 @@
<tr height="64" style="background: url('/background.png');" align="center">
<td colspan="6"><h1 style="line-height: 64px;font-size: 48px; margin:0;">WELCOME</h1></td>
</tr>
<% for (var article of articles) { %>
<tr height="85" bgcolor="#96C8EA" style="overflow: scroll">
<td></td>
<td bgcolor="white" align="center">
<img src="http://howfeed.biz/a/<%= article.image %>" height="75" alt="<%= article.title %>">
</td>
<td colspan="4"><%= article.title %></td>
<% for (var i = 0; i < 4; i++) { %>
<tr height="80" bgcolor="#96C8EA" style="overflow: scroll">
<% if (i < articles.length) { %>
<td></td>
<td bgcolor="white" align="center" valign="center">
<a href="/a/<%= articles[i].slug %>">
<img style="vertical-align: top;" src="/a/<%= articles[i].image %>" height="65" alt="<%= articles[i].title %>">
</a>
</td>
<td colspan="4">
<a href="/a/<%= articles[i].slug %>" style="margin-left: 8px; font-weight: normal;">
<%= articles[i].title %>
</a>
</td>
<% } else { %>
<td colspan="6"></td>
<% } %>
</tr>
<% } %>
<% if (page > 1 || hasNextPage) { %>
<tr bgcolor="#96C8EA" height="40">
<% if (page > 1) { %>
<td colspan="<%= hasNextPage ? 2 : 6 %>" align="center">
<button onclick="window.location.href = '/?page=<%= page - 1 %>';">&lt; Previous Page</button>
</td>
<% } %>
<% if (page > 1 && hasNextPage) { %>
<td colspan="2"></td>
<% } %>
<% if (hasNextPage) { %>
<td colspan="<%= page > 1 ? 2 : 6 %>" align="center">
<button onclick="window.location.href = '/?page=<%= page + 1 %>';">Next Page &gt;</button>
</td>
<% } %>
</tr>
<% } %>
<%- include('footer') -%>