From 712d74a02025380541ee0aa2cc44d6ef50224a62 Mon Sep 17 00:00:00 2001 From: nilesh Date: Sat, 23 Jan 2021 19:20:38 +0530 Subject: [PATCH] Added youtube_url for experts --- .ruby-version | 2 +- CONTRIBUTING.md | 4 +--- app/controllers/people_controller.rb | 4 ++++ app/views/people/_form.html+tailwind.erb | 10 ++++++++++ .../20210123134411_add_you_tube_to_people.rb | 5 +++++ db/structure.sql | 6 ++++-- lib/tasks/mrb.rake | 18 +++++++++++++++++- 7 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20210123134411_add_you_tube_to_people.rb diff --git a/.ruby-version b/.ruby-version index 37c2961c..4a36342f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +3.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94aecdc1..71b08951 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,4 @@ Our discussions happen in the #meta channel of our community Slack which you can join here: https://learnawesome.org/join_slack -LearnAwesome is a web application built with Ruby, Rails, PostgreSQL, and TailwindCSS. - -You can pick any issue labeled with `good first issue` or `Hacktoberfest` and send a PR. For anything else, we recommend starting a discussion on either the issue or in Slack first. \ No newline at end of file +LearnAwesome is a web application built with Ruby 3.0, Rails 6.1.1, PostgreSQL, and TailwindCSS 2.0. \ No newline at end of file diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index a324dcfc..fcf7df9e 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -38,6 +38,8 @@ def wikidata @person.website = data[:website] @person.goodreads = data[:goodreads] unless @person.goodreads.present? @person.twitter = data[:twitter] + @person.wikipedia_url = data[:wikipedia_url] + @person.youtube_url = data[:youtube_url] render 'edit' end @@ -56,6 +58,8 @@ def update @person.twitter = params[:person][:twitter] @person.goodreads = params[:person][:goodreads] @person.image_url = params[:person][:image_url] + @person.wikipedia_url = data[:wikipedia_url] + @person.youtube_url = data[:youtube_url] @person.kind = params[:person][:kind] if @person.save diff --git a/app/views/people/_form.html+tailwind.erb b/app/views/people/_form.html+tailwind.erb index 7d6e545d..b9e04f0e 100644 --- a/app/views/people/_form.html+tailwind.erb +++ b/app/views/people/_form.html+tailwind.erb @@ -35,6 +35,16 @@ <%= form.text_field :goodreads, class: "w-full mt-1 px-4 py-2 block rounded bg-gray-200 text-gray-800 border border-gray-300 focus:outline-none focus:bg-white" %> +
+ <%= form.label :wikipedia_url, class: "text-gray-700" %> + <%= form.url_field :wikipedia_url, class: "w-full mt-1 px-4 py-2 block rounded bg-gray-200 text-gray-800 border border-gray-300 focus:outline-none focus:bg-white" %> +
+ +
+ <%= form.label :youtube_url, class: "text-gray-700" %> + <%= form.url_field :youtube_url, class: "w-full mt-1 px-4 py-2 block rounded bg-gray-200 text-gray-800 border border-gray-300 focus:outline-none focus:bg-white" %> +
+
<%= form.label :image_url, class: "text-gray-700" %> <%= form.text_field :image_url, class: "w-full mt-1 px-4 py-2 block rounded bg-gray-200 text-gray-800 border border-gray-300 focus:outline-none focus:bg-white" %> diff --git a/db/migrate/20210123134411_add_you_tube_to_people.rb b/db/migrate/20210123134411_add_you_tube_to_people.rb new file mode 100644 index 00000000..a515da1f --- /dev/null +++ b/db/migrate/20210123134411_add_you_tube_to_people.rb @@ -0,0 +1,5 @@ +class AddYouTubeToPeople < ActiveRecord::Migration[6.1] + def change + add_column :people, :youtube_url, :string + end +end diff --git a/db/structure.sql b/db/structure.sql index 2c7efba0..1596d105 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -911,7 +911,8 @@ CREATE TABLE public.people ( image_url character varying, kind character varying, second_kind character varying, - wikipedia_url character varying + wikipedia_url character varying, + youtube_url character varying ); @@ -2485,6 +2486,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20201018233116'), ('20201019010226'), ('20201230145346'), -('20210116203058'); +('20210116203058'), +('20210123134411'); diff --git a/lib/tasks/mrb.rake b/lib/tasks/mrb.rake index 0edf9bd1..b799d3a1 100644 --- a/lib/tasks/mrb.rake +++ b/lib/tasks/mrb.rake @@ -23,4 +23,20 @@ namespace :mrb do end end end -end \ No newline at end of file +end + +=begin +// /_next/data/OobI_r5osFBZZ3qHQV04X/experts.json +let experts = window.__NEXT_DATA__.props.pageProps.data.topRecommenders; + +// /mike-rowe-books + +let recos = Array.from(document.querySelectorAll('div#maincontent div.tab-pane')[0].querySelectorAll('li')).map((li) => ({ + cover: li.querySelector('img').src, + genius_link: li.querySelector('a').href, + title: li.querySelector('h3').innerText, + author: li.querySelector('h4').innerText, + review: li.querySelector('p').innerText.replace("Source:",""), + source: li.querySelector('p a').href +})); +=end \ No newline at end of file