Skip to content

Load 4 random photos on homepage #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'activerecord-session_store'
gem 'authlogic'
gem 'd3js-rails', '~> 3.1.6'
gem 'exception_notification', '~> 4'
gem 'flickraw'
gem 'haml-rails'
gem 'jquery-rails', '~> 2.1.4'
gem 'mechanize'
Expand All @@ -25,6 +26,7 @@ gem 'will_paginate', '~> 3.0'
gem 'yaml_db'
gem 'rubycas-client', :git => 'git://github.com/rubycas/rubycas-client.git'


group :development, :test do
gem 'autotest-standalone'
gem 'rspec-rails'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ GEM
ffi-compiler (0.1.3)
ffi (>= 1.0.0)
rake
flickraw (0.9.8)
haml (4.0.5)
tilt
haml-rails (0.5.3)
Expand Down Expand Up @@ -204,6 +205,7 @@ DEPENDENCIES
autotest-standalone
d3js-rails (~> 3.1.6)
exception_notification (~> 4)
flickraw
haml-rails
jquery-rails (~> 2.1.4)
mechanize
Expand Down
16 changes: 0 additions & 16 deletions app/assets/stylesheets/home.css.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,6 @@
background: #f7e26b;
}

#main #what_sec{
background: url(<%= asset_path 'site/hkn_members.png' %>);
}

#main #student-services_sec{
background: url(<%= asset_path 'site/hkn_tutoring.png' %>);
}

#main #ind_rel_sec{
background: url(<%= asset_path 'site/hkn_faculty.png' %>);
}

#main #membership_sec{
background: url(<%= asset_path 'site/hkn_banquet.png' %>);
}

/*Tutoring Calendar*/
#daily_tutoring_schedule th{
border: none;
Expand Down
24 changes: 23 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class HomeController < ApplicationController
helper EventsHelper

require 'flickraw'
def index
@events = Event.upcoming_events(0, @current_user)
@show_searcharea = true
Expand All @@ -18,6 +18,28 @@ def index
else
@tutoring_message = prop.tutoring_message
end

FlickRaw.api_key="bb6eccbf731a58f02b4acacfcb36e85d"
FlickRaw.shared_secret="aa8d976469254029"
default_photos = [ActionController::Base.helpers.asset_path('site/hkn_members.png'), ActionController::Base.helpers.asset_path('site/hkn_tutoring.png'), ActionController::Base.helpers.asset_path('site/hkn_faculty.png'), ActionController::Base.helpers.asset_path('site/hkn_banquet.png')]
@photo_links = []
photo_indices = []
for i in 0..3
photo_index = rand(1000)
while photo_indices.include? photo_index
photo_index = rand(1000)
end
photo = flickr.people.getPublicPhotos(:user_id => '121225723@N05', :per_page => '1', :page => photo_index.to_s)
break if photo.nil?
photo_id = photo[0].id
sizes = flickr.photos.getSizes(:photo_id => photo_id)
link = sizes[5].source
photo_indices << photo_index
@photo_links << link
end
if @photo_links.length < 4
@photo_links = default_photos
end
end

def factorial
Expand Down
8 changes: 4 additions & 4 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div id="what" class="section-header current-header">
<div class="text"><h1>What is HKN?</h1></div>
</div>
<div id="what_sec" class="section current-section">
<div id="what_sec" class="section current-section" style="background-image: url(<%= @photo_links[0] %>);background-size: cover;">
<div class="text">
<div>
Eta Kappa Nu (HKN) is the <a href="http://www.hkn.org/">national Electrical and Computer Engineering honor society</a>.
Expand All @@ -54,7 +54,7 @@
<div id="student-services" class="section-header">
<div class="text"><h1>Student Services</h1></div>
</div>
<div id="student-services_sec" class="section">
<div id="student-services_sec" class="section" style="background-image: url(<%= @photo_links[1] %>); background-size: cover;">
<div class="text">
<div>
<h2>Tutoring</h2>
Expand All @@ -72,7 +72,7 @@
<div id="ind_rel" class="section-header">
<div class="text"><h1>Industrial Relations</h1></div>
</div>
<div id="ind_rel_sec" class="section">
<div id="ind_rel_sec" class="section" style="background-image: url(<%= @photo_links[2] %>); background-size:cover;">
<div class="text">
<div>
HKN has strong ties with industry, linking students with companies by setting up <%= link_to "info sessions", infosessions_path %> where companies can give a presentation about themselves and provide a forum for students to talk to industry and find out more about the work environment. Additionally, we sell <%= link_to "resume books", resume_books_about_path %> containing the resumes of our members.
Expand All @@ -83,7 +83,7 @@
<div id="membership" class="section-header">
<div class="text"><h1>Membership</h1></div>
</div>
<div id="membership_sec" class="section">
<div id="membership_sec" class="section" style="background-image: url(<%= @photo_links[3] %>); background-size:cover;">
<div class="text">
<div>
<p>Membership in Eta Kappa Nu is extended to undergraduates in the top fourth of the junior class and the top third of the senior class in EECS, and all continuing EE graduate students. Interested students should watch for the list of eligible names, which is posted around Cory Hall and Soda Hall about a month after the beginning of each semester. </p>
Expand Down