├── .gitignore ├── .ruby-version ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── cable.js │ │ ├── channels │ │ │ └── .keep │ │ ├── datalist.js │ │ └── reorderable.js │ └── stylesheets │ │ ├── application.scss │ │ ├── presentation.scss │ │ └── slides.scss ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ ├── copy │ │ ├── destroyed_playlist_items_controller.rb │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb │ ├── create │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb │ ├── default │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb │ ├── destroy │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb │ ├── destroyed_playlist_items_controller.rb │ ├── final │ │ ├── destroyed_playlist_items_controller.rb │ │ ├── playlist_items_controller.rb │ │ ├── playlists_controller.rb │ │ └── posters_controller.rb │ ├── playlist_items_controller.rb │ ├── playlists_controller.rb │ ├── posters_controller.rb │ ├── presentation_controller.rb │ ├── reorder │ │ ├── destroyed_playlist_items_controller.rb │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb │ ├── slides_controller.rb │ ├── undo │ │ ├── destroyed_playlist_items_controller.rb │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb │ └── update │ │ ├── destroyed_playlist_items_controller.rb │ │ ├── playlist_items_controller.rb │ │ └── playlists_controller.rb ├── helpers │ ├── application_helper.rb │ └── playlists_helper.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ ├── concerns │ │ ├── .keep │ │ └── reorderable.rb │ ├── playlist.rb │ ├── playlist_item.rb │ └── poster.rb └── views │ ├── application │ ├── _flash_notice.html.erb │ └── _flash_undo.html.erb │ ├── copy │ ├── destroyed_playlist_items │ │ └── update.js.erb │ ├── playlist_items │ │ ├── _form.html.erb │ │ ├── _playlist_item.html.erb │ │ ├── create.js.erb │ │ ├── destroy.js.erb │ │ └── update.js.erb │ └── playlists │ │ └── show.html.erb │ ├── create │ ├── playlist_items │ │ ├── _form.html.erb │ │ ├── _playlist_item.html.erb │ │ └── create.js.erb │ └── playlists │ │ └── show.html.erb │ ├── default │ ├── application │ │ └── _flash_notice.html.erb │ ├── playlist_items │ │ ├── _form.html.erb │ │ └── _playlist_item.html.erb │ └── playlists │ │ └── show.html.erb │ ├── destroy │ ├── playlist_items │ │ ├── _form.html.erb │ │ ├── _playlist_item.html.erb │ │ ├── create.js.erb │ │ └── destroy.js.erb │ └── playlists │ │ └── show.html.erb │ ├── final │ ├── application │ │ ├── _flash_notice.html.erb │ │ └── _flash_undo.html.erb │ ├── destroyed_playlist_items │ │ └── update.js.erb │ ├── playlist_items │ │ ├── _form.html.erb │ │ ├── _playlist_item.html.erb │ │ ├── create.js.erb │ │ ├── destroy.js.erb │ │ └── update.js.erb │ └── playlists │ │ └── show.html.erb │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ ├── mailer.text.erb │ ├── presentation.html.erb │ └── slides.html.erb │ ├── presentation │ └── index.html.erb │ ├── reorder │ ├── destroyed_playlist_items │ │ └── update.js.erb │ ├── playlist_items │ │ ├── _form.html.erb │ │ ├── _playlist_item.html.erb │ │ ├── create.js.erb │ │ ├── destroy.js.erb │ │ └── update.js.erb │ └── playlists │ │ └── show.html.erb │ ├── slides │ ├── admin_framework.html.erb │ ├── controller.html.erb │ ├── copy-1.html.erb │ ├── copy-2.html.erb │ ├── create-1.html.erb │ ├── create-2.html.erb │ ├── definition.html.erb │ ├── destroy-1.html.erb │ ├── destroy-2.html.erb │ ├── kiosk.html.erb │ ├── latency.html.erb │ ├── libraries_not_used.html.erb │ ├── old_school.html.erb │ ├── orange_barrel.html.erb │ ├── rails_list.html.erb │ ├── render-flash.html.erb │ ├── reorder-1.html.erb │ ├── reorder-2.html.erb │ ├── reorder-3.html.erb │ ├── repo.html.erb │ ├── storytime.html.erb │ ├── thanks.erb │ ├── title.html.erb │ ├── undo-1.html.erb │ ├── undo-2.html.erb │ ├── undo-3.html.erb │ ├── update-1.html.erb │ ├── update-2.html.erb │ ├── what-we-didnt-do.html.erb │ └── yay_rails.html.erb │ ├── undo │ ├── destroyed_playlist_items │ │ └── update.js.erb │ ├── playlist_items │ │ ├── _form.html.erb │ │ ├── _playlist_item.html.erb │ │ ├── create.js.erb │ │ ├── destroy.js.erb │ │ └── update.js.erb │ └── playlists │ │ └── show.html.erb │ └── update │ ├── playlist_items │ ├── _form.html.erb │ ├── _playlist_item.html.erb │ ├── create.js.erb │ ├── destroy.js.erb │ └── update.js.erb │ └── playlists │ └── show.html.erb ├── bin ├── bundle ├── rails ├── rake ├── setup ├── spring ├── update └── yarn ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── content_security_policy.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── puma.rb ├── routes.rb ├── spring.rb └── storage.yml ├── db ├── migrate │ ├── 20180226020838_create_playlists.rb │ ├── 20180226022852_create_playlist_items.rb │ └── 20180304031049_create_posters.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── package.json ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico ├── kiosk.jpg ├── obm-logo.svg └── robots.txt ├── test ├── fixtures │ ├── playlist_item_posters.yml │ └── posters.yml └── models │ ├── playlist_item_poster_test.rb │ └── poster_test.rb ├── tmp └── .keep └── vendor └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore uploaded files in development 21 | /storage/* 22 | 23 | /node_modules 24 | /yarn-error.log 25 | 26 | /public/assets 27 | .byebug_history 28 | 29 | # Ignore master key for decrypting credentials and more. 30 | /config/master.key 31 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.5.0 -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.5.0' 5 | 6 | gem 'bootsnap', '>= 1.1.0', require: false 7 | gem 'bootstrap', '~> 4.0.0' 8 | gem 'coderay' 9 | gem 'jbuilder', '~> 2.5' 10 | gem 'puma', '~> 3.11' 11 | gem 'pry-rails' 12 | gem 'rails', '~> 5.2.0.rc1' 13 | gem 'sass-rails', '~> 5.0' 14 | gem 'sqlite3' 15 | gem 'turbolinks', '~> 5' 16 | gem 'uglifier', '>= 1.3.0' 17 | 18 | # Use ActiveStorage variant 19 | # gem 'mini_magick', '~> 4.8' 20 | 21 | group :development, :test do 22 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 23 | end 24 | 25 | group :development do 26 | gem 'listen', '>= 3.0.5', '< 3.2' 27 | gem 'spring' 28 | gem 'spring-watcher-listen', '~> 2.0.0' 29 | gem 'web-console', '>= 3.3.0' 30 | end 31 | 32 | group :test do 33 | gem 'capybara', '~> 2.15' 34 | gem 'chromedriver-helper' 35 | gem 'selenium-webdriver' 36 | end 37 | 38 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 39 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 40 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.2.0) 5 | actionpack (= 5.2.0) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailer (5.2.0) 9 | actionpack (= 5.2.0) 10 | actionview (= 5.2.0) 11 | activejob (= 5.2.0) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.2.0) 15 | actionview (= 5.2.0) 16 | activesupport (= 5.2.0) 17 | rack (~> 2.0) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.2.0) 22 | activesupport (= 5.2.0) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.2.0) 28 | activesupport (= 5.2.0) 29 | globalid (>= 0.3.6) 30 | activemodel (5.2.0) 31 | activesupport (= 5.2.0) 32 | activerecord (5.2.0) 33 | activemodel (= 5.2.0) 34 | activesupport (= 5.2.0) 35 | arel (>= 9.0) 36 | activestorage (5.2.0) 37 | actionpack (= 5.2.0) 38 | activerecord (= 5.2.0) 39 | marcel (~> 0.3.1) 40 | activesupport (5.2.0) 41 | concurrent-ruby (~> 1.0, >= 1.0.2) 42 | i18n (>= 0.7, < 2) 43 | minitest (~> 5.1) 44 | tzinfo (~> 1.1) 45 | addressable (2.5.2) 46 | public_suffix (>= 2.0.2, < 4.0) 47 | archive-zip (0.11.0) 48 | io-like (~> 0.3.0) 49 | arel (9.0.0) 50 | autoprefixer-rails (8.0.0) 51 | execjs 52 | bindex (0.5.0) 53 | bootsnap (1.1.8) 54 | msgpack (~> 1.0) 55 | bootstrap (4.0.0) 56 | autoprefixer-rails (>= 6.0.3) 57 | popper_js (>= 1.12.9, < 2) 58 | sass (>= 3.5.2) 59 | builder (3.2.3) 60 | byebug (10.0.0) 61 | capybara (2.18.0) 62 | addressable 63 | mini_mime (>= 0.1.3) 64 | nokogiri (>= 1.3.3) 65 | rack (>= 1.0.0) 66 | rack-test (>= 0.5.4) 67 | xpath (>= 2.0, < 4.0) 68 | childprocess (0.8.0) 69 | ffi (~> 1.0, >= 1.0.11) 70 | chromedriver-helper (1.2.0) 71 | archive-zip (~> 0.10) 72 | nokogiri (~> 1.8) 73 | coderay (1.1.2) 74 | concurrent-ruby (1.0.5) 75 | crass (1.0.4) 76 | erubi (1.7.1) 77 | execjs (2.7.0) 78 | ffi (1.9.23) 79 | globalid (0.4.1) 80 | activesupport (>= 4.2.0) 81 | i18n (1.0.0) 82 | concurrent-ruby (~> 1.0) 83 | io-like (0.3.0) 84 | jbuilder (2.7.0) 85 | activesupport (>= 4.2.0) 86 | multi_json (>= 1.2) 87 | listen (3.1.5) 88 | rb-fsevent (~> 0.9, >= 0.9.4) 89 | rb-inotify (~> 0.9, >= 0.9.7) 90 | ruby_dep (~> 1.2) 91 | loofah (2.2.2) 92 | crass (~> 1.0.2) 93 | nokogiri (>= 1.5.9) 94 | mail (2.7.0) 95 | mini_mime (>= 0.1.1) 96 | marcel (0.3.2) 97 | mimemagic (~> 0.3.2) 98 | method_source (0.9.0) 99 | mimemagic (0.3.2) 100 | mini_mime (1.0.0) 101 | mini_portile2 (2.3.0) 102 | minitest (5.11.3) 103 | msgpack (1.2.2) 104 | multi_json (1.13.1) 105 | nio4r (2.3.0) 106 | nokogiri (1.8.2) 107 | mini_portile2 (~> 2.3.0) 108 | popper_js (1.12.9) 109 | pry (0.11.3) 110 | coderay (~> 1.1.0) 111 | method_source (~> 0.9.0) 112 | pry-rails (0.3.6) 113 | pry (>= 0.10.4) 114 | public_suffix (3.0.2) 115 | puma (3.11.2) 116 | rack (2.0.4) 117 | rack-test (1.0.0) 118 | rack (>= 1.0, < 3) 119 | rails (5.2.0) 120 | actioncable (= 5.2.0) 121 | actionmailer (= 5.2.0) 122 | actionpack (= 5.2.0) 123 | actionview (= 5.2.0) 124 | activejob (= 5.2.0) 125 | activemodel (= 5.2.0) 126 | activerecord (= 5.2.0) 127 | activestorage (= 5.2.0) 128 | activesupport (= 5.2.0) 129 | bundler (>= 1.3.0) 130 | railties (= 5.2.0) 131 | sprockets-rails (>= 2.0.0) 132 | rails-dom-testing (2.0.3) 133 | activesupport (>= 4.2.0) 134 | nokogiri (>= 1.6) 135 | rails-html-sanitizer (1.0.4) 136 | loofah (~> 2.2, >= 2.2.2) 137 | railties (5.2.0) 138 | actionpack (= 5.2.0) 139 | activesupport (= 5.2.0) 140 | method_source 141 | rake (>= 0.8.7) 142 | thor (>= 0.18.1, < 2.0) 143 | rake (12.3.1) 144 | rb-fsevent (0.10.2) 145 | rb-inotify (0.9.10) 146 | ffi (>= 0.5.0, < 2) 147 | ruby_dep (1.5.0) 148 | rubyzip (1.2.1) 149 | sass (3.5.5) 150 | sass-listen (~> 4.0.0) 151 | sass-listen (4.0.0) 152 | rb-fsevent (~> 0.9, >= 0.9.4) 153 | rb-inotify (~> 0.9, >= 0.9.7) 154 | sass-rails (5.0.7) 155 | railties (>= 4.0.0, < 6) 156 | sass (~> 3.1) 157 | sprockets (>= 2.8, < 4.0) 158 | sprockets-rails (>= 2.0, < 4.0) 159 | tilt (>= 1.1, < 3) 160 | selenium-webdriver (3.9.0) 161 | childprocess (~> 0.5) 162 | rubyzip (~> 1.2) 163 | spring (2.0.2) 164 | activesupport (>= 4.2) 165 | spring-watcher-listen (2.0.1) 166 | listen (>= 2.7, < 4.0) 167 | spring (>= 1.2, < 3.0) 168 | sprockets (3.7.1) 169 | concurrent-ruby (~> 1.0) 170 | rack (> 1, < 3) 171 | sprockets-rails (3.2.1) 172 | actionpack (>= 4.0) 173 | activesupport (>= 4.0) 174 | sprockets (>= 3.0.0) 175 | sqlite3 (1.3.13) 176 | thor (0.20.0) 177 | thread_safe (0.3.6) 178 | tilt (2.0.8) 179 | turbolinks (5.1.0) 180 | turbolinks-source (~> 5.1) 181 | turbolinks-source (5.1.0) 182 | tzinfo (1.2.5) 183 | thread_safe (~> 0.1) 184 | uglifier (4.1.6) 185 | execjs (>= 0.3.0, < 3) 186 | web-console (3.5.1) 187 | actionview (>= 5.0) 188 | activemodel (>= 5.0) 189 | bindex (>= 0.4.0) 190 | railties (>= 5.0) 191 | websocket-driver (0.7.0) 192 | websocket-extensions (>= 0.1.0) 193 | websocket-extensions (0.1.3) 194 | xpath (3.0.0) 195 | nokogiri (~> 1.8) 196 | 197 | PLATFORMS 198 | ruby 199 | 200 | DEPENDENCIES 201 | bootsnap (>= 1.1.0) 202 | bootstrap (~> 4.0.0) 203 | byebug 204 | capybara (~> 2.15) 205 | chromedriver-helper 206 | coderay 207 | jbuilder (~> 2.5) 208 | listen (>= 3.0.5, < 3.2) 209 | pry-rails 210 | puma (~> 3.11) 211 | rails (~> 5.2.0.rc1) 212 | sass-rails (~> 5.0) 213 | selenium-webdriver 214 | spring 215 | spring-watcher-listen (~> 2.0.0) 216 | sqlite3 217 | turbolinks (~> 5) 218 | tzinfo-data 219 | uglifier (>= 1.3.0) 220 | web-console (>= 3.3.0) 221 | 222 | RUBY VERSION 223 | ruby 2.5.0p0 224 | 225 | BUNDLED WITH 226 | 1.16.1 227 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Setup 4 | 5 | Should work just with SQLite3 6 | 7 | - `rails db:migrate && rails db:seed` 8 | - `rails s` 9 | 10 | ## Todos: 11 | 12 | - [ ] Disable table on Re-order 13 | - [ ] Refactor destroyed resource route 14 | - [ ] Finish combobox ajax 15 | - [ ] Refactor reorder unobtrusive JS 16 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will 2 | // include all the files listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or 5 | // any plugin's vendor/assets/javascripts directory can be referenced here 6 | // using a relative path. 7 | // 8 | // It's not advisable to add code directly here, but if you do, it'll appear at 9 | // the bottom of the compiled file. JavaScript code in this file should be 10 | // added after the last require_* statement. 11 | // 12 | // Read Sprockets README 13 | // (https://github.com/rails/sprockets#sprockets-directives) for details 14 | // about supported directives. 15 | // 16 | //= require rails-ujs 17 | //= require activestorage 18 | //= require turbolinks 19 | //= require reorderable 20 | //= require datalist 21 | //= require_tree . 22 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the 3 | // `rails generate channel` command. 4 | // 5 | //= require action_cable 6 | //= require_self 7 | //= require_tree ./channels 8 | 9 | (function() { 10 | this.App || (this.App = {}); 11 | 12 | App.cable = ActionCable.createConsumer(); 13 | 14 | }).call(this); 15 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/datalist.js: -------------------------------------------------------------------------------- 1 | function fetchData(event) { 2 | var url = event.target.getAttribute("data-datalist") 3 | var list = event.target.getAttribute("list") 4 | console.log(url, list) 5 | } 6 | 7 | function makeDatalist() { 8 | if (node = document.querySelector('[data-datalist]')) { 9 | node.addEventListener("keyup", fetchData); 10 | } 11 | } 12 | 13 | document.addEventListener("turbolinks:load", makeDatalist) 14 | -------------------------------------------------------------------------------- /app/assets/javascripts/reorderable.js: -------------------------------------------------------------------------------- 1 | function reorder(event) { 2 | var container = event.target.closest('[data-reorderable]'); 3 | var target = event.target.closest('[draggable]'); 4 | var data = event.dataTransfer.getData("text"); 5 | var index = Array.from(container.children).indexOf(target) + 1; 6 | var url = container.getAttribute("data-reorderable"); 7 | reorder_requset(url, data, index); 8 | } 9 | 10 | function reorder_requset(url, data, index) { 11 | data = data.split('-'); 12 | Rails.ajax({ 13 | data: '&['+ data[0] +']position=' + index, 14 | url: url + '/' + data[1], 15 | type: 'PATCH', 16 | }) 17 | } 18 | 19 | function allowDrop(event) { 20 | event.preventDefault(); 21 | } 22 | 23 | function setData(event) { 24 | event.dataTransfer.setData("text", event.target.id); 25 | } 26 | 27 | function makeReorderable() { 28 | if (node = document.querySelector('[data-reorderable]')) { 29 | node.addEventListener("dragstart", setData); 30 | node.addEventListener("dragover", allowDrop); 31 | node.addEventListener("drop", reorder); 32 | } 33 | } 34 | 35 | document.addEventListener("turbolinks:load", makeReorderable) 36 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will 3 | * include all the files listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any 6 | * plugin's vendor/assets/stylesheets directory can be referenced here using a 7 | * relative path. 8 | * 9 | * You're free to add application-wide styles to this file and they'll appear 10 | * at the bottom of the compiled file so the styles you add here take 11 | * precedence over styles defined in any other CSS/SCSS files in this 12 | * directory. Styles in this file should be added after the last require_* 13 | * statement. It is generally better to create a new file per style scope. 14 | * 15 | *= require_tree . 16 | *= require_self 17 | */ 18 | 19 | @import "bootstrap"; 20 | 21 | tr form { 22 | display: inline; 23 | } 24 | 25 | .table td { 26 | vertical-align: middle; 27 | } 28 | -------------------------------------------------------------------------------- /app/assets/stylesheets/presentation.scss: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | 5 | body { 6 | display: flex; 7 | flex-direction: column; 8 | height: 100%; 9 | margin: 0; 10 | } 11 | 12 | iframe { 13 | border: 0; 14 | height: 93vh; 15 | width: 100%; 16 | } 17 | 18 | #slide-navigation { 19 | background: darkgray; 20 | text-align: center; 21 | flex: auto; 22 | } 23 | -------------------------------------------------------------------------------- /app/assets/stylesheets/slides.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap"; 2 | 3 | html { 4 | height: 100%; 5 | } 6 | 7 | body { 8 | height: 100%; 9 | margin: 0; 10 | } 11 | 12 | .slide { 13 | box-sizing: border-box; 14 | height: 100%; 15 | padding: 2em 15%; 16 | 17 | code strong { 18 | text-decoration: underline; 19 | } 20 | 21 | .centered { 22 | height: 100%; 23 | align-items: center; 24 | justify-content: center; 25 | display: flex; 26 | } 27 | 28 | h1 { 29 | text-align: center; 30 | } 31 | 32 | .main-list { 33 | font-size: 200%; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/copy/destroyed_playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Copy::DestroyedPlaylistItemsController < DestroyedPlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/copy/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Copy::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/copy/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Copy::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/create/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Create::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/create/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Create::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/default/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Default::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/default/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Default::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/destroy/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Destroy::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/destroy/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Destroy::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/destroyed_playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class DestroyedPlaylistItemsController < ApplicationController 2 | before_action :set_playlist_item, only: :update 3 | 4 | def update 5 | @playlist_item.update playlist_item_params 6 | end 7 | 8 | private 9 | 10 | def set_playlist_item 11 | @playlist_item = PlaylistItem.unscoped 12 | .where.not(destroyed_at: nil).find params[:id] 13 | end 14 | 15 | def playlist_item_params 16 | params.require(:playlist_item).permit :destroyed_at 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/controllers/final/destroyed_playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Final::DestroyedPlaylistItemsController < DestroyedPlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/final/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Final::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/final/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Final::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/final/posters_controller.rb: -------------------------------------------------------------------------------- 1 | class Final::PostersController < PostersController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class PlaylistItemsController < ApplicationController 2 | before_action :set_playlist, only: %i[create update destroy] 3 | before_action :set_playlist_item, only: %i[update destroy] 4 | 5 | def create 6 | @playlist_item = @playlist.playlist_items.new playlist_item_params 7 | 8 | if @playlist_item.save 9 | respond_to do |format| 10 | format.js 11 | format.html do 12 | redirect_to request.referrer 13 | flash[:notice] = :Created 14 | end 15 | end 16 | else 17 | # TODO: Add some failure handling 👍 18 | end 19 | end 20 | 21 | def update 22 | @playlist_item.update playlist_item_params 23 | end 24 | 25 | def destroy 26 | if @playlist_item.destroy 27 | respond_to do |format| 28 | format.js 29 | format.html do 30 | redirect_to request.referrer 31 | flash[:notice] = :Destroyed 32 | end 33 | end 34 | else 35 | # TODO: Add some failure handling 👍 36 | end 37 | end 38 | 39 | private 40 | 41 | def set_playlist_item 42 | @playlist_item = @playlist.playlist_items.find params[:id] 43 | end 44 | 45 | def set_playlist 46 | @playlist = Playlist.find params[:playlist_id] 47 | end 48 | 49 | def playlist_item_params 50 | params.require(:playlist_item) 51 | .permit :duration, :poster_id, :position, :poster_name 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /app/controllers/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class PlaylistsController < ApplicationController 2 | before_action :set_playlist, only: %i[show] 3 | 4 | def show 5 | end 6 | 7 | private 8 | 9 | def set_playlist 10 | @playlist = Playlist.find params[:id] 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/controllers/posters_controller.rb: -------------------------------------------------------------------------------- 1 | class PostersController < ApplicationController 2 | def index 3 | Poster.all 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/presentation_controller.rb: -------------------------------------------------------------------------------- 1 | class PresentationController < ApplicationController 2 | SLIDES = %w[ 3 | slides/title 4 | slides/repo 5 | slides/storytime 6 | slides/orange_barrel 7 | slides/kiosk 8 | slides/admin_framework 9 | slides/yay_rails 10 | slides/rails_list 11 | slides/old_school 12 | default/playlists/1 13 | slides/controller 14 | slides/create-1 15 | slides/create-2 16 | create/playlists/1 17 | slides/destroy-1 18 | slides/destroy-2 19 | destroy/playlists/1 20 | slides/render-flash 21 | slides/update-1 22 | update/playlists/1 23 | slides/update-2 24 | slides/undo-1 25 | slides/undo-2 26 | undo/playlists/1 27 | slides/undo-3 28 | slides/copy-1 29 | slides/copy-2 30 | copy/playlists/1 31 | slides/reorder-1 32 | reorder/playlists/1 33 | slides/reorder-2 34 | slides/reorder-3 35 | final/playlists/1 36 | slides/latency 37 | final/playlists/1 38 | slides/what-we-didnt-do 39 | slides/thanks 40 | ] 41 | 42 | def index 43 | @src = SLIDES[params[:index].to_i || 0] 44 | render layout: 'presentation' 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /app/controllers/reorder/destroyed_playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Reorder::DestroyedPlaylistItemsController < DestroyedPlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/reorder/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Reorder::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/reorder/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Reorder::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/slides_controller.rb: -------------------------------------------------------------------------------- 1 | class SlidesController < ApplicationController 2 | def show 3 | render params[:view], layout: 'slides' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/undo/destroyed_playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Undo::DestroyedPlaylistItemsController < DestroyedPlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/undo/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Undo::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/undo/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Undo::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/update/destroyed_playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Update::DestroyedPlaylistItemsController < DestroyedPlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/update/playlist_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Update::PlaylistItemsController < PlaylistItemsController 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/update/playlists_controller.rb: -------------------------------------------------------------------------------- 1 | class Update::PlaylistsController < PlaylistsController 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def replace_with(id, content) 3 | end 4 | 5 | def undo_destroy_path(model) 6 | name = model.model_name.singular 7 | params = [[name, { destroyed_at: nil }]].to_h 8 | polymorphic_path("destroyed_#{name}", params) 9 | end 10 | 11 | # TODO: Complete this 🤷 12 | def disable_test 13 | 'console.log("test")' 14 | end 15 | 16 | # TODO: Use Rails UJS setData/expando to stash original state 😎 17 | def show(model) 18 | raw "document.getElementById('#{model.html_id}').style.display = 'table-row'" 19 | end 20 | 21 | def hide(model) 22 | raw "document.getElementById('#{model.html_id}').style.display = 'none'" 23 | end 24 | 25 | def render_flash(partial: 'application/flash_notice', **locals) 26 | html = j render partial: partial, locals: locals 27 | raw "document.getElementById('flash').innerHTML = '#{html}'" 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /app/helpers/playlists_helper.rb: -------------------------------------------------------------------------------- 1 | module PlaylistsHelper 2 | def poster_choices 3 | Poster.order(name: :asc).collect { |p| [p.name, p.id] } 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | 4 | def html_id 5 | "#{model_name.singular}-#{id}" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/concerns/reorderable.rb: -------------------------------------------------------------------------------- 1 | module Reorderable 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | before_commit :reorder, if: :position_changed?, unless: :newly_created? 6 | before_create :set_position 7 | def reset_all 8 | siblings.each.with_index(1) { |s, i| s.update_column :position, i } 9 | end 10 | end 11 | 12 | def reorder 13 | from, to = previous_changes[:position] 14 | move_down(from, to) if from < to 15 | move_up(from, to) if from > to 16 | end 17 | 18 | def move_up(from, to) 19 | siblings 20 | .where.not(id: self) 21 | .where(column.lt(from)) 22 | .where(column.gteq(to)) 23 | .update_all update_sql(:+) 24 | end 25 | 26 | def move_down(from, to) 27 | siblings 28 | .where.not(id: self) 29 | .where(column.gt(from)) 30 | .where(column.lteq(to)) 31 | .update_all update_sql(:-) 32 | end 33 | 34 | def update_sql(sign) 35 | "position = position #{sign} 1, updated_at = '#{Time.current}'" 36 | end 37 | 38 | def position_changed? 39 | attribute_previously_changed? :position 40 | end 41 | 42 | def newly_created? 43 | attribute_previously_changed? :id 44 | end 45 | 46 | def set_position 47 | self.position = siblings.count + 1 48 | end 49 | 50 | def column 51 | self.class.arel_table[:position] 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /app/models/playlist.rb: -------------------------------------------------------------------------------- 1 | class Playlist < ApplicationRecord 2 | has_many :playlist_items, dependent: :destroy 3 | end 4 | -------------------------------------------------------------------------------- /app/models/playlist_item.rb: -------------------------------------------------------------------------------- 1 | class PlaylistItem < ApplicationRecord 2 | include Reorderable 3 | 4 | default_scope { where destroyed_at: nil } 5 | 6 | belongs_to :playlist, touch: true 7 | belongs_to :poster 8 | 9 | has_many :siblings, through: :playlist, source: :playlist_items 10 | 11 | def playlistable 12 | poster 13 | end 14 | 15 | def poster_name=(value) 16 | poster = Poster.find_by name_parameterized: value.parameterize 17 | self.poster = poster if poster 18 | end 19 | 20 | def copy_attrs 21 | { duration: self.duration, poster_id: self.poster_id } 22 | end 23 | 24 | # TODO: If destroyed, only allow `destroyed_at` to be set to `nil` 25 | 26 | def destroy 27 | raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly? 28 | # TODO: destroy_associations 29 | touch(:destroyed_at) if persisted? 30 | @destroyed = true 31 | freeze 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /app/models/poster.rb: -------------------------------------------------------------------------------- 1 | class Poster < ApplicationRecord 2 | has_many :playlist_items, as: :playlistable 3 | 4 | before_save :parameterize_name 5 | 6 | private 7 | 8 | def parameterize_name 9 | self.name_parameterized = self.name.parameterize 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/views/application/_flash_notice.html.erb: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/views/application/_flash_undo.html.erb: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/views/copy/destroyed_playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= render_flash message: 'Undone!' %> 2 | <%= show @playlist_item %> 3 | -------------------------------------------------------------------------------- /app/views/copy/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit( 18 | data: { disable_with: 'Submitting' }, 19 | class: 'btn btn-primary') %> 20 |
21 | <% end %> 22 | -------------------------------------------------------------------------------- /app/views/copy/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | 5 | <%= form_with(model: [:copy, playlist_item.playlist, playlist_item]) do |f| %> 6 | <%= f.label :duration, class: 'sr-only' %> 7 | <%= f.text_field :duration, 8 | id: :playlist_item_duration, 9 | autocomplete: :off, 10 | class: 'form-control', 11 | size: 3 %> 12 | <% end %> 13 | 14 | 15 | <%= button_to 'Copy', polymorphic_path([:copy, playlist_item.playlist, :playlist_items], 16 | playlist_item: playlist_item.copy_attrs), 17 | data: { disable_with: '…' }, 18 | class: 'btn btn-link', 19 | method: :create, 20 | remote: true %> 21 | 22 | <%= button_to raw('×'), 23 | [:copy, playlist_item.playlist, playlist_item], 24 | data: { disable_with: '…' }, 25 | class: 'btn btn-link', 26 | method: :delete, 27 | remote: true %> 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/views/copy/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | 11 | <%= render_flash message: 'Created' %> 12 | -------------------------------------------------------------------------------- /app/views/copy/playlist_items/destroy.js.erb: -------------------------------------------------------------------------------- 1 | <%= hide @playlist_item %> 2 | <%= render_flash message: 'Deleted', partial: 'application/flash_undo', 3 | link: button_to('Undo', copy_destroyed_playlist_item_path(@playlist_item, 4 | playlist_item: { destroyed_at: nil }), 5 | data: { disable_with: 'Restoring…' }, 6 | class: 'btn btn-link', 7 | method: :patch, 8 | remote: true) %> 9 | -------------------------------------------------------------------------------- /app/views/copy/playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= render_flash message: 'Updated' %> 2 | -------------------------------------------------------------------------------- /app/views/copy/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Copy Example
4 |
5 | 6 | 7 | <%= render @playlist.playlist_items.order :position %> 8 | 9 |
10 |
11 |
12 | <%= render partial: 'copy/playlist_items/form', locals: { 13 | playlist_item: [:copy, @playlist, PlaylistItem.new] } %> 14 |
15 | -------------------------------------------------------------------------------- /app/views/create/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit( 18 | data: { disable_with: 'Submitting' }, 19 | class: 'btn btn-primary') %> 20 |
21 | <% end %> 22 | -------------------------------------------------------------------------------- /app/views/create/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | <%= playlist_item.duration %> 5 | 6 | <%= link_to raw('×'), 7 | [:create, playlist_item.playlist, playlist_item], 8 | method: :delete %> 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/views/create/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | -------------------------------------------------------------------------------- /app/views/create/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Create Example
4 |
5 | 6 | 7 | <%= render @playlist.playlist_items.order :position %> 8 | 9 |
10 |
11 |
12 | <%= render partial: 'create/playlist_items/form', locals: { 13 | playlist_item: [:create, @playlist, PlaylistItem.new] } %> 14 |
15 | -------------------------------------------------------------------------------- /app/views/default/application/_flash_notice.html.erb: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/views/default/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item, local: true do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit(class: 'btn btn-primary') %> 18 |
19 | <% end %> 20 | -------------------------------------------------------------------------------- /app/views/default/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | <%= playlist_item.duration %> 5 | 6 | <%= link_to raw('×'), 7 | [:default, playlist_item.playlist, playlist_item], 8 | method: :delete %> 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/views/default/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Basic Example
4 |
5 | 6 | 7 | <%= render @playlist.playlist_items.order :position %> 8 | 9 |
10 |
11 |
12 | <%= render partial: 'default/playlist_items/form', locals: { 13 | playlist_item: [:default, @playlist, PlaylistItem.new] } %> 14 |
15 | -------------------------------------------------------------------------------- /app/views/destroy/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit( 18 | data: { disable_with: 'Submitting' }, 19 | class: 'btn btn-primary') %> 20 |
21 | <% end %> 22 | -------------------------------------------------------------------------------- /app/views/destroy/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | <%= playlist_item.duration %> 5 | 6 | <%= button_to raw('×'), 7 | [:destroy, playlist_item.playlist, playlist_item], 8 | data: { disable_with: '…' }, 9 | class: 'btn btn-link', 10 | method: :delete, 11 | remote: true %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/destroy/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | 11 | <%= render_flash message: 'Created' %> 12 | -------------------------------------------------------------------------------- /app/views/destroy/playlist_items/destroy.js.erb: -------------------------------------------------------------------------------- 1 | <%= hide @playlist_item %> 2 | <%= render_flash message: 'Deleted' %> 3 | -------------------------------------------------------------------------------- /app/views/destroy/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Destroy/Delete Example
4 |
5 | 6 | 7 | <%= render @playlist.playlist_items.order :position %> 8 | 9 |
10 |
11 |
12 | <%= render partial: 'destroy/playlist_items/form', locals: { 13 | playlist_item: [:destroy, @playlist, PlaylistItem.new] } %> 14 |
15 | -------------------------------------------------------------------------------- /app/views/final/application/_flash_notice.html.erb: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/views/final/application/_flash_undo.html.erb: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/views/final/destroyed_playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= flash message: 'Undone!' %> 2 | <%= show @playlist_item %> 3 | -------------------------------------------------------------------------------- /app/views/final/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%# form.label :poster_id %> 11 | <%# form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 | <%= form.label :poster_name %> 15 | <%= form.text_field :poster_name, 16 | data: { datalist: final_posters_path }, 17 | list: :poster_names, 18 | class: 'form-control' %> 19 | 20 | <% Poster.first(3).each do |poster| %> 21 | 22 | <% end %> 23 | 24 |
25 | 26 |
27 | <%= form.submit( 28 | data: { disable_with: 'Submitting' }, 29 | class: 'btn btn-primary') %> 30 |
31 | <% end %> 32 | -------------------------------------------------------------------------------- /app/views/final/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | 5 | <%= form_with(model: [:final, playlist_item.playlist, playlist_item]) do |f| %> 6 | <%= f.label :duration, class: 'sr-only' %> 7 | <%= f.text_field :duration, 8 | id: :playlist_item_duration, 9 | autocomplete: :off, 10 | class: 'form-control', 11 | size: 3 %> 12 | <% end %> 13 | 14 | 15 | <%= button_to 'Copy', 16 | polymorphic_path([:final, playlist_item.playlist, :playlist_items], 17 | playlist_item: playlist_item.copy_attrs), 18 | data: { disable_with: '…' }, 19 | class: 'btn btn-link', 20 | method: :create, 21 | remote: true %> 22 | 23 | <%= button_to raw('×'), 24 | [:final, playlist_item.playlist, playlist_item], 25 | data: { disable_with: '…' }, 26 | class: 'btn btn-link', 27 | method: :delete, 28 | remote: true %> 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/views/final/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | 11 | <%= render_flash message: 'Created' %> 12 | -------------------------------------------------------------------------------- /app/views/final/playlist_items/destroy.js.erb: -------------------------------------------------------------------------------- 1 | <%= hide @playlist_item %> 2 | <%= render_flash message: 'Deleted', partial: 'application/flash_undo', 3 | link: button_to('Undo', reorder_destroyed_playlist_item_path(@playlist_item, 4 | playlist_item: { destroyed_at: nil }), 5 | data: { disable_with: 'Restoring…' }, 6 | class: 'btn btn-link', 7 | method: :patch, 8 | remote: true) %> 9 | -------------------------------------------------------------------------------- /app/views/final/playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <% if @playlist_item.attribute_previously_changed? :position %> 2 | var content ='<%= j render(@playlist_item.siblings.order :position) %>' 3 | var node = document.getElementById('playlist_items').cloneNode(true); 4 | node.innerHTML = content; 5 | document.getElementById('playlist_items').replaceWith(node); 6 | makeReorderable() 7 | <%= render_flash message: 'Reordered' %> 8 | <% else %> 9 | <%= render_flash message: 'Updated' %> 10 | <% end %> 11 | -------------------------------------------------------------------------------- /app/views/final/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | Final form with Combobox 5 |
6 |
7 | 8 | 11 | <%= render @playlist.playlist_items.order :position %> 12 | 13 |
14 |
15 |
16 | <%= render partial: 'final/playlist_items/form', locals: { 17 | playlist_item: [:final, @playlist, PlaylistItem.new] } %> 18 |
19 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Old-school JavaScript in Rails 5 | <% options = { data: { 'turbolinks-track': :reload } } %> 6 | <%= csrf_meta_tags %> 7 | <%= stylesheet_link_tag :application, options %> 8 | <%= javascript_include_tag :application, options %> 9 | 10 | 11 | 14 |
15 |
16 | <% if flash[:notice] %> 17 | <%= render partial: 'flash_notice', locals: { 18 | message: flash[:notice] } %> 19 | <% end %> 20 |
21 |
22 | <%= yield %> 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/views/layouts/presentation.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Old School Javascript 5 | <%# options = { data: { 'turbolinks-track': :reload } } %> 6 | <%# csrf_meta_tags %> 7 | <%= stylesheet_link_tag :presentation %> 8 | <%# javascript_include_tag :application, options %> 9 | 10 | 11 | <%= yield %> 12 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /app/views/layouts/slides.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Old School Javascript 5 | <%# options = { data: { 'turbolinks-track': :reload } } %> 6 | <%# csrf_meta_tags %> 7 | <%= stylesheet_link_tag :slides %> 8 | <%# javascript_include_tag :application, options %> 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/presentation/index.html.erb: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/views/reorder/destroyed_playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= render_flash message: 'Undone!' %> 2 | <%= show @playlist_item %> 3 | -------------------------------------------------------------------------------- /app/views/reorder/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit( 18 | data: { disable_with: 'Submitting' }, 19 | class: 'btn btn-primary') %> 20 |
21 | <% end %> 22 | -------------------------------------------------------------------------------- /app/views/reorder/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | 5 | <%= form_with(model: [:reorder, playlist_item.playlist, playlist_item]) do |f| %> 6 | <%= f.label :duration, class: 'sr-only' %> 7 | <%= f.text_field :duration, 8 | id: :playlist_item_duration, 9 | autocomplete: :off, 10 | class: 'form-control', 11 | size: 3 %> 12 | <% end %> 13 | 14 | 15 | <%= button_to 'Copy', polymorphic_path([:reorder, playlist_item.playlist, :playlist_items], 16 | playlist_item: playlist_item.copy_attrs), 17 | data: { disable_with: '…' }, 18 | class: 'btn btn-link', 19 | method: :create, 20 | remote: true %> 21 | 22 | <%= button_to raw('×'), 23 | [:reorder, playlist_item.playlist, playlist_item], 24 | data: { disable_with: '…' }, 25 | class: 'btn btn-link', 26 | method: :delete, 27 | remote: true %> 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/views/reorder/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | 11 | <%= render_flash message: 'Created' %> 12 | -------------------------------------------------------------------------------- /app/views/reorder/playlist_items/destroy.js.erb: -------------------------------------------------------------------------------- 1 | <%= hide @playlist_item %> 2 | <%= render_flash message: 'Deleted', partial: 'application/flash_undo', 3 | link: button_to('Undo', reorder_destroyed_playlist_item_path(@playlist_item, 4 | playlist_item: { destroyed_at: nil }), 5 | data: { disable_with: 'Restoring…' }, 6 | class: 'btn btn-link', 7 | method: :patch, 8 | remote: true) %> 9 | -------------------------------------------------------------------------------- /app/views/reorder/playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <% if @playlist_item.attribute_previously_changed? :position %> 2 | var content ='<%= j render(@playlist_item.siblings.order :position) %>' 3 | var node = document.getElementById('playlist_items').cloneNode(true); 4 | node.innerHTML = content; 5 | document.getElementById('playlist_items').replaceWith(node); 6 | makeReorderable() 7 | <%= render_flash message: 'Reordered' %> 8 | <% else %> 9 | <%= render_flash message: 'Updated' %> 10 | <% end %> 11 | -------------------------------------------------------------------------------- /app/views/reorder/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Reordering
4 |
5 | 6 | 8 | <%= render @playlist.playlist_items.order :position %> 9 | 10 |
11 |
12 |
13 | <%= render partial: 'reorder/playlist_items/form', locals: { 14 | playlist_item: [:reorder, @playlist, PlaylistItem.new] } %> 15 |
16 | -------------------------------------------------------------------------------- /app/views/slides/admin_framework.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Admin Framework

