Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

importing and info rendering work

  • Loading branch information...
commit 8f976316701888cd8945d65e52e5e8a0c6672d52 1 parent 41dadb9
@tenderlove authored
View
20 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
View
2  app/models/account.rb
@@ -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
View
90 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>
View
1  app/views/accounts/_name.html.erb
@@ -0,0 +1 @@
+<li><%= name.value %></li>
View
3  app/views/accounts/_portrait.html.erb
@@ -0,0 +1,3 @@
+<div class='image-wrapper'>
+ <%= image_tag portrait.url %>
+</div>
View
3  app/views/accounts/_service.html.erb
@@ -0,0 +1,3 @@
+<li>
+ <%= link_to_service service.name, service %>
+</li>
View
1  app/views/accounts/_site.html.erb
@@ -0,0 +1 @@
+<li><%= link_to site.title, site.url %></li>
View
2  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 %>
View
6 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
View
7 public/stylesheets/site.css
@@ -0,0 +1,7 @@
+.image-wrapper {
+ height: 100px;
+}
+
+.image-wrapper img {
+ height: 100%;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.