Commit 47b4bf82 authored by Zac Wood's avatar Zac Wood
Browse files

Compile assets correctly, serve them with Rails for now

parent 5b36225f
Pipeline #3477 failed with stages
in 1 minute and 53 seconds
FROM ruby:2.5 FROM starefossen/ruby-node:latest
RUN mkdir /api RUN mkdir /api
WORKDIR /api WORKDIR /api
...@@ -10,5 +10,6 @@ ENV RAILS_ENV production ...@@ -10,5 +10,6 @@ ENV RAILS_ENV production
RUN bundle install RUN bundle install
RUN export SECRET_KEY_BASE=$(rails secret) RUN export SECRET_KEY_BASE=$(rails secret)
RUN rake assets:precompile
RUN rails db:migrate RUN rails db:migrate
RUN rails db:seed RUN rails db:seed
...@@ -16,6 +16,8 @@ gem 'sass-rails', '~> 5.0' ...@@ -16,6 +16,8 @@ gem 'sass-rails', '~> 5.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5' gem 'jbuilder', '~> 2.5'
gem 'uglifier'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0' # gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password # Use ActiveModel has_secure_password
......
...@@ -60,6 +60,7 @@ GEM ...@@ -60,6 +60,7 @@ GEM
concurrent-ruby (1.1.3) concurrent-ruby (1.1.3)
crass (1.0.4) crass (1.0.4)
erubi (1.7.1) erubi (1.7.1)
execjs (2.7.0)
ffi (1.9.25) ffi (1.9.25)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
...@@ -187,6 +188,8 @@ GEM ...@@ -187,6 +188,8 @@ GEM
tilt (2.0.9) tilt (2.0.9)
tzinfo (1.2.5) tzinfo (1.2.5)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.0) unicode-display_width (1.4.0)
web-console (3.7.0) web-console (3.7.0)
actionview (>= 5.0) actionview (>= 5.0)
...@@ -226,6 +229,7 @@ DEPENDENCIES ...@@ -226,6 +229,7 @@ DEPENDENCIES
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
sqlite3 sqlite3
tzinfo-data tzinfo-data
uglifier
web-console (>= 3.3.0) web-console (>= 3.3.0)
BUNDLED WITH BUNDLED WITH
......
class SearchController < ApplicationController class SearchController < ApplicationController
def index def index
results = SearchHelper::GenericItem.fetchall(String.new(params[:query]), semester: @semester).group_by(&:type) redirect_to home_url unless params[:query].length > 1
# results = search(params[:query]) results = SearchHelper::GenericItem.fetchall(String.new(params[:query]), semester: @semester).group_by(&:type)
@instructors = results[:instructor]&.map(&:data) @instructors = results[:instructor]&.map(&:data)
@courses = results[:course]&.map(&:data) @courses = results[:course]&.map(&:data)
end end
# cases
# math 113 - [a-zA-Z]{3,} [1-9]{3}
end end
...@@ -25,10 +25,11 @@ Rails.application.configure do ...@@ -25,10 +25,11 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = true
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.css_compressor = :sass # config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed. # Do not fallback to assets pipeline if a precompiled asset is missed.
......
# Registers all routes for the app. # Registers all routes for the app.
Rails.application.routes.draw do Rails.application.routes.draw do
get '/', to: 'home#index', as: 'home'
get 'search', to: 'search#index' get 'search', to: 'search#index'
get 'sessions/update', as: 'update_session' get 'sessions/update', as: 'update_session'
get 'sessions/cart' get 'sessions/cart'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment