Skip to content
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

Integrate rubygems.org and gittip #505

Closed
wants to merge 5 commits into from
Closed
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
7 changes: 7 additions & 0 deletions app/controllers/api/v1/profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Api::V1::ProfilesController < Api::BaseController
respond_to :json, :only => [:show]

def show
respond_with User.find_by_slug!(params[:id])
end
end
4 changes: 4 additions & 0 deletions app/helpers/rubygems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def download_link(version)
link_to "Download", "/downloads/#{version.full_name}.gem", :id => :download
end

def gittip_link(rubygem)
link_to "Gittip", rubygem.gittip_url, :id => :gittip
end

def documentation_link(version, linkset)
link_to 'Documentation', documentation_path(version), :id => :docs if linkset.nil? ||
linkset.docs.blank?
Expand Down
8 changes: 8 additions & 0 deletions app/models/rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ def first_built_date
versions.by_earliest_built_at.limit(1).last.built_at
end

def gittip_url
'https://www.gittip.com/on/rubygems/gem/' + name + '/'
end

def gittip_enabled?
owners.where('gittip_username is not null').count > 0
end

private

def ensure_name_format
Expand Down
11 changes: 9 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class User < ActiveRecord::Base
include Gravtastic
is_gravtastic :default => "retro"

attr_accessible :bio, :email, :handle, :location, :password, :website
attr_accessible :bio, :email, :handle, :location, :password, :website, :gittip_username

has_many :rubygems, :through => :ownerships

Expand Down Expand Up @@ -55,7 +55,10 @@ def all_hooks
end

def payload
{"email" => email}
attrs = {"email" => email}
attrs["gittip_username"] = gittip_username if gittip_username

attrs
end

def as_json(options={})
Expand Down Expand Up @@ -97,4 +100,8 @@ def rubygems_downloaded
def total_rubygems_count
rubygems.count
end

def gittip_url
'https://www.gittip.com/' + gittip_username + '/'
end
end
6 changes: 6 additions & 0 deletions app/views/profiles/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<%= form.email_field :email, :size => 25 %>
</div>

<div class="text_field">
<%= form.label :gittip_username %>
<%= link_to "What's this?", "https://www.gittip.com/about/" %>
<%= form.text_field :gittip_username, :size => 25 %>
</div>

<div class="submit_field">
<%= form.submit "Update", :data => {:disable_with => t('form_disable_with')} %>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
</div>
<div id="profile-info">
<h2 id="profile-name"><%= link_to @user.display_handle, profile_path(@user.display_id) %></h2>
<h3 id="profile-email"><%= mail_to @user.email, "(email)", :encode => "hex" %></h3>
<h3 id="profile-email"><%= mail_to @user.email, "email", :encode => "hex" %></h3>
<h3 id="profile-gittip"><%= link_to "gittip", @user.gittip_url unless @user.gittip_username.blank? %></h3>
<h3 id="profile-gems-count"><%= @user.total_rubygems_count.to_s %> <%= "gem".pluralize(@user.total_rubygems_count) %></h3>
</div>
<div id="downloads-ego">
Expand Down
1 change: 1 addition & 0 deletions app/views/rubygems/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<div class="meta">
<div class="admin">
<%= link_to t('edit'), edit_rubygem_path(@rubygem), :id => "edit" if @rubygem.owned_by?(current_user) %>
<%= gittip_link(@rubygem) if @rubygem.gittip_enabled? %>
<%= download_link(@latest_version) %>
<%= documentation_link(@latest_version, @rubygem.linkset) %>
<%= subscribe_link(@rubygem) if @latest_version.indexed %>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
resource :api_key, :only => :show do
put :reset
end
resources :profiles, :only => :show
resources :downloads, :only => :index do
get :top, :on => :collection
get :all, :on => :collection
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20130110064832_add_gittip_username_to_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddGittipUsernameToProfile < ActiveRecord::Migration
def change
add_column :users, :gittip_username, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20121124000000) do
ActiveRecord::Schema.define(:version => 20130110064832) do

create_table "announcements", :force => true do |t|
t.text "body"
Expand Down Expand Up @@ -111,6 +111,7 @@
t.datetime "updated_at"
t.boolean "email_reset"
t.string "handle"
t.string "gittip_username"
end

add_index "users", ["email"], :name => "index_users_on_email"
Expand Down
Binary file added public/images/gittip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/stylesheets/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ table {
background: url('/images/unsubscribe.png') no-repeat;
}

.main .info .meta .admin #gittip {
background: url('/images/gittip.png') no-repeat;
}

.main .info .meta .admin #download {
background: url('/images/download.png') no-repeat;
}
Expand Down