Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Bytes while they are Down #152

Merged
merged 6 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/fly_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ jobs:
uses: superfly/fly-pr-review-apps@1.2.1
with:
name: coreyja-com-pr-${{ github.event.number }}
secrets: APP_BASE_URL="https://coreyja-com-pr-${{ github.event.number }}.fly.dev" DATABASE_URL="${{ steps.create-branch.outputs.db_url }}?sslmode=require" TWITCH_CLIENT_ID="FAKE" TWITCH_CLIENT_SECRET="FAKE" TWITCH_BOT_ACCESS_TOKEN="FAKE" TWITCH_BOT_USER_ID="FAKE" TWITCH_CHANNEL_USER_ID="FAKE" GITHUB_APP_ID="123" GITHUB_APP_CLIENT_ID="FAKE" GITHUB_APP_CLIENT_SECRET="FAKE" GITHUB_APP_PRIVATE_KEY="FAKE" GITHUB_PERSONAL_ACCESS_TOKEN="FAKE" OPEN_AI_API_KEY="FAKE" GOOGLE_CLIENT_ID="FAKE" GOOGLE_CLIENT_SECRET="FAKE" ENCRYPTION_SECRET_KEY="FAKE" JOBS_DISABLED="true" CRON_DISABLED="true"
secrets: APP_BASE_URL="https://coreyja-com-pr-${{ github.event.number }}.fly.dev" DATABASE_URL="${{ steps.create-branch.outputs.db_url }}?sslmode=require" TWITCH_CLIENT_ID="FAKE" TWITCH_CLIENT_SECRET="FAKE" TWITCH_BOT_ACCESS_TOKEN="FAKE" TWITCH_BOT_USER_ID="FAKE" TWITCH_CHANNEL_USER_ID="FAKE" GITHUB_APP_ID="123" GITHUB_APP_CLIENT_ID="FAKE" GITHUB_APP_CLIENT_SECRET="FAKE" GITHUB_APP_PRIVATE_KEY="FAKE" GITHUB_PERSONAL_ACCESS_TOKEN="FAKE" OPEN_AI_API_KEY="FAKE" GOOGLE_CLIENT_ID="FAKE" GOOGLE_CLIENT_SECRET="FAKE" ENCRYPTION_SECRET_KEY="FAKE" JOBS_DISABLED="true" CRON_DISABLED="true" DISCORD_TOKEN="FAKE" DISCORD_BOT_DISABLED="true"
memory: 512
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"rustc",
"syntect",
"thiserror",
"tils",
"UNNEST",
"vergen"
],
]
}
26 changes: 26 additions & 0 deletions server/src/http_server/pages/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,37 @@ impl Render for ByteList {
}
}

fn bytes_warning() -> maud::Markup {
maud::html! {
div."rounded-md bg-yellow-50 p-4 my-4" {
div."flex" {
div."shrink-0" {
svg."size-5 text-yellow-400" fill="currentColor" aria-hidden="true" viewBox="0 0 20 20" data-slot="icon" {
path fill-rule="evenodd" clip-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" {}
}
}
div."ml-3" {
h3."text-sm font-medium text-yellow-800" {
"Bytes are currently disabled"
}
div."mt-2 text-sm text-yellow-700" {
p {
"Bytes are currently broken, due to losing a DB that didn't have backups. I'm working on rebuilding them, but in the meantime they will break below and have been removed from the homepage."
}
}
}
}
}
}
}