3 | 4 | 12 |
13 | -------------------------------------------------------------------------------- /app/views/slides/controller.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <% file = 'app/controllers/playlist_items_controller.rb' %> 3 | <%== CodeRay.highlight_file(file, css: :style) %> 4 |
5 | -------------------------------------------------------------------------------- /app/views/slides/copy-1.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Copy

3 | 4 |
5 | models/playlist_item.rb 6 |

7 | 8 | 9 | def copy_attrs
10 |   { duration: self.duration, poster_id: self.poster_id }
11 | end
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /app/views/slides/copy-2.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Copy

3 | 4 |
5 | playlist_items/_playlist_item.html.erb 6 |

7 | 8 | 9 | <td class="text-right">
10 |   <%%= button_to 'Copy',
11 |     polymorphic_path([playlist_item.playlist, :playlist_items],
12 |       playlist_item: playlist_item.copy_attrs),
13 |     data: { disable_with: '…' },
14 |     method: :create,
15 |     remote: true %>
16 |
17 |
18 |
19 | -------------------------------------------------------------------------------- /app/views/slides/create-1.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Remote Create

3 | 4 |
5 | Create Form 6 |
7 |
8 | 9 | <%%= form_with model: playlist_item, local: true 10 | do |form| %> 11 |
12 | <%% end %> 13 |
14 | 15 |

