diff --git a/Gemfile b/Gemfile index 2762ea0..6cb16c1 100644 --- a/Gemfile +++ b/Gemfile @@ -9,13 +9,13 @@ gem 'sqlite3', '>= 2.1' # Use the Puma web server [https://github.com/puma/puma] gem 'puma', '>= 5.0' # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] -gem 'jsbundling-rails' +# gem 'jsbundling-rails' # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] # gem "turbo-rails" # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] # gem "stimulus-rails" # Bundle and process CSS [https://github.com/rails/cssbundling-rails] -gem 'cssbundling-rails' +# gem 'cssbundling-rails' # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem 'jbuilder' @@ -26,9 +26,9 @@ gem 'jbuilder' gem 'shrine', '~> 3.0' # Use the database-backed adapters for Rails.cache, Active Job, and Action Cable -gem 'solid_cable' -gem 'solid_cache' -gem 'solid_queue' +# gem 'solid_cable' +# gem 'solid_cache' +# gem 'solid_queue' # To create variants (different sizes) of screenshot images gem 'fastimage' @@ -167,3 +167,5 @@ gem 'rails-healthcheck' # (Dokku) uses environment variables to specify the database connection string # https://github.com/bkeepers/dotenv gem 'dotenv' + +gem "cssbundling-rails", "~> 1.4" diff --git a/Gemfile.lock b/Gemfile.lock index ec27a5d..8840abb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,8 +131,6 @@ GEM email_validator (2.2.4) activemodel erubi (1.13.1) - et-orbi (1.2.11) - tzinfo factory_bot (6.5.1) activesupport (>= 6.1.0) factory_bot_rails (6.4.4) @@ -158,9 +156,6 @@ GEM font-awesome-rails (4.7.0.9) railties (>= 3.2, < 9.0) formatador (1.1.0) - fugit (1.11.1) - et-orbi (~> 1, >= 1.2.11) - raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) gravtastic (3.2.6) @@ -196,8 +191,6 @@ GEM jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jsbundling-rails (1.3.1) - railties (>= 6.0.0) json (2.10.2) json-jwt (1.16.7) activesupport (>= 4.2) @@ -337,7 +330,6 @@ GEM public_suffix (6.0.1) puma (6.6.0) nio4r (~> 2.0) - raabro (1.4.0) racc (1.8.1) rack (3.1.12) rack-oauth2 (2.2.1) @@ -471,22 +463,6 @@ GEM actionpack (>= 3.1) railties (>= 3.1) slim (>= 3.0, < 6.0, != 5.0.0) - solid_cable (3.0.7) - actioncable (>= 7.2) - activejob (>= 7.2) - activerecord (>= 7.2) - railties (>= 7.2) - solid_cache (1.0.7) - activejob (>= 7.2) - activerecord (>= 7.2) - railties (>= 7.2) - solid_queue (1.1.4) - activejob (>= 7.1) - activerecord (>= 7.1) - concurrent-ruby (>= 1.3.1) - fugit (~> 1.11.0) - railties (>= 7.1) - thor (~> 1.3.1) sorbet-runtime (0.5.11934) sqlite3 (2.6.0-aarch64-linux-gnu) sqlite3 (2.6.0-aarch64-linux-musl) @@ -569,7 +545,7 @@ DEPENDENCIES bzip2-ffi cancancan capybara - cssbundling-rails + cssbundling-rails (~> 1.4) debug devise dotenv @@ -581,7 +557,6 @@ DEPENDENCIES guard-rails image_processing jbuilder - jsbundling-rails kamal listen (~> 3.5) mini_magick @@ -604,9 +579,6 @@ DEPENDENCIES selenium-webdriver shrine (~> 3.0) slim-rails - solid_cable - solid_cache - solid_queue sqlite3 (>= 2.1) thruster web-console diff --git a/Procfile.dev b/Procfile.dev index 3d2a66e..7eaba23 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,2 @@ web: env RUBY_DEBUG_OPEN=true bin/rails server -js: yarn build --watch css: bun run build:css --watch diff --git a/app/assets/javascripts/debshots.js b/app/assets/javascripts/debshots.js new file mode 100644 index 0000000..157f7ce --- /dev/null +++ b/app/assets/javascripts/debshots.js @@ -0,0 +1,131 @@ +// Entry point for the build script in your package.json +// import "@hotwired/turbo-rails"; +// import "jquery"; +// import "foundation-sites"; +// import 'foundation-sites/dist/css/foundation.min.css'; // CSS +// import "./controllers"; + +// // Entry point for the build script in your package.json + +// import "./jquery/dist/jquery.min.js"; +// import $ from './node_modules/jquery/dist/jquery.min.js'; + +// import jQuery from "../../jquery/dist/jquery.min.js"; // Direct file path +// window.$ = window.jQuery = jQuery; // Expose globally (if needed) + +// import "./foundation-sites/dist/js/foundation.min"; + + +// import jquery from "jquery"; + +// window.jQuery = jquery; +// window.$ = jquery; + +$(function () { + $(document).foundation(); +}); + +// Load reviews on package's details page +// load_reviews = function() { +// // Display message while loading reviews +// // $('#reviews').html("Loading reviews..."); + +// // Hide the DIV so that in can be faded in later +// $('#reviews').hide(); + +// // The URL is specified in the #reviews's DIV data attribute +// var url = $('#reviews').attr('data-package-reviews-url'); +// $('#reviews').load(url, null, +// // Fade in the reviews as soon as the DIV is loaded and filled +// function(){ +// $(this).fadeIn('slow') +// } +// ); +// }; + +// Initialize the upload form. +function upload_form_init() { + // Disable the submit button if Javascript is supported. + // Upload will start right after selecting images. + $('#file-submit').hide(); + + // Install event handler to notice when files were selected. + $('#file').on('change', upload_form_files_selected); +}; + +function upload_form_files_selected() { + no_files = this.files.length; + if (no_files > 0) { + $('#file-label').html(no_files+" files selected - uploading…"); // change label + $('#file-select-button').attr('disabled','disabled'); // disable select button + $('#file-form').trigger('submit'); // start upload + } +}; + + +// Handle Ctrl-V to paste an image directly +function upload_paste_handler(event) +{ + console.log("paste!"); + var items = (event.clipboardData || event.originalEvent.clipboardData).items; + + // /*Make Sure Only One File is Copied*/ + // if (items.length != 1) { + // return; + // } + + for (var i = 0 ; i < items.length ; i++) + { + var item = items[i]; + console.log(item); + console.log("item size="+item.size); + if (!item.type.startsWith('image/')) + { + console.log("Skipping file with type "+item.type); + continue + } + console.log(item.type); + var file = item.getAsFile(); + console.log(file); + upload_file_with_ajax(file); + } +} + +function upload_file_with_ajax(file) +{ + if (file==null) + { + console.log("File was null. Strange."); + display_error('Maybe the image was too large.'); + return; + } + var formData = new FormData(); + formData.append('file', file); + + $.ajax(ajax_upload_url, + { + type: 'POST', + contentType: false, + processData: false, + data: formData, + //dataType: 'json', + error: function(xhr, txt, err) + { + console.log("AJAX file upload returned error: "+txt+" / "+err); + response = JSON.parse(xhr.responseText); + display_error(response); + }, + success: function(res) + { + console.log("AJAX file upload was ok"); + // Go back to details page to show the new upload + window.location.replace(after_upload_url); + } + }); +} + +function display_error(msg) +{ + $('#messages').html( + '