pub(crate) async fn bytes_index() -> Result<impl IntoResponse, ServerError> {
Ok(base_constrained(
maud::html! {
h1 class="text-3xl mb-4" { "Bytes - Coding Challenges" }

(bytes_warning())

p class="mb-4" {
"Bytes are bite-sized coding challenges that are designed to be fun and educational. "
"They are a great way to practice your coding skills and learn new things."
Expand Down
33 changes: 14 additions & 19 deletions server/src/http_server/pages/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@ use posts::{blog::BlogPosts, til::TilPosts};

use crate::{
http_server::{
pages::{
bytes::{get_most_recent_bytes, ByteList},
videos::{VideoList, YoutubeVideo},
},
pages::videos::{VideoList, YoutubeVideo},
templates::{
base,
buttons::LinkButton,
constrained_width,
header::OpenGraph,
post_templates::{BlogPostList, TilPostList},
},
LinkTo, ServerError,
ServerError,
},
AppState,
};

use super::bytes::Byte;

pub(crate) async fn home_page(
State(app_state): State<AppState>,
State(til_posts): State<Arc<TilPosts>>,
Expand All @@ -44,10 +39,10 @@ pub(crate) async fn home_page(
.fetch_all(&app_state.db)
.await?;

let bytes = get_most_recent_bytes();
let most_recent_byte = bytes.first();
// let bytes = get_most_recent_bytes();
// let most_recent_byte = bytes.first();

let top_3_bytes: Vec<Byte> = bytes.iter().take(3).cloned().collect();
// let top_3_bytes: Vec<Byte> = bytes.iter().take(3).cloned().collect();

Ok(base(
html! {
Expand All @@ -64,9 +59,9 @@ pub(crate) async fn home_page(

div class="text-xl flex flex-row space-x-8" {
(LinkButton::primary(html!("View Posts"), "/posts"))
@if let Some(most_recent_byte) = most_recent_byte {
(LinkButton::primary(html!("Play Latest Byte"), most_recent_byte.relative_link()))
}
// @if let Some(most_recent_byte) = most_recent_byte {
// (LinkButton::primary(html!("Play Latest Byte"), most_recent_byte.relative_link()))
// }
}
}

Expand All @@ -75,14 +70,14 @@ pub(crate) async fn home_page(
}
}

div class="mb-8" {
h2 ."text-3xl" { a href="/bytes" { "Recent Bytes" } }
h3 class="text-xl mb-4 text-gray-500" { "Code Review Challenges" }
// div class="mb-8" {
// h2 ."text-3xl" { a href="/bytes" { "Recent Bytes" } }
// h3 class="text-xl mb-4 text-gray-500" { "Code Review Challenges" }

(ByteList::new(top_3_bytes))
// (ByteList::new(top_3_bytes))

(LinkButton::primary(html!("View All Bytes"), "/bytes"))
}
// (LinkButton::primary(html!("View All Bytes"), "/bytes"))
// }

div class="flex flex-col md:flex-row md:space-x-8" {
div class="flex-grow" {
Expand Down
2 changes: 1 addition & 1 deletion server/src/http_server/pages/videos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Render for VideoList {

pub(crate) struct VideoThumbnailCard<'a>(pub(crate) &'a YoutubeVideo);

impl<'video> Render for VideoThumbnailCard<'video> {
impl Render for VideoThumbnailCard<'_> {
fn render(&self) -> Markup {
let video = &self.0;

Expand Down
1 change: 0 additions & 1 deletion server/src/http_server/templates/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ pub fn header() -> Markup {
nav class="flex flex-grow w-full pb-4 sm:pb-8" {
ul class="text-lg flex flex-wrap flex-row justify-center sm:items-center flex-grow" {
(HeaderLink { href: "/", text: "Home" })
(HeaderLink { href: "/bytes", text: "Bytes" })
(HeaderLink { href: "/posts", text: "Posts" })
(HeaderLink { href: "/til", text: "TILs" })
(HeaderLink { href: "/videos", text: "Videos" })
Expand Down
4 changes: 2 additions & 2 deletions server/src/http_server/templates/post_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::http_server::LinkTo;

pub(crate) struct TilPostList<'a>(pub(crate) Vec<&'a TilPost>);

impl<'a> Render for TilPostList<'a> {
impl Render for TilPostList<'_> {
fn render(&self) -> Markup {
html! {
ul {
Expand All @@ -26,7 +26,7 @@ impl<'a> Render for TilPostList<'a> {

pub(crate) struct BlogPostList<'a>(pub(crate) Vec<&'a BlogPost>);

impl<'a> Render for BlogPostList<'a> {
impl Render for BlogPostList<'_> {
fn render(&self) -> Markup {
html! {
ul {
Expand Down
4 changes: 2 additions & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ fn main() -> Result<()> {
.worker_threads(4)
.enable_all()
.build()?
.block_on(async { _main().await })
.block_on(async { async_main().await })
}

async fn _main() -> Result<()> {
async fn async_main() -> Result<()> {
setup_tracing("server")?;

let cli = CliArgs::parse();
Expand Down
5 changes: 4 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const colors = {

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./**/*.{rs,html,md}"],
content: [
"./**/*.{rs,html,md}",
"!./target/**/*",
],
theme: {
fontSize: {
sm: "0.8rem",
Expand Down
Loading