Skip to content

Commit

Permalink
Home page header
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpigford committed Apr 23, 2024
1 parent 85675b8 commit eb37b08
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@

/app/assets/builds/*
!/app/assets/builds/.keep

# Ignore Cursor AI rules
.cursorrules
1 change: 1 addition & 0 deletions app/assets/images/icon-chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/icon-discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/icon-github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/icon-maybe-color.svg
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 app/assets/images/icon-team.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "net/http"
require "json"

class PagesController < ApplicationController
def index
@stargazers_count = Rails.cache.fetch("stargazers_count", expires_in: 24.hours) do
fetch_stargazers_count
end
end

private

def fetch_stargazers_count
url = URI("https://ungh.cc/repos/maybe-finance/maybe")
response = Net::HTTP.get(url)
json = JSON.parse(response)
json["repo"]["stars"]
rescue StandardError => e
Rails.logger.error "Failed to fetch stargazers count: #{e.message}"
nil
end
end
2 changes: 2 additions & 0 deletions app/helpers/pages_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PagesHelper
end
29 changes: 25 additions & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) || "Maybe Marketing" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title><%= content_for(:title) || "Maybe: The OS for your personal finances" %></title>
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
Expand All @@ -16,11 +16,32 @@
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<%= hotwire_livereload_tags if Rails.env.development? %>
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
</head>

<body>
<main class="container mx-auto mt-28 px-5 flex">
<body class="min-h-screen bg-gradient-to-b from-neutral-50 to-neutral-100">
<header class="flex items-center justify-between py-5 px-7">
<div class="flex items-center">
<%= link_to image_tag('logo.svg', alt: 'Maybe Logo', class: 'h-6'), root_path %>
</div>
<nav class="flex-1 text-sm text-center">
<a href="#" class="mx-4 text-neutral-800 hover:text-neutral-900">Articles</a>
<a href="#" class="mx-4 text-neutral-800 hover:text-neutral-900">Resources</a>
<a href="#" class="mx-4 text-neutral-800 hover:text-neutral-900">Contribute</a>
</nav>
<div class="flex gap-x-2">
<%= link_to 'https://github.com/maybe-finance/maybe', class: "px-3 py-[0.45rem] text-sm font-medium text-black bg-neutral-900 rounded-xl hover:bg-neutral-800 bg-transparent border border-neutral-300 hover:border-neutral-400 hover:bg-neutral-100 flex items-center gap-2" do %>
<%= image_tag('icon-github.svg', alt: 'GitHub icon', class: 'h-4 w-4') %> Self-Host
<% end %>
<%= link_to 'Join waitlist', '#', class: "px-3 py-[0.45rem] text-sm font-medium text-white bg-neutral-900 rounded-xl hover:bg-neutral-800 border border-neutral-900" %>
</div>
</header>
<main class="max-w-5xl mx-auto my-10">
<%= yield %>
</main>
<footer>

</footer>
</body>
</html>
13 changes: 13 additions & 0 deletions app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="text-center">
<div class="max-w-xl pt-8 mx-auto text-3xl">
Maybe <%= image_tag('icon-maybe-color.svg', alt: 'Maybe Logo', class: 'inline') %> is a <em class="relative"><span class="border-b-2 border-dotted border-neutral-400">fully</span><sup>*</sup> <span class="absolute w-64 text-xs text-left left-16 -top-7 -rotate-3 text-neutral-400"><sup>*</sup>your finances are secure</span></em> open-source
<div class="inline-flex border rounded-md shadow-[0_1px_8px_0_rgba(0,0,0,0.04)] border-neutral-200">
<%= link_to 'https://github.com/maybe-finance/maybe', class: "px-2 py-1.5 border-r shadow-[inset_0_-2px_5px_0_rgba(0,0,0,0.07)] bg-neutral-100 rounded-l-md border-neutral-200 flex items-center justify-center" do %>
<%= image_tag('icon-github.svg', alt: 'GitHub icon', class: 'h-5 w-5') %>
<% end %>
<span class="px-2 py-1.5 text-sm font-medium bg-white shadow-[inset_0_-2px_5px_0_rgba(0,0,0,0.07)] rounded-r-md"><%= number_to_human(@stargazers_count, format: "%n%u", units: { thousand: "k" }) %></span>
</div>
OS for your personal finances <%= image_tag('icon-chart.svg', alt: 'Chart', class: 'inline') %> built by a small team <%= image_tag('icon-team.png', alt: 'Maybe Team', class: 'inline h-9') %> alongside an incredible community <%= image_tag('icon-discord.svg', alt: 'Discord', class: 'inline') %>
</div>
</div>

2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
get "manifest" => "rails/pwa#manifest", as: :pwa_manifest

# Defines the root path route ("/")
# root "posts#index"
root "pages#index"
end
Binary file removed public/icon.png
Binary file not shown.
3 changes: 0 additions & 3 deletions public/icon.svg

This file was deleted.

8 changes: 8 additions & 0 deletions test/controllers/pages_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "test_helper"

class PagesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get pages_index_url
assert_response :success
end
end

0 comments on commit eb37b08

Please sign in to comment.