Skip to content

Commit

Permalink
Added Phlex
Browse files Browse the repository at this point in the history
  • Loading branch information
yatish27 committed May 16, 2024
1 parent 193b21b commit acb390f
Show file tree
Hide file tree
Showing 20 changed files with 1,931 additions and 279 deletions.
1,847 changes: 1,844 additions & 3 deletions .rubocop.yml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ gem "stimulus-rails", "~> 1.3", ">= 1.3.3"
gem "turbo-rails", "~> 2.0", ">= 2.0.5"
gem "tzinfo-data", "~> 1.2024", ">= 1.2024.1", platforms: %i[windows jruby]
gem "vite_rails", "~> 3.0", ">= 3.0.17"
gem "phlex-rails", "~> 1.2"

group :development, :test do
gem "debug", "~> 1.9", ">= 1.9.2", platforms: %i[mri windows]
gem "dotenv", "~> 3.1", ">= 3.1.2"
gem "factory_bot_rails", "~> 6.4", ">= 6.4.3"
gem "rubocop-rails-omakase", "~> 1.0", require: false, group: [ :development ]
gem "rubocop-rails-omakase", "~> 1.0", require: false, group: [:development]
gem "minitest-reporters", "~> 1.6", ">= 1.6.1"
end

Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ GEM
ast (~> 2.4.1)
racc
pg (1.5.6)
phlex (1.10.2)
phlex-rails (1.2.1)
phlex (~> 1.10.0)
railties (>= 6.1, < 8)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -336,6 +340,7 @@ DEPENDENCIES
letter_opener (~> 1.10)
minitest-reporters (~> 1.6, >= 1.6.1)
pg (~> 1.5, >= 1.5.6)
phlex-rails (~> 1.2)
puma (~> 6.4, >= 6.4.2)
rails (~> 7.1, >= 7.1.3.2)
rubocop (~> 1.63, >= 1.63.5)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/inline_svg_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module InlineSvgHelper
def inline_svg_tag(filename, title: nil)
svg = ViteInlineSvgFileLoader.named(filename)
svg = svg.sub(/\A<svg/, '<svg role="img"')
svg = svg.sub(/\A<svg.*?>/, safe_join([ '\0', "\n", tag.title(title) ])) if title.present?
svg = svg.sub(/\A<svg.*?>/, safe_join(['\0', "\n", tag.title(title)])) if title.present?

svg.strip.html_safe # rubocop:disable Rails/OutputSafety
end
Expand Down
9 changes: 9 additions & 0 deletions app/views/application_view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class ApplicationView < ApplicationComponent
# The ApplicationView is an abstract class for all your views.

# By default, it inherits from `ApplicationComponent`, but you
# can change that to `Phlex::HTML` if you want to keep views and
# components independent.
end
12 changes: 12 additions & 0 deletions app/views/components/application_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class ApplicationComponent < Phlex::HTML
include Phlex::Rails::Helpers::Routes

if Rails.env.development?
def before_template
comment { "Before #{self.class.name}" }
super
end
end
end
6 changes: 3 additions & 3 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<% provide(:title, "Home") %>
<div class="py-24">
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-16">
<div class="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center gap-2">
<%= vite_image_tag("images/logo-sm.png", class: "h-12 w-12 rounded-full") %>
<h1 class="scroll-m-20 text-4xl font-bold tracking-tight">Shore</h1>
</div>
<p class=" max-w-2xl text-lg text-gray-600">An opinionated and modern Ruby on Rails template with pragmatic defaults to start your next project 🚀</p>
<p class=" text-lg text-gray-600">An opinionated and modern Ruby on Rails template with pragmatic defaults to start your next project 🚀</p>
<p class="text-lg text-gray-600 mt-6">
Stimulus says,
<i class="text-indigo-600" data-controller="hello">Stimulus not loaded 😥</i>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= vite_client_tag %>
<%= vite_javascript_tag "application", data: {"turbo-track": "reload"} %>
<%= vite_javascript_tag "application" %>
<%= vite_stylesheet_tag "application", data: {"turbo-track": "reload"} %>
</head>
<body>
Expand Down
24 changes: 24 additions & 0 deletions app/views/layouts/application_layout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

class ApplicationLayout < ApplicationView
include Phlex::Rails::Layout

def view_template(&block)
doctype

html do
head do
title { "You're awesome" }
meta name: "viewport", content: "width=device-width,initial-scale=1"
csp_meta_tag
csrf_meta_tags
stylesheet_link_tag "application", data_turbo_track: "reload"
javascript_importmap_tags
end

body do
main(&block)
end
end
end
end
243 changes: 0 additions & 243 deletions bin/configure

This file was deleted.

4 changes: 2 additions & 2 deletions bin/rename_project
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def gsub_in_file(path, from, to)
end

def underscore(string)
string.gsub(/::/, '/')
string.gsub("::", "/")
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr("-", "_")
Expand Down Expand Up @@ -38,4 +38,4 @@ gsub_in_file("config/database.yml", /shore/, new_snake_name)
gsub_in_file("docker-compose.yml", /shore/, new_snake_name)

puts "Renamed the project to #{new_name}."
puts "Check the changes using git diff"
puts "Check the changes using git diff"
Loading

0 comments on commit acb390f

Please sign in to comment.