├── .browserslistrc ├── .gitignore ├── .ruby-version ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ └── stylesheets │ │ └── application.css ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── api │ │ ├── courses_controller.rb │ │ ├── email_preferences_controller.rb │ │ ├── hooks_controller.rb │ │ ├── sessions_controller.rb │ │ ├── stripe_controller.rb │ │ ├── tags_controller.rb │ │ ├── training_completions_controller.rb │ │ ├── training_items_controller.rb │ │ ├── training_modules_controller.rb │ │ ├── training_sections_controller.rb │ │ ├── training_users_controller.rb │ │ ├── users_controller.rb │ │ ├── video_plays_controller.rb │ │ ├── video_tags_controller.rb │ │ └── videos_controller.rb │ ├── application_controller.rb │ └── concerns │ │ └── .keep ├── helpers │ └── application_helper.rb ├── javascript │ ├── channels │ │ ├── consumer.js │ │ └── index.js │ └── packs │ │ └── application.js ├── jobs │ └── application_job.rb ├── mailers │ ├── application_mailer.rb │ └── vue_training_mailer.rb ├── models │ ├── application_record.rb │ ├── concerns │ │ └── .keep │ ├── course.rb │ ├── email.rb │ ├── tag.rb │ ├── training_completion.rb │ ├── training_item.rb │ ├── training_module.rb │ ├── training_section.rb │ ├── user.rb │ ├── video.rb │ ├── video_play.rb │ └── video_tag.rb ├── serializers │ ├── course_serializer.rb │ ├── tag_serializer.rb │ ├── training_item_serializer.rb │ ├── training_module_serializer.rb │ ├── training_section_serializer.rb │ ├── user_serializer.rb │ └── video_serializer.rb └── views │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb │ └── vue_training_mailer │ ├── already_exists.html.erb │ └── login_info.html.erb ├── babel.config.js ├── bin ├── bundle ├── rails ├── rake ├── setup ├── spring ├── webpack ├── webpack-dev-server └── 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 ├── webpack │ ├── development.js │ ├── environment.js │ ├── production.js │ └── test.js └── webpacker.yml ├── db ├── migrate │ ├── 20190909155809_create_videos.rb │ ├── 20190909180420_create_tags.rb │ ├── 20190909180505_create_video_tags.rb │ ├── 20190917003054_add_users.rb │ ├── 20190922215121_add_password_and_salt.rb │ ├── 20190923073459_add_token.rb │ ├── 20190925080948_add_admin_to_users.rb │ ├── 20190930134531_add_watched_video_relationship_to_users.rb │ ├── 20191103161647_add_fields_to_video.rb │ ├── 20191201134808_add_series.rb │ ├── 20191201141427_add_series_type.rb │ ├── 20191201153951_add_image_url_to_course.rb │ ├── 20191202151424_add.rb │ ├── 20191202195455_add_order_to_video_and_chapter.rb │ ├── 20191212205314_add_email_fields.rb │ ├── 20191214171653_add_difficulty_to_courses.rb │ ├── 20191229055737_add_pro_option_to_videos.rb │ ├── 20200108151514_add_stripe_ids_to_user.rb │ ├── 20200113211401_add_subscription_properties.rb │ ├── 20200205195030_add_types_to_course_and_video.rb │ ├── 20200224033312_add_plan_id_and_plan_to_user.rb │ ├── 20200224201444_add_phone_number.rb │ ├── 20200225175024_add_next_steps_data.rb │ ├── 20200327163206_add_free_subscription.rb │ ├── 20200331043754_add_needs_code_summary_field_to_video.rb │ ├── 20200414181716_plan_seats.rb │ ├── 20200427093554_add_active_campaign_id_to_user.rb │ ├── 20200615003946_create_modules_sections_and_items.rb │ ├── 20200625141651_add_intro_to_module.rb │ ├── 20200704061057_add_vimeo_id.rb │ ├── 20200704223359_switch_from_id_to_uid.rb │ ├── 20200706165738_make_bootcamp_creation_easier.rb │ ├── 20200710191127_add_youtube_uid.rb │ ├── 20200710192436_add_video_url.rb │ ├── 20200714162618_add_published_bool_to_module.rb │ ├── 20200716083445_add_answers_and_published_boolean.rb │ └── 20200803093713_add_playback_rate.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ ├── .keep │ ├── connect_email_to_activecampaign.rake │ ├── email_resolving.rake │ └── heroku_db.rake ├── log └── .keep ├── package.json ├── postcss.config.js ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico └── robots.txt ├── storage └── .keep ├── test ├── application_system_test_case.rb ├── channels │ └── application_cable │ │ └── connection_test.rb ├── controllers │ └── .keep ├── fixtures │ ├── .keep │ └── files │ │ └── .keep ├── helpers │ └── .keep ├── integration │ └── .keep ├── mailers │ ├── .keep │ └── previews │ │ └── vue_training_preview.rb ├── models │ └── .keep ├── system │ └── .keep └── test_helper.rb ├── tmp └── .keep ├── vendor └── .keep └── yarn.lock /.browserslistrc: -------------------------------------------------------------------------------- 1 | defaults 2 | -------------------------------------------------------------------------------- /.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 | !/storage/.keep 23 | 24 | /public/assets 25 | .byebug_history 26 | 27 | # Ignore master key for decrypting credentials and more. 28 | /config/master.key 29 | 30 | /public/packs 31 | /public/packs-test 32 | /node_modules 33 | /yarn-error.log 34 | yarn-debug.log* 35 | .yarn-integrity 36 | 37 | .env 38 | 39 | *.dump -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.5.3' 5 | 6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7 | gem 'rails', '~> 6.0.0' 8 | gem 'stripe' 9 | gem 'dotenv-rails', groups: [:development, :test] 10 | # Use sqlite3 as the database for Active Record 11 | # Use Puma as the app server 12 | gem 'puma', '~> 3.12' 13 | # Use SCSS for stylesheets 14 | gem 'sass-rails', '~> 5' 15 | # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 16 | gem 'webpacker', '~> 4.0' 17 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 18 | gem 'turbolinks', '~> 5' 19 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 20 | gem 'fast_jsonapi' 21 | # Use Redis adapter to run Action Cable in production 22 | # gem 'redis', '~> 4.0' 23 | # Use Active Model has_secure_password 24 | # gem 'bcrypt', '~> 3.1.7' 25 | 26 | gem 'rack-cors' 27 | 28 | # Use Active Storage variant 29 | # gem 'image_processing', '~> 1.2' 30 | 31 | # Reduces boot times through caching; required in config/boot.rb 32 | gem 'bootsnap', '>= 1.4.2', require: false 33 | 34 | gem 'faraday' 35 | 36 | group :development, :test do 37 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 38 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 39 | end 40 | 41 | group :development do 42 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 43 | gem 'web-console', '>= 3.3.0' 44 | gem 'listen', '>= 3.0.5', '< 3.2' 45 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 46 | gem 'spring' 47 | gem 'spring-watcher-listen', '~> 2.0.0' 48 | gem 'byebug' 49 | 50 | gem 'seed_dump' 51 | end 52 | 53 | group :production do 54 | gem 'pg', '~> 1.1.4' 55 | end 56 | 57 | group :test do 58 | # Adds support for Capybara system testing and selenium driver 59 | gem 'capybara', '>= 2.15' 60 | gem 'selenium-webdriver' 61 | # Easy installation and use of web drivers to run system tests with browsers 62 | gem 'webdrivers' 63 | end 64 | 65 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 66 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 67 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (6.0.0) 5 | actionpack (= 6.0.0) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailbox (6.0.0) 9 | actionpack (= 6.0.0) 10 | activejob (= 6.0.0) 11 | activerecord (= 6.0.0) 12 | activestorage (= 6.0.0) 13 | activesupport (= 6.0.0) 14 | mail (>= 2.7.1) 15 | actionmailer (6.0.0) 16 | actionpack (= 6.0.0) 17 | actionview (= 6.0.0) 18 | activejob (= 6.0.0) 19 | mail (~> 2.5, >= 2.5.4) 20 | rails-dom-testing (~> 2.0) 21 | actionpack (6.0.0) 22 | actionview (= 6.0.0) 23 | activesupport (= 6.0.0) 24 | rack (~> 2.0) 25 | rack-test (>= 0.6.3) 26 | rails-dom-testing (~> 2.0) 27 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 28 | actiontext (6.0.0) 29 | actionpack (= 6.0.0) 30 | activerecord (= 6.0.0) 31 | activestorage (= 6.0.0) 32 | activesupport (= 6.0.0) 33 | nokogiri (>= 1.8.5) 34 | actionview (6.0.0) 35 | activesupport (= 6.0.0) 36 | builder (~> 3.1) 37 | erubi (~> 1.4) 38 | rails-dom-testing (~> 2.0) 39 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 40 | activejob (6.0.0) 41 | activesupport (= 6.0.0) 42 | globalid (>= 0.3.6) 43 | activemodel (6.0.0) 44 | activesupport (= 6.0.0) 45 | activerecord (6.0.0) 46 | activemodel (= 6.0.0) 47 | activesupport (= 6.0.0) 48 | activestorage (6.0.0) 49 | actionpack (= 6.0.0) 50 | activejob (= 6.0.0) 51 | activerecord (= 6.0.0) 52 | marcel (~> 0.3.1) 53 | activesupport (6.0.0) 54 | concurrent-ruby (~> 1.0, >= 1.0.2) 55 | i18n (>= 0.7, < 2) 56 | minitest (~> 5.1) 57 | tzinfo (~> 1.1) 58 | zeitwerk (~> 2.1, >= 2.1.8) 59 | addressable (2.7.0) 60 | public_suffix (>= 2.0.2, < 5.0) 61 | bindex (0.8.1) 62 | bootsnap (1.4.5) 63 | msgpack (~> 1.0) 64 | builder (3.2.3) 65 | byebug (11.0.1) 66 | capybara (3.29.0) 67 | addressable 68 | mini_mime (>= 0.1.3) 69 | nokogiri (~> 1.8) 70 | rack (>= 1.6.0) 71 | rack-test (>= 0.6.3) 72 | regexp_parser (~> 1.5) 73 | xpath (~> 3.2) 74 | childprocess (2.0.0) 75 | rake (< 13.0) 76 | concurrent-ruby (1.1.5) 77 | crass (1.0.5) 78 | dotenv (2.7.5) 79 | dotenv-rails (2.7.5) 80 | dotenv (= 2.7.5) 81 | railties (>= 3.2, < 6.1) 82 | erubi (1.8.0) 83 | faraday (1.0.1) 84 | multipart-post (>= 1.2, < 3) 85 | fast_jsonapi (1.5) 86 | activesupport (>= 4.2) 87 | ffi (1.11.1) 88 | globalid (0.4.2) 89 | activesupport (>= 4.2.0) 90 | i18n (1.6.0) 91 | concurrent-ruby (~> 1.0) 92 | listen (3.1.5) 93 | rb-fsevent (~> 0.9, >= 0.9.4) 94 | rb-inotify (~> 0.9, >= 0.9.7) 95 | ruby_dep (~> 1.2) 96 | loofah (2.3.1) 97 | crass (~> 1.0.2) 98 | nokogiri (>= 1.5.9) 99 | mail (2.7.1) 100 | mini_mime (>= 0.1.1) 101 | marcel (0.3.3) 102 | mimemagic (~> 0.3.2) 103 | method_source (0.9.2) 104 | mimemagic (0.3.3) 105 | mini_mime (1.0.2) 106 | mini_portile2 (2.4.0) 107 | minitest (5.11.3) 108 | msgpack (1.3.1) 109 | multipart-post (2.1.1) 110 | nio4r (2.5.1) 111 | nokogiri (1.10.8) 112 | mini_portile2 (~> 2.4.0) 113 | pg (1.1.4) 114 | public_suffix (4.0.1) 115 | puma (3.12.2) 116 | rack (2.1.1) 117 | rack-cors (1.1.1) 118 | rack (>= 2.0.0) 119 | rack-proxy (0.6.5) 120 | rack 121 | rack-test (1.1.0) 122 | rack (>= 1.0, < 3) 123 | rails (6.0.0) 124 | actioncable (= 6.0.0) 125 | actionmailbox (= 6.0.0) 126 | actionmailer (= 6.0.0) 127 | actionpack (= 6.0.0) 128 | actiontext (= 6.0.0) 129 | actionview (= 6.0.0) 130 | activejob (= 6.0.0) 131 | activemodel (= 6.0.0) 132 | activerecord (= 6.0.0) 133 | activestorage (= 6.0.0) 134 | activesupport (= 6.0.0) 135 | bundler (>= 1.3.0) 136 | railties (= 6.0.0) 137 | sprockets-rails (>= 2.0.0) 138 | rails-dom-testing (2.0.3) 139 | activesupport (>= 4.2.0) 140 | nokogiri (>= 1.6) 141 | rails-html-sanitizer (1.2.0) 142 | loofah (~> 2.2, >= 2.2.2) 143 | railties (6.0.0) 144 | actionpack (= 6.0.0) 145 | activesupport (= 6.0.0) 146 | method_source 147 | rake (>= 0.8.7) 148 | thor (>= 0.20.3, < 2.0) 149 | rake (12.3.3) 150 | rb-fsevent (0.10.3) 151 | rb-inotify (0.10.0) 152 | ffi (~> 1.0) 153 | regexp_parser (1.6.0) 154 | ruby_dep (1.5.0) 155 | rubyzip (1.3.0) 156 | sass (3.7.4) 157 | sass-listen (~> 4.0.0) 158 | sass-listen (4.0.0) 159 | rb-fsevent (~> 0.9, >= 0.9.4) 160 | rb-inotify (~> 0.9, >= 0.9.7) 161 | sass-rails (5.1.0) 162 | railties (>= 5.2.0) 163 | sass (~> 3.1) 164 | sprockets (>= 2.8, < 4.0) 165 | sprockets-rails (>= 2.0, < 4.0) 166 | tilt (>= 1.1, < 3) 167 | seed_dump (3.3.1) 168 | activerecord (>= 4) 169 | activesupport (>= 4) 170 | selenium-webdriver (3.142.4) 171 | childprocess (>= 0.5, < 3.0) 172 | rubyzip (~> 1.2, >= 1.2.2) 173 | spring (2.1.0) 174 | spring-watcher-listen (2.0.1) 175 | listen (>= 2.7, < 4.0) 176 | spring (>= 1.2, < 3.0) 177 | sprockets (3.7.2) 178 | concurrent-ruby (~> 1.0) 179 | rack (> 1, < 3) 180 | sprockets-rails (3.2.1) 181 | actionpack (>= 4.0) 182 | activesupport (>= 4.0) 183 | sprockets (>= 3.0.0) 184 | stripe (5.12.0) 185 | thor (0.20.3) 186 | thread_safe (0.3.6) 187 | tilt (2.0.9) 188 | turbolinks (5.2.0) 189 | turbolinks-source (~> 5.2) 190 | turbolinks-source (5.2.0) 191 | tzinfo (1.2.5) 192 | thread_safe (~> 0.1) 193 | web-console (4.0.1) 194 | actionview (>= 6.0.0) 195 | activemodel (>= 6.0.0) 196 | bindex (>= 0.4.0) 197 | railties (>= 6.0.0) 198 | webdrivers (4.1.2) 199 | nokogiri (~> 1.6) 200 | rubyzip (~> 1.0) 201 | selenium-webdriver (>= 3.0, < 4.0) 202 | webpacker (4.0.7) 203 | activesupport (>= 4.2) 204 | rack-proxy (>= 0.6.1) 205 | railties (>= 4.2) 206 | websocket-driver (0.7.1) 207 | websocket-extensions (>= 0.1.0) 208 | websocket-extensions (0.1.4) 209 | xpath (3.2.0) 210 | nokogiri (~> 1.8) 211 | zeitwerk (2.1.10) 212 | 213 | PLATFORMS 214 | ruby 215 | 216 | DEPENDENCIES 217 | bootsnap (>= 1.4.2) 218 | byebug 219 | capybara (>= 2.15) 220 | dotenv-rails 221 | faraday 222 | fast_jsonapi 223 | listen (>= 3.0.5, < 3.2) 224 | pg (~> 1.1.4) 225 | puma (~> 3.12) 226 | rack-cors 227 | rails (~> 6.0.0) 228 | sass-rails (~> 5) 229 | seed_dump 230 | selenium-webdriver 231 | spring 232 | spring-watcher-listen (~> 2.0.0) 233 | stripe 234 | turbolinks (~> 5) 235 | tzinfo-data 236 | web-console (>= 3.3.0) 237 | webdrivers 238 | webpacker (~> 4.0) 239 | 240 | RUBY VERSION 241 | ruby 2.5.3p105 242 | 243 | BUNDLED WITH 244 | 1.17.3 245 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /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 ../stylesheets .css 3 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreybiles/vue-screencasts-server/bbefcb63620392e6863a42a54b79ec11d049644b/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /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/api/courses_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::CoursesController < ApplicationController 2 | def create 3 | course = Course.create(course_params) 4 | render json: course_json(course) 5 | end 6 | 7 | def show 8 | course = Course.find(params[:id]) 9 | render json: CourseSerializer.new(course, include: [:videos]).serializable_hash 10 | end 11 | 12 | def index 13 | courses = Course.all 14 | render json: course_json(courses) 15 | end 16 | 17 | def update 18 | course = Course.find(params[:id]) 19 | course.update(course_params) 20 | course.save 21 | render json: course_json(course) 22 | end 23 | 24 | def destroy 25 | Course.find(params[:id]).destroy 26 | head 204 27 | end 28 | 29 | def attach_video 30 | video = Video.find(params[:video_id]) 31 | course = Course.find(params[:id]) 32 | video.course_id = course.id 33 | video.order = (course.max_order || 0) + 1 34 | video.save 35 | 36 | render json: VideoSerializer.new(video, include: [:course]).serializable_hash 37 | end 38 | 39 | def attach_chapter 40 | chapter = Course.find(params[:chapter_id]) 41 | parent = Course.find(params[:id]) 42 | chapter.parent_id = parent.id 43 | chapter.order = (parent.max_order || 0) + 1 44 | chapter.save 45 | 46 | render json: CourseSerializer.new(chapter, include: [:parent]).serializable_hash 47 | end 48 | 49 | def detach_video 50 | video = Video.find(params[:video_id]) 51 | course = Course.find(params[:id]) 52 | course.videos.delete(video) 53 | course.save 54 | render json: course_json(course) 55 | end 56 | 57 | def detach_chapter 58 | chapter = Course.find(params[:chapter_id]) 59 | course = Course.find(params[:id]) 60 | course.chapters.delete(chapter) 61 | course.save 62 | render json: course_json(course) 63 | end 64 | 65 | private 66 | 67 | def course_json(courses) 68 | CourseSerializer.new(courses).serializable_hash 69 | end 70 | 71 | def course_params 72 | params.require(:course).permit(:name, :description, :image_url, :series_type, :order, :parent_id, :difficulty) 73 | end 74 | 75 | end 76 | -------------------------------------------------------------------------------- /app/controllers/api/email_preferences_controller.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | require 'openssl' 4 | 5 | class Api::EmailPreferencesController < ApplicationController 6 | def change_subscription 7 | id = params['id'] 8 | is_subscribed = params['isSubscribed'] 9 | 10 | result = Email.new.update_subscription(current_user, id, is_subscribed) 11 | # TODO: put in error handling 12 | head 200 13 | end 14 | 15 | def status 16 | result = Email.new.contact(current_user) 17 | render json: { 18 | contactLists: result['contactLists'] 19 | } 20 | end 21 | 22 | def create_and_tag 23 | tag_id = params['tag_id'] 24 | email = params['email'] 25 | result = Email.new.create_and_tag(email, tag_id) 26 | head 200 27 | end 28 | end -------------------------------------------------------------------------------- /app/controllers/api/hooks_controller.rb: -------------------------------------------------------------------------------- 1 | require 'securerandom' 2 | 3 | class Api::HooksController < ApplicationController 4 | def new_training_customer 5 | email = params[:email] 6 | 7 | if user = User.find_by(email: email) 8 | user.bootcamp = true 9 | user.save 10 | 11 | VueTrainingMailer.already_exists(email).deliver! 12 | else 13 | password = SecureRandom.alphanumeric(10) 14 | user = User.bootcamp_user(email, password) 15 | if user.email == email 16 | VueTrainingMailer.login_info(email, password).deliver! 17 | end 18 | end 19 | 20 | 21 | end 22 | end -------------------------------------------------------------------------------- /app/controllers/api/sessions_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::SessionsController < ApplicationController 2 | def create 3 | user = User.find_by email: params["email"].downcase 4 | if(user and user.check_password(params["password"])) then 5 | render json: {token: user.token} 6 | else 7 | head 401 8 | end 9 | end 10 | 11 | def destroy 12 | head 200 13 | end 14 | 15 | def user 16 | if current_user 17 | render json: UserSerializer.new(current_user, params: { admin: current_user.admin }).serializable_hash 18 | else 19 | head 401 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/controllers/api/stripe_controller.rb: -------------------------------------------------------------------------------- 1 | Stripe.api_key = ENV['STRIPE_SECRET'] 2 | 3 | class Api::StripeController < ApplicationController 4 | def create_subscription 5 | source = params['source'] 6 | planId = params['planId'] 7 | seats = params['seats'] 8 | 9 | user = current_user 10 | 11 | if(user.stripe_id) 12 | customer = Stripe::Customer.retrieve(user.stripe_id) 13 | end 14 | 15 | if !customer 16 | customer = Stripe::Customer.create({ 17 | email: user.email, 18 | name: user.name, 19 | source: source['id'], 20 | metadata: { 21 | app_id: user.id 22 | } 23 | }) 24 | 25 | user.stripe_id = customer.id 26 | user.save 27 | end 28 | 29 | # TODO: test what happens when it's called multiple times on one user 30 | # Desired behavior is to cancel the old subscription and create a new one 31 | 32 | subscription = Stripe::Subscription.create({ 33 | customer: customer.id, 34 | items: [{plan: planId, quantity: seats}] 35 | }) 36 | 37 | user.subscription_id = subscription.id 38 | user.plan_id = planId 39 | user.plan_seats = seats.to_i 40 | user.plan_hash = subscription.plan.to_hash 41 | user.save 42 | 43 | render json: UserSerializer.new(user).serializable_hash 44 | end 45 | 46 | def user_info 47 | customer_id = current_user.stripe_id 48 | if(!customer_id) 49 | head 400 50 | end 51 | 52 | if(current_user.subscription_id) then 53 | subscription = Stripe::Subscription.retrieve(current_user.subscription_id) 54 | card = Stripe::Customer.retrieve_source(customer_id, subscription.default_payment_method) 55 | card = card.data[0].card 56 | end 57 | charges = Stripe::Charge.list({customer: customer_id}) 58 | 59 | 60 | render json: { 61 | charges: charges.data, 62 | card: card, 63 | subscription: subscription, 64 | } 65 | end 66 | 67 | def cancel_subscription 68 | user = current_user 69 | subscription = Stripe::Subscription.update(user.subscription_id, {cancel_at_period_end: true}) 70 | user.subscription_cancelled = true 71 | user.save 72 | render json: subscription 73 | end 74 | 75 | 76 | def resubscribe 77 | user = current_user 78 | subscription = Stripe::Subscription.update(user.subscription_id, {cancel_at_period_end: false}) 79 | user.subscription_cancelled = false 80 | user.save 81 | render json: subscription 82 | end 83 | 84 | def change_card 85 | response = Stripe::Customer.update(current_user.stripe_id, { 86 | source: params[:source][:id] 87 | }) 88 | card = response.sources.data.first 89 | render json: card 90 | end 91 | end -------------------------------------------------------------------------------- /app/controllers/api/tags_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::TagsController < ApplicationController 2 | def create 3 | tag = Tag.create(name: params[:name]) 4 | render json: TagSerializer.new(tag).serializable_hash 5 | end 6 | 7 | def show 8 | tag = Tag.find(params[:id]) 9 | render json: TagSerializer.new(tag, include: [:videos, :'videos.tags']).serializable_hash 10 | end 11 | 12 | def index 13 | tags = Tag.all 14 | render json: TagSerializer.new(tags).serializable_hash 15 | end 16 | 17 | def update 18 | tag = Tag.find(params[:id]) 19 | tag.name = params[:name] 20 | tag.save 21 | render json: TagSerializer.new(tag).serializable_hash 22 | end 23 | 24 | def destroy 25 | Tag.find(params[:id]).destroy 26 | head 204 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /app/controllers/api/training_completions_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::TrainingCompletionsController < ApplicationController 2 | def create 3 | TrainingCompletion.create(user_id: current_user.id, training_item_id: params[:training_item_id]) 4 | head 201 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/controllers/api/training_items_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::TrainingItemsController < ApplicationController 2 | before_action :authenticate_user, only: [:create, :update, :destroy] 3 | 4 | def create 5 | training_item = TrainingItem.create(item_params) 6 | render_item(training_item) 7 | end 8 | 9 | def update 10 | training_item = TrainingItem.find(params[:id]) 11 | training_item.update_attributes(item_params) 12 | training_item.save 13 | render_item(training_item) 14 | end 15 | 16 | def destroy 17 | TrainingItem.find(params[:id]).destroy 18 | head 204 19 | end 20 | 21 | def render_item(items) 22 | render json: TrainingItemSerializer.new(items).serializable_hash 23 | end 24 | 25 | def item_params 26 | params.require(:training_item).permit(:title, :position, :training_section_id, :text, :exercise_type, :vimeo_uid, :youtube_uid, :video_url, :published, :answer) 27 | end 28 | end -------------------------------------------------------------------------------- /app/controllers/api/training_modules_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::TrainingModulesController < ApplicationController 2 | before_action :authenticate_user, only: [:create, :update, :destroy] 3 | 4 | def create 5 | training_module = TrainingModule.create(module_params) 6 | render_module(training_module) 7 | end 8 | 9 | def show 10 | training_module = TrainingModule.find(params[:id]) 11 | render json: TrainingModuleSerializer.new( 12 | training_module, 13 | include: [:training_sections, :'training_sections.training_items'], 14 | ).serializable_hash 15 | end 16 | 17 | def index 18 | training_modules = TrainingModule.all 19 | render json: TrainingModuleSerializer.new( 20 | training_modules, 21 | include: [:training_sections, :'training_sections.training_items'], 22 | ).serializable_hash 23 | end 24 | 25 | def update 26 | training_module = TrainingModule.find(params[:id]) 27 | training_module.update_attributes(module_params) 28 | training_module.save 29 | render_module(training_module) 30 | end 31 | 32 | def destroy 33 | TrainingModule.find(params[:id]).destroy 34 | head 204 35 | end 36 | 37 | def render_module(modules) 38 | render json: TrainingModuleSerializer.new(modules).serializable_hash 39 | end 40 | 41 | def module_params 42 | params.require(:training_module).permit(:name, :week_number, :intro, :state) 43 | end 44 | end -------------------------------------------------------------------------------- /app/controllers/api/training_sections_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::TrainingSectionsController < ApplicationController 2 | before_action :authenticate_user, only: [:create, :update, :destroy] 3 | 4 | def create 5 | training_section = TrainingSection.create(section_params) 6 | render_section(training_section) 7 | end 8 | 9 | def update 10 | training_section = TrainingSection.find(params[:id]) 11 | training_section.update_attributes(section_params) 12 | training_section.save 13 | render_section(training_section) 14 | end 15 | 16 | def destroy 17 | TrainingSection.find(params[:id]).destroy 18 | head 204 19 | end 20 | 21 | def render_section(modules) 22 | render json: TrainingSectionSerializer.new(modules).serializable_hash 23 | end 24 | 25 | def section_params 26 | params.require(:training_section).permit(:name, :position, :training_module_id) 27 | end 28 | end -------------------------------------------------------------------------------- /app/controllers/api/training_users_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::TrainingUsersController < ApplicationController 2 | before_action :authenticate_user 3 | 4 | def index 5 | users = User.where(bootcamp: true) 6 | render json: UserSerializer.new(users).serializable_hash 7 | end 8 | 9 | def create 10 | user = User.bootcamp_user(params[:username], params[:password]) 11 | render json: UserSerializer.new(user).serializable_hash 12 | end 13 | end -------------------------------------------------------------------------------- /app/controllers/api/users_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::UsersController < ApplicationController 2 | before_action :authenticate_user, only: [:index] 3 | 4 | def index 5 | users = User.all 6 | render json: user_json(users) 7 | end 8 | 9 | def create 10 | if(User.find_by email: params["email"].downcase) then 11 | head 401 12 | else 13 | user = User.build_user(user_create_params, params["password"]) 14 | 15 | result = Email.new.create_contact(user) 16 | user.active_campaign_id = result['contact']['id'] 17 | user.save 18 | 19 | Email.new.update_subscription(user, "1", true) #Master List 20 | Email.new.update_subscription(user, "2", user.email_weekly) 21 | Email.new.update_subscription(user, "3", user.email_daily) 22 | 23 | Email.new.add_tag(user, '2') #created-account 24 | 25 | render json: UserSerializer.new(user, params: { token: true }).serializable_hash 26 | end 27 | end 28 | 29 | def update 30 | user = current_user 31 | old_email = user.email 32 | if user.check_password(params[:old_password]) then 33 | user.update(user_update_params) 34 | user.save 35 | 36 | if(old_email != user.email) then 37 | Email.new.update_contact(user) 38 | end 39 | 40 | new_password = params[:new_password] 41 | if new_password && new_password.length >= 8 then 42 | user.set_password(new_password) 43 | end 44 | render json: UserSerializer.new(user).serializable_hash 45 | else 46 | head 401 47 | end 48 | end 49 | 50 | def update_nonsensitive 51 | user = current_user 52 | user.next_steps_taken = params[:next_steps_taken] if params[:next_steps_taken] 53 | user.phone_number = params[:phone_number] if params[:phone_number] 54 | user.playback_rate = params[:playback_rate] if params[:playback_rate] 55 | 56 | user.save 57 | 58 | render json: UserSerializer.new(user).serializable_hash 59 | end 60 | 61 | def get_user_from_token 62 | user = User.find(params[:id]) 63 | if(user.email_subscription_token == params[:email_subscription_token]) then 64 | render json: UserSerializer.new(user).serializable_hash 65 | else 66 | head 401 67 | end 68 | end 69 | 70 | private 71 | 72 | def user_create_params 73 | params.require(:user).permit(:name, :email, :password, :email_weekly, :email_daily) 74 | end 75 | 76 | def user_update_params 77 | params.require(:user).permit(:name, :email, :playback_rate) 78 | end 79 | 80 | def user_json(user) 81 | UserSerializer.new(user).serializable_hash 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /app/controllers/api/video_plays_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::VideoPlaysController < ApplicationController 2 | def create 3 | VideoPlay.create(user_id: current_user.id, video_id: params[:video_id]) 4 | head 201 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/controllers/api/video_tags_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::VideoTagsController < ApplicationController 2 | def create 3 | VideoTag.create(video_id: params[:video_id], tag_id: params[:tag_id]) 4 | head 201 5 | end 6 | 7 | def delete 8 | VideoTag.find_by(video_id: params[:video_id], tag_id: params[:tag_id]).destroy 9 | head 204 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/api/videos_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::VideosController < ApplicationController 2 | before_action :authenticate_user, only: [:create, :update, :destroy] 3 | 4 | def index 5 | videos = Video.all 6 | render json: video_json(videos) 7 | end 8 | 9 | def show 10 | video = Video.find(params[:id]) 11 | render json: video_json(video) 12 | end 13 | 14 | def create 15 | video = Video.create(video_params) 16 | render json: video_json(video) 17 | end 18 | 19 | def destroy 20 | Video.find(params[:id]).destroy 21 | head 204 22 | end 23 | 24 | def update 25 | video = Video.find(params[:id]) 26 | video.update(video_params) 27 | video.save() 28 | render json: video_json(video) 29 | end 30 | 31 | private 32 | 33 | def video_json(video) 34 | VideoSerializer.new(video, params: { user_pro: current_user && current_user.pro, user_admin: current_user && current_user.admin }).serializable_hash 35 | end 36 | 37 | def video_params 38 | params.require(:video).permit(:name, :description, :thumbnail, :videoUrl, :duration, :published_at, :code_summary, :order, :course_id, :pro, :lesson_type, :code, :code_summary_state) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::API 2 | def current_user 3 | auth_token = request.headers['Authorization'] 4 | return unless auth_token 5 | 6 | User.find_by(token: auth_token) 7 | end 8 | 9 | def is_admin 10 | current_user && current_user.admin 11 | end 12 | 13 | def authenticate_user 14 | return head 401 unless is_admin 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreybiles/vue-screencasts-server/bbefcb63620392e6863a42a54b79ec11d049644b/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/javascript/channels/consumer.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 `rails generate channel` command. 3 | 4 | import { createConsumer } from "@rails/actioncable" 5 | 6 | export default createConsumer() 7 | -------------------------------------------------------------------------------- /app/javascript/channels/index.js: -------------------------------------------------------------------------------- 1 | // Load all the channels within this directory and all subdirectories. 2 | // Channel files must be named *_channel.js. 3 | 4 | const channels = require.context('.', true, /_channel\.js$/) 5 | channels.keys().forEach(channels) 6 | -------------------------------------------------------------------------------- /app/javascript/packs/application.js: -------------------------------------------------------------------------------- 1 | // This file is automatically compiled by Webpack, along with any other files 2 | // present in this directory. You're encouraged to place your actual application logic in 3 | // a relevant structure within app/javascript and only use these pack files to reference 4 | // that code so it'll be compiled. 5 | 6 | require("@rails/ujs").start() 7 | require("turbolinks").start() 8 | require("@rails/activestorage").start() 9 | require("channels") 10 | 11 | 12 | // Uncomment to copy all static images under ../images to the output folder and reference 13 | // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) 14 | // or the `imagePath` JavaScript helper below. 15 | // 16 | // const images = require.context('../images', true) 17 | // const imagePath = (name) => images(name, true) 18 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'jeffrey@vuetraining.net' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/mailers/vue_training_mailer.rb: -------------------------------------------------------------------------------- 1 | class VueTrainingMailer < ApplicationMailer 2 | def login_info(email, password) 3 | @email = email 4 | @password = password 5 | mail(to: @email, subject: 'Welcome to VueTraining! Here\'s your login info.') 6 | end 7 | 8 | def already_exists(email) 9 | @email = email 10 | mail(to: @email, subject: 'Welcome to VueTraining! Here\'s your login info.') 11 | end 12 | end -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreybiles/vue-screencasts-server/bbefcb63620392e6863a42a54b79ec11d049644b/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/course.rb: -------------------------------------------------------------------------------- 1 | class Course < ApplicationRecord 2 | has_many :videos 3 | belongs_to :parent, optional: true, class_name: "Course" 4 | has_many :chapters, class_name: "Course", foreign_key: "parent_id" 5 | 6 | def max_order 7 | orders = self.chapters.map(&:order) + self.videos.map(&:order) 8 | orders.select{|x| x}.max 9 | end 10 | 11 | # go through the description and title of every course and video to replace an old word with a new word. 12 | # First use was VueX -> Vuex 13 | def self.update_data(old_word, new_word) 14 | Course.all.each do |course| 15 | course.name = course.name.gsub(old_word, new_word) 16 | course.description = course.description.gsub(old_word, new_word) 17 | course.save 18 | end 19 | 20 | Video.all.each do |video| 21 | video.name = video.name.gsub(old_word, new_word) 22 | video.description = video.description.gsub(old_word, new_word) 23 | video.save 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/models/email.rb: -------------------------------------------------------------------------------- 1 | class Email 2 | def contact(user) 3 | get("contacts/#{user.active_campaign_id}") 4 | end 5 | 6 | def update_subscription(user, list_id, is_subscribed) 7 | post('contactLists', { 8 | contactList: { 9 | list: list_id, 10 | contact: user.active_campaign_id, 11 | status: is_subscribed ? 1 : 2 12 | } 13 | }) 14 | end 15 | 16 | def create_and_tag(email, tag_id) 17 | result = post('contact/sync', { 18 | contact: { 19 | email: email, 20 | } 21 | }) 22 | ac_id = result['contact']['id'] 23 | post('contactTags', { 24 | contactTag: { 25 | contact: ac_id, 26 | tag: tag_id 27 | } 28 | }) 29 | end 30 | 31 | def create_contact(user) 32 | post('contact/sync', { 33 | contact: { 34 | email: user.email, 35 | firstName: user.name 36 | } 37 | }) 38 | end 39 | 40 | def update_contact(user) 41 | put("contacts/#{user.active_campaign_id}", { 42 | contact: { 43 | email: user.email, 44 | firstName: user.name 45 | } 46 | }) 47 | end 48 | 49 | def tags 50 | get("tags") 51 | end 52 | 53 | def add_tag(user, tag_id) 54 | post('contactTags', { 55 | contactTag: { 56 | contact: user.active_campaign_id, 57 | tag: tag_id 58 | } 59 | }) 60 | end 61 | 62 | def get(url, props = {}) 63 | parse Faraday.get("#{base_url}/#{url}", props, {"Api-Token" => api_key, "Content-Type" => "application/json"}) 64 | end 65 | 66 | def post(url, props = {}) 67 | parse Faraday.post("#{base_url}/#{url}", props.to_json, {"Api-Token" => api_key}) 68 | end 69 | 70 | def put(url, props = {}) 71 | parse Faraday.put("#{base_url}/#{url}", props.to_json, {"Api-Token" => api_key}) 72 | end 73 | 74 | def parse(json) 75 | JSON.parse(json.body) 76 | end 77 | 78 | def base_url 79 | ENV['ACTIVE_CAMPAIGN_BASE_URL'] 80 | end 81 | 82 | def api_key 83 | ENV['ACTIVE_CAMPAIGN_API_KEY'] 84 | end 85 | end -------------------------------------------------------------------------------- /app/models/tag.rb: -------------------------------------------------------------------------------- 1 | class Tag < ApplicationRecord 2 | has_many :video_tags 3 | has_many :videos, through: :video_tags 4 | end 5 | -------------------------------------------------------------------------------- /app/models/training_completion.rb: -------------------------------------------------------------------------------- 1 | class TrainingCompletion < ApplicationRecord 2 | belongs_to :training_item 3 | belongs_to :user 4 | end -------------------------------------------------------------------------------- /app/models/training_item.rb: -------------------------------------------------------------------------------- 1 | class TrainingItem < ApplicationRecord 2 | belongs_to :training_section 3 | has_many :training_completions 4 | end -------------------------------------------------------------------------------- /app/models/training_module.rb: -------------------------------------------------------------------------------- 1 | class TrainingModule < ApplicationRecord 2 | has_many :training_sections 3 | end -------------------------------------------------------------------------------- /app/models/training_section.rb: -------------------------------------------------------------------------------- 1 | class TrainingSection < ApplicationRecord 2 | has_many :training_items 3 | belongs_to :training_module 4 | end -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | require 'digest/sha1' 2 | Stripe.api_key = ENV['STRIPE_SECRET'] 3 | 4 | class User < ApplicationRecord 5 | has_many :video_plays 6 | has_many :played_videos, through: :video_plays, class_name: 'video' 7 | has_many :training_completions 8 | before_save :downcase_fields 9 | 10 | def set_password(password) 11 | self.salt = Digest::SHA1.hexdigest("#{self.email}#{Time.now}") 12 | self.encrypted_password = Digest::SHA1.hexdigest("#{password}#{self.salt}") 13 | self.save 14 | end 15 | 16 | def self.bootcamp_user(username, password) 17 | User.build_user({ 18 | email: username, 19 | bootcamp: true 20 | }, password) 21 | end 22 | 23 | def self.build_user(user_create_params, password) 24 | user = User.create(user_create_params) 25 | user.set_password(password) 26 | user.set_token 27 | user.set_email_token 28 | return user 29 | end 30 | 31 | def set_token 32 | self.token = generate_token 33 | self.save 34 | end 35 | 36 | def set_email_token 37 | self.email_subscription_token = generate_token(Time.now + 20000) 38 | self.save 39 | end 40 | 41 | def generate_token(extra_salt = Time.now) 42 | Digest::SHA1.hexdigest("#{self.salt}#{extra_salt}") 43 | end 44 | 45 | def check_password(password) 46 | self.encrypted_password == Digest::SHA1.hexdigest("#{password}#{self.salt}") 47 | end 48 | 49 | def pro 50 | return true 51 | # return calculate_pro 52 | end 53 | 54 | def calculate_pro 55 | return true if self.free_subscription 56 | 57 | return false if !self.subscription_id 58 | 59 | subscription_still_good = self.subscription_end_date && DateTime.now < self.subscription_end_date 60 | return true if subscription_still_good 61 | 62 | return false if self.subscription_cancelled 63 | 64 | update_pro_status 65 | return calculate_pro 66 | end 67 | 68 | def update_pro_status 69 | subscription = Stripe::Subscription.retrieve(self.subscription_id) 70 | self.subscription_end_date = Time.at(subscription.current_period_end) 71 | self.subscription_cancelled = !!subscription.canceled_at 72 | self.save 73 | end 74 | 75 | def __testing__clear_subscription 76 | self.subscription_cancelled = nil 77 | self.subscription_end_date = nil 78 | self.subscription_id = nil 79 | self.save 80 | end 81 | 82 | def downcase_fields 83 | self.email.downcase! 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /app/models/video.rb: -------------------------------------------------------------------------------- 1 | class Video < ApplicationRecord 2 | has_many :video_tags 3 | has_many :tags, through: :video_tags 4 | 5 | has_many :video_plays 6 | has_many :users, through: :video_plays 7 | 8 | belongs_to :course, optional: true 9 | 10 | def in_free_period 11 | published_at && (DateTime.now - 7.days) < published_at 12 | end 13 | 14 | def released 15 | published_at && DateTime.now > published_at 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/models/video_play.rb: -------------------------------------------------------------------------------- 1 | class VideoPlay < ApplicationRecord 2 | belongs_to :video 3 | belongs_to :user 4 | end 5 | -------------------------------------------------------------------------------- /app/models/video_tag.rb: -------------------------------------------------------------------------------- 1 | class VideoTag < ApplicationRecord 2 | belongs_to :video 3 | belongs_to :tag 4 | end 5 | -------------------------------------------------------------------------------- /app/serializers/course_serializer.rb: -------------------------------------------------------------------------------- 1 | class CourseSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :name, :series_type, :image_url, :description, :order, :difficulty 4 | has_many :videos 5 | belongs_to :parent, serializer: :course 6 | has_many :chapters 7 | end 8 | -------------------------------------------------------------------------------- /app/serializers/tag_serializer.rb: -------------------------------------------------------------------------------- 1 | class TagSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :name 4 | has_many :videos 5 | end 6 | -------------------------------------------------------------------------------- /app/serializers/training_item_serializer.rb: -------------------------------------------------------------------------------- 1 | class TrainingItemSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :title, :position, :text, :exercise_type, :training_section_id, :vimeo_uid, :youtube_uid, :video_url, :published, :answer 4 | end 5 | -------------------------------------------------------------------------------- /app/serializers/training_module_serializer.rb: -------------------------------------------------------------------------------- 1 | class TrainingModuleSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :name, :week_number, :intro, :state 4 | has_many :training_sections 5 | end 6 | -------------------------------------------------------------------------------- /app/serializers/training_section_serializer.rb: -------------------------------------------------------------------------------- 1 | class TrainingSectionSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :name, :position, :training_module_id 4 | has_many :training_items 5 | end 6 | -------------------------------------------------------------------------------- /app/serializers/user_serializer.rb: -------------------------------------------------------------------------------- 1 | class UserSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :id, :name, :email, :admin, :created_at, :pro, :subscription_cancelled, :subscription_end_date, :plan_id, :next_steps_taken, :plan_seats, :playback_rate 4 | 5 | attribute :played_video_ids do |object| 6 | object.video_plays.map(&:video_id).uniq 7 | end 8 | 9 | attribute :completed_training_item_ids do |object| 10 | object.training_completions.map(&:training_item_id).uniq 11 | end 12 | 13 | attribute :has_stripe do |object| 14 | !!object.stripe_id && !!object.subscription_id 15 | end 16 | 17 | attribute :token, if: Proc.new { |record, params| 18 | params && params[:token] 19 | } 20 | 21 | attribute :s3_keys, if: Proc.new { |record, params| 22 | params && params[:admin] 23 | } do |object| 24 | { 25 | id: ENV['S3_ACCESS_KEY_ID'], 26 | secret: ENV['S3_ACCESS_KEY_SECRET'], 27 | } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /app/serializers/video_serializer.rb: -------------------------------------------------------------------------------- 1 | class VideoSerializer 2 | include FastJsonapi::ObjectSerializer 3 | attributes :id, :name, :description, :thumbnail, :pro, :in_free_period, :lesson_type, 4 | :created_at, :updated_at, :duration, :published_at, :order, 5 | :code, :code_summary, :code_summary_state, :videoUrl 6 | belongs_to :course 7 | 8 | end 9 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |By the time you're done, you'll be ready to write real-world programs in both Vue 2 and Vue 3.
4 | 5 |So let's get you started.
6 | 7 |I saw that you already have a VueScreencasts account, so I've modified that account to give you access to VueTraining as well (same backend). 8 | 9 |
That is, your VueTraining password is the same as your VueScreencasts password, and your username is this email address.
10 | 11 |You can access the curriculum here.
12 | 13 |See you in the Slack.
14 | 15 |--Jeffrey
-------------------------------------------------------------------------------- /app/views/vue_training_mailer/login_info.html.erb: -------------------------------------------------------------------------------- 1 |By the time you're done, you'll be ready to write real-world programs in both Vue 2 and Vue 3.
4 | 5 |So let's get you started.
6 | 7 |Here's your login info to access the curriculum:
8 | Username: <%= @email %>See you in the Slack.
12 | 13 |--Jeffrey
-------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | var validEnv = ['development', 'test', 'production'] 3 | var currentEnv = api.env() 4 | var isDevelopmentEnv = api.env('development') 5 | var isProductionEnv = api.env('production') 6 | var isTestEnv = api.env('test') 7 | 8 | if (!validEnv.includes(currentEnv)) { 9 | throw new Error( 10 | 'Please specify a valid `NODE_ENV` or ' + 11 | '`BABEL_ENV` environment variables. Valid values are "development", ' + 12 | '"test", and "production". Instead, received: ' + 13 | JSON.stringify(currentEnv) + 14 | '.' 15 | ) 16 | } 17 | 18 | return { 19 | presets: [ 20 | isTestEnv && [ 21 | require('@babel/preset-env').default, 22 | { 23 | targets: { 24 | node: 'current' 25 | } 26 | } 27 | ], 28 | (isProductionEnv || isDevelopmentEnv) && [ 29 | require('@babel/preset-env').default, 30 | { 31 | forceAllTransforms: true, 32 | useBuiltIns: 'entry', 33 | corejs: 3, 34 | modules: false, 35 | exclude: ['transform-typeof-symbol'] 36 | } 37 | ] 38 | ].filter(Boolean), 39 | plugins: [ 40 | require('babel-plugin-macros'), 41 | require('@babel/plugin-syntax-dynamic-import').default, 42 | isTestEnv && require('babel-plugin-dynamic-import-node'), 43 | require('@babel/plugin-transform-destructuring').default, 44 | [ 45 | require('@babel/plugin-proposal-class-properties').default, 46 | { 47 | loose: true 48 | } 49 | ], 50 | [ 51 | require('@babel/plugin-proposal-object-rest-spread').default, 52 | { 53 | useBuiltIns: true 54 | } 55 | ], 56 | [ 57 | require('@babel/plugin-transform-runtime').default, 58 | { 59 | helpers: false, 60 | regenerator: true, 61 | corejs: false 62 | } 63 | ], 64 | [ 65 | require('@babel/plugin-transform-regenerator').default, 66 | { 67 | async: false 68 | } 69 | ] 70 | ].filter(Boolean) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 || ">= 0.a" 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../../Gemfile", __FILE__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_version 64 | @bundler_version ||= begin 65 | env_var_version || cli_arg_version || 66 | lockfile_version || "#{Gem::Requirement.default}.a" 67 | end 68 | end 69 | 70 | def load_bundler! 71 | ENV["BUNDLE_GEMFILE"] ||= gemfile 72 | 73 | # must dup string for RG < 1.8 compatibility 74 | activate_bundler(bundler_version.dup) 75 | end 76 | 77 | def activate_bundler(bundler_version) 78 | if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0") 79 | bundler_version = "< 2" 80 | end 81 | gem_error = activation_error_handling do 82 | gem "bundler", bundler_version 83 | end 84 | return if gem_error.nil? 85 | require_error = activation_error_handling do 86 | require "bundler/version" 87 | end 88 | return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 89 | warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" 90 | exit 42 91 | end 92 | 93 | def activation_error_handling 94 | yield 95 | nil 96 | rescue StandardError, LoadError => e 97 | e 98 | end 99 | end 100 | 101 | m.load_bundler! 102 | 103 | if m.invoked_as_script? 104 | load Gem.bin_path("bundler", "bundle") 105 | end 106 | -------------------------------------------------------------------------------- /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 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path('..', __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to setup or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at anytime and get an expectable outcome. 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 21 | # system('bin/yarn') 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:prepare' 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/webpack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "rubygems" 11 | require "bundler/setup" 12 | 13 | require "webpacker" 14 | require "webpacker/webpack_runner" 15 | 16 | APP_ROOT = File.expand_path("..", __dir__) 17 | Dir.chdir(APP_ROOT) do 18 | Webpacker::WebpackRunner.run(ARGV) 19 | end 20 | -------------------------------------------------------------------------------- /bin/webpack-dev-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "rubygems" 11 | require "bundler/setup" 12 | 13 | require "webpacker" 14 | require "webpacker/dev_server_runner" 15 | 16 | APP_ROOT = File.expand_path("..", __dir__) 17 | Dir.chdir(APP_ROOT) do 18 | Webpacker::DevServerRunner.run(ARGV) 19 | end 20 | -------------------------------------------------------------------------------- /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 VueScreencastsServer 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 6.0 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 | 19 | 20 | config.middleware.insert_before 0, Rack::Cors do 21 | allow do 22 | origins '*' 23 | resource '*', headers: :any, methods: [:get, :post, :delete, :put, :patch, :options, :head] 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /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: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: vue_screencasts_server_production 11 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | bX1/aBd+Bm6+PGdvEFrURzPSbFf1M7VuAggC1noibrqggv+SU+5D2d8w8JoA8VBrhXb472+Lzsg1nEtipSlBREp1zggsML54AlpX3CrRIBY2L1ExFc56B0cNu1cNhW6iDlj7/jLihfVM4GYgRnQJD/vJ96WriUu/UvlDtb6kjCaB53mtN/aTMpUxIRDG9ZNNnJHSfY7jqzrjX/qckd1qrLpXfM+cIAhCs0cA6KH1tbi0bca9JBmC1hHU0uV/YC8viRwbuAGas3ukFp4uCSrG+0QdBym5EAqAZxIAmESo1PXPt8mvJCRQLPckGw69msE1cIMG46HOydpk4TyekLJ47HNXOT1EN308uIp3xHwXWeiCC5L/EsLW0oX3g1V136l9pulqlAxmFpZd3qJ2GMXzvyPAvw3vQkFBdxnP--KnnqCJIhhMTRpheL--e6p8ro3Ht8SBH+sogaqh1w== -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 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: postgresql 9 | encoding: unicode 10 | username: jeffreybiles 11 | password: <%= ENV['DATABASE_PASSWORD'] %> 12 | 13 | development: 14 | <<: *default 15 | database: vuescreencasts_dev 16 | 17 | # Warning: The database defined as "test" will be erased and 18 | # re-generated from your development database when you run "rake". 19 | # Do not set this db to the same as development or production. 20 | test: 21 | <<: *default 22 | database: vuescreencasts_test 23 | 24 | production: 25 | adapter: postgresql 26 | encoding: unicode 27 | database: vuescreencasts_production 28 | username: vuescreencasts 29 | password: <%= ENV['DATABASE_PASSWORD'] %> 30 | -------------------------------------------------------------------------------- /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 | config.action_controller.enable_fragment_cache_logging = true 20 | 21 | config.cache_store = :memory_store 22 | config.public_file_server.headers = { 23 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 24 | } 25 | else 26 | config.action_controller.perform_caching = false 27 | 28 | config.cache_store = :null_store 29 | end 30 | 31 | # Store uploaded files on the local file system (see config/storage.yml for options). 32 | config.active_storage.service = :local 33 | 34 | config.action_mailer.delivery_method = :smtp 35 | # SMTP settings for hover mail 36 | config.action_mailer.smtp_settings = { 37 | :address => "mail.hover.com", 38 | :port => 587, 39 | :user_name => ENV['mail_username'], 40 | :password => ENV['mail_password'], 41 | :authentication => "plain", 42 | # :enable_starttls_auto => true 43 | } 44 | 45 | # Don't care if the mailer can't send. 46 | config.action_mailer.raise_delivery_errors = true 47 | 48 | config.action_mailer.perform_caching = false 49 | 50 | # Print deprecation notices to the Rails logger. 51 | config.active_support.deprecation = :log 52 | 53 | # Raise an error on page load if there are pending migrations. 54 | config.active_record.migration_error = :page_load 55 | 56 | # Highlight code that triggered database queries in logs. 57 | config.active_record.verbose_query_logs = true 58 | 59 | # Debug mode disables concatenation and preprocessing of assets. 60 | # This option may cause significant delays in view rendering with a large 61 | # number of complex assets. 62 | config.assets.debug = true 63 | 64 | # Suppress logger output for asset requests. 65 | config.assets.quiet = true 66 | 67 | # Raises error for missing translations. 68 | # config.action_view.raise_on_missing_translations = true 69 | 70 | # Use an evented file watcher to asynchronously detect changes in source code, 71 | # routes, locales, etc. This feature depends on the listen gem. 72 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 73 | end 74 | -------------------------------------------------------------------------------- /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 CSS using a preprocessor. 26 | # config.assets.css_compressor = :sass 27 | 28 | # Do not fallback to assets pipeline if a precompiled asset is missed. 29 | config.assets.compile = false 30 | 31 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 32 | # config.action_controller.asset_host = 'http://assets.example.com' 33 | 34 | # Specifies the header that your server uses for sending files. 35 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 36 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 37 | 38 | # Store uploaded files on the local file system (see config/storage.yml for options). 39 | config.active_storage.service = :local 40 | 41 | # Mount Action Cable outside main process or domain. 42 | # config.action_cable.mount_path = nil 43 | # config.action_cable.url = 'wss://example.com/cable' 44 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 45 | 46 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 47 | config.force_ssl = true 48 | 49 | # Use the lowest log level to ensure availability of diagnostic information 50 | # when problems arise. 51 | config.log_level = :debug 52 | 53 | # Prepend all log lines with the following tags. 54 | config.log_tags = [ :request_id ] 55 | 56 | # Use a different cache store in production. 57 | # config.cache_store = :mem_cache_store 58 | 59 | # Use a real queuing backend for Active Job (and separate queues per environment). 60 | # config.active_job.queue_adapter = :resque 61 | # config.active_job.queue_name_prefix = "vue_screencasts_server_production" 62 | 63 | 64 | config.action_mailer.delivery_method = :smtp 65 | # SMTP settings for hover mail 66 | config.action_mailer.smtp_settings = { 67 | :address => "mail.hover.com", 68 | :port => 587, 69 | :user_name => ENV['mail_username'], 70 | :password => ENV['mail_password'], 71 | :authentication => "plain", 72 | # :enable_starttls_auto => true 73 | } 74 | config.action_mailer.perform_caching = false 75 | 76 | # Ignore bad email addresses and do not raise email delivery errors. 77 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 78 | # config.action_mailer.raise_delivery_errors = false 79 | 80 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 81 | # the I18n.default_locale when a translation cannot be found). 82 | config.i18n.fallbacks = true 83 | 84 | # Send deprecation notices to registered listeners. 85 | config.active_support.deprecation = :notify 86 | 87 | # Use default logging formatter so that PID and timestamp are not suppressed. 88 | config.log_formatter = ::Logger::Formatter.new 89 | 90 | # Use a different logger for distributed setups. 91 | # require 'syslog/logger' 92 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 93 | 94 | if ENV["RAILS_LOG_TO_STDOUT"].present? 95 | logger = ActiveSupport::Logger.new(STDOUT) 96 | logger.formatter = config.log_formatter 97 | config.logger = ActiveSupport::TaggedLogging.new(logger) 98 | end 99 | 100 | # Do not dump schema after migrations. 101 | config.active_record.dump_schema_after_migration = false 102 | 103 | # Inserts middleware to perform automatic connection switching. 104 | # The `database_selector` hash is used to pass options to the DatabaseSelector 105 | # middleware. The `delay` is used to determine how long to wait after a write 106 | # to send a subsequent read to the primary. 107 | # 108 | # The `database_resolver` class is used by the middleware to determine which 109 | # database is appropriate to use based on the time delay. 110 | # 111 | # The `database_resolver_context` class is used by the middleware to set 112 | # timestamps for the last write to the primary. The resolver uses the context 113 | # class timestamps to determine how long to wait before reading from the 114 | # replica. 115 | # 116 | # By default Rails will store a last write timestamp in the session. The 117 | # DatabaseSelector middleware is designed as such you can define your own 118 | # strategy for connection switching and pass that into the middleware through 119 | # these configuration options. 120 | # config.active_record.database_selector = { delay: 2.seconds } 121 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver 122 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session 123 | end 124 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # The test environment is used exclusively to run your application's 2 | # test suite. You never need to work with it otherwise. Remember that 3 | # your test database is "scratch space" for the test suite and is wiped 4 | # and recreated between test runs. Don't rely on the data there! 5 | 6 | Rails.application.configure do 7 | # Settings specified here will take precedence over those in config/application.rb. 8 | 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. This avoids loading your whole application 12 | # just for the purpose of running a single test. If you are using a tool that 13 | # preloads Rails for running tests, you may have to set it to true. 14 | config.eager_load = false 15 | 16 | # Configure public file server for tests with Cache-Control for performance. 17 | config.public_file_server.enabled = true 18 | config.public_file_server.headers = { 19 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 20 | } 21 | 22 | # Show full error reports and disable caching. 23 | config.consider_all_requests_local = true 24 | config.action_controller.perform_caching = false 25 | config.cache_store = :null_store 26 | 27 | # Raise exceptions instead of rendering exception templates. 28 | config.action_dispatch.show_exceptions = false 29 | 30 | # Disable request forgery protection in test environment. 31 | config.action_controller.allow_forgery_protection = false 32 | 33 | # Store uploaded files on the local file system in a temporary directory. 34 | config.active_storage.service = :test 35 | 36 | config.action_mailer.perform_caching = false 37 | 38 | # Tell Action Mailer not to deliver emails to the real world. 39 | # The :test delivery method accumulates sent emails in the 40 | # ActionMailer::Base.deliveries array. 41 | config.action_mailer.delivery_method = :test 42 | 43 | # Print deprecation notices to the stderr. 44 | config.active_support.deprecation = :stderr 45 | 46 | # Raises error for missing translations. 47 | # config.action_view.raise_on_missing_translations = true 48 | end 49 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 14 | # # If you are using webpack-dev-server then specify webpack-dev-server host 15 | # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? 16 | 17 | # # Specify URI for violation reports 18 | # # policy.report_uri "/csp-violation-report-endpoint" 19 | # end 20 | 21 | # If you are using UJS then enable automatic nonce generation 22 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 23 | 24 | # Set the nonce only to specific directives 25 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src) 26 | 27 | # Report CSP violations to a specified URI 28 | # For further information see the following documentation: 29 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 30 | # Rails.application.config.content_security_policy_report_only = true 31 | -------------------------------------------------------------------------------- /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 https://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 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 12 | # 13 | port ENV.fetch("PORT") { 3000 } 14 | 15 | # Specifies the `environment` that Puma will run in. 16 | # 17 | environment ENV.fetch("RAILS_ENV") { "development" } 18 | 19 | # Specifies the `pidfile` that Puma will use. 20 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 21 | 22 | # Specifies the number of `workers` to boot in clustered mode. 23 | # Workers are forked web server processes. If using threads and workers together 24 | # the concurrency of the application would be max `threads` * `workers`. 25 | # Workers do not work on JRuby or Windows (both of which do not support 26 | # processes). 27 | # 28 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 29 | 30 | # Use the `preload_app!` method when specifying a `workers` number. 31 | # This directive tells Puma to first boot the application and load code 32 | # before forking the application. This takes advantage of Copy On Write 33 | # process behavior so workers use less memory. 34 | # 35 | # preload_app! 36 | 37 | # Allow puma to be restarted by `rails restart` command. 38 | plugin :tmp_restart 39 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html 3 | namespace 'api' do 4 | resources :videos 5 | resources :video_tags, only: [:create] 6 | post 'video_tags/delete', to: 'video_tags#delete' 7 | resources :tags, only: [:index, :show, :create, :update, :destroy] 8 | resources :users, only: [:index, :create, :destroy, :update] 9 | put 'users/:id/update_nonsensitive', to: 'users#update_nonsensitive' 10 | get 'email_preferences/status', to: 'email_preferences#status' 11 | post 'email_preferences/change_subscription', to: 'email_preferences#change_subscription' 12 | post 'email_preferences/create_and_tag', to: 'email_preferences#create_and_tag' 13 | get 'users/:id/:email_subscription_token', to: 'users#get_user_from_token' 14 | post 'users/:id/:email_subscription_token', to: 'users#update_email_subscriptions_from_token' 15 | resources :sessions, only: [:create, :destroy] 16 | get 'sessions/user', to: 'sessions#user' 17 | resources :video_plays, only: :create 18 | resources :courses 19 | post 'courses/:id/attach-video/:video_id', to: "courses#attach_video" 20 | post 'courses/:id/attach-chapter/:chapter_id', to: "courses#attach_chapter" 21 | post 'courses/:id/detach-video/:video_id', to: "courses#detach_video" 22 | post 'courses/:id/detach-chapter/:chapter_id', to: "courses#detach_chapter" 23 | post 'stripe/create_subscription', "stripe#create_subscription" 24 | get 'stripe/user_info', "stripe#user_info" 25 | post 'stripe/cancel_subscription', "stripe#cancel_subscription" 26 | post 'stripe/resubscribe', "stripe#resubscribe" 27 | post 'stripe/change_card', "stripe#change_card" 28 | 29 | resources :training_modules 30 | resources :training_sections 31 | resources :training_items 32 | resources :training_completions, only: :create 33 | 34 | resources :training_users, only: [:index, :create] 35 | 36 | post 'hooks/new_training_customer', "hooks#new_training_customer" 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | Spring.watch( 2 | ".ruby-version", 3 | ".rbenv-vars", 4 | "tmp/restart.txt", 5 | "tmp/caching-dev.txt" 6 | ) 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 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /config/webpack/development.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /config/webpack/environment.js: -------------------------------------------------------------------------------- 1 | const { environment } = require('@rails/webpacker') 2 | 3 | module.exports = environment 4 | -------------------------------------------------------------------------------- /config/webpack/production.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'production' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /config/webpack/test.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /config/webpacker.yml: -------------------------------------------------------------------------------- 1 | # Note: You must restart bin/webpack-dev-server for changes to take effect 2 | 3 | default: &default 4 | source_path: app/javascript 5 | source_entry_path: packs 6 | public_root_path: public 7 | public_output_path: packs 8 | cache_path: tmp/cache/webpacker 9 | check_yarn_integrity: false 10 | webpack_compile_output: false 11 | 12 | # Additional paths webpack should lookup modules 13 | # ['app/assets', 'engine/foo/app/assets'] 14 | resolved_paths: [] 15 | 16 | # Reload manifest.json on all requests so we reload latest compiled packs 17 | cache_manifest: false 18 | 19 | # Extract and emit a css file 20 | extract_css: false 21 | 22 | static_assets_extensions: 23 | - .jpg 24 | - .jpeg 25 | - .png 26 | - .gif 27 | - .tiff 28 | - .ico 29 | - .svg 30 | - .eot 31 | - .otf 32 | - .ttf 33 | - .woff 34 | - .woff2 35 | 36 | extensions: 37 | - .mjs 38 | - .js 39 | - .sass 40 | - .scss 41 | - .css 42 | - .module.sass 43 | - .module.scss 44 | - .module.css 45 | - .png 46 | - .svg 47 | - .gif 48 | - .jpeg 49 | - .jpg 50 | 51 | development: 52 | <<: *default 53 | compile: true 54 | 55 | # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules 56 | check_yarn_integrity: true 57 | 58 | # Reference: https://webpack.js.org/configuration/dev-server/ 59 | dev_server: 60 | https: false 61 | host: localhost 62 | port: 3035 63 | public: localhost:3035 64 | hmr: false 65 | # Inline should be set to true if using HMR 66 | inline: true 67 | overlay: true 68 | compress: true 69 | disable_host_check: true 70 | use_local_ip: false 71 | quiet: false 72 | headers: 73 | 'Access-Control-Allow-Origin': '*' 74 | watch_options: 75 | ignored: '**/node_modules/**' 76 | 77 | 78 | test: 79 | <<: *default 80 | compile: true 81 | 82 | # Compile test packs to a separate directory 83 | public_output_path: packs-test 84 | 85 | production: 86 | <<: *default 87 | 88 | # Production depends on precompilation of packs prior to booting for performance. 89 | compile: false 90 | 91 | # Extract and emit a css file 92 | extract_css: true 93 | 94 | # Cache manifest.json for performance 95 | cache_manifest: true 96 | -------------------------------------------------------------------------------- /db/migrate/20190909155809_create_videos.rb: -------------------------------------------------------------------------------- 1 | class CreateVideos < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :videos do |t| 4 | t.string :name 5 | t.text :description 6 | t.string :thumbnail 7 | t.string :videoUrl 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20190909180420_create_tags.rb: -------------------------------------------------------------------------------- 1 | class CreateTags < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :tags do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20190909180505_create_video_tags.rb: -------------------------------------------------------------------------------- 1 | class CreateVideoTags < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :video_tags do |t| 4 | t.references :video 5 | t.references :tag 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20190917003054_add_users.rb: -------------------------------------------------------------------------------- 1 | class AddUsers < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :users do |t| 4 | t.string :name 5 | t.string :email 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20190922215121_add_password_and_salt.rb: -------------------------------------------------------------------------------- 1 | class AddPasswordAndSalt < ActiveRecord::Migration[6.0] 2 | def change 3 | change_table :users do |t| 4 | t.column :encrypted_password, :string 5 | t.column :salt, :string 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /db/migrate/20190923073459_add_token.rb: -------------------------------------------------------------------------------- 1 | class AddToken < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :token, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20190925080948_add_admin_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddAdminToUsers < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :admin, :boolean 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20190930134531_add_watched_video_relationship_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddWatchedVideoRelationshipToUsers < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :video_plays do |t| 4 | t.references :user 5 | t.references :video 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20191103161647_add_fields_to_video.rb: -------------------------------------------------------------------------------- 1 | class AddFieldsToVideo < ActiveRecord::Migration[6.0] 2 | def change 3 | change_table :videos do |t| 4 | t.column :duration, :integer 5 | t.column :published_at, :datetime 6 | t.column :code_summary, :text 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20191201134808_add_series.rb: -------------------------------------------------------------------------------- 1 | class AddSeries < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :courses do |t| 4 | t.string :name 5 | t.integer :parent_id 6 | 7 | t.timestamps 8 | end 9 | 10 | add_reference :videos, :course, foreign_key: true 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20191201141427_add_series_type.rb: -------------------------------------------------------------------------------- 1 | class AddSeriesType < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :courses, :series_type, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20191201153951_add_image_url_to_course.rb: -------------------------------------------------------------------------------- 1 | class AddImageUrlToCourse < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :courses, :image_url, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20191202151424_add.rb: -------------------------------------------------------------------------------- 1 | class Add < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :courses, :description, :text 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20191202195455_add_order_to_video_and_chapter.rb: -------------------------------------------------------------------------------- 1 | class AddOrderToVideoAndChapter < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :videos, :order, :decimal 4 | add_column :courses, :order, :decimal 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20191212205314_add_email_fields.rb: -------------------------------------------------------------------------------- 1 | class AddEmailFields < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :email_weekly, :boolean 4 | add_column :users, :email_daily, :boolean 5 | add_column :users, :email_subscription_token, :string 6 | 7 | User.all.each do |user| 8 | user.set_email_token 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20191214171653_add_difficulty_to_courses.rb: -------------------------------------------------------------------------------- 1 | class AddDifficultyToCourses < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :courses, :difficulty, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20191229055737_add_pro_option_to_videos.rb: -------------------------------------------------------------------------------- 1 | class AddProOptionToVideos < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :videos, :pro, :boolean 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200108151514_add_stripe_ids_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddStripeIdsToUser < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :stripe_id, :string 4 | add_column :users, :subscription_id, :string 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20200113211401_add_subscription_properties.rb: -------------------------------------------------------------------------------- 1 | class AddSubscriptionProperties < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :subscription_end_date, :datetime 4 | add_column :users, :subscription_cancelled, :boolean 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20200205195030_add_types_to_course_and_video.rb: -------------------------------------------------------------------------------- 1 | class AddTypesToCourseAndVideo < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :videos, :lesson_type, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200224033312_add_plan_id_and_plan_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddPlanIdAndPlanToUser < ActiveRecord::Migration[6.0] 2 | def change 3 | enable_extension 'hstore' 4 | 5 | add_column :users, :plan_id, :string 6 | add_column :users, :plan_hash, :hstore, default: {} 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /db/migrate/20200224201444_add_phone_number.rb: -------------------------------------------------------------------------------- 1 | class AddPhoneNumber < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :phone_number, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200225175024_add_next_steps_data.rb: -------------------------------------------------------------------------------- 1 | class AddNextStepsData < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :next_steps_taken, :hstore, default: {} 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200327163206_add_free_subscription.rb: -------------------------------------------------------------------------------- 1 | class AddFreeSubscription < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :free_subscription, :boolean 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200331043754_add_needs_code_summary_field_to_video.rb: -------------------------------------------------------------------------------- 1 | class AddNeedsCodeSummaryFieldToVideo < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :videos, :code, :text 4 | add_column :videos, :code_summary_state, :string, default: 'not_ready' 5 | # possible states: 6 | # not_ready 7 | # ready 8 | # started 9 | # finished 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20200414181716_plan_seats.rb: -------------------------------------------------------------------------------- 1 | class PlanSeats < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :plan_seats, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200427093554_add_active_campaign_id_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddActiveCampaignIdToUser < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :active_campaign_id, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200615003946_create_modules_sections_and_items.rb: -------------------------------------------------------------------------------- 1 | class CreateModulesSectionsAndItems < ActiveRecord::Migration[6.0] 2 | def change 3 | create_table :training_modules do |t| 4 | t.string :name 5 | t.integer :week_number 6 | 7 | t.timestamps 8 | end 9 | 10 | create_table :training_sections do |t| 11 | t.string :name 12 | t.decimal :position 13 | t.references :training_module 14 | 15 | t.timestamps 16 | end 17 | 18 | create_table :training_items do |t| 19 | t.string :title 20 | t.string :exercise_type 21 | t.text :text 22 | t.decimal :position 23 | t.references :training_section 24 | 25 | t.timestamps 26 | end 27 | 28 | create_table :training_completions do |t| 29 | t.references :training_item 30 | t.references :user 31 | 32 | t.timestamps 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /db/migrate/20200625141651_add_intro_to_module.rb: -------------------------------------------------------------------------------- 1 | class AddIntroToModule < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :training_modules, :intro, :text 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200704061057_add_vimeo_id.rb: -------------------------------------------------------------------------------- 1 | class AddVimeoId < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :training_items, :vimeo_id, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200704223359_switch_from_id_to_uid.rb: -------------------------------------------------------------------------------- 1 | class SwitchFromIdToUid < ActiveRecord::Migration[6.0] 2 | def change 3 | remove_column :training_items, :vimeo_id, :string 4 | add_column :training_items, :vimeo_uid, :string 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20200706165738_make_bootcamp_creation_easier.rb: -------------------------------------------------------------------------------- 1 | class MakeBootcampCreationEasier < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :bootcamp, :boolean 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200710191127_add_youtube_uid.rb: -------------------------------------------------------------------------------- 1 | class AddYoutubeUid < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :training_items, :youtube_uid, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200710192436_add_video_url.rb: -------------------------------------------------------------------------------- 1 | class AddVideoUrl < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :training_items, :video_url, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200714162618_add_published_bool_to_module.rb: -------------------------------------------------------------------------------- 1 | class AddPublishedBoolToModule < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :training_modules, :state, :string, default: 'published' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20200716083445_add_answers_and_published_boolean.rb: -------------------------------------------------------------------------------- 1 | class AddAnswersAndPublishedBoolean < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :training_items, :published, :boolean, default: true 4 | add_column :training_items, :answer, :text 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20200803093713_add_playback_rate.rb: -------------------------------------------------------------------------------- 1 | class AddPlaybackRate < ActiveRecord::Migration[6.0] 2 | def change 3 | add_column :users, :playback_rate, :decimal, default: 1.0 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /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 | # This file is the source Rails uses to define your schema when running `rails 6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2020_08_03_093713) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "hstore" 17 | enable_extension "plpgsql" 18 | 19 | create_table "comments", force: :cascade do |t| 20 | t.text "content" 21 | t.boolean "deleted" 22 | t.integer "parent_id" 23 | t.integer "user_id" 24 | t.integer "video_id" 25 | t.datetime "created_at", precision: 6, null: false 26 | t.datetime "updated_at", precision: 6, null: false 27 | end 28 | 29 | create_table "courses", force: :cascade do |t| 30 | t.string "name" 31 | t.integer "parent_id" 32 | t.datetime "created_at", precision: 6, null: false 33 | t.datetime "updated_at", precision: 6, null: false 34 | t.string "series_type" 35 | t.string "image_url" 36 | t.text "description" 37 | t.decimal "order" 38 | t.string "difficulty" 39 | end 40 | 41 | create_table "notifications", force: :cascade do |t| 42 | t.boolean "read" 43 | t.boolean "email_sent" 44 | t.integer "user_id" 45 | t.integer "comment_id" 46 | t.text "content" 47 | t.datetime "created_at", precision: 6, null: false 48 | t.datetime "updated_at", precision: 6, null: false 49 | t.integer "video_id" 50 | end 51 | 52 | create_table "tags", force: :cascade do |t| 53 | t.string "name" 54 | t.datetime "created_at", precision: 6, null: false 55 | t.datetime "updated_at", precision: 6, null: false 56 | end 57 | 58 | create_table "training_completions", force: :cascade do |t| 59 | t.bigint "training_item_id" 60 | t.bigint "user_id" 61 | t.datetime "created_at", precision: 6, null: false 62 | t.datetime "updated_at", precision: 6, null: false 63 | t.index ["training_item_id"], name: "index_training_completions_on_training_item_id" 64 | t.index ["user_id"], name: "index_training_completions_on_user_id" 65 | end 66 | 67 | create_table "training_items", force: :cascade do |t| 68 | t.string "title" 69 | t.string "exercise_type" 70 | t.text "text" 71 | t.decimal "position" 72 | t.bigint "training_section_id" 73 | t.datetime "created_at", precision: 6, null: false 74 | t.datetime "updated_at", precision: 6, null: false 75 | t.string "vimeo_uid" 76 | t.string "youtube_uid" 77 | t.string "video_url" 78 | t.boolean "published", default: true 79 | t.text "answer" 80 | t.index ["training_section_id"], name: "index_training_items_on_training_section_id" 81 | end 82 | 83 | create_table "training_modules", force: :cascade do |t| 84 | t.string "name" 85 | t.integer "week_number" 86 | t.datetime "created_at", precision: 6, null: false 87 | t.datetime "updated_at", precision: 6, null: false 88 | t.text "intro" 89 | t.string "state", default: "published" 90 | end 91 | 92 | create_table "training_sections", force: :cascade do |t| 93 | t.string "name" 94 | t.decimal "position" 95 | t.bigint "training_module_id" 96 | t.datetime "created_at", precision: 6, null: false 97 | t.datetime "updated_at", precision: 6, null: false 98 | t.index ["training_module_id"], name: "index_training_sections_on_training_module_id" 99 | end 100 | 101 | create_table "users", force: :cascade do |t| 102 | t.string "name" 103 | t.string "email" 104 | t.datetime "created_at", precision: 6, null: false 105 | t.datetime "updated_at", precision: 6, null: false 106 | t.string "encrypted_password" 107 | t.string "salt" 108 | t.string "token" 109 | t.boolean "admin" 110 | t.boolean "email_weekly" 111 | t.boolean "email_daily" 112 | t.string "email_subscription_token" 113 | t.string "stripe_id" 114 | t.string "subscription_id" 115 | t.datetime "subscription_end_date" 116 | t.boolean "subscription_cancelled" 117 | t.string "plan_id" 118 | t.hstore "plan_hash", default: {} 119 | t.string "phone_number" 120 | t.hstore "next_steps_taken", default: {} 121 | t.boolean "free_subscription" 122 | t.integer "plan_seats" 123 | t.string "active_campaign_id" 124 | t.boolean "bootcamp" 125 | t.decimal "playback_rate", default: "1.0" 126 | end 127 | 128 | create_table "video_plays", force: :cascade do |t| 129 | t.bigint "user_id" 130 | t.bigint "video_id" 131 | t.datetime "created_at", precision: 6, null: false 132 | t.datetime "updated_at", precision: 6, null: false 133 | t.index ["user_id"], name: "index_video_plays_on_user_id" 134 | t.index ["video_id"], name: "index_video_plays_on_video_id" 135 | end 136 | 137 | create_table "video_tags", force: :cascade do |t| 138 | t.bigint "video_id" 139 | t.bigint "tag_id" 140 | t.datetime "created_at", precision: 6, null: false 141 | t.datetime "updated_at", precision: 6, null: false 142 | t.index ["tag_id"], name: "index_video_tags_on_tag_id" 143 | t.index ["video_id"], name: "index_video_tags_on_video_id" 144 | end 145 | 146 | create_table "videos", force: :cascade do |t| 147 | t.string "name" 148 | t.text "description" 149 | t.string "thumbnail" 150 | t.string "videoUrl" 151 | t.datetime "created_at", precision: 6, null: false 152 | t.datetime "updated_at", precision: 6, null: false 153 | t.integer "duration" 154 | t.datetime "published_at" 155 | t.text "code_summary" 156 | t.bigint "course_id" 157 | t.decimal "order" 158 | t.boolean "pro" 159 | t.string "lesson_type" 160 | t.text "code" 161 | t.string "code_summary_state", default: "not_ready" 162 | t.index ["course_id"], name: "index_videos_on_course_id" 163 | end 164 | 165 | add_foreign_key "videos", "courses" 166 | end 167 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreybiles/vue-screencasts-server/bbefcb63620392e6863a42a54b79ec11d049644b/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreybiles/vue-screencasts-server/bbefcb63620392e6863a42a54b79ec11d049644b/lib/tasks/.keep -------------------------------------------------------------------------------- /lib/tasks/connect_email_to_activecampaign.rake: -------------------------------------------------------------------------------- 1 | task :connect_email_to_active_campaign => :environment do 2 | total_results = Email.new.get("contacts?limit=2")['meta']['total'].to_i 3 | offset = 0 4 | limit = 20 5 | puts total_results 6 | while offset < total_results do 7 | contacts = Email.new.get("contacts?limit=#{limit}&offset=#{offset}")['contacts'] 8 | puts "doing the thing" 9 | contacts.each do |contact| 10 | user = User.find_by(email: contact['email']) 11 | 12 | if user then 13 | user.active_campaign_id = contact['id'] 14 | user.save! 15 | end 16 | end 17 | 18 | offset += limit 19 | end 20 | 21 | end -------------------------------------------------------------------------------- /lib/tasks/email_resolving.rake: -------------------------------------------------------------------------------- 1 | task :email_resolving => :environment do 2 | User.all.each do |user| 3 | user.email.downcase! 4 | user.save! 5 | end 6 | end -------------------------------------------------------------------------------- /lib/tasks/heroku_db.rake: -------------------------------------------------------------------------------- 1 | namespace :heroku_db do 2 | desc "Take downloaded db dump and put it into dev dabatase" 3 | task :restore_to_dev do 4 | sh "pg_restore --verbose --clean --no-acl --no-owner -h localhost -U jeffreybiles -d vuescreencasts_dev latest.dump" 5 | end 6 | 7 | task :from_heroku_to_dev do 8 | sh "heroku pg:backups:capture" 9 | sh "curl -o latest.dump `heroku pg:backups:url`" 10 | sh "pg_restore --verbose --clean --no-acl --no-owner -h localhost -U jeffreybiles -d vuescreencasts_dev latest.dump" 11 | end 12 | end 13 | 14 | 15 | task :remove_numbers_from_videos => :environment do 16 | Video.all.each do |video| 17 | video.name = video.name.gsub(/[\/\d\.]+ /, '') 18 | video.save 19 | end 20 | end -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreybiles/vue-screencasts-server/bbefcb63620392e6863a42a54b79ec11d049644b/log/.keep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue_screencasts_server", 3 | "private": true, 4 | "dependencies": { 5 | "@rails/actioncable": "^6.0.0-alpha", 6 | "@rails/activestorage": "^6.0.0-alpha", 7 | "@rails/ujs": "^6.0.0-alpha", 8 | "@rails/webpacker": "^4.0.7", 9 | "turbolinks": "^5.2.0" 10 | }, 11 | "version": "0.1.0", 12 | "devDependencies": { 13 | "webpack-dev-server": "^3.8.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('postcss-import'), 4 | require('postcss-flexbugs-fixes'), 5 | require('postcss-preset-env')({ 6 | autoprefixer: { 7 | flexbox: 'no-2009' 8 | }, 9 | stage: 3 10 | }) 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |You may have mistyped the address or the page may have moved.
63 |If you are the application owner check the logs for more information.
65 |Maybe you tried to change something you didn't have access to.
63 |If you are the application owner check the logs for more information.
65 |If you are the application owner check the logs for more information.
64 |