16 | 17 | 18 | <%%= form_with model: playlist_item do |form| %> 19 |
20 | <%% end %> 21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /app/views/slides/create-2.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Remote Create

3 | 4 |
5 | playlist_items/create.js.erb 6 | 7 |

8 | 9 | 10 | var content = '<%%= j render @playlist_item %>' 11 |
12 | 13 |
14 | document
15 |   .getElementById('playlist_items')
16 |   .insertAdjacentHTML('beforeend', content) 17 |
18 |
19 | 20 | document
21 |   .querySelector('[action$="/playlist_items"]')
22 |   .reset()
23 |
24 |
25 |
26 | -------------------------------------------------------------------------------- /app/views/slides/definition.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

What do we mean by "Old-school"?

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/destroy-1.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Remote Destroy

3 | 4 |
5 | playlist_items/_playlist_item.js.erb 6 |

7 | 8 | Was 9 |

10 | 11 | 12 | 13 | <%%= link_to '×', 14 | [playlist_item.playlist, playlist_item], 15 | method: :delete %> 16 | 17 | 18 |

19 | 20 | Change to 21 |

22 | 23 | 24 | 25 | <%%= button_to '×', [playlist_item.playlist, playlist_item],
26 |   data: { disable_with: '…' },
27 |   method: :delete,
28 |   remote: true %> 29 | 30 |
31 |

