diff --git a/.gitignore b/.gitignore index 82701fe..d826989 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ /yarn-error.log .byebug_history + +# Ignore application configuration +/config/application.yml diff --git a/Gemfile b/Gemfile index 613528e..5c391b0 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,10 @@ gem 'pg', '~> 0.18' gem 'pg_search' gem 'httparty' +gem 'figaro' +gem 'twitter' +gem 'bootstrap-sass', '~> 3.3.7' +gem 'jquery-rails' # Use Puma as the app server gem 'puma', '~> 3.7' diff --git a/Gemfile.lock b/Gemfile.lock index 2234f81..24ea2bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,7 +41,13 @@ GEM addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) arel (8.0.0) + autoprefixer-rails (7.1.1) + execjs bindex (0.5.0) + bootstrap-sass (3.3.7) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) + buftok (0.2.0) builder (3.2.3) byebug (9.1.0) capybara (2.16.1) @@ -62,11 +68,25 @@ GEM coffee-script-source (1.12.2) concurrent-ruby (1.0.5) crass (1.0.3) + domain_name (0.5.20170404) + unf (>= 0.0.5, < 1.0.0) + equalizer (0.0.11) erubi (1.7.0) execjs (2.7.0) ffi (1.9.18) + figaro (1.1.1) + thor (~> 0.14) globalid (0.4.1) activesupport (>= 4.2.0) + http (3.0.0) + addressable (~> 2.3) + http-cookie (~> 1.0) + http-form_data (>= 2.0.0.pre.pre2, < 3) + http_parser.rb (~> 0.6.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + http-form_data (2.0.0) + http_parser.rb (0.6.0) httparty (0.14.0) multi_xml (>= 0.5.2) i18n (0.9.1) @@ -74,6 +94,10 @@ GEM jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + jquery-rails (4.3.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -83,12 +107,16 @@ GEM nokogiri (>= 1.5.9) mail (2.7.0) mini_mime (>= 0.1.1) + memoizable (0.4.2) + thread_safe (~> 0.3, >= 0.3.1) method_source (0.9.0) mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.10.3) multi_json (1.12.2) multi_xml (0.6.0) + multipart-post (2.0.0) + naught (1.1.0) nio4r (2.1.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) @@ -145,6 +173,7 @@ GEM selenium-webdriver (3.8.0) childprocess (~> 0.5) rubyzip (~> 1.0) + simple_oauth (0.3.1) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -163,10 +192,24 @@ GEM turbolinks (5.0.1) turbolinks-source (~> 5) turbolinks-source (5.0.3) + twitter (6.2.0) + addressable (~> 2.3) + buftok (~> 0.2.0) + equalizer (~> 0.0.11) + http (~> 3.0) + http-form_data (~> 2.0) + http_parser.rb (~> 0.6.0) + memoizable (~> 0.4.0) + multipart-post (~> 2.0) + naught (~> 1.0) + simple_oauth (~> 0.3.0) tzinfo (1.2.4) thread_safe (~> 0.1) uglifier (4.0.2) execjs (>= 0.3.0, < 3) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.4) web-console (3.5.1) actionview (>= 5.0) activemodel (>= 5.0) @@ -182,11 +225,14 @@ PLATFORMS ruby DEPENDENCIES + bootstrap-sass (~> 3.3.7) byebug capybara (~> 2.13) coffee-rails (~> 4.2) + figaro httparty jbuilder (~> 2.5) + jquery-rails listen (>= 3.0.5, < 3.2) pg (~> 0.18) pg_search @@ -197,6 +243,7 @@ DEPENDENCIES spring spring-watcher-listen (~> 2.0.0) turbolinks (~> 5) + twitter tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) diff --git a/app/assets/stylesheets/commands.scss b/app/assets/stylesheets/commands.scss index 4498205..06939ee 100644 --- a/app/assets/stylesheets/commands.scss +++ b/app/assets/stylesheets/commands.scss @@ -1,3 +1,6 @@ // Place all the styles related to the Commands controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +@import "bootstrap-sprockets"; +@import "bootstrap"; \ No newline at end of file diff --git a/app/controllers/commands_controller.rb b/app/controllers/commands_controller.rb index 6122617..5aada65 100644 --- a/app/controllers/commands_controller.rb +++ b/app/controllers/commands_controller.rb @@ -23,7 +23,7 @@ def contents(quote) "attachments": [ { "title": quote.contents, - "title_link": quote.url, + "title_link": quote.twitter_url, "image_url": quote.url } ] diff --git a/app/controllers/effin_quotes_controller.rb b/app/controllers/effin_quotes_controller.rb index c839f9b..2574755 100644 --- a/app/controllers/effin_quotes_controller.rb +++ b/app/controllers/effin_quotes_controller.rb @@ -3,14 +3,43 @@ def index @quotes = EffinQuote.all end + def check + @quote = EffinQuote.incomplete.first + @count = EffinQuote.incomplete.count + + render :show + end + def show @quote = EffinQuote.find(params[:id]) + @count = EffinQuote.incomplete.count end - def find - @quote = EffinQuote.find_by_word(params[:query]) - @quote = EffinQuote.all.sample unless @quote + def incomplete + @quotes = EffinQuote.incomplete + + render :index + end + + def update + @quote = EffinQuote.find(params[:id]) + @quote.update!(quote_params) + redirect_to check_effin_quotes_path + end + + def find + @quote = EffinQuote.find_by_word(params[:query]) || EffinQuote.all.sample redirect_to @quote end + + def destroy + @quote = EffinQuote.find(params[:id]) + @quote.destroy + redirect_to check_effin_quotes_path + end + + def quote_params + params.require(:effin_quote).permit(:contents) + end end diff --git a/app/models/effin_quote.rb b/app/models/effin_quote.rb index 99fdfe1..114f075 100644 --- a/app/models/effin_quote.rb +++ b/app/models/effin_quote.rb @@ -2,7 +2,19 @@ class EffinQuote < ApplicationRecord include PgSearch pg_search_scope :search_by_word, against: [ :contents ] + def complete? + url && twitter_url && contents + end + + def self.complete + where("url is not null and twitter_url is not null and contents is not null") + end + + def self.incomplete + where("url is null or twitter_url is null or contents is null") + end + def self.find_by_word(word) - search_by_word(word).first + complete.search_by_word(word).first end end diff --git a/app/views/effin_quotes/index.html.erb b/app/views/effin_quotes/index.html.erb index 25b33e5..1612151 100644 --- a/app/views/effin_quotes/index.html.erb +++ b/app/views/effin_quotes/index.html.erb @@ -1,8 +1,23 @@

Effin Quotes

-