mirror of
https://github.com/System-End/cdn.git
synced 2026-04-19 20:55:10 +00:00
⌘
This commit is contained in:
parent
4619ba5944
commit
cacae5730e
6 changed files with 204 additions and 8 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Components::StaticPages::Home < Components::StaticPages::Base
|
class Components::StaticPages::Home < Components::StaticPages::Base
|
||||||
def initialize(stats:, user:)
|
def initialize(stats:, user:, flavor_text:)
|
||||||
@stats = stats
|
@stats = stats
|
||||||
@user = user
|
@user = user
|
||||||
|
@flavor_text = flavor_text
|
||||||
end
|
end
|
||||||
|
|
||||||
def view_template
|
def view_template
|
||||||
|
|
@ -16,7 +17,7 @@ class Components::StaticPages::Home < Components::StaticPages::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :stats, :user
|
attr_reader :stats, :user, :flavor_text
|
||||||
|
|
||||||
def header_section
|
def header_section
|
||||||
header(style: "display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--borderColor-default, #d0d7de);") do
|
header(style: "display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--borderColor-default, #d0d7de);") do
|
||||||
|
|
@ -25,7 +26,10 @@ class Components::StaticPages::Home < Components::StaticPages::Base
|
||||||
plain "Welcome back, "
|
plain "Welcome back, "
|
||||||
strong { user&.name || "friend" }
|
strong { user&.name || "friend" }
|
||||||
end
|
end
|
||||||
h1(style: "font-size: 2rem; font-weight: 300; margin: 0;") { "Your CDN Stash" }
|
h1(style: "font-size: 2rem; font-weight: 300; margin: 0;") { "Hack Club CDN" }
|
||||||
|
div(style: "margin-top: 8px;") do
|
||||||
|
render(Primer::Beta::Label.new(scheme: :secondary)) { flavor_text }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
div(style: "display: flex; gap: 8px; flex-wrap: wrap;") do
|
div(style: "display: flex; gap: 8px; flex-wrap: wrap;") do
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Components::StaticPages::LoggedOut < Components::StaticPages::Base
|
class Components::StaticPages::LoggedOut < Components::StaticPages::Base
|
||||||
def initialize(stats:)
|
def initialize(stats:, flavor_text:)
|
||||||
@stats = stats
|
@stats = stats
|
||||||
|
@flavor_text = flavor_text
|
||||||
end
|
end
|
||||||
|
|
||||||
def view_template
|
def view_template
|
||||||
|
|
@ -15,7 +16,7 @@ class Components::StaticPages::LoggedOut < Components::StaticPages::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :stats
|
attr_reader :stats, :flavor_text
|
||||||
|
|
||||||
def header_section
|
def header_section
|
||||||
header(style: "display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--borderColor-default, #d0d7de);") do
|
header(style: "display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--borderColor-default, #d0d7de);") do
|
||||||
|
|
@ -24,9 +25,10 @@ class Components::StaticPages::LoggedOut < Components::StaticPages::Base
|
||||||
plain "Hack Club CDN"
|
plain "Hack Club CDN"
|
||||||
sup(style: "font-size: 0.5em; margin-left: 4px;") { "v4" }
|
sup(style: "font-size: 0.5em; margin-left: 4px;") { "v4" }
|
||||||
end
|
end
|
||||||
p(style: "color: var(--fgColor-muted, #656d76); margin: 0; max-width: 600px;") do
|
p(style: "color: var(--fgColor-muted, #656d76); margin: 0 0 8px; max-width: 600px;") do
|
||||||
plain "File hosting for Hack Clubbers."
|
plain "File hosting for Hack Clubbers."
|
||||||
end
|
end
|
||||||
|
render(Primer::Beta::Label.new(scheme: :secondary)) { flavor_text }
|
||||||
end
|
end
|
||||||
|
|
||||||
div(style: "display: flex; gap: 8px; flex-wrap: wrap;") do
|
div(style: "display: flex; gap: 8px; flex-wrap: wrap;") do
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ class StaticPagesController < ApplicationController
|
||||||
skip_before_action :require_authentication!, only: [:home]
|
skip_before_action :require_authentication!, only: [:home]
|
||||||
|
|
||||||
def home
|
def home
|
||||||
|
@flavor_text = FlavorTextService.new(user: current_user).generate
|
||||||
if signed_in?
|
if signed_in?
|
||||||
@user_stats = CDNStatsService.user_stats(current_user)
|
@user_stats = CDNStatsService.user_stats(current_user)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
179
app/services/flavor_text_service.rb
Normal file
179
app/services/flavor_text_service.rb
Normal file
|
|
@ -0,0 +1,179 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class FlavorTextService
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
|
def initialize(user: nil, env: Rails.env, deterministic: true)
|
||||||
|
@user = user
|
||||||
|
@env = env
|
||||||
|
@seed = deterministic ? Time.now.to_i / 5.minutes : Random.new_seed
|
||||||
|
@random = Random.new(@seed)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate
|
||||||
|
flavor_text = sample
|
||||||
|
flavor_text = flavor_text.call if flavor_text.respond_to? :call
|
||||||
|
|
||||||
|
flavor_text
|
||||||
|
end
|
||||||
|
|
||||||
|
def flavor_texts
|
||||||
|
[
|
||||||
|
"bytes bytes bytes bytes bytes",
|
||||||
|
"A hard drive stuffed with cat photos",
|
||||||
|
"The Hack Foundation dba The File Store",
|
||||||
|
"Open on weekends",
|
||||||
|
"Open on holidays",
|
||||||
|
"please don't hack",
|
||||||
|
"Contentedly Delivering Nonsense",
|
||||||
|
"Cool Dino Network",
|
||||||
|
"Compressed Data Nuggets",
|
||||||
|
"Cozy Digital Nest",
|
||||||
|
"Open late",
|
||||||
|
"Now in color!",
|
||||||
|
"Filmed on location",
|
||||||
|
"Soon to be a major blockchain!",
|
||||||
|
"As seen on the internet",
|
||||||
|
"Most viewed site on this domain!",
|
||||||
|
"Coming to a browser near you",
|
||||||
|
"#{@random.rand 4..9}0% bug free!",
|
||||||
|
"#{@random.rand 1..4}0% fewer bugs!",
|
||||||
|
'Now with "code"',
|
||||||
|
"Holds lots of bytes",
|
||||||
|
"Educational!",
|
||||||
|
"Don't use while driving",
|
||||||
|
"Support local file hosting!",
|
||||||
|
"Take frequent breaks!",
|
||||||
|
"Technically good!",
|
||||||
|
"Operating at a loss since 2025!",
|
||||||
|
"Does anyone actually read this?",
|
||||||
|
"Like and subscribe!",
|
||||||
|
"As seen on cdn.hackclub.com",
|
||||||
|
"As seen on hackclub.com",
|
||||||
|
"Now running in production!",
|
||||||
|
"put files in computer",
|
||||||
|
"TODO: get that bread",
|
||||||
|
"Coming soon to a screen near your face",
|
||||||
|
"Coming soon to a screen near you",
|
||||||
|
"As seen on the internet",
|
||||||
|
"Operating at a loss so you don't have to",
|
||||||
|
"It holds files!",
|
||||||
|
"uwu",
|
||||||
|
"owo",
|
||||||
|
"ovo",
|
||||||
|
"An important part of this nutritional breakfast",
|
||||||
|
"By people with files, for people with files",
|
||||||
|
'Made using "files"',
|
||||||
|
"Chosen #1 by dinosaurs everywhere",
|
||||||
|
"IT departments HATE them",
|
||||||
|
"Congratulations, you are the #{number_with_delimiter(10**@random.rand(1..5))}th visitor!",
|
||||||
|
"You've got this",
|
||||||
|
"Don't forget to drink water!",
|
||||||
|
"Putting the 'fun' in 'upload'",
|
||||||
|
"Putting the 'fun' in 'cloud storage'",
|
||||||
|
"Putting the 'do' in 'download'",
|
||||||
|
"Putting the 'based' in 'cloud-based hosting'",
|
||||||
|
"Putting the 'host' in 'ghost'",
|
||||||
|
"Putting the 'sus' in 'sustainable bandwidth'",
|
||||||
|
"Open on weekdays!",
|
||||||
|
"Open on #{Date.today.strftime("%A")}s",
|
||||||
|
"??? storage!",
|
||||||
|
"Did you see the size of that #{%w[image video file].sample(random: @random)}?!",
|
||||||
|
"Guess how much it costs to run this thing!",
|
||||||
|
"Bytes served fresh daily by Cloudflare",
|
||||||
|
"Running with Ruby on Rails #{Rails.gem_version.canonical_segments.first}",
|
||||||
|
"Now with 1% downtime!",
|
||||||
|
"Achievement unlocked!",
|
||||||
|
"#{@random.rand(10..50)},#{@random.rand(100..999).to_s.rjust(3, '0')} lines of code",
|
||||||
|
"Your move, Dropbox",
|
||||||
|
"If you can read this, the page's status code is 200",
|
||||||
|
"If you can read this, the page has loaded",
|
||||||
|
"Now go and upload yourself something nice",
|
||||||
|
"[Insert splash text here]",
|
||||||
|
"Condemned by the sheriff of storage",
|
||||||
|
"Coded on location",
|
||||||
|
'Voted "3rd"',
|
||||||
|
"You are now breathing manually",
|
||||||
|
"If you can read this, thanks!",
|
||||||
|
"(or similar product)",
|
||||||
|
"[OK]",
|
||||||
|
"tell your parents it's educational",
|
||||||
|
"You found the 3rd Easter egg on the site",
|
||||||
|
"The best site you're using right now",
|
||||||
|
"It Is What It Is",
|
||||||
|
"Made in Vermont, with love",
|
||||||
|
"Your move S3!",
|
||||||
|
"Flash plugin failed to load",
|
||||||
|
"Upload, they said",
|
||||||
|
"U want sum storage?",
|
||||||
|
"Check the back of this page for an exclusive promo code!",
|
||||||
|
"You've found the 5th easter egg on the site!",
|
||||||
|
"A folder is fine too",
|
||||||
|
"Welcome to #{%w[data storage].sample(random: @random)} town, population: you",
|
||||||
|
"So... what's your favorite file format?",
|
||||||
|
"<span style='font-size: 2px !important'>If you can read this you've got tiny eyes</span>".html_safe,
|
||||||
|
"Page loaded in: < 24 hrs (I hope)",
|
||||||
|
"Old and improved!",
|
||||||
|
"Newly loaded!",
|
||||||
|
"Refreshing! (if you keep hitting ⌘+R)",
|
||||||
|
"Recommended by people somewhere!",
|
||||||
|
"Recommended by people in some places!",
|
||||||
|
"Recommended by hackers on this site!",
|
||||||
|
"Recommended by me!",
|
||||||
|
"Recommended by Hack Club!",
|
||||||
|
"Recommended by the recommend-o-tron 3000",
|
||||||
|
"Recommended! (probably)",
|
||||||
|
"Please stow your files in the upright and locked position",
|
||||||
|
"Loaded in #{@random.rand(10..35)}ms... jk– i don't actually know how long it took",
|
||||||
|
"Loaded in #{@random.rand(10..35)}ms... jk– i can't count",
|
||||||
|
"Turns out it's hard to make one of these things",
|
||||||
|
"TODO: come up with some actual jokes for this box",
|
||||||
|
"asdgfhjdk I'm out of jokes",
|
||||||
|
"Send your jokes to nora@hackclub.com",
|
||||||
|
"You're looking great today :)",
|
||||||
|
"Great! You're here!",
|
||||||
|
"You need to wake up",
|
||||||
|
"you need to wake up! Pinch yourself",
|
||||||
|
"stop dreaming, you need to wake up!",
|
||||||
|
"Are you suuuuure you aren't a robot?",
|
||||||
|
"Show emotion here if you aren't a robot",
|
||||||
|
"Your ad here!",
|
||||||
|
"Are you feeling lucky?",
|
||||||
|
"...and you can take that to the cloud",
|
||||||
|
"Ever just wonder... why?",
|
||||||
|
"Redstone update out now!",
|
||||||
|
"educational edition",
|
||||||
|
"Where's the file lebowski?!",
|
||||||
|
"We put the 'fun' in 'cloud storage' (there isn't any)",
|
||||||
|
"Not responsible for any major data loss!",
|
||||||
|
"In today's internet?!",
|
||||||
|
"Send us your best haiku!",
|
||||||
|
"«⋄⇠◇«─◆─»⇢$$$⇠«─◆─»◇⇢⋄»",
|
||||||
|
"¸¸.•*📁*•.¸¸¸.•*📁*•.¸¸¸.•*📁*•.¸¸¸.•*📁*•.¸",
|
||||||
|
"◥◤◢◤◢📁📁📁◣◥◣◥◤",
|
||||||
|
"store no evil",
|
||||||
|
"byte me",
|
||||||
|
"not running on the blockchain!",
|
||||||
|
"not available offline!",
|
||||||
|
"as seen online",
|
||||||
|
"online only!",
|
||||||
|
"new strawberry flavor!",
|
||||||
|
"same classic taste",
|
||||||
|
"<marquee scrollamount='5'>📁📁📁</marquee>".html_safe,
|
||||||
|
-> { "#{@random.rand(5..50)} users online" },
|
||||||
|
"Raccoon-tested, dinosaur-approved.",
|
||||||
|
"original recipe!",
|
||||||
|
"now sugar-free!",
|
||||||
|
"low-sodium edition",
|
||||||
|
'we put the ":3" in "S3"!',
|
||||||
|
"do not adjust your monitor.",
|
||||||
|
"only #{@random.rand(5..50)} missing #{["file", "files"].sample(random: @random)}!",
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def sample
|
||||||
|
flavor_texts.sample(random: @random)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -35,6 +35,16 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<%= render(Components::HeaderBar.new) if signed_in? %>
|
<%= render(Components::HeaderBar.new) if signed_in? %>
|
||||||
|
<% if flash[:notice] || flash[:alert] %>
|
||||||
|
<div style="max-width: 768px; margin: 16px auto; padding: 0 16px;">
|
||||||
|
<% if flash[:notice] %>
|
||||||
|
<%= render(Primer::Beta::Flash.new(scheme: :success, icon: :check)) { flash[:notice] } %>
|
||||||
|
<% end %>
|
||||||
|
<% if flash[:alert] %>
|
||||||
|
<%= render(Primer::Beta::Flash.new(scheme: :danger, icon: :alert)) { flash[:alert] } %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<% if signed_in? %>
|
<% if signed_in? %>
|
||||||
<%= render Components::StaticPages::Home.new(stats: @user_stats, user: current_user) %>
|
<%= render Components::StaticPages::Home.new(stats: @user_stats, user: current_user, flavor_text: @flavor_text) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render Components::StaticPages::LoggedOut.new(stats: @global_stats) %>
|
<%= render Components::StaticPages::LoggedOut.new(stats: @global_stats, flavor_text: @flavor_text) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
Loading…
Add table
Reference in a new issue