32 |
33 |
34 | -------------------------------------------------------------------------------- /app/views/slides/destroy-2.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Remote Destroy

3 | 4 |
5 | playlist_items/destroy.js.erb 6 |

7 | 8 | 9 | <%%= hide @playlist_item %>
10 | <%%= render_flash message: 'Deleted' %> 11 |
12 |

13 | 14 | helpers/application_helper.rb 15 |

16 | 17 | 18 | def hide(model)
19 |   raw "document.getElementById('#{model.html_id}').style.display = 'none'"
20 | end 21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /app/views/slides/kiosk.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 | -------------------------------------------------------------------------------- /app/views/slides/latency.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Latency and Modile

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/libraries_not_used.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

libraries not used in this talk

3 | 4 | 11 |
12 | -------------------------------------------------------------------------------- /app/views/slides/old_school.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

"Old School"

3 | 4 | 12 | * Plus the UJS library Rails ships with 13 |
14 | -------------------------------------------------------------------------------- /app/views/slides/orange_barrel.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 | -------------------------------------------------------------------------------- /app/views/slides/rails_list.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Just Plain Rails Admin Panel 🍦

3 | 4 | 11 |
12 | -------------------------------------------------------------------------------- /app/views/slides/render-flash.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Render Flash

3 | 4 |
5 | helpers/application_helper.rb 6 |

