forked from jonthewayne/altered_beast
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update application.rb for newer rails and implement openid login
- Loading branch information
Showing
43 changed files
with
1,126 additions
and
24 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
class MonitorshipsController < ApplicationController | |||
before_filter :login_required | |||
|
|||
def create | |||
@monitorship = Monitorship.find_or_initialize_by_user_id_and_topic_id(current_user.id, params[:topic_id]) | |||
@monitorship.update_attribute :active, true | |||
respond_to do |format| | |||
format.html { redirect_to topic_path(params[:forum_id], params[:topic_id]) } | |||
format.js | |||
end | |||
end | |||
|
|||
def destroy | |||
Monitorship.update_all ['active = ?', false], ['user_id = ? and topic_id = ?', current_user.id, params[:topic_id]] | |||
respond_to do |format| | |||
format.html { redirect_to topic_path(params[:forum_id], params[:topic_id]) } | |||
format.js | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
class MonitorshipsSweeper < ActionController::Caching::Sweeper | |||
observe Monitorship | |||
|
|||
def after_save(monitorship) | |||
FileUtils.rm_rf File.join(RAILS_ROOT, 'public', 'users', monitorship.user_id.to_s) | |||
end | |||
|
|||
alias_method :after_destroy, :after_save | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
class PostsSweeper < ActionController::Caching::Sweeper | |||
observe Post | |||
|
|||
def after_save(post) | |||
FileUtils.rm_rf File.join(RAILS_ROOT, 'public', 'forums', post.forum_id.to_s, 'posts.rss') | |||
FileUtils.rm_rf File.join(RAILS_ROOT, 'public', 'forums', post.forum_id.to_s, 'topics', "#{post.topic_id}.rss") | |||
FileUtils.rm_rf File.join(RAILS_ROOT, 'public', 'users') | |||
FileUtils.rm_rf File.join(RAILS_ROOT, 'public', 'posts.rss') | |||
end | |||
|
|||
alias_method :after_destroy, :after_save | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
#page["monitorship-icon-topics-#{params[:topic_id]}"].remove_class_name(:grey) | |||
#page["monitorship-icon-topics-#{params[:topic_id]}"].add_class_name(:green) | |||
|
|||
page[:monitor_label].innerHTML = "Monitoring topic"[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
#page["monitorship-icon-topics-#{params[:topic_id]}"].remove_class_name(:green) | |||
#page["monitorship-icon-topics-#{params[:topic_id]}"].add_class_name(:darkgrey) | |||
|
|||
page[:monitor_label].innerHTML = "Monitor topic"[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,16 +1,42 @@ | |||
<h1>Log In</h1> | <h1>Log In</h1> | ||
|
|
||
<% form_tag session_path do -%> | <% form_tag(session_path) do -%> | ||
<div id="openid_fields" style="display:none"> | |||
<p> | |||
<label for="openid_url">Login with OpenID</label> | |||
<br /> | |||
<%= text_field_tag 'openid_url', params[:openid_url], :class => "openid_url" %> | |||
</p> | |||
<p>or login with <a href="#" onclick="LoginForm.setToPassword()">username/password</a></p> | |||
</div> | |||
|
|||
<div id="password_fields"> | |||
<p><%= label_tag 'login' %><br /> | <p><%= label_tag 'login' %><br /> | ||
<%= text_field_tag 'login', @login %></p> | <%= text_field_tag 'login', @login %></p> | ||
|
|
||
<p><%= label_tag 'password' %><br/> | <p><%= label_tag 'password' %><br/> | ||
<%= password_field_tag 'password', nil %></p> | <%= password_field_tag 'password', nil %></p> | ||
|
|
||
<!-- Uncomment this if you want this functionality | |||
<p><%= label_tag 'remember_me', 'Remember me' %> | <p><%= label_tag 'remember_me', 'Remember me' %> | ||
<%= check_box_tag 'remember_me', '1', @remember_me %></p> | <%= check_box_tag 'remember_me', '1', @remember_me %></p> | ||
--> | |||
|
|
||
<p><%= submit_tag 'Log in' %></p> | <p>or login with <a href="#" onclick="LoginForm.setToOpenID()">OpenID</a></p> | ||
</div> | |||
|
|||
<p><%= submit_tag 'Log in' %> or <%= link_to_function('reset password'[], "$('reset-password').toggle();") %></p> | |||
|
|||
<% end -%> | <% end -%> | ||
<% form_tag users_path, :id => 'reset-password', :style => 'display:none' do -%> | |||
|
|||
<hr /> | |||
<h5><%= 'Reset Password'[] %></h5> | |||
|
|||
<p><%= 'Enter your email, and a brand new login key will be sent to you. Click the link in the email to log in, and then change your password.'[:email_directions] %></p> | |||
<p><%= text_field_tag :email, "", :size => 30 %></p> | |||
<p><%= submit_tag 'E-mail me the link'[:email_submit] %> | |||
or <%= link_to_function('cancel'[], "$('reset-password').hide()") %></p> | |||
|
|||
<% end -%> | |||
<%= javascript_tag "$('openid_input').focus();"%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
OpenIdAuthentication.store = :file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
db/migrate/20090317123901_add_open_id_authentication_tables.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
class AddOpenIdAuthenticationTables < ActiveRecord::Migration | |||
def self.up | |||
create_table "open_id_authentication_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_authentication_nonces", :force => true do |t| | |||
t.column "nonce", :string | |||
t.column "created", :integer | |||
end | |||
|
|||
create_table "open_id_authentication_settings", :force => true do |t| | |||
t.column "setting", :string | |||
t.column "value", :binary | |||
end | |||
end | |||
|
|||
def self.down | |||
drop_table "open_id_authentication_associations" | |||
drop_table "open_id_authentication_nonces" | |||
drop_table "open_id_authentication_settings" | |||
end | |||
end |
Oops, something went wrong.