Added option to delete published articles

This commit is contained in:
sairaj mote 2022-02-16 17:10:57 +05:30
parent 0aa329d82e
commit edd35f992d
4 changed files with 148 additions and 131 deletions

View File

@ -510,6 +510,7 @@ sm-copy {
.page {
height: 100%;
flex: 1;
}
.page-layout,
@ -578,10 +579,9 @@ sm-copy {
}
#main {
display: grid;
height: 100%;
grid-template-rows: auto 1fr;
grid-template-columns: minmax(0, 1fr);
display: flex;
min-height: 100vh;
flex-direction: column;
}
#main_header {
@ -777,7 +777,6 @@ theme-toggle {
#article {
display: flex;
overflow-y: auto;
}
#article main > section:last-of-type {
padding-bottom: 6rem;
@ -934,30 +933,15 @@ theme-toggle {
align-content: flex-start;
}
.request-card {
.request-card,
.article-row {
display: grid;
align-items: center;
gap: 0.5rem;
border-radius: 0.5rem;
align-items: flex-start;
grid-template-columns: minmax(0, 1fr);
}
.request-card__title {
grid-area: 2/1;
}
.request-card__time {
font-size: 0.75rem;
}
.request-card .flex {
grid-row: span 2;
margin-top: 0.5rem;
}
.article-row {
align-items: center;
gap: 1rem;
grid-template-columns: 1fr auto auto;
}
.article-row__published {
.request-card__time,
.article-row__time {
font-size: 0.75rem;
}
@ -1086,6 +1070,16 @@ theme-toggle {
border-radius: 0 0 0.5rem 0.5rem;
}
#main_footer {
background-color: #256eff;
color: white;
padding: 3rem 0;
gap: 1.5rem 0;
}
#main_footer a {
color: inherit;
}
.hide {
display: none !important;
}
@ -1226,13 +1220,13 @@ theme-toggle {
}
#article_aside {
width: 20rem;
padding: 1.5rem;
display: flex;
flex-direction: column;
position: -webkit-sticky;
position: sticky;
top: 0;
display: flex;
flex-direction: column;
padding: 1.5rem;
width: 20rem;
height: 100%;
overflow-y: auto;
}
@ -1251,19 +1245,16 @@ theme-toggle {
#action_panel {
position: relative;
margin-top: auto;
}
#article_body {
margin-top: 1rem;
}
.request-card {
.request-card,
.article-row {
grid-template-columns: 1fr auto;
}
.request-card .flex {
margin-top: 0;
}
#preview_popup {
--width: 60ch;

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -485,6 +485,7 @@ sm-copy {
}
.page {
height: 100%;
flex: 1;
}
.page-layout,
#preview_page {
@ -544,10 +545,9 @@ sm-copy {
}
#main {
display: grid;
height: 100%;
grid-template-rows: auto 1fr;
grid-template-columns: minmax(0, 1fr);
display: flex;
min-height: 100vh;
flex-direction: column;
}
#main_header {
@ -736,7 +736,6 @@ theme-toggle {
#article {
display: flex;
overflow-y: auto;
main {
& > section:last-of-type {
padding-bottom: 6rem;
@ -888,31 +887,15 @@ theme-toggle {
align-content: flex-start;
}
.request-card {
.request-card,
.article-row {
display: grid;
align-items: center;
gap: 0.5rem;
border-radius: 0.5rem;
align-items: flex-start;
grid-template-columns: minmax(0, 1fr);
&__title {
grid-area: 2/1;
}
&__time {
font-size: 0.75rem;
}
.flex {
grid-row: span 2;
margin-top: 0.5rem;
}
}
.article-row {
align-items: center;
gap: 1rem;
grid-template-columns: 1fr auto auto;
&__published {
font-size: 0.75rem;
}
}
#preview_popup,
@ -1032,6 +1015,16 @@ theme-toggle {
border-radius: 0 0 0.5rem 0.5rem;
}
#main_footer {
background-color: #256eff;
color: white;
padding: 3rem 0;
gap: 1.5rem 0;
a {
color: inherit;
}
}
.hide {
display: none !important;
}
@ -1157,12 +1150,12 @@ theme-toggle {
}
}
#article_aside {
width: 20rem;
padding: 1.5rem;
display: flex;
flex-direction: column;
position: sticky;
top: 0;
display: flex;
flex-direction: column;
padding: 1.5rem;
width: 20rem;
height: 100%;
overflow-y: auto;
}
@ -1180,17 +1173,14 @@ theme-toggle {
#action_panel {
position: relative;
margin-top: auto;
}
#article_body {
margin-top: 1rem;
}
.request-card {
.request-card,
.article-row {
grid-template-columns: 1fr auto;
.flex {
margin-top: 0;
}
}
#preview_popup {
--width: 60ch;

View File

@ -47,10 +47,6 @@
<body onload="onLoadStartUp()" class="hide">
<sm-notifications id="notification_drawer"></sm-notifications>
<audio id="notification_sound">
<source src="https://rmservices.duckdns.org/files/notification-sound.mp3" type="audio/mpeg">
<source src="https://rmservices.duckdns.org/files/notification-sound.ogg" type="audio/ogg">
</audio>
<sm-popup id="confirmation_popup">
<h4 id="confirm_title"></h4>
<p id="confirm_message"></p>
@ -291,11 +287,11 @@
</strip-select>
</div>
<section id="analytic_section" class="admin-section">
<ul id="article_analytics" class="grid gap-1-5 observe-empty-state"></ul>
<ul id="article_analytics" class="grid gap-2 observe-empty-state"></ul>
<p class="empty-state">No articles</p>
</section>
<section id="request_section" class="admin-section hide">
<ul id="publishing_requests" class="grid gap-1-5 observe-empty-state"></ul>
<ul id="publishing_requests" class="grid gap-2 observe-empty-state"></ul>
<p class="empty-state">No requests</p>
</section>
<section id="writers_section" class="admin-section hide">
@ -328,6 +324,14 @@
<p class="empty-state">No approved FLO IDs</p>
</section>
</article>
<footer id="main_footer" class="page-layout">
<h4>A RanchiMall product</h4>
<ul>
<li>
<a href="#/about_us">How it works</a>
</li>
</ul>
</footer>
</div>
<sm-popup id="sign_in_popup">
<header slot="header" class="popup__header">
@ -581,33 +585,45 @@
</template>
<template id="article_row_template">
<li class="grid article-row">
<div class="grid gap-0-5">
<h4 class="article-card__title"></h4>
<time class="article-row__published"></time>
<!-- <time class="article-row__published"></time> -->
<h4 class="article-card__title"></h4>
<div class="flex space-between align-center gap-0-5">
<div class="flex align-center">
<span class="article-row__votes"></span>
<svg class="icon button__icon--right" xmlns="http://www.w3.org/2000/svg" height="24px"
viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0z" fill="none" />
<path
d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
</svg>
</div>
<div class="flex gap-0-5">
<button class="icon-only edit-article">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" />
</svg>
</button>
<button class="icon-only delete-article" title="Delete article">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" />
</svg>
</button>
</div>
</div>
<div class="flex align-center">
<span class="article-row__votes"></span>
<svg class="icon button__icon--right" xmlns="http://www.w3.org/2000/svg" height="24px"
viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0z" fill="none" />
<path
d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
</svg>
</div>
<button class="icon-only edit-article">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" />
</svg>
</button>
</li>
</template>
<template id="request_template">
<li class="request-card">
<h4 class="request-card__title"></h4>
<time class="request-card__time"></time>
<div class="grid gap-0-5">
<time class="request-card__time"></time>
<h4 class="request-card__title"></h4>
</div>
<div class="flex space-between align-center gap-0-5">
<div class="flex gap-0-5">
<button class="icon-only preview-button" title="Preview article">
@ -697,14 +713,13 @@
if (!navigator.onLine)
notify(
"There seems to be a problem connecting to the internet, Please check you internet connection.",
"error",
{ sound: true }
"error"
);
window.addEventListener("offline", () => {
notify(
"There seems to be a problem connecting to the internet, Please check you internet connection.",
"error",
{ pinned: true, sound: true }
{ pinned: true }
);
});
window.addEventListener("online", () => {
@ -827,10 +842,6 @@
break;
}
getRef("notification_drawer").push(message, { pinned, icon });
if (navigator.onLine && sound) {
getRef("notification_sound").currentTime = 0;
getRef("notification_sound").play();
}
if (mode === 'error') {
console.error(message)
}
@ -1150,10 +1161,10 @@
articleRow(articleID) {
const { category, title, published, votes } = floGlobals.appObjects.rmTimes.articles[articleID]
const clone = getRef('article_row_template').content.cloneNode(true).firstElementChild
clone.dataset.articleId = articleID
clone.querySelector('.article-card__title').textContent = title
clone.querySelector('.article-row__published').textContent = relativeTime.from(published)
// clone.querySelector('.article-row__published').textContent = relativeTime.from(published)
clone.querySelector('.article-row__votes').textContent = votes
clone.querySelector('.edit-article').dataset.articleId = articleID
return clone
},
writerCard(writerID) {
@ -1189,7 +1200,7 @@
sortedByVotes.slice(0, 4).forEach(articleDetail => {
frag.append(render.trendingArticleCard({
...articleDetail,
heroImage: allImages[articleDetail.uid].heroImage.thumbnail
heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
}))
})
getRef('trending_article_container').innerHTML = ''
@ -1199,7 +1210,7 @@
sortedArticles.slice(0, 4).forEach(articleDetail => {
frag.append(render.articleCard({
...articleDetail,
heroImage: allImages[articleDetail.uid].heroImage.thumbnail
heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
}))
})
getRef('latest_articles_list').innerHTML = ''
@ -1215,7 +1226,7 @@
getRef('article_summary').textContent = summary
getRef('published_time').textContent = `${getFormattedTime(published, 'date-only')}${updated ? `, Updated ${relativeTime.from(updated)}` : ''}`
getRef('reading_time').textContent = `${readTime} Min read`
getRef('article_image').src = allImages[articleID].heroImage.full
getRef('article_image').src = allImages[articleID] ? allImages[articleID].heroImage.full : ''
getRef('article_body').innerHTML = DOMPurify.sanitize(allArticles[articleID])
const allHeadings = getRef('article_body').querySelectorAll('h3')
allHeadings.forEach(heading => {
@ -1258,7 +1269,7 @@
}
randomNumbers.forEach((index) => {
const { uid } = searchResult[index]
frag.append(render.articleCard({ ...searchResult[index], heroImage: allImages[uid].heroImage.thumbnail }))
frag.append(render.articleCard({ ...searchResult[index], heroImage: allImages[uid] ? allImages[uid].heroImage.thumbnail : '' }))
})
getRef('related_articles').innerHTML = ''
getRef('related_articles').append(frag)
@ -1296,7 +1307,7 @@
sortedByTime.forEach(articleDetail => {
frag.append(render.trendingArticleCard({
...articleDetail,
heroImage: allImages[articleDetail.uid].heroImage.thumbnail
heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
}))
})
} else {
@ -1306,7 +1317,7 @@
searchResult.forEach(articleDetail => {
frag.append(render.trendingArticleCard({
...articleDetail,
heroImage: allImages[articleDetail.uid].heroImage.thumbnail
heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
}))
})
getRef('explore_heading').textContent = `${type === 'category' ? 'Explore' : 'Related to'} ${query}`
@ -1335,7 +1346,7 @@
searchResult.forEach(articleDetail => {
frag.append(render.trendingArticleCard({
...articleDetail,
heroImage: allImages[articleDetail.uid].heroImage.thumbnail
heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
}))
})
getRef('written_article_list').innerHTML = ''
@ -1344,17 +1355,18 @@
}
const getArticles = async () => {
Promise.all([
floCloudAPI.requestObjectData('rmTimes'),
floCloudAPI.requestObjectData('articlesContent'),
floCloudAPI.requestApplicationData('images'),
]).then((res) => {
floCloudAPI.requestApplicationData('images').then((images) => {
for (const articleID in floGlobals.appObjects.rmTimes.articles) {
const { heroImage } = floGlobals.appObjects.rmTimes.articles[articleID]
compactIDB.writeData('images', {
heroImage: res[2][heroImage].message,
heroImage: images[heroImage].message,
}, articleID)
}
})
Promise.all([
floCloudAPI.requestObjectData('rmTimes'),
floCloudAPI.requestObjectData('articlesContent'),
]).then((res) => {
delete floGlobals.appObjects.articlesContent
showPage(window.location.hash, { firstLoad: true })
})
@ -1377,22 +1389,18 @@
title: 'Culture',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><g><g><g><path d="M12,22C6.49,22,2,17.51,2,12S6.49,2,12,2s10,4.04,10,9c0,3.31-2.69,6-6,6h-1.77c-0.28,0-0.5,0.22-0.5,0.5 c0,0.12,0.05,0.23,0.13,0.33c0.41,0.47,0.64,1.06,0.64,1.67C14.5,20.88,13.38,22,12,22z M12,4c-4.41,0-8,3.59-8,8s3.59,8,8,8 c0.28,0,0.5-0.22,0.5-0.5c0-0.16-0.08-0.28-0.14-0.35c-0.41-0.46-0.63-1.05-0.63-1.65c0-1.38,1.12-2.5,2.5-2.5H16 c2.21,0,4-1.79,4-4C20,7.14,16.41,4,12,4z"/><circle cx="6.5" cy="11.5" r="1.5"/><circle cx="9.5" cy="7.5" r="1.5"/><circle cx="14.5" cy="7.5" r="1.5"/><circle cx="17.5" cy="11.5" r="1.5"/></g></g></g></g></svg>`
},
{
title: 'People',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24" x="0"/></g><g><path d="M22.47,5.2C22,4.96,21.51,4.76,21,4.59v12.03C19.86,16.21,18.69,16,17.5,16c-1.9,0-3.78,0.54-5.5,1.58V5.48 C10.38,4.55,8.51,4,6.5,4C4.71,4,3.02,4.44,1.53,5.2C1.2,5.36,1,5.71,1,6.08v12.08c0,0.58,0.47,0.99,1,0.99 c0.16,0,0.32-0.04,0.48-0.12C3.69,18.4,5.05,18,6.5,18c2.07,0,3.98,0.82,5.5,2c1.52-1.18,3.43-2,5.5-2c1.45,0,2.81,0.4,4.02,1.04 c0.16,0.08,0.32,0.12,0.48,0.12c0.52,0,1-0.41,1-0.99V6.08C23,5.71,22.8,5.36,22.47,5.2z M10,16.62C8.86,16.21,7.69,16,6.5,16 c-1.19,0-2.36,0.21-3.5,0.62V6.71C4.11,6.24,5.28,6,6.5,6C7.7,6,8.89,6.25,10,6.72V16.62z M19,0.5l-5,5V15l5-4.5V0.5z"/></g></svg>`
},
{
title: 'Economics',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M20 7h-4V5l-2-2h-4L8 5v2H4c-1.1 0-2 .9-2 2v5c0 .75.4 1.38 1 1.73V19c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2v-3.28c.59-.35 1-.99 1-1.72V9c0-1.1-.9-2-2-2zM10 5h4v2h-4V5zM4 9h16v5h-5v-3H9v3H4V9zm9 6h-2v-2h2v2zm6 4H5v-3h4v1h6v-1h4v3z"/></svg>`
},
{
title: 'Crypto',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M22,11V3h-7v3H9V3H2v8h7V8h2v10h4v3h7v-8h-7v3h-2V8h2v3H22z M7,9H4V5h3V9z M17,15h3v4h-3V15z M17,5h3v4h-3V5z"/></svg>`
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M17.06,11.57C17.65,10.88,18,9.98,18,9c0-1.86-1.27-3.43-3-3.87L15,3h-2v2h-2V3H9v2H6v2h2v10H6v2h3v2h2v-2h2v2h2v-2 c2.21,0,4-1.79,4-4C19,13.55,18.22,12.27,17.06,11.57z M10,7h4c1.1,0,2,0.9,2,2s-0.9,2-2,2h-4V7z M15,17h-5v-4h5c1.1,0,2,0.9,2,2 S16.1,17,15,17z"/></g></svg>`
},
{
title: 'Discover',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-5.5-2.5l7.51-3.49L17.5 6.5 9.99 9.99 6.5 17.5zm5.5-6.6c.61 0 1.1.49 1.1 1.1s-.49 1.1-1.1 1.1-1.1-.49-1.1-1.1.49-1.1 1.1-1.1z"/></svg>`
},
{
title: 'Economics',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M20 7h-4V5l-2-2h-4L8 5v2H4c-1.1 0-2 .9-2 2v5c0 .75.4 1.38 1 1.73V19c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2v-3.28c.59-.35 1-.99 1-1.72V9c0-1.1-.9-2-2-2zM10 5h4v2h-4V5zM4 9h16v5h-5v-3H9v3H4V9zm9 6h-2v-2h2v2zm6 4H5v-3h4v1h6v-1h4v3z"/></svg>`
},
{
title: 'Fiction',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><g/><g><path d="M12,3c-0.46,0-0.93,0.04-1.4,0.14C7.84,3.67,5.64,5.9,5.12,8.66c-0.48,2.61,0.48,5.01,2.22,6.56 C7.77,15.6,8,16.13,8,16.69V19c0,1.1,0.9,2,2,2h0.28c0.35,0.6,0.98,1,1.72,1s1.38-0.4,1.72-1H14c1.1,0,2-0.9,2-2v-2.31 c0-0.55,0.22-1.09,0.64-1.46C18.09,13.95,19,12.08,19,10C19,6.13,15.87,3,12,3z M14,17h-4v-1h4V17z M10,19v-1h4v1H10z M15.31,13.74c-0.09,0.08-0.16,0.18-0.24,0.26H8.92c-0.08-0.09-0.15-0.19-0.24-0.27c-1.32-1.18-1.91-2.94-1.59-4.7 c0.36-1.94,1.96-3.55,3.89-3.93C11.32,5.03,11.66,5,12,5c2.76,0,5,2.24,5,5C17,11.43,16.39,12.79,15.31,13.74z"/></g><g><rect height="3" width="1" x="11.5" y="11"/><rect height="3" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -4.0312 10.8536)" width="1" x="10.59" y="8.79"/><rect height="3" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 14.7678 26.7028)" width="1" x="12.41" y="8.79"/></g></g></svg>`
@ -1401,13 +1409,21 @@
title: 'History',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M6.5 10h-2v7h2v-7zm6 0h-2v7h2v-7zm8.5 9H2v2h19v-2zm-2.5-9h-2v7h2v-7zm-7-6.74L16.71 6H6.29l5.21-2.74m0-2.26L2 6v2h19V6l-9.5-5z"/></svg>`
},
{
title: 'People',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24" x="0"/></g><g><path d="M22.47,5.2C22,4.96,21.51,4.76,21,4.59v12.03C19.86,16.21,18.69,16,17.5,16c-1.9,0-3.78,0.54-5.5,1.58V5.48 C10.38,4.55,8.51,4,6.5,4C4.71,4,3.02,4.44,1.53,5.2C1.2,5.36,1,5.71,1,6.08v12.08c0,0.58,0.47,0.99,1,0.99 c0.16,0,0.32-0.04,0.48-0.12C3.69,18.4,5.05,18,6.5,18c2.07,0,3.98,0.82,5.5,2c1.52-1.18,3.43-2,5.5-2c1.45,0,2.81,0.4,4.02,1.04 c0.16,0.08,0.32,0.12,0.48,0.12c0.52,0,1-0.41,1-0.99V6.08C23,5.71,22.8,5.36,22.47,5.2z M10,16.62C8.86,16.21,7.69,16,6.5,16 c-1.19,0-2.36,0.21-3.5,0.62V6.71C4.11,6.24,5.28,6,6.5,6C7.7,6,8.89,6.25,10,6.72V16.62z M19,0.5l-5,5V15l5-4.5V0.5z"/></g></svg>`
},
{
title: 'Politics',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M6.5 10h-2v7h2v-7zm6 0h-2v7h2v-7zm8.5 9H2v2h19v-2zm-2.5-9h-2v7h2v-7zm-7-6.74L16.71 6H6.29l5.21-2.74m0-2.26L2 6v2h19V6l-9.5-5z"/></svg>`
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><path d="M18,11c0,0.67,0,1.33,0,2c1.2,0,2.76,0,4,0c0-0.67,0-1.33,0-2C20.76,11,19.2,11,18,11z"/><path d="M16,17.61c0.96,0.71,2.21,1.65,3.2,2.39c0.4-0.53,0.8-1.07,1.2-1.6c-0.99-0.74-2.24-1.68-3.2-2.4 C16.8,16.54,16.4,17.08,16,17.61z"/><path d="M20.4,5.6C20,5.07,19.6,4.53,19.2,4c-0.99,0.74-2.24,1.68-3.2,2.4c0.4,0.53,0.8,1.07,1.2,1.6 C18.16,7.28,19.41,6.35,20.4,5.6z"/><path d="M4,9c-1.1,0-2,0.9-2,2v2c0,1.1,0.9,2,2,2h1v4h2v-4h1l5,3V6L8,9H4z M9.03,10.71L11,9.53v4.94l-1.97-1.18L8.55,13H8H4v-2h4 h0.55L9.03,10.71z"/><path d="M15.5,12c0-1.33-0.58-2.53-1.5-3.35v6.69C14.92,14.53,15.5,13.33,15.5,12z"/></svg>`
},
{
title: 'Science',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M19.93,8.35l-3.6,1.68L14,7.7V6.3l2.33-2.33l3.6,1.68c0.38,0.18,0.82,0.01,1-0.36c0.18-0.38,0.01-0.82-0.36-1l-3.92-1.83 c-0.38-0.18-0.83-0.1-1.13,0.2L13.78,4.4C13.6,4.16,13.32,4,13,4c-0.55,0-1,0.45-1,1v1H8.82C8.4,4.84,7.3,4,6,4C4.34,4,3,5.34,3,7 c0,1.1,0.6,2.05,1.48,2.58L7.08,18H6c-1.1,0-2,0.9-2,2v1h13v-1c0-1.1-0.9-2-2-2h-1.62L8.41,8.77C8.58,8.53,8.72,8.28,8.82,8H12v1 c0,0.55,0.45,1,1,1c0.32,0,0.6-0.16,0.78-0.4l1.74,1.74c0.3,0.3,0.75,0.38,1.13,0.2l3.92-1.83c0.38-0.18,0.54-0.62,0.36-1 C20.75,8.34,20.31,8.17,19.93,8.35z M6,8C5.45,8,5,7.55,5,7c0-0.55,0.45-1,1-1s1,0.45,1,1C7,7.55,6.55,8,6,8z M11.11,18H9.17 l-2.46-8h0.1L11.11,18z"/></g></svg>`
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M13,11.33L18,18H6l5-6.67V6h2 M15.96,4H8.04C7.62,4,7.39,4.48,7.65,4.81L9,6.5v4.17L3.2,18.4C2.71,19.06,3.18,20,4,20h16 c0.82,0,1.29-0.94,0.8-1.6L15,10.67V6.5l1.35-1.69C16.61,4.48,16.38,4,15.96,4L15.96,4z"/></g></svg>`
},
{
title: 'Sustenance',
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M12.87,11.81c-0.23-0.38-0.37-0.83-0.37-1.31C12.5,9.12,13.62,8,15,8l1,0c1.51,0,2-1,2-1s0.55,6-3,6 c-0.49,0-0.94-0.14-1.32-0.38c-0.24,0.64-0.59,1.76-0.76,2.96c1.26,0.22,2.28,0.89,2.77,1.77c1.69-1.17,2.81-3.13,2.81-5.35h3 c0,5.24-4.26,9.5-9.5,9.5S2.5,17.24,2.5,12S6.76,2.5,12,2.5V0l4,4l-4,4V5.5c-3.58,0-6.5,2.92-6.5,6.5c0,2.21,1.11,4.17,2.81,5.35 c0.51-0.92,1.63-1.62,2.98-1.8c-0.09-0.69-0.26-1.42-0.49-2.03C10.45,13.82,10,14,9.5,14c-1.1,0-2-0.9-2-2v-0.99 c0-0.56-0.19-1.09-0.5-1.51c0,0,4.45-0.23,4.5,2.5c0,0.29-0.06,0.56-0.17,0.8C10.91,12.48,10.47,12.2,10,12 c0.58,0.43,1.37,1.37,2,2.6c0.67-1.62,1.68-3.27,3-4.6C14.24,10.52,13.53,11.12,12.87,11.81z"/></svg>`
},
{
title: 'Tech',
@ -1728,7 +1744,7 @@
})
function goToTop() {
getRef('article').scroll({
window.scroll({
top: 0,
behavior: 'smooth'
});
@ -1979,7 +1995,7 @@
function handleAnalyticsClick(e) {
if (e.target.closest('.edit-article')) {
const button = e.target.closest('.edit-article');
const articleID = button.dataset.articleId;
const articleID = button.closest('.article-row').dataset.articleId;
setArticleMetaData(floGlobals.appObjects.rmTimes.articles[articleID], articleID)
floGlobals.subAdminData = {
actionType: 'analytics',
@ -1988,6 +2004,26 @@
getRef('set_article_meta').textContent = "UPDATE"
getRef('edit_popup__title').textContent = "Update"
showPopup('edit_article_meta_popup')
} else if (e.target.closest('.delete-article')) {
getConfirmation(`Delete this article?`, {
confirmText: 'Delete'
}).then(res => {
if (res) {
const articleCard = e.target.closest('.article-row');
const articleID = articleCard.dataset.articleId;
delete floGlobals.appObjects.rmTimes.articles[articleID]
delete floGlobals.appObjects.adminData.articleVotes[articleID]
delete floGlobals.appObjects.articlesContent[articleID]
Promise.all([
floCloudAPI.updateObjectData('rmTimes'),
floCloudAPI.updateObjectData('adminData'),
floCloudAPI.updateObjectData('articlesContent'),
]).then(() => {
notify(`Deleted article`, 'success')
articleCard.remove()
})
}
})
}
}