Skip to content

Commit

Permalink
better post formatting, handle quotes (#9)
Browse files Browse the repository at this point in the history
* extract single post into component

* improve post formatting, handle quotes

* fix workflow event type

* fix incorrect quote

* tweak talbroda json & snapshot timings

* fix local image paths
  • Loading branch information
sterlingwes authored Jan 30, 2024
1 parent 83c31c3 commit 5586167
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 199 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
pull_request:
types: [open, reopened, synchronize]
types: [opened, reopened, synchronize]
paths:
- "**.json"
- "**.js"
Expand Down
Binary file added site/public/post_assets/hilzfuld-20231010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added site/public/post_assets/themossadil-20231009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
270 changes: 270 additions & 0 deletions site/src/components/Post.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
---
import PostTypeIcon from "../components/PostTypeIcon.astro";
import type { getEnhancedPosts } from "../lib/server/posts";
interface Props {
enablerImageUrl?: string;
post: ReturnType<typeof getEnhancedPosts>[0];
postDelayLookup: Record<number, number>;
}
const { post, postDelayLookup, enablerImageUrl } = Astro.props;
---

<div class="post-wrapper">
<div
class="post"
data-dateval={post.dateValue}
style={`animation-delay: ${postDelayLookup[post.dateValue] / 1_000}s`}
>
<div class="post-card">
<div class="post-load-bar">
<div
class="post-load-bar-fill"
style={`animation-delay: ${postDelayLookup[post.dateValue] / 1_000}s; animation-duration: ${post.readTime.time / 1_000}s`}
>
</div>
</div>
{
post.structuredText.length && (
<div class="post-body">
{post.structuredText.map((part) =>
part.type === "url" ? (
<a href={part.href} title={part.href} target="_blank">
{part.text}
</a>
) : part.type === "space" ? (
<span>&nbsp;</span>
) : part.type === "break" ? (
<div class="post-linebreak" />
) : (
part.text
)
)}
</div>
)
}
{
!!post.image && (
<div class="post-image">
<img src={post.image} />
</div>
)
}
{!!post.text && !!post.quote && <div class="post-quoted-spacer" />}
{
post.quote && (
<div class="post-quoted">
<div class="post-quoted-meta">Post by {post.quote.author}</div>
<div class="post-quoted-body">
{post.structuredQuoteText.length && (
<div class="post-body">
{post.structuredQuoteText.map((part) =>
part.type === "url" ? (
<a href={part.href} title={part.href} target="_blank">
{part.text}
</a>
) : part.type === "space" ? (
<span>&nbsp;</span>
) : part.type === "break" ? (
<div class="post-linebreak" />
) : (
part.text
)
)}
</div>
)}
</div>
{post.quote.image && (
<div class="post-quoted-image">
<img src={post.quote.image} />
</div>
)}
</div>
)
}
<div class="post-meta">
<div>{post.formattedDate}</div>
<div class="post-meta-type">
<a href={post.href} target="_blank">
<PostTypeIcon icon={post.type} />
</a>
</div>
{
enablerImageUrl && (
<div class="post-avatar">
<img src={enablerImageUrl} />
</div>
)
}
</div>
</div>
{post.commentary && <div class="post-commentary">{post.commentary}</div>}
</div>
</div>
<style>
.post {
opacity: 0;
position: relative;
left: -500px;
width: 400px;
max-width: 50%;

animation-duration: 1s;
animation-name: fadein;
animation-fill-mode: forwards;
}

.post-wrapper {
pointer-events: auto;
padding-bottom: 20px;
}

.post-card {
box-shadow: 0px 10px 10px rgba(10, 10, 10, 0.5);
position: relative;
background-color: #eee;
border-radius: 3px;

padding: 10px;
}

.post-load-bar {
position: absolute;
bottom: 0;
left: 0;
right: 0;
}

.post-load-bar-fill {
height: 4px;
width: 0%;
opacity: 1;
animation-name: post-load-fill;
animation-timing-function: ease-out;
background-color: rgba(168, 44, 44, 1);
}

@keyframes post-load-fill {
0% {
width: 0%;
opacity: 1;
}
80% {
width: 100%;
opacity: 1;
}
100% {
width: 100%;
opacity: 0;
}
}

.post-quoted-spacer {
margin-top: 10px;
}

.post-quoted {
border: 1px solid #444;
border-radius: 4px;
font-size: 0.9em;
overflow: hidden;
}

.post-quoted-meta {
color: #555;
font-weight: bold;
padding: 6px;
padding-bottom: 10px;
}

.post-quoted-body {
padding: 6px;
padding-top: 0px;
}

.post-image {
margin-top: 10px;
border-radius: 4px;
overflow: hidden;
}

.post-linebreak {
display: block;
margin-bottom: 10px;
}

.post-image img,
.post-quoted-image img {
max-width: 100%;
margin-bottom: -4px;
}

.post-commentary {
border: 1px solid #eee;
border-radius: 3px;
padding: 10px;
color: white;
margin-top: 15px;
}

.post-avatar {
position: absolute;
left: -65px;
bottom: -1px;
width: 50px;
height: 50px;
overflow: hidden;
border-radius: 25px;
box-shadow: 0px 10px 10px rgba(10, 10, 10, 0.5);
}

.post-avatar > img {
width: 100%;
height: 100%;
}

.post-meta {
margin-top: 10px;
font-size: 0.8rem;
display: grid;
grid-template-columns: 1fr 1fr;
}

.post-meta > div {
align-self: center;
}

.post-meta-type {
text-align: right;
}

.post-meta-type > a {
display: inline-block;
}

@keyframes fadein {
from {
opacity: 0;
left: -500px;
}

to {
opacity: 0.8;
left: 0;
}
}

@media (max-aspect-ratio: 800/900) {
.post {
max-width: none;
width: 100%;
}

.post-avatar {
width: 35px;
height: 35px;
left: -48px;
}
}
</style>
2 changes: 2 additions & 0 deletions site/src/content/enabler/scott-aitchison.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
"date": "2023-10-26",
"quote": {
"text": "In Jerusalem tonight, 224 pillars of light for each child, woman and man being held hostage by #Hamas in Gaza. 💔\n\n📸 Arnon Bosanni #BringThemHome",
"image": "https://pbs.twimg.com/media/F9Z88crXMAAyWYx?format=jpg&name=small",
"author": "CIJA"
},
"type": "twitter",
"href": "https://x.com/CIJAinfo/status/1717697691000406341?s=20"
},
{
"text": "Hamas cannot be trusted to respect any ceasefire.\n\nThey are a terrorist group.\n\nI continue to support Israel's right to defend itself and to take action to eliminate Hamas and bring home the hostages.",
"image": "https://pbs.twimg.com/media/F_Y_-TPWcAEYOcS?format=jpg&name=small",
"date": "2023-11-20",
"type": "twitter",
"href": "https://x.com/ScottAAitchison/status/1726637851515711576?s=20"
Expand Down
29 changes: 8 additions & 21 deletions site/src/content/enabler/tal-broda.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
"playDurationSeconds": 20,
"image": "https://pbs.twimg.com/profile_images/1599598218047881216/U45uXUkS_400x400.jpg",
"posts": [
{
"skip": true,
"text": "@HilzFuld Unfortunately, this is far from over. The IDF didn't even start to clean southern Gaza.",
"date": "2023-11-23",
"type": "twitter",
"href": "https://twitter.com/StopArabHate/status/1734923782949568711/photo/1"
},
{
"text": "Accomplices should be rewarded exactly the same way as Hamas.",
"date": "2023-11-08T14:25:00.000Z",
Expand All @@ -33,7 +26,7 @@
"text": "100%. We should have never left. Now we need take it back, by force, and keep it forever. Nothing else works.",
"date": "2023-10-09T06:09:00.000Z",
"quote": {
"text": "Israel made a colossal mistake in 2005 when it withdrew from Gaza [...]",
"text": "Israel made a colossal mistake in 2005 when it withdrew from Gaza and turned the whole territory over to the Palestinian Authority. That decision has led to 18 years of terrorism, violence, and atrocities. Israel must reoccupy...",
"author": "Jeff Jacoby"
},
"type": "twitter",
Expand All @@ -43,8 +36,8 @@
"text": "@Bundeskanzler take a page from @EmmanuelMacron's book, and do not allow any Pro-Palestine demonstrations on German soil. You're done with Nazis, right?",
"date": "2023-10-13T08:12:00.000Z",
"quote": {
"text": "German Chancellor @OlafScholz: No more aid will be sent [...]",
"author": "The Mossad: Satirical, Yet Aweso..."
"text": "German Chancellor @OlafScholz:\nNo more aid will be sent to the Palestinians until a thorough review has been conducted.\n-Hamas would not haev been able to carry out the terrorist attack without the help of Iran in...",
"author": "The Mossad: Satirical"
},
"type": "twitter",
"href": "https://twitter.com/StopArabHate/status/1734923782949568711/photo/3"
Expand All @@ -53,7 +46,7 @@
"text": "Don't worry about [killing civilians]. Worry about us.",
"date": "2023-10-12T07:52:00.000Z",
"quote": {
"text": "This is unacceptable and not the way. twitter.com/garrytan/statu[...]",
"text": "This is unacceptable and not the way. twitter.com/garrytan/statu...",
"author": "Shaun Maquire"
},
"type": "twitter",
Expand All @@ -63,7 +56,8 @@
"text": "More. Don't stop.",
"date": "2023-10-09T07:30:00.000Z",
"quote": {
"text": "To the citizens of Gaza. Listen to the IDF. [...]",
"text": "To the citizens of Gaza. Listen to the IDF.\nHamas wants you to stay because they need you as human shields.\nYou do not want to be in the building when this happens. And it will.",
"image": "themossadil-20231009.png",
"author": "The Mossad: Satirical, Yet Aweso..."
},
"type": "twitter",
Expand All @@ -73,7 +67,8 @@
"text": "More! No mercy! @IDF don't stop!",
"date": "2023-10-10T10:57:14.000Z",
"quote": {
"text": "This is the Beverly Hills of Gaza. [...]",
"text": "This is the Beverly Hills of Gaza. This is where all the leaders of Hamas have their palaces. Or should I say, had their palaces.\nAnd let there be no doubt, the IDF is just getting started.",
"image": "hilzfuld-20231010.png",
"author": "Hillel Fuld"
},
"type": "twitter",
Expand All @@ -82,20 +77,12 @@
{
"text": "I truly hope Gaza is just the first stop of the IDF.",
"date": "2023-11-01T06:16:45.000Z",
"quote": {
"text": "This is the Beverly Hills of Gaza. [...]",
"author": "Hillel Fuld"
},
"type": "twitter",
"href": "https://www.ravenmission.org/people/professionals/tal-broda"
},
{
"text": "I want to address a few tweets that I deleted several weeks ago. [...]",
"date": "2023-12-17T12:52:00.000Z",
"quote": {
"text": "This is the Beverly Hills of Gaza. [...]",
"author": "Hillel Fuld"
},
"commentary": "He deleted more than 80 tweets, of which this is just a sampling.",
"type": "twitter",
"href": "https://twitter.com/StopArabHate/status/1736029519050330489?s=20"
Expand Down
Loading

0 comments on commit 5586167

Please sign in to comment.