Skip to content

Commit

Permalink
Completely remove usage of sprockets or propshaft (#24)
Browse files Browse the repository at this point in the history
Why:

- Sprockets v4 manifest file has all sorts of rough edges with rails engines
- Exposing the engines assets publicly can give away details about things that should be internal only
- We can easily avoid it altogether and just load the assets as part of the application layout
- There are such minimal amount of asset code that there really is no benefit to any HTTP caching
  • Loading branch information
westonganger authored Jan 18, 2025
1 parent fc9b424 commit a34051a
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 510 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

### Unreleased - [View Diff](https://github.com/westonganger/rails_i18n_manager/compare/v1.0.3...master)
- [#24](https://github.com/westonganger/rails_i18n_manager/pull/24) - Completely remove usage of sprockets or propshaft
- [#23](https://github.com/westonganger/rails_i18n_manager/pull/23) - Fix issues with rubyzip 2.4+ create option

### v1.0.3 - December 2, 2024 - [View Diff](https://github.com/westonganger/rails_i18n_manager/compare/v1.0.2...v1.0.3)
Expand Down
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ rails_version = get_env("RAILS_VERSION")

gem "rails", rails_version

if rails_version.nil? || rails_version.sub("~>","").to_f >= 8.0
gem "propshaft"
else
gem "sprockets-rails", require: "sprockets/railtie"
end

db_gem = get_env("DB_GEM") || "sqlite3"
gem db_gem, get_env("DB_GEM_VERSION")

Expand Down
3 changes: 0 additions & 3 deletions app/assets/config/rails_i18n_manager_manifest.rb

This file was deleted.

Binary file removed app/assets/images/rails_i18n_manager/favicon.ico
Binary file not shown.
37 changes: 0 additions & 37 deletions app/assets/javascripts/rails_i18n_manager/application.js

This file was deleted.

67 changes: 0 additions & 67 deletions app/assets/stylesheets/rails_i18n_manager/application.css

This file was deleted.

99 changes: 0 additions & 99 deletions app/assets/stylesheets/rails_i18n_manager/utility.css

This file was deleted.

5 changes: 0 additions & 5 deletions app/helpers/rails_i18n_manager/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ def custom_fields_for(*args, **options, &block)
fields_for(*args, options, &block)
end

ASSET_VERSION = `git show -s --format=%ci`.parameterize.freeze
def custom_asset_path(path)
"#{path}?v=#{Rails.env.development? ? Time.now.to_i : ASSET_VERSION}"
end

def breadcrumb_item(title, url=nil)
if url.nil?
%Q(<span class="breadcrumb-item">#{title}</span>).html_safe
Expand Down
69 changes: 69 additions & 0 deletions app/views/layouts/rails_i18n_manager/_app_css.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<style>
h1, h2, h3, h4, h5{
color: #424242;
}

body{
background-color: #F5F6F6;
padding-top: 80px;
padding-bottom: 20px;
}

label{
margin-right: 10px;
}

footer{
position: fixed;
text-align: center;
bottom: 10px;
right: 0;
left: 0;
}

.btn-default{
border-color: gray;
background-color: gray;
background-image: none;
}

.breadcrumb-item:before{
content: "/":
}

.form-group{
margin-bottom: 15px !important;
}

select{
min-width: 300px;
}

form label{
margin-bottom: 5px;
font-weight: bold;
}

.nav-link.active{
font-weight: bold;
}

.navbar-nav .nav-item{
margin-left: 10px;
}

.navbar-brand{
font-weight: bold;
text-decoration: underline;
}

.ss-main{
// for slimselect.js
background-image: none !important;
height: 38px;
}

.ss-option{
min-height: 32px !important;
}
</style>
39 changes: 39 additions & 0 deletions app/views/layouts/rails_i18n_manager/_app_javascript.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script type="text/javascript">
window.init = function(){
$("form").attr("autocomplete", "off");

$('.field_with_errors').addClass('is-invalid');

var alerts = $(".alert:not(.permanent)")
setTimeout(function(){
alerts.fadeOut();
}, 8000);

autosize($('textarea'));

$("select").each(function(){
$(this).removeClass("form-select");

new SlimSelect({
select: this,
settings: {
//contentLocation: document.body,
contentLocation: this.parentElement,
closeOnSelect: !this.hasAttribute("multiple"),
openPosition: 'down', // options: auto, up, down
//placeholderText: "Select Value",
placeholderText: "Select...",
//searchPlaceholder: 'Search',
//searchText: 'No Results',
//searchingText: 'Searching...',
maxValuesShown: 999, // defaults to 20, max selected items show in multi-selects
//maxValuesShown: 20,
}
})
});
}

$(function(){
window.init();
});
</script>
20 changes: 20 additions & 0 deletions app/views/layouts/rails_i18n_manager/_assets.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" referrerpolicy="no-referrer"

link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"
script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"

= render "layouts/rails_i18n_manager/utility_css"
= render "layouts/rails_i18n_manager/app_css"

script src="https://cdn.jsdelivr.net/npm/@rails/[email protected]/lib/assets/compiled/rails-ujs.min.js"

link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slim-select/2.4.5/slimselect.min.css" integrity="sha512-GvqWM4KWH8mbgWIyvwdH8HgjUbyZTXrCq0sjGij9fDNiXz3vJoy3jCcAaWNekH2rJe4hXVWCJKN+bEW8V7AAEQ==" crossorigin="anonymous" referrerpolicy="no-referrer"
script src="https://cdnjs.cloudflare.com/ajax/libs/slim-select/2.4.5/slimselect.global.min.js" integrity="sha512-r2ujllVbPV4gVNZyqAB6LS3cnpEenEl18yFYoowmutUX5zVXQi5mp13lMWv3FQpsn96eFJTcd5VqBkZuatGtWQ==" crossorigin="anonymous" referrerpolicy="no-referrer"

script src="https://cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.20/autosize.min.js" integrity="sha512-EAEoidLzhKrfVg7qX8xZFEAebhmBMsXrIcI0h7VPx2CyAyFHuDvOAUs9CEATB2Ou2/kuWEDtluEVrQcjXBy9yw==" crossorigin="anonymous" referrerpolicy="no-referrer"

link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.min.css" integrity="sha512-IJ+BZHGlT4K43sqBGUzJ90pcxfkREDVZPZxeexRigVL8rzdw/gyJIflDahMdNzBww4k0WxpyaWpC2PLQUWmMUQ==" crossorigin="anonymous" referrerpolicy="no-referrer"

link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==" crossorigin="anonymous" referrerpolicy="no-referrer"

= render "layouts/rails_i18n_manager/app_javascript"
Loading

0 comments on commit a34051a

Please sign in to comment.