Skip to content

Commit

Permalink
importing and info rendering work
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jan 1, 2011
1 parent 41dadb9 commit 8f97631
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 15 deletions.
20 changes: 20 additions & 0 deletions app/helpers/accounts_helper.rb
@@ -1,2 +1,22 @@
module AccountsHelper
def link_to_service name, service
case service.name
when 'twitter'
link_to name, 'http://twitter.com/' + service.key
when 'friendfeed'
link_to name, 'http://friendfeed.com/' + service.key
when 'mixi'
link_to name, 'http://mixi.jp/show_friend.pl?id=' + service.key
when 'github'
link_to name, 'http://github.com/' + service.key
when 'facebook'
if service.key =~ /^\sd+$/
link_to name, 'http://www.facebook.com/profile.php?id=' + service.key
else
link_to name, 'http://www.facebook.com/' + service.key
end
when 'iddy'
link_to name, 'http://iddy.jp/profile/' + service.key
end
end
end
2 changes: 1 addition & 1 deletion app/models/account.rb
Expand Up @@ -15,7 +15,7 @@ def self.import io
doc = Psych.load io
doc.each do |record|
account = Account.create!(:username => record['account'])
record['name'].each do |name|
(record['name'] || []).each do |name|
account.names.create!(:value => name)
end

Expand Down
90 changes: 77 additions & 13 deletions app/views/accounts/_account.html.erb
@@ -1,15 +1,79 @@
<li>
Account: <%= account.username %>
Names:
<ul>
<% account.names.each do |name| %>
<li><%= name %></li>
<% end %>
</ul>
Nicknames:
<ul>
<% account.nicks.each do |name| %>
<li><%= name %></li>
<% end %>
</ul>
<table>
<tr>
<td>Account:</td>
<td><%= account.username %></td>
</tr>

<% if account.names.length > 0 %>
<tr>
<td>Names:</td>
<td>
<ul>
<%= render :partial => 'name', :collection => account.names %>
</ul>
</td>
</tr>
<% end %>
<% if account.nicks.length > 0 %>
<tr>
<td>Nicknames:</td>
<td>
<ul>
<%= render :partial => 'name', :collection => account.nicks %>
</ul>
</td>
</tr>
<% end %>
<% if account.sites.length > 0 %>
<tr>
<td>Sites:</td>
<td>
<ul>
<%= render :partial => 'site', :collection => account.sites %>
</ul>
</td>
</tr>
<% end %>
<% if account.services.length > 0 %>
<tr>
<td>Services:</td>
<td>
<ul>
<%= render :partial => 'service', :collection => account.services %>
</ul>
</td>
</tr>
<% end %>
<% if account.portraits.length > 0 %>
<tr>
<td>Portraits:</td>
<td>
<ul>
<%= render :partial => 'portrait', :collection => account.portraits %>
</ul>
</td>
</tr>
<% end %>

<!-- FIXME: unsure how to link to ISBN. :-( -->
<!--
<% if account.books.length > 0 %>
<tr>
<td>Books:</td>
<td>
<ul>
<% account.books.each do |book| %>
<li><%= book.key %></li>
<% end %>
</ul>
</td>
</tr>
<% end %>
-->
</table>
</li>
1 change: 1 addition & 0 deletions app/views/accounts/_name.html.erb
@@ -0,0 +1 @@
<li><%= name.value %></li>
3 changes: 3 additions & 0 deletions app/views/accounts/_portrait.html.erb
@@ -0,0 +1,3 @@
<div class='image-wrapper'>
<%= image_tag portrait.url %>
</div>
3 changes: 3 additions & 0 deletions app/views/accounts/_service.html.erb
@@ -0,0 +1,3 @@
<li>
<%= link_to_service service.name, service %>
</li>
1 change: 1 addition & 0 deletions app/views/accounts/_site.html.erb
@@ -0,0 +1 @@
<li><%= link_to site.title, site.url %></li>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Rubycommitters</title>
<title>Ruby Committers</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
Expand Down
6 changes: 6 additions & 0 deletions lib/tasks/import.rake
@@ -0,0 +1,6 @@
require 'open-uri'

desc "import the list of ruby committers"
task :import => 'db:migrate' do
Account.import open('http://svn.coderepos.org/share/lang/ruby/ruby-committers/ruby-committers.yml')
end
7 changes: 7 additions & 0 deletions public/stylesheets/site.css
@@ -0,0 +1,7 @@
.image-wrapper {
height: 100px;
}

.image-wrapper img {
height: 100%;
}

0 comments on commit 8f97631

Please sign in to comment.