Project

General

Profile

Feature #11357 » redmine-openid_dropdown-DrewDahl-11357.patch

Patch to add drop-down to login menu - Andrew Dahl, 2012-12-16 12:51

View differences:

app/models/open_id_providers.rb
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class OpenIdProvider < ActiveRecord::Base
self.table_name = "#{table_name_prefix}open_id_providers#{table_name_suffix}"
validates_presence_of :name, :url
end
app/views/account/login.html.erb
<% if Setting.openid? %>
<tr>
<td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td>
<td align="left"><%= text_field_tag "openid_url", nil, :tabindex => '3' %></td>
<td align="left">
<%= text_field_tag 'openid_url', nil, :tabindex => '3' %>
<%= select_tag :openid_url_select, options_for_select(OpenIdProvider.all.collect {|p| [p.name, p.url]}), { :tabindex => '4', :prompt => l(:field_identity_url) } %>
</td>
</tr>
<% end %>
<tr>
......
</tr>
</table>
<%= javascript_tag "$('#username').focus();" %>
<% if Setting.openid? %>
<%= javascript_tag "$('#openid_url_select').change(function() { $('#openid_url').val ($('#openid_url_select').val());});" %>
<% end %>
<% end %>
</div>
<%= call_hook :view_account_login_bottom %>
public/stylesheets/application.css
div.modal h3.title {display:none;}
div.modal p.buttons {text-align:right; margin-bottom:0;}
input#openid_url { background: url(../images/openid-bg.gif) no-repeat; background-color: #fff; background-position: 0 50%; padding-left: 18px; }
input#openid_url { background: url(../images/openid-bg.gif) no-repeat; background-color: #fff; background-position: 0 50%; padding-left: 18px; width: 177px;}
select#openid_url_select { width: 100px; }
.clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; }
-
app/models/open_id_provider.rb
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class OpenIdProvider < ActiveRecord::Base
self.table_name = "#{table_name_prefix}open_id_providers#{table_name_suffix}"
validates_presence_of :name, :url
end
app/models/open_id_providers.rb
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class OpenIdProvider < ActiveRecord::Base
self.table_name = "#{table_name_prefix}open_id_providers#{table_name_suffix}"
validates_presence_of :name, :url
end
-
db/migrate/20121216105941_add_open_id_providers_table.rb
class AddOpenIdProvidersTable < ActiveRecord::Migration
def self.up
create_table :open_id_providers, :force => true do |t|
t.string :url, :null => false
t.string :name, :limit => 30, :null => false
end
end
def self.down
drop_table :open_id_providers
end
end
db/migrate/20121216110401_insert_open_id_providers.rb
class InsertOpenIdProviders < ActiveRecord::Migration
def self.up
OpenIdProvider.reset_column_information
google = OpenIdProvider.new(:name => 'Google', :url => 'https://www.google.com/accounts/o8/id')
google.save
yahoo = OpenIdProvider.new(:name => 'Yahoo', :url => 'http://me.yahoo.com/')
yahoo.save
aol = OpenIdProvider.new(:name => 'AOL', :url => 'http://openid.aol.com/{username}')
aol.save
myopenid = OpenIdProvider.new(:name => 'MyOpenID', :url => 'http://{username}.myopenid.com/')
myopenid.save
livejournal = OpenIdProvider.new(:name => 'LiveJournal', :url => 'http://{username}.livejournal.com/')
livejournal.save
wordpress = OpenIdProvider.new(:name => 'Wordpress', :url => 'http://{username}.wordpress.com/')
wordpress.save
blogger = OpenIdProvider.new(:name => 'Blogger', :url => 'http://{username}.blogspot.com/')
blogger.save
verisign = OpenIdProvider.new(:name => 'Verisign', :url => 'http://{username}.pip.verisignlabs.com/')
verisign.save
claimid = OpenIdProvider.new(:name => 'ClaimID', :url => 'http://claimid.com/{username}')
claimid.save
clickpass = OpenIdProvider.new(:name => 'ClickPass', :url => 'http://clickpass.com/public/{username}')
clickpass.save
googleprofile = OpenIdProvider.new(:name => 'Google Profile', :url => 'http://www.google.com/profiles/{username}')
googleprofile.save
end
def self.down
OpenIdProvider.destroy_all
end
end
(1-1/5)