Permalink
Browse files

use talks from the database on talks page

  • Loading branch information...
1 parent 77f963b commit 5ab9fbaf40407e9e59c806dae976cda30ddd9562 @croaky croaky committed Jan 16, 2011
@@ -0,0 +1,5 @@
+class TalksController < ApplicationController
+ def index
+ @talks = Talk.chronological
+ end
+end
View
@@ -2,4 +2,16 @@ class Talk < ActiveRecord::Base
validates_presence_of :name, :abstract, :speaker_name, :speaker_bio
has_many :resources
+
+ def slug
+ name.remove_mid_word_characters.
+ replace_non_words_with_spaces.
+ strip.
+ replace_spaces_with_hyphens.
+ downcase
+ end
+
+ def self.chronological
+ order("time asc")
+ end
end

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,69 @@
+<section id="free-event">
+ <h1>What It Is</h1>
+</section>
+<section id="main">
+ <p id="what-it-is">The goal of this event is to act as a welcome wagon for student entering the startup community as developers and designers. The content is driven by what actual startups need right now. Each 10-minute talk is given by a community leader. Further resources on each topic are listed below (this is a constant work in progress: check back often). Startups that are interested in hiring students as interns or full-time employees post-graduation will be available afterwards to chat and hand out information.</p>
+
+ <% @talks.each do |talk| %>
+ <hr class="alternate"/>
+ <section class="talk-wrapper">
+ <a name="<%= talk.slug %>"></a>
+ <h2><%= talk.name %> - <%= talk.speaker_name %></h2>
+ <div class="left abstract bio">
+ <%= simple_format talk.abstract %>
+ <h3>Speaker Bio</h3>
+ <%= simple_format talk.speaker_bio %>
+ </div>
+ <div class="right resources">
+ <h3>Learn More</h3>
+ <ul>
+ <% talk.resources.each do |resource| %>
+ <li><%= link_to resource.name, resource.url %> &#8220;<%= resource.description %>&#8221;</li>
+ <% end %>
+ </ul>
+ </div>
+ </section>
+ <% end %>
+
+ <hr class="alternate"/>
+ <section class="talk-wrapper">
+ <h2>More details coming soon...</h2>
+ </section>
+ <!--
+ <hr class="alternate"/>
+ <section class="talk-wrapper">
+ <a name="postgresql"></a>
+ <h2>PostgreSQL - Jim Psota</h2>
+ <div class="left description">
+ <p></p>
+ <h3>Speaker Bio</h3>
+ <p></p>
+ </div>
+ <div class="right resources">
+ <h3>Learn More</h3>
+ <ul>
+ <li><a href="http://railsonpostgresql.com/">Rails on PostgreSQL</a> </li>
+ <li><a href=""></a> </li>
+ </ul>
+ </div>
+ </section>
+ <hr class="alternate"/>
+ <section class="talk-wrapper">
+ <a name="nosql"></a>
+ <h2>NoSQL - Daniel Weinreb</h2>
+ <div class="left description">
+ <p></p>
+ <h3>Speaker Bio</h3>
+ <p></p>
+ </div>
+ <div class="right resources">
+ <h3>Learn More</h3>
+ <ul>
+ <li><a href=""></a> </li>
+ <li><a href=""></a> </li>
+ </ul>
+ </div>
+ </section>
+ <hr class="alternate"/>
+ -->
+</section>
@@ -0,0 +1,5 @@
+ruby_files = Rails.root.join('lib', 'monkey_patches', '*.rb')
+
+Dir.glob(ruby_files).each do |file|
+ require file
+end
View
@@ -2,4 +2,7 @@
root :to => 'registrations#new'
resources :registrations, :only => [:new, :create]
+ resources :talks, :only => [:index]
+
+ match 'pages/what' => 'talks#index'
end
@@ -0,0 +1,9 @@
+class AddTimeToTalks < ActiveRecord::Migration
+ def self.up
+ add_column :talks, :time, :time
+ end
+
+ def self.down
+ remove_column :talks, :time
+ end
+end
@@ -0,0 +1,16 @@
+Then /^I should see the following talks:$/ do |table|
+ table.hashes.each do |talk_hash|
+ talk = Talk.find_by_name(talk_hash['name'])
+
+ page.should have_css("a[name='#{talk.slug}']")
+ page.should have_css("h2", :text => "#{talk.name} - #{talk.speaker_name}")
+ page.should have_css(".abstract p", :text => talk.abstract)
+ page.should have_css(".bio p", :text => talk.speaker_bio)
+
+ talk.resources.each do |resource|
+ page.should have_css(".resources li", :text => resource.description)
+ page.should have_css(".resources li a", :text => resource.name)
+ page.should have_css(".resources li a[href='#{resource.url}']")
+ end
+ end
+end
@@ -10,6 +10,8 @@ def path_to(page_name)
when /the home\s?page/
'/'
+ when /the what page/
+ '/pages/what'
# Add more mappings here.
when /the sign up page/i
@@ -0,0 +1,20 @@
+Feature: Visitor views talks
+
+ In order to learn more about each talk
+ As a college student
+ I want to see the talk abstract, the speaker bio, and resources
+
+ Scenario: Student views talks
+ Given the following talks exist:
+ | name | speaker name | speaker bio | abstract |
+ | Git | Tom Preston-Werner | Github dude. | Version control is your friend. |
+ | jQuery | John Resig | jQuery dude. | CSS selectors are your friends. |
+ And the following resources exist:
+ | name | url | description | talk |
+ | Github | http://github.com | Bad-ass. | name: Git |
+ | jQuery | http://jquery.com | Bad-ass. | name: jQuery |
+ And I am on the what page
+ Then I should see the following talks:
+ | name |
+ | Git |
+ | jQuery |
@@ -0,0 +1,13 @@
+class String
+ def remove_mid_word_characters
+ gsub(/'/, '')
+ end
+
+ def replace_non_words_with_spaces
+ gsub(/[\W]/, ' ')
+ end
+
+ def replace_spaces_with_hyphens
+ gsub(/\ +/, '-')
+ end
+end
View
@@ -16,3 +16,21 @@
factory.name { 'Heroku' }
factory.description { 'Deploy' }
end
+
+Factory.define :talk do |factory|
+ factory.name { 'Ship It' }
+ factory.speaker_name { 'Ben Scofield' }
+ factory.speaker_bio { 'Developer advocate at Heroku' }
+ factory.abstract do
+ "The second most important thing you can do is ship something good. The most important thing you can do? Ship something."
+ end
+end
+
+Factory.define :resource do |factory|
+ factory.association(:talk)
+ factory.name { 'Quieting the Lizard Brain' }
+ factory.url { 'http://vimeo.com/5895898' }
+ factory.description do
+ "In this 18-minute video, Seth Godin entertains on the topic of shipping."
+ end
+end
View
@@ -8,3 +8,22 @@
it { should have_many(:resources) }
end
+
+describe Talk, "#slug" do
+ subject { Factory(:talk, :name => "Why Work at a Startup?") }
+
+ it "is a lowercase identifier" do
+ subject.slug.should == "why-work-at-a-startup"
+ end
+end
+
+describe Talk, ".chronological" do
+ before do
+ @one_pm = Factory(:talk, :time => DateTime.new(2011, 2, 5, 13, 0, 0))
+ @ten_am = Factory(:talk, :time => DateTime.new(2011, 2, 5, 10, 0, 0))
+ end
+
+ it "finds all talks, sorted chronologically" do
+ Talk.chronological.should == [@ten_am, @one_pm]
+ end
+end

0 comments on commit 5ab9fba

Please sign in to comment.