Add post header with link to board and timestamp

This commit is contained in:
Philipp Volguine 2023-07-18 16:10:46 -04:00
parent 7c428f77a6
commit f54fa02886
3 changed files with 86 additions and 21 deletions

View File

@ -559,13 +559,52 @@ function renderNav() {
return nav return nav
} }
function linkToBoard(website_name, board_name, thread_id) {
let root = `${GlobalVars.settings.website_urls[website_name]}/${board_name}`
console.log(GlobalVars.settings.website_urls, GlobalVars.settings.website_urls[website_name], board_name);
if (thread_id) {
return root + `/res/${thread_id}.html`;
} else {
return root + 'index.html';
}
}
function renderPostElem(post) { function renderPostElem(post) {
var postContainer = div(); const postContainer = div();
postContainer.classList.add('post'); postContainer.classList.add('post');
var postElem = div();
// Header with timestamp, link to the thread
const postHeader = div();
postHeader.classList.add('post--header');
postContainer.appendChild(postHeader);
console.log('renderPostElem POST:', post);
if (post.website_name != null) {
const link_url = linkToBoard(post.website_name, post.board_name, post.thread_id);
const boardlink = span()
const boardlink_a = document.createElement('a');
boardlink_a.appendChild(text(post.website_name));
boardlink_a.setAttribute('href', link_url);
boardlink_a.setAttribute('title', 'Destination this post was originally headed for (thread or board)');
boardlink.appendChild(text('['));
boardlink.appendChild(boardlink_a);
boardlink.appendChild(text(']'));
postHeader.appendChild(boardlink);
}
postHeader.appendChild(span(text((new Date(post.time_stamp).toUTCString()))));
postContainer.appendChild(postHeader);
const postElem = div();
postElem.classList.add('post--body_container'); postElem.classList.add('post--body_container');
postContainer.appendChild(postElem); postContainer.appendChild(postElem);
var bodyTextElem = div(); const bodyTextElem = div();
bodyTextElem.classList.add('post--body'); bodyTextElem.classList.add('post--body');
bodyTextElem.innerText = post.body; bodyTextElem.innerText = post.body;
@ -851,14 +890,6 @@ function aClickNav(e) {
function bindEventHandlers() { function bindEventHandlers() {
window.addEventListener('urlchange', onUrlChange); window.addEventListener('urlchange', onUrlChange);
window.addEventListener('popstate', onRealUrlChange); window.addEventListener('popstate', onRealUrlChange);
function on_pushstate(e) {
for (var i=0; i < 10; i++) {
console.log("pushstate", e);
}
}
window.addEventListener('pushstate', on_pushstate);
} }
function gatherElements() { function gatherElements() {

View File

@ -1,7 +1,10 @@
{ {
"postgrest_url": "http://192.168.4.147:3000", "postgrest_url": "http://192.168.4.6:3000",
"postgrest_url": "http://localhost:3000", "postgrest_url": "http://10.4.0.96:3000",
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A", "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A",
"audio_mpeg_thumbnail_path": "/etc/SpamNoticer/static/mpg.png", "audio_mpeg_thumbnail_path": "/var/www/static/mpg.png",
"website_urls": {
"leftychan.net": "https://leftychan.net"
},
"content_directory": "/var/www/spam" "content_directory": "/var/www/spam"
} }

View File

@ -11,29 +11,60 @@ header {
margin: 1em 0; margin: 1em 0;
box-shadow: .4em .4em .4em grey; box-shadow: .4em .4em .4em grey;
border: 1px solid grey; border: 1px solid grey;
padding: 1em;
} }
.post--overview:hover { .post--overview:hover {
background-color: #FFEEEE; background-color: yellow;
box-shadow: .4em .4em .4em hsl(60, 100%, 30%);
}
.post--overview:hover .post--header {
background-color: yellow;
color: black;
} }
.post--image_container { .post--image_container {
float: left; float: left;
margin-right: 1em; margin-right: 1em;
} }
.post--image_container img { .post--image_container img {
max-width: 100%; max-width: 100%;
} }
.post--body_container {
margin: 1em;
}
.post--body_container, .post--body_container,
.attachment-reason, .attachment-reason,
.attachment { .attachment {
display: flow-root; display: flow-root;
} }
nav a { .post--header {
margin: 1rem; background-color: #DDDDDD;
font-size: 1.5em; background-color: #333333;
color: white;
margin-bottom: 0.5em;
padding: 0.2em;
display: flex;
flex-direction: row;
}
.post--header a {
color: hsl(240, 100%, 75%)
}
.post--header a:visited {
color: hsl(300, 100%, 75%)
}
.post--header span {
flex: 1;
}
nav a {
margin: 1rem;
font-size: 1.5em;
} }