diff --git a/app.rb b/app.rb index 8fefaca..6d9ded1 100755 --- a/app.rb +++ b/app.rb @@ -10,28 +10,29 @@ module StudentSite class App < Sinatra::Base - def initialize - super - @artists = ["Frank Sinatra", "Bing Crosby", "Bob\n\n\n\n", 1, 2, "dslajkffoiejfijasdlfl"] - end + # def initialize + # super + # @artists = ["Frank Sinatra", "Bing Crosby", "Bob\n\n\n\n", 1, 2, "dslajkffoiejfijasdlfl"] + # end - def set_random_numbers(arg) - @random_numbers = arg - end + # def set_random_numbers(arg) + # @random_numbers = arg + # end get '/' do - "hello world!" + @students = Student.all + erb :'students/students' end - get '/hello-world' do - set_random_numbers((1..20).to_a) - p @random_numbers - erb :hello - end + # get '/hello-world' do + # set_random_numbers((1..20).to_a) + # p @random_numbers + # erb :hello + # end - get '/artists' do - erb :artists - end + # get '/artists' do + # erb :artists + # end get '/students' do @students = Student.all @@ -43,5 +44,13 @@ def set_random_numbers(arg) @student = Student.find_by_url(params[:url]) erb :'students/student_profile' end + + get '/id/:id' do + # @students = Student.all + @student = Student.find(params[:id]) + erb :'students/student_profile' + end + end -end \ No newline at end of file +end + diff --git a/lib/models/flatiron.db b/lib/models/flatiron.db index b53cd8e..aed5415 100644 Binary files a/lib/models/flatiron.db and b/lib/models/flatiron.db differ diff --git a/lib/models/scraper.rb b/lib/models/scraper.rb index d2d6399..61eb84b 100644 --- a/lib/models/scraper.rb +++ b/lib/models/scraper.rb @@ -44,7 +44,7 @@ def scrape_index(index_html) urls = urls.collect{ |url| url.sub("students/","") } student_img_selector = "li.home-blog-post div.blog-thumb img" - imgs = index.css(student_img_selector).collect{|student| student.attr("src").downcase} + imgs = index.css(student_img_selector).collect{|student| student.attr("src")} imgs = imgs.collect{ |img| (img[0..3]=="http" ? "" : "/") + img } student_tagline_selector = "li.home-blog-post p.home-blog-post-meta" @@ -105,9 +105,21 @@ def scrape_students(index_html) info[:github] = student_page.css(social_media_selector)[2].attr("href") info[:blog] = student_page.css(social_media_selector)[3].attr("href") - quote_selector = "div.textwidget" + quote_selector = "div.section-testimonials-curriculum div.textwidget" info[:quote] = student_page.css(quote_selector).text + # section_title_selector = "div.section-title span.actual-title" + # info[:section_titles] = student_page.css(section_title_selector).collect{|x| x.text} + + # services_selector = "div.ok-text-column" + # info[:services] = student_page.css(services_selector).collect{|x| x.inner_html} + + # section_selector = "div.this-div-is-just-a-helpful-container" + # section_htmls = student_page.css(section_selector).collect{|x| x.inner_html} + # section_htmls.each_with_index do |section, index| + # info["section_html_#{index+1}".to_sym] = section + # end + student = {(index+1) => info} p student @@ -162,7 +174,7 @@ def insert_into_db(db_name) scraper.scrape_index(index_html) scraper.scrape_students(index_html) -# pp scraper.students +pp scraper.students scraper.insert_into_db(db_name) diff --git a/student.db b/student.db index b53cd8e..aed5415 100644 Binary files a/student.db and b/student.db differ diff --git a/views/layout.erb b/views/layout.erb index db957ae..a2711ca 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -17,10 +17,11 @@ + - +