7 | 8 | 9 | def render_flash(partial: 'application/flash_notice', **locals)
10 |   html = j render partial: partial, locals: locals
11 |   raw "document.getElementById('flash').innerHTML = '#{html}'"
12 | end 13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /app/views/slides/reorder-1.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Reordering

3 | 4 |
5 | playlists/show.html.erb 6 |

7 | 8 | 9 | <tbody data-reorderable="<%%= playlist_playlist_items_path @playlist %>" 10 |
11 |       id="playlist_items">
12 |   <%%= render @playlist.playlist_items.order :position%>
13 | </tbody>

14 |
15 | 16 | playlists/_playlist_item.html.erb 17 |

18 | 19 | 20 | <tr id="<%%= playlist_item.html_id %>" draggable="true"> 21 | 22 |
23 |
24 | -------------------------------------------------------------------------------- /app/views/slides/reorder-2.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Reordering

3 | 4 |
5 | playlists/update.html.erb 6 |

7 | 8 | 9 | <%% if @playlist_item.attribute_previously_changed? :position %>
10 |   var content ='<%%= j render(@playlist_item.siblings.order :position) %>'
11 |   var node = document.getElementById('playlist_items').cloneNode(true);
12 |   node.innerHTML = content;
13 |   document.getElementById('playlist_items').replaceWith(node);
14 |   makeReorderable()
15 |   <%%= render_flash message: 'Reordered' %>
16 | <%% else %>
17 |   <%%= render_flash message: 'Updated' %>
18 | <%% end %>
19 |
20 |
21 |
22 | -------------------------------------------------------------------------------- /app/views/slides/reorder-3.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Reordering

