mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-10 09:24:22 +01:00
Updated to svn tags/tracks-1.6
This commit is contained in:
parent
103fcb8049
commit
02496f2d44
2274 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,86 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
class OpenIdConsumerControllerGenerator < Rails::Generator::NamedBase
|
||||
attr_reader :controller_name,
|
||||
:controller_class_path,
|
||||
:controller_file_path,
|
||||
:controller_class_nesting,
|
||||
:controller_class_nesting_depth,
|
||||
:controller_class_name,
|
||||
:controller_singular_name,
|
||||
:controller_plural_name
|
||||
alias_method :controller_file_name, :controller_singular_name
|
||||
alias_method :controller_table_name, :controller_plural_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
runtime_args << 'open_id' if runtime_args.empty?
|
||||
super
|
||||
|
||||
# Take controller name from the next argument. Default to the pluralized model name.
|
||||
@controller_name = args.shift
|
||||
@controller_name ||= ActiveRecord::Base.pluralize_table_names ? @name.pluralize : @name
|
||||
|
||||
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
||||
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
||||
|
||||
if @controller_class_nesting.empty?
|
||||
@controller_class_name = @controller_class_name_without_nesting
|
||||
else
|
||||
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
||||
end
|
||||
end
|
||||
|
||||
def manifest
|
||||
record do |m|
|
||||
# Check for class naming collisions.
|
||||
m.class_collisions controller_class_path, "#{controller_class_name}Controller",
|
||||
"#{controller_class_name}Helper"
|
||||
|
||||
# Controller, helper, views, and test directories.
|
||||
m.directory File.join('app/controllers', controller_class_path)
|
||||
m.directory File.join('app/helpers', controller_class_path)
|
||||
m.directory File.join('app/views', controller_class_path, controller_file_name)
|
||||
m.directory File.join('test/functional', controller_class_path)
|
||||
|
||||
m.template 'controller.rb',
|
||||
File.join('app/controllers',
|
||||
controller_class_path,
|
||||
"#{controller_file_name}_controller.rb")
|
||||
|
||||
m.template 'functional_test.rb',
|
||||
File.join('test/functional',
|
||||
controller_class_path,
|
||||
"#{controller_file_name}_controller_test.rb")
|
||||
|
||||
m.template 'helper.rb',
|
||||
File.join('app/helpers',
|
||||
controller_class_path,
|
||||
"#{controller_file_name}_helper.rb")
|
||||
|
||||
# Controller templates
|
||||
m.template "index.rhtml",
|
||||
File.join('app/views', controller_class_path, controller_file_name, "index.rhtml")
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
# Override with your own usage banner.
|
||||
def banner
|
||||
"Usage: #{$0} open_id_consumer_controller [open_id]"
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
class <%= controller_class_name %>Controller < ApplicationController
|
||||
open_id_consumer :required => [:email, :nickname], :optional => [:fullname, :dob, :gender, :country]
|
||||
|
||||
def index
|
||||
@title = 'Welcome'
|
||||
end
|
||||
|
||||
def begin
|
||||
# If the URL was unusable (either because of network conditions,
|
||||
# a server error, or that the response returned was not an OpenID
|
||||
# identity page), the library will return HTTP_FAILURE or PARSE_ERROR.
|
||||
# Let the user know that the URL is unusable.
|
||||
case open_id_response.status
|
||||
when OpenID::SUCCESS
|
||||
# The URL was a valid identity URL. Now we just need to send a redirect
|
||||
# to the server using the redirect_url the library created for us.
|
||||
|
||||
# redirect to the server
|
||||
redirect_to open_id_response.redirect_url((request.protocol + request.host_with_port + '/'), url_for(:action => 'complete'))
|
||||
else
|
||||
flash[:error] = "Unable to find openid server for <q>#{params[:openid_url]}</q>"
|
||||
render :action => :index
|
||||
end
|
||||
end
|
||||
|
||||
def complete
|
||||
case open_id_response.status
|
||||
when OpenID::FAILURE
|
||||
# In the case of failure, if info is non-nil, it is the
|
||||
# URL that we were verifying. We include it in the error
|
||||
# message to help the user figure out what happened.
|
||||
if open_id_response.identity_url
|
||||
flash[:message] = "Verification of #{open_id_response.identity_url} failed. "
|
||||
else
|
||||
flash[:message] = "Verification failed. "
|
||||
end
|
||||
flash[:message] += open_id_response.msg.to_s
|
||||
|
||||
when OpenID::SUCCESS
|
||||
# Success means that the transaction completed without
|
||||
# error. If info is nil, it means that the user cancelled
|
||||
# the verification.
|
||||
flash[:message] = "You have successfully verified #{open_id_response.identity_url} as your identity."
|
||||
if open_id_fields.any?
|
||||
flash[:message] << "<hr /> With simple registration fields:<br/>"
|
||||
open_id_fields.each {|k,v| flash[:message] << "<br /><b>#{k}</b>: #{v}"}
|
||||
end
|
||||
|
||||
when OpenID::CANCEL
|
||||
flash[:message] = "Verification cancelled."
|
||||
|
||||
else
|
||||
flash[:message] = "Unknown response status: #{open_id_response.status}"
|
||||
end
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require '<%= controller_file_name %>_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
|
||||
|
||||
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@controller = <%= controller_class_name %>Controller.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
19
vendor/plugins/openid_consumer_plugin/generators/open_id_consumer_controller/templates/helper.rb
vendored
Normal file
19
vendor/plugins/openid_consumer_plugin/generators/open_id_consumer_controller/templates/helper.rb
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
module <%= controller_class_name %>Helper
|
||||
end
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<% # Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
%>
|
||||
|
||||
<h1><%%= @title %></h1>
|
||||
|
||||
<div><strong><%%= flash[:message] %></strong></div>
|
||||
<div><strong><%%= flash[:error] %></strong></div>
|
||||
|
||||
<p>Please login with your OpenID Identity URL</p>
|
||||
|
||||
<div id="verify-form">
|
||||
<%%= start_form_tag :action => 'begin' %>
|
||||
Identity URL:
|
||||
<input type="text" name="openid_url" style="width: 200px" />
|
||||
<input type="submit" value="Verify" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
class OpenIdMigrationGenerator < Rails::Generator::NamedBase
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
runtime_args << 'add_open_id_tables' if runtime_args.empty?
|
||||
super
|
||||
end
|
||||
|
||||
def manifest
|
||||
record do |m|
|
||||
m.migration_template 'migration.rb', 'db/migrate'
|
||||
end
|
||||
end
|
||||
end
|
||||
45
vendor/plugins/openid_consumer_plugin/generators/open_id_migration/templates/migration.rb
vendored
Normal file
45
vendor/plugins/openid_consumer_plugin/generators/open_id_migration/templates/migration.rb
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
class <%= class_name %> < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table "open_id_associations", :force => true do |t|
|
||||
t.column "server_url", :binary
|
||||
t.column "handle", :string
|
||||
t.column "secret", :binary
|
||||
t.column "issued", :integer
|
||||
t.column "lifetime", :integer
|
||||
t.column "assoc_type", :string
|
||||
end
|
||||
|
||||
create_table "open_id_nonces", :force => true do |t|
|
||||
t.column "nonce", :string
|
||||
t.column "created", :integer
|
||||
end
|
||||
|
||||
create_table "open_id_settings", :force => true do |t|
|
||||
t.column "setting", :string
|
||||
t.column "value", :binary
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table "open_id_associations"
|
||||
drop_table "open_id_nonces"
|
||||
drop_table "open_id_settings"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue