Skip to content

Commit

Permalink
prep for authors, minimize article-i
Browse files Browse the repository at this point in the history
  • Loading branch information
Faisal N committed Oct 11, 2023
1 parent 62e26c9 commit f50767c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 26 deletions.
28 changes: 16 additions & 12 deletions frontend/pages/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,37 @@
<div class="info">
<h1><%= article.title %></h1>
<% if (article.description != null) { %><h3><%= article.description.slice(0, 50) %>...</h3><% } %>
<h5><%= pageviews %> Views</h5>
<h5><%= pageviews %> Views | Published <% var date = new Date(article.date); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article._created != article._modified) && (date < (new Date(article._modified * 1000)))) { %> | Edited <% var date = new Date(article._modified * 1000); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } } %></h5>
<% if (article.tags != null) { %><p>Tags: <% for (tag of article.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>">#<%= tag.toLowerCase().replaceAll(" ", "-") %></a> <% } %></p><% } %>
</div>
<div class="author">
<img src="<%- vars.asset_prefix %><%= cms.siteDetails[0].favicon.path %>" />
<img src="<%- vars.asset_prefix %><% if ((article.author != "") && (article.author != null)) { %><%= cms.siteDetails[0].unknown.path %><% } else { %><%= cms.siteDetails[0].favicon.path %><% } %>" />
<div class="info">
<h4><% if ((article.author != "") && (article.author != null)) { %><%= article.author %><% } else { %><a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a> Writers, <a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a><% } %></h4>
<h5>Published <% var date = new Date(article.date); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></h5>
<% if ((article._created != article._modified) && (date < (new Date(article._modified * 1000)))) { %><h5>Edited <% var date = new Date(article._modified * 1000); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %></h5><% } } %>
<h4><% if ((article.author != "") && (article.author != null)) { %><%= article.author %><% } else { %><%= cms.siteDetails[0].title %><% } %></h4>
<h5><a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a> - Writer<% if ((article.author != "") && (article.author != null)) { %><% } else { %>s<% } %></h5>
</div>
</div>
</div>
<div class="right">
<div class="icons">
<i class="fas fa-link" onClick="const el = document.createElement('textarea'); el.value = window.location.href; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select(); document.execCommand('copy'); document.body.removeChild(el); if (selected) { document.getSelection().removeAllRanges(); document.getSelection().addRange(selected); } alert('Link copied!');"></i>
<i class="fas fa-link" onClick="copyLink();"></i>
</div>
</div>
</div>
<% if (article.images[0] != null) { %>
<div class="images">
<% for (image of article.images) { if (image._id === article.images[0]._id) { %>
<a class="image" href="<%- vars.asset_prefix %><%= image.path %>" data-lightbox="<%= image._id %>"<% if (image.description != "") { %> data-title="<%= image.description %>"<% } %>><img src="<%- vars.asset_prefix %><%= image.path %>" /><% if (image.description != "") { %><h2><%= image.description %></h2><% } %></a>
<a class="image" href="<%- vars.asset_prefix %><%= image.path %>" data-lightbox="<%= image._id %>" <% if (image.description != "") { %> data-title="<%= image.description %>" <% } %>><img src="<%- vars.asset_prefix %><%= image.path %>" /><% if (image.description != "") { %><h2><%= image.description %></h2><% } %></a>
<% } else { %>
<a class="image" style="background-image: url('<%- vars.asset_prefix %><%= image.path %>');<% if ((image.height / image.width) >= 1.25) { %> width: <%= image.width %>px;<% } %>" href="<%- vars.asset_prefix %><%= image.path %>" data-lightbox="<%= image._id %>"<% if (image.description != "") { %> data-title="<%= image.description %>"<% } %>><% if (image.description != "") { %><h2><%= image.description %></h2><% } %></a>
<a class="image" style="background-image: url('<%- vars.asset_prefix %><%= image.path %>');<% if ((image.height / image.width) >= 1.25) { %> width: <%= image.width %>px;<% } %>" href="<%- vars.asset_prefix %><%= image.path %>" data-lightbox="<%= image._id %>" <% if (image.description != "") { %> data-title="<%= image.description %>" <% } %>><% if (image.description != "") { %><h2><%= image.description %></h2><% } %></a>
<% } } %>
</div>
<% } %>
<style>.article-i .content:before { content: '(<% if ((article.author != "") && (article.author != null)) { %><%- article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — ' }</style>
<style>
.article-i .content:before {
content: '(<% if ((article.author != "") && (article.author != null)) { %><%- article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — '
}
</style>
<div class="content"><%- article.content.replaceAll('/.spaces/', vars.asset_url) %></div>
<div class="comments">
<h1>Comments</h1>
Expand All @@ -61,12 +64,13 @@
<input name="content" type="text" placeholder="Your Comment">
<button>Post Comment</button>
</form>
<% if (comments.length > 0) { %><hr><% } %>
<% if (comments.length > 0) { %>
<hr><% } %>
<% for (comment of comments.reverse()) { %>
<div id="<%= comment.id %>" class="comment">
<h4><%= comment.author_name %>
<h5><% var date = new Date(comment.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></h5>
<p><%= comment.content %></p>
<h5><% var date = new Date(comment.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></h5>
<p><%= comment.content %></p>
</div>
<% } %>
</div>
Expand Down
13 changes: 7 additions & 6 deletions frontend/pages/artwork.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@
<div class="left">
<div class="info">
<h1><%= artwork.title %></h1>
<% if (artwork.tags != null) { %><p>Tags: <% for (tag of artwork.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>"><%= toTitleCase(tag) %></a> <% } %></p><% } %>
<% if (artwork.description != null) { %><h3><%= artwork.description.slice(0, 50) %>...</h3><% } %>
<h5><%= pageviews %> Views | Published <% var date = new Date(artwork.date); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((artwork._created != artwork._modified) && (date < (new Date(artwork._modified * 1000)))) { %> | Edited <% var date = new Date(artwork._modified * 1000); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } } %></h5>
<% if (artwork.tags != null) { %><p>Tags: <% for (tag of artwork.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>">#<%= tag.toLowerCase().replaceAll(" ", "-") %></a> <% } %></p><% } %>
</div>
<div class="author">
<img src="<%- vars.asset_prefix %><%= cms.siteDetails[0].favicon.path %>" />
<img src="<%- vars.asset_prefix %><% if ((artwork.author != "") && (artwork.author != null)) { %><%= cms.siteDetails[0].unknown.path %><% } else { %><%= cms.siteDetails[0].favicon.path %><% } %>" />
<div class="info">
<h4>By <% if ((artwork.author != "") && (artwork.author != null)) { %><%= artwork.author %><% } else { %><a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a> Writers, <a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a><% } %></h4>
<h5>Published <% var date = new Date(artwork.date); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></h5>
<% if ((artwork._created != artwork._modified) && (date < (new Date(artwork._modified * 1000)))) { %><h5>Edited <% var date = new Date(artwork._modified * 1000); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %></h5><% } } %>
<h4><% if ((artwork.author != "") && (artwork.author != null)) { %><%= artwork.author %><% } else { %><%= cms.siteDetails[0].title %><% } %></h4>
<h5><a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a> - Writer<% if ((artwork.author != "") && (artwork.author != null)) { %><% } else { %>s<% } %></h5>
</div>
</div>
</div>
<div class="right">
<div class="icons">
<i class="fas fa-link" onClick="const el = document.createElement('textarea'); el.value = window.location.href; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select(); document.execCommand('copy'); document.body.removeChild(el); if (selected) { document.getSelection().removeAllRanges(); document.getSelection().addRange(selected); } alert('Link copied!');"></i>
<i class="fas fa-link" onClick="copyLink();"></i>
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions frontend/pages/newspaper.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
<div class="info">
<h1><%= newspaper.title %></h1>
<h3><%= newspaper.description %></h3>
<h5><%= pageviews %> Views</h5>
<h5><%= pageviews %> Views | Published <% var date = new Date(newspaper.date); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((newspaper._created != newspaper._modified) && (date < (new Date(newspaper._modified * 1000)))) { %> | Edited <% var date = new Date(newspaper._modified * 1000); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } } %></h5>
<% if (newspaper.tags != null) { %><p>Tags: <% for (tag of newspaper.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>">#<%= tag.toLowerCase().replaceAll(" ", "-") %></a> <% } %></p><% } %>
</div>
<div class="author">
<img src="<%- vars.asset_prefix %><%= cms.siteDetails[0].favicon.path %>" />
<div class="info">
<h4>By <a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a> Writers, <a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a></h4>
<h5>Published <% var date = new Date(newspaper.date); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></h5>
<% if ((newspaper._created != newspaper._modified) && (date < (new Date(newspaper._modified * 1000)))) { %><h5>Edited <% var date = new Date(newspaper._modified * 1000); if (date.isToday()) { %>today<% } else if (ifYesterday(date)) { %>yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %></h5><% } } %>
<h4><%= cms.siteDetails[0].title %></h4>
<h5><a href="<%- vars.domain %>"><%= cms.siteDetails[0].title %></a> - Writers</h5>
</div>
</div>
</div>
<div class="right">
<div class="icons">
<i class="fas fa-link" onClick="const el = document.createElement('textarea'); el.value = window.location.href; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select(); document.execCommand('copy'); document.body.removeChild(el); if (selected) { document.getSelection().removeAllRanges(); document.getSelection().addRange(selected); } alert('Link copied!');"></i>
<i class="fas fa-link" onClick="copyLink();"></i>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/poll.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>
<div class="right">
<div class="icons">
<i class="fas fa-link" onClick="const el = document.createElement('textarea'); el.value = window.location.href; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select(); document.execCommand('copy'); document.body.removeChild(el); if (selected) { document.getSelection().removeAllRanges(); document.getSelection().addRange(selected); } alert('Link copied!');"></i>
<i class="fas fa-link" onClick="copyLink();"></i>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion frontend/public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ header .main .search form input::placeholder {
}

.article-i .split .left .author img {
border-radius: 100%;
height: 63px;
border-radius: 100%;
}

.article-i .split .left .author .info {
Expand Down
19 changes: 18 additions & 1 deletion frontend/public/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ window.addEventListener('scroll', () => {
} else {
document.querySelector('.toTop').classList.remove('visible');
};
});
});

function copyLink() {
const el = document.createElement('textarea');
el.value = window.location.href;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select();
document.execCommand('copy');
document.body.removeChild(el);
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
};
alert('Link copied!');
};

0 comments on commit f50767c

Please sign in to comment.