3 | 4 |
5 | reorderable.js 6 |

7 | 8 | 9 | function allowDrop(event) {
10 |   event.preventDefault();
11 | }
12 |
13 | function setData(event) {
14 |   event.dataTransfer.setData("text", event.target.id);
15 | }
16 |
17 | function makeReorderable() {
18 |   if (node = document.querySelector('[data-reorderable]')) {
19 |     node.addEventListener("dragstart", setData);
20 |     node.addEventListener("dragover", allowDrop);
21 |     node.addEventListener("drop", reorder);
22 |   }
23 | }
24 |
25 | document.addEventListener("turbolinks:load", makeReorderable)
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /app/views/slides/repo.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Github: conzett/old-school-javascript

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/storytime.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Story Time 📖

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/thanks.erb: -------------------------------------------------------------------------------- 1 |
2 |

Thanks! Questions?

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/title.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Old-school JavaScript in Rails

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/undo-1.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Soft Deletes

3 | 4 |
5 | destroyed_playlist_items_controller.rb 6 |

7 | 8 | 9 | def set_playlist_item
10 |   @playlist_item = PlaylistItem.unscoped
11 |     .where.not(destroyed_at: nil).find params[:id]
12 | end
13 |
14 | def playlist_item_params
15 |   params.require(:playlist_item).permit :destroyed_at
16 | end 17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /app/views/slides/undo-2.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Undo Functionality

3 | 4 |
5 | playlist_items/destroy.js.erb 6 |

7 | 8 | 9 | <%%= hide @playlist_item %>

10 | <%% link = button_to('Undo',
11 |     destroyed_playlist_item_path(@playlist_item, playlist_item: { destroyed_at: nil }),
12 |     data: { disable_with: 'Restoring…' },
13 |     class: 'btn btn-link',
14 |     method: :patch,
15 |     remote: true) %>
16 |
17 | <%%= render_flash message: 'Deleted', partial: 'application/flash_undo', link: link %> 18 |
19 |
20 |
21 | -------------------------------------------------------------------------------- /app/views/slides/undo-3.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Undo Functionality

3 | 4 |
5 | destroyed_playlist_items/update.js.erb 6 |

7 | 8 | 9 | <%%= render_flash message: 'Undone!' %>
10 | <%%= show @playlist_item %>
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /app/views/slides/update-1.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Inline Updates

3 | 4 |
5 | playlist_items/_playlist_item.js.erb 6 |

7 | 8 | Was 9 |

10 | 11 | 12 | <%%= playlist_item.duration %> 13 | 14 |

15 | 16 | Change to 17 |

