Skip to content

Commit

Permalink
Update database and views to remove broken pics
Browse files Browse the repository at this point in the history
  • Loading branch information
gglin committed Jun 26, 2013
1 parent 1cc22ed commit 288bc78
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
43 changes: 26 additions & 17 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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
end

Binary file modified lib/models/flatiron.db
Binary file not shown.
18 changes: 15 additions & 3 deletions lib/models/scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Binary file modified student.db
Binary file not shown.
3 changes: 2 additions & 1 deletion views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
<script type='text/javascript' src="/js/comment-reply.min.js"></script>
<script type='text/javascript' src="/js/jquery.js"></script>
<script type='text/javascript' src="/js/chirp.min.js"></script>
<script type='text/javascript' src="/js/smooth-scroll.js"></script>
<style type="text/css">a{color:#60BDDB}</style>
</head>

<body class="home page students">
<body id="scroll-header" class="home page students">
<!-- Begin Main Wrapper -->
<div class="main-wrapper">
<!-- Begin Header -->
Expand Down

0 comments on commit 288bc78

Please sign in to comment.