18 | 19 | 20 | 21 | <%%= form_with(model: [playlist_item.playlist, playlist_item] do |f| %>
22 |   <%%= f.label :duration, class: 'sr-only' %>
23 |   <%%= f.text_field :duration, size: 3 %>
24 | <%% end %> 25 | 26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /app/views/slides/update-2.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Inline Updates

3 | 4 |
5 | playlist_items/update.js.erb 6 |

7 | 8 | 9 | <%%= render_flash message: 'Updated' %> 10 | 11 |
12 |
13 | -------------------------------------------------------------------------------- /app/views/slides/what-we-didnt-do.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

What we didn't do.

3 |
4 | -------------------------------------------------------------------------------- /app/views/slides/yay_rails.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Let's just use Rails! 🚂

3 |
4 | -------------------------------------------------------------------------------- /app/views/undo/destroyed_playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= render_flash message: 'Undone!' %> 2 | <%= show @playlist_item %> 3 | -------------------------------------------------------------------------------- /app/views/undo/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit( 18 | data: { disable_with: 'Submitting' }, 19 | class: 'btn btn-primary') %> 20 |
21 | <% end %> 22 | -------------------------------------------------------------------------------- /app/views/undo/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | 5 | <%= form_with(model: [:undo, playlist_item.playlist, playlist_item]) do |f| %> 6 | <%= f.label :duration, class: 'sr-only' %> 7 | <%= f.text_field :duration, 8 | id: :playlist_item_duration, 9 | autocomplete: :off, 10 | class: 'form-control', 11 | size: 3 %> 12 | <% end %> 13 | 14 | 15 | <%= button_to raw('×'), 16 | [:undo, playlist_item.playlist, playlist_item], 17 | data: { disable_with: '…' }, 18 | class: 'btn btn-link', 19 | method: :delete, 20 | remote: true %> 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/views/undo/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | 11 | <%= render_flash message: 'Created' %> 12 | -------------------------------------------------------------------------------- /app/views/undo/playlist_items/destroy.js.erb: -------------------------------------------------------------------------------- 1 | <%= hide @playlist_item %> 2 | <%= render_flash message: 'Deleted', partial: 'application/flash_undo', 3 | link: button_to('Undo', undo_destroyed_playlist_item_path(@playlist_item, 4 | playlist_item: { destroyed_at: nil }), 5 | data: { disable_with: 'Restoring…' }, 6 | class: 'btn btn-link', 7 | method: :patch, 8 | remote: true) %> 9 | -------------------------------------------------------------------------------- /app/views/undo/playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= render_flash message: 'Updated' %> 2 | -------------------------------------------------------------------------------- /app/views/undo/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Undo Example
4 |
5 | 6 | 7 | <%= render @playlist.playlist_items.order :position %> 8 | 9 |
10 |
11 |
12 | <%= render partial: 'undo/playlist_items/form', locals: { 13 | playlist_item: [:undo, @playlist, PlaylistItem.new] } %> 14 |
15 | -------------------------------------------------------------------------------- /app/views/update/playlist_items/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: playlist_item do |form| %> 2 |
3 | <%= form.label :duration %> 4 | <%= form.text_field :duration, 5 | id: :playlist_item_duration, 6 | class: 'form-control' %> 7 |
8 | 9 |
10 | <%= form.label :poster_id %> 11 | <%= form.select( 12 | :poster_id, poster_choices, { include_blank: true }, 13 | { class: 'form-control', id: :poster_id }) %> 14 |
15 | 16 |
17 | <%= form.submit( 18 | data: { disable_with: 'Submitting' }, 19 | class: 'btn btn-primary') %> 20 |
21 | <% end %> 22 | -------------------------------------------------------------------------------- /app/views/update/playlist_items/_playlist_item.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= playlist_item.position %> 3 | <%= playlist_item.playlistable.try :name %> 4 | 5 | <%= form_with(model: [:update, playlist_item.playlist, playlist_item]) do |f| %> 6 | <%= f.label :duration, class: 'sr-only' %> 7 | <%= f.text_field :duration, 8 | id: :playlist_item_duration, 9 | autocomplete: :off, 10 | class: 'form-control', 11 | size: 3 %> 12 | <% end %> 13 | 14 | 15 | <%= button_to raw('×'), 16 | [:update, playlist_item.playlist, playlist_item], 17 | data: { disable_with: '…' }, 18 | class: 'btn btn-link', 19 | method: :delete, 20 | remote: true %> 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/views/update/playlist_items/create.js.erb: -------------------------------------------------------------------------------- 1 | var content = '<%= j render @playlist_item %>' 2 | 3 | document 4 | .getElementById('playlist_items') 5 | .insertAdjacentHTML('beforeend', content) 6 | 7 | document 8 | .querySelector('[action$="/playlist_items"]') 9 | .reset() 10 | 11 | <%= render_flash message: 'Created' %> 12 | -------------------------------------------------------------------------------- /app/views/update/playlist_items/destroy.js.erb: -------------------------------------------------------------------------------- 1 | <%= hide @playlist_item %> 2 | <%= render_flash message: 'Deleted' %> 3 | -------------------------------------------------------------------------------- /app/views/update/playlist_items/update.js.erb: -------------------------------------------------------------------------------- 1 | <%= render_flash message: 'Updated' %> 2 | -------------------------------------------------------------------------------- /app/views/update/playlists/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Update Example
4 |
5 | 6 | 7 | <%= render @playlist.playlist_items.order :position %> 8 | 9 |
10 |
11 |
12 | <%= render partial: 'update/playlist_items/form', locals: { 13 | playlist_item: [:update, @playlist, PlaylistItem.new] } %> 14 |
15 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a starting point to setup your application. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:setup' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a way to update your development environment automatically. 14 | # Add necessary update steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | puts "\n== Updating database ==" 24 | system! 'bin/rails db:migrate' 25 | 26 | puts "\n== Removing old logs and tempfiles ==" 27 | system! 'bin/rails log:clear tmp:clear' 28 | 29 | puts "\n== Restarting application server ==" 30 | system! 'bin/rails restart' 31 | end 32 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | begin 5 | exec "yarnpkg", *ARGV 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module OldSchoolJavascript 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.2 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration can go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded after loading 17 | # the framework and any gems in your application. 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: old-school-javascript_production 11 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | o7nqnC4sZXQ1Mo+FCWomrYymZ32f7Ju4Rf1Y43yrRfZfqb0quU2k7K3D4zEwp9abBnN2UqLzqtvpCh7a0XwH3hJn1mAFWcR3GpVvzIP2JiOOWvk4reWFfe5+XK7jNITRUzfB3FtHni5ZEb+adHvB+yCwqAqG4n+B+eUMR5X7HVei1m7pCx7ZsLllatWxm2Dc162kd/wfO+FqTzEMP5a79iUc+6+tWqJovUWgF+YFngHZcuAuxjm36snRLYsXQ3GN+L+ghZwn5qlV/wrr5I6rn/CQhtMD0iYbSTk7PucdHtXYvDiqIZ8wPMN/5uy4WEZtZDLgrXNJQxMVy3zMchHVj+y5YsHIbGWWLwyi39Zhg/FyIVEAQkjcVuSuuSkD/TWTtzGteMDlzHNiLahJnVyHvDWVikWl2OZt--zb0cgBPizBt/gw5G--Bjcg39XE17OVB7ol8Qx8CQ== -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | # Run rails dev:cache to toggle caching. 17 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | 20 | config.cache_store = :memory_store 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 | } 24 | else 25 | config.action_controller.perform_caching = false 26 | 27 | config.cache_store = :null_store 28 | end 29 | 30 | # Store uploaded files on the local file system (see config/storage.yml for options) 31 | config.active_storage.service = :local 32 | 33 | # Don't care if the mailer can't send. 34 | config.action_mailer.raise_delivery_errors = false 35 | 36 | config.action_mailer.perform_caching = false 37 | 38 | # Print deprecation notices to the Rails logger. 39 | config.active_support.deprecation = :log 40 | 41 | # Raise an error on page load if there are pending migrations. 42 | config.active_record.migration_error = :page_load 43 | 44 | # Highlight code that triggered database queries in logs. 45 | config.active_record.verbose_query_logs = true 46 | 47 | # Debug mode disables concatenation and preprocessing of assets. 48 | # This option may cause significant delays in view rendering with a large 49 | # number of complex assets. 50 | config.assets.debug = true 51 | 52 | # Suppress logger output for asset requests. 53 | config.assets.quiet = true 54 | 55 | # Raises error for missing translations 56 | # config.action_view.raise_on_missing_translations = true 57 | 58 | # Use an evented file watcher to asynchronously detect changes in source code, 59 | # routes, locales, etc. This feature depends on the listen gem. 60 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 61 | end 62 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | # config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 33 | 34 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 35 | # config.action_controller.asset_host = 'http://assets.example.com' 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 40 | 41 | # Store uploaded files on the local file system (see config/storage.yml for options) 42 | config.active_storage.service = :local 43 | 44 | # Mount Action Cable outside main process or domain 45 | # config.action_cable.mount_path = nil 46 | # config.action_cable.url = 'wss://example.com/cable' 47 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 48 | 49 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 50 | # config.force_ssl = true 51 | 52 | # Use the lowest log level to ensure availability of diagnostic information 53 | # when problems arise. 54 | config.log_level = :debug 55 | 56 | # Prepend all log lines with the following tags. 57 | config.log_tags = [ :request_id ] 58 | 59 | # Use a different cache store in production. 60 | # config.cache_store = :mem_cache_store 61 | 62 | # Use a real queuing backend for Active Job (and separate queues per environment) 63 | # config.active_job.queue_adapter = :resque 64 | # config.active_job.queue_name_prefix = "old-school-javascript_#{Rails.env}" 65 | 66 | config.action_mailer.perform_caching = false 67 | 68 | # Ignore bad email addresses and do not raise email delivery errors. 69 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 70 | # config.action_mailer.raise_delivery_errors = false 71 | 72 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 73 | # the I18n.default_locale when a translation cannot be found). 74 | config.i18n.fallbacks = true 75 | 76 | # Send deprecation notices to registered listeners. 77 | config.active_support.deprecation = :notify 78 | 79 | # Use default logging formatter so that PID and timestamp are not suppressed. 80 | config.log_formatter = ::Logger::Formatter.new 81 | 82 | # Use a different logger for distributed setups. 83 | # require 'syslog/logger' 84 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 85 | 86 | if ENV["RAILS_LOG_TO_STDOUT"].present? 87 | logger = ActiveSupport::Logger.new(STDOUT) 88 | logger.formatter = config.log_formatter 89 | config.logger = ActiveSupport::TaggedLogging.new(logger) 90 | end 91 | 92 | # Do not dump schema after migrations. 93 | config.active_record.dump_schema_after_migration = false 94 | end 95 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory 32 | config.active_storage.service = :test 33 | 34 | config.action_mailer.perform_caching = false 35 | 36 | # Tell Action Mailer not to deliver emails to the real world. 37 | # The :test delivery method accumulates sent emails in the 38 | # ActionMailer::Base.deliveries array. 39 | config.action_mailer.delivery_method = :test 40 | 41 | # Print deprecation notices to the stderr. 42 | config.active_support.deprecation = :stderr 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | Rails.application.config.assets.precompile += %w(presentation.scss slides.scss) 16 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https, :unsafe_inline 14 | 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | 19 | # Report CSP violations to a specified URI 20 | # For further information see the following documentation: 21 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 22 | # Rails.application.config.content_security_policy_report_only = true 23 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. 30 | # 31 | # preload_app! 32 | 33 | # Allow puma to be restarted by `rails restart` command. 34 | plugin :tmp_restart 35 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # For details on the DSL available within this file, 3 | # see http://guides.rubyonrails.org/routing.html 4 | 5 | root 'presentation#index' 6 | 7 | resources :slides, only: :show, param: :view 8 | resources :presentation, only: :index 9 | 10 | concern :shared_routes do 11 | resources :destroyed_playlist_items, only: :update 12 | resources :posters, only: :index 13 | resources :playlists, only: %i[index create show update destroy] do 14 | resources :playlist_items, only: %i[create update destroy] 15 | end 16 | end 17 | 18 | namespace :default do 19 | concerns :shared_routes 20 | end 21 | 22 | namespace :create do 23 | concerns :shared_routes 24 | end 25 | 26 | namespace :destroy do 27 | concerns :shared_routes 28 | end 29 | 30 | namespace :update do 31 | concerns :shared_routes 32 | end 33 | 34 | namespace :undo do 35 | concerns :shared_routes 36 | end 37 | 38 | namespace :copy do 39 | concerns :shared_routes 40 | end 41 | 42 | namespace :reorder do 43 | concerns :shared_routes 44 | end 45 | 46 | namespace :final do 47 | concerns :shared_routes 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w[ 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ].each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # path: your_azure_storage_path 28 | # storage_account_name: your_account_name 29 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 30 | # container: your_container_name 31 | 32 | # mirror: 33 | # service: Mirror 34 | # primary: local 35 | # mirrors: [ amazon, google, microsoft ] 36 | -------------------------------------------------------------------------------- /db/migrate/20180226020838_create_playlists.rb: -------------------------------------------------------------------------------- 1 | class CreatePlaylists < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :playlists do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20180226022852_create_playlist_items.rb: -------------------------------------------------------------------------------- 1 | class CreatePlaylistItems < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :playlist_items do |t| 4 | t.references :playlist, foreign_key: true 5 | t.integer :duration, null: false, default: 10 6 | t.integer :position, null: false 7 | 8 | t.references :poster, foreign_key: true 9 | 10 | t.timestamps 11 | 12 | t.timestamp :destroyed_at, nullable: true, default: nil 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /db/migrate/20180304031049_create_posters.rb: -------------------------------------------------------------------------------- 1 | class CreatePosters < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :posters do |t| 4 | t.string :name, null: false 5 | t.string :name_parameterized, null: false 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2018_03_04_031049) do 14 | 15 | create_table "playlist_items", force: :cascade do |t| 16 | t.integer "playlist_id" 17 | t.integer "duration", default: 10, null: false 18 | t.integer "position", null: false 19 | t.integer "poster_id" 20 | t.datetime "created_at", null: false 21 | t.datetime "updated_at", null: false 22 | t.datetime "destroyed_at" 23 | t.index ["playlist_id"], name: "index_playlist_items_on_playlist_id" 24 | t.index ["poster_id"], name: "index_playlist_items_on_poster_id" 25 | end 26 | 27 | create_table "playlists", force: :cascade do |t| 28 | t.string "name" 29 | t.datetime "created_at", null: false 30 | t.datetime "updated_at", null: false 31 | end 32 | 33 | create_table "posters", force: :cascade do |t| 34 | t.string "name", null: false 35 | t.string "name_parameterized", null: false 36 | t.datetime "created_at", null: false 37 | t.datetime "updated_at", null: false 38 | end 39 | 40 | end 41 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database 2 | # with its default values. The data can then be loaded with the rails db:seed 3 | # command (or created alongside the database with db:setup). 4 | # 5 | # Examples: 6 | # 7 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Robocop' }]) 8 | # Character.create(name: 'Luke', movie: movies.first) 9 | 10 | playlist1 = Playlist.create! name: 'Cool Playlist' 11 | 12 | poster1 = Poster.create! name: 'Welcome to Pittsburgh' 13 | poster2 = Poster.create! name: 'Cityscape' 14 | poster3 = Poster.create! name: 'Things to do' 15 | 16 | playlist1.playlist_items.create! position: 1, poster: poster1 17 | playlist1.playlist_items.create! position: 2, poster: poster2 18 | playlist1.playlist_items.create! position: 3, poster: poster3 19 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/log/.keep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "old-school-javascript", 3 | "private": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/public/favicon.ico -------------------------------------------------------------------------------- /public/kiosk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/public/kiosk.jpg -------------------------------------------------------------------------------- /public/obm-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 18 | 24 | 26 | 28 | 37 | 39 | 48 | 50 | 56 | 62 | 64 | 65 | 68 | 70 | 76 | 77 | 79 | 80 | 81 | 94 | 100 | 111 | 121 | 133 | 139 | 141 | 143 | 153 | 155 | 164 | 170 | 175 | 179 | 191 | 195 | 201 | 215 | 216 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /test/fixtures/playlist_item_posters.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | playlist_item: one 5 | poster: one 6 | 7 | two: 8 | playlist_item: two 9 | poster: two 10 | -------------------------------------------------------------------------------- /test/fixtures/posters.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyString 5 | 6 | two: 7 | name: MyString 8 | -------------------------------------------------------------------------------- /test/models/playlist_item_poster_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PlaylistItemPosterTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/poster_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PosterTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/tmp/.keep -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conzett/old-school-javascript/e0c425e090f85e279a3c9d302202044e298edc4a/vendor/.keep --------------------------------------------------------------------------------