Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e82a6fb
Showing
94 changed files
with
4,239 additions
and
0 deletions.
There are no files selected for viewing
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
This is a default rails app I made to use as a template for my projects. I tried using various different forks of Bort, but all of them had something wrong, and none of them were really right for me. If you find this useful, then enjoy! | ||
|
||
Details | ||
--------------------------- | ||
Rails 2.3.2 | ||
|
||
User Authentication with Authlogic and Open_id_authentication | ||
Jrails replaces prototype and scriptaculous | ||
Default layout created with Ryanb's nifty_layout generator | ||
Pagination using will_paginate |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require(File.join(File.dirname(__FILE__), 'config', 'boot')) | ||
|
||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
require 'tasks/rails' |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Filters added to this controller apply to all controllers in the application. | ||
# Likewise, all the methods added will be available for all controllers. | ||
|
||
class ApplicationController < ActionController::Base | ||
helper :all # include all helpers, all the time | ||
protect_from_forgery # See ActionController::RequestForgeryProtection for details | ||
|
||
# Scrub sensitive parameters from your log | ||
# filter_parameter_logging :password | ||
helper_method :current_user | ||
|
||
private | ||
|
||
def current_user_session | ||
return @current_user_session if defined?(@current_user_session) | ||
@current_user_session = UserSession.find | ||
end | ||
|
||
def current_user | ||
return @current_user if defined?(@current_user) | ||
@current_user = current_user_session && current_user_session.record | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class UserSessionsController < ApplicationController | ||
def new | ||
@user_session = UserSession.new | ||
end | ||
|
||
def create | ||
@user_session = UserSession.new(params[:user_session]) | ||
@user_session.save do |result| | ||
if result | ||
flash[:notice] = "Successfully logged in." | ||
redirect_to root_url | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
end | ||
|
||
|
||
def destroy | ||
@user_session = UserSession.find | ||
@user_session.destroy | ||
flash[:notice] = "Successfully logged out." | ||
redirect_to root_url | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class UsersController < ApplicationController | ||
def new | ||
@user = User.new | ||
end | ||
|
||
def create | ||
@user = User.new(params[:user]) | ||
@user.save do |result| | ||
if result | ||
flash[:notice] = "Registration successful." | ||
redirect_to root_url | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
end | ||
|
||
def update | ||
@user = current_user | ||
@user.attributes = params[:user] | ||
@user.save do |result| | ||
if result | ||
flash[:notice] = "Successfully updated profile." | ||
redirect_to root_url | ||
else | ||
render :action => 'edit' | ||
end | ||
end | ||
end | ||
|
||
def edit | ||
@user = current_user | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Methods added to this helper will be available to all templates in the application. | ||
module ApplicationHelper | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# These helper methods can be called in your template to set variables to be used in the layout | ||
# This module should be included in all views globally, | ||
# to do so you may need to add this line to your ApplicationController | ||
# helper :layout | ||
module LayoutHelper | ||
def title(page_title, show_title = true) | ||
@content_for_title = page_title.to_s | ||
@show_title = show_title | ||
end | ||
|
||
def show_title? | ||
@show_title | ||
end | ||
|
||
def stylesheet(*args) | ||
content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) } | ||
end | ||
|
||
def javascript(*args) | ||
args = args.map { |arg| arg == :defaults ? arg : arg.to_s } | ||
content_for(:head) { javascript_include_tag(*args) } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module UserSessionsHelper | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module UsersHelper | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class User < ActiveRecord::Base | ||
acts_as_authentic do |c| | ||
c.openid_required_fields = [:nickname, :email] | ||
end | ||
|
||
private | ||
|
||
def map_openid_registration(registration) | ||
self.email = registration["email"] if email.blank? | ||
self.username = registration["nickname"] if username.blank? | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class UserSession < Authlogic::Session::Base | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html> | ||
<head> | ||
<title><%= h(yield(:title) || "Untitled") %></title> | ||
<%= stylesheet_link_tag 'application' %> | ||
<%= javascript_include_tag :defaults %> | ||
<%= yield(:head) %> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<div id="user_nav"> | ||
<% if current_user %> | ||
<%= link_to "Edit Profile", edit_user_path(:current) %> | | ||
<%= link_to "logout", logout_path %> | ||
<% else %> | ||
<%= link_to "Register", new_user_path %> | | ||
<%= link_to "Login", login_path %> | ||
<% end %> | ||
</div> | ||
<%- flash.each do |name, msg| -%> | ||
<%= content_tag :div, msg, :id => "flash_#{name}" %> | ||
<%- end -%> | ||
<div class="clear"></div> | ||
<%- if show_title? -%> | ||
<h1><%=h yield(:title) %></h1> | ||
<%- end -%> | ||
<%= yield %> | ||
|
||
</div> | ||
</body> | ||
</html> |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<% title "New User Session" %> | ||
<% form_for @user_session do |f| %> | ||
<%= f.error_messages %> | ||
<p> | ||
<%= f.label :username %><br /> | ||
<%= f.text_field :username %> | ||
</p> | ||
<p> | ||
<%= f.label :password %><br /> | ||
<%= f.password_field :password %> | ||
</p> | ||
<p><%= f.submit "Submit", :disable_with => 'Processing...' %></p> | ||
|
||
<h2>Or use OpenID</h2> | ||
<p> | ||
<%= f.label :openid_identifier, "OpenID URL" %><br /> | ||
<%= f.text_field :openid_identifier %> | ||
</p> | ||
<p><%= f.submit "Submit", :disable_with => 'Processing...' %></p> | ||
<% 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<% form_for @user do |f| %> | ||
<%= f.error_messages %> | ||
<p> | ||
<%= f.label :username %> <br /> | ||
<%= f.text_field :username %> | ||
</p> | ||
<p> | ||
<%= f.label :email %> <br /> | ||
<%= f.text_field :email %> | ||
</p> | ||
|
||
<% if @user.openid_identifier.blank? %> | ||
<p> | ||
<%= f.label :password %><br /> | ||
<%= f.password_field :password %> | ||
</p> | ||
<p> | ||
<%= f.label :password_confirmation %><br /> | ||
<%= f.password_field :password_confirmation %> | ||
</p> | ||
<p><%= f.submit "Submit", :disable_with => 'Processing...' %></p> | ||
|
||
<h2>Or use OpenID</h2> | ||
<% end %> | ||
<p> | ||
<%= f.label :openid_identifier, "OpenID URL" %><br /> | ||
<%= f.text_field :openid_identifier %> | ||
</p> | ||
<p><%= f.submit "Submit", :disable_with => 'Processing...' %></p> | ||
|
||
<% 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<% title "Edit User" %> | ||
<%= render :partial => 'form' %> | ||
|
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% title "New User" %> | ||
<%= render :partial => 'form' %> | ||
<%= link_to_function 'click' do |page| | ||
page.visual_effect :switch_off, "test" | ||
end %> | ||
<div id="test"> | ||
This is a really cool test paragraph to see if jquery works properly | ||
</div> | ||
|
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Don't change this file! | ||
# Configure your app in config/environment.rb and config/environments/*.rb | ||
|
||
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) | ||
|
||
module Rails | ||
class << self | ||
def boot! | ||
unless booted? | ||
preinitialize | ||
pick_boot.run | ||
end | ||
end | ||
|
||
def booted? | ||
defined? Rails::Initializer | ||
end | ||
|
||
def pick_boot | ||
(vendor_rails? ? VendorBoot : GemBoot).new | ||
end | ||
|
||
def vendor_rails? | ||
File.exist?("#{RAILS_ROOT}/vendor/rails") | ||
end | ||
|
||
def preinitialize | ||
load(preinitializer_path) if File.exist?(preinitializer_path) | ||
end | ||
|
||
def preinitializer_path | ||
"#{RAILS_ROOT}/config/preinitializer.rb" | ||
end | ||
end | ||
|
||
class Boot | ||
def run | ||
load_initializer | ||
Rails::Initializer.run(:set_load_path) | ||
end | ||
end | ||
|
||
class VendorBoot < Boot | ||
def load_initializer | ||
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" | ||
Rails::Initializer.run(:install_gem_spec_stubs) | ||
Rails::GemDependency.add_frozen_gem_path | ||
end | ||
end | ||
|
||
class GemBoot < Boot | ||
def load_initializer | ||
self.class.load_rubygems | ||
load_rails_gem | ||
require 'initializer' | ||
end | ||
|
||
def load_rails_gem | ||
if version = self.class.gem_version | ||
gem 'rails', version | ||
else | ||
gem 'rails' | ||
end | ||
rescue Gem::LoadError => load_error | ||
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) | ||
exit 1 | ||
end | ||
|
||
class << self | ||
def rubygems_version | ||
Gem::RubyGemsVersion rescue nil | ||
end | ||
|
||
def gem_version | ||
if defined? RAILS_GEM_VERSION | ||
RAILS_GEM_VERSION | ||
elsif ENV.include?('RAILS_GEM_VERSION') | ||
ENV['RAILS_GEM_VERSION'] | ||
else | ||
parse_gem_version(read_environment_rb) | ||
end | ||
end | ||
|
||
def load_rubygems | ||
require 'rubygems' | ||
min_version = '1.3.1' | ||
unless rubygems_version >= min_version | ||
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) | ||
exit 1 | ||
end | ||
|
||
rescue LoadError | ||
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) | ||
exit 1 | ||
end | ||
|
||
def parse_gem_version(text) | ||
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ | ||
end | ||
|
||
private | ||
def read_environment_rb | ||
File.read("#{RAILS_ROOT}/config/environment.rb") | ||
end | ||
end | ||
end | ||
end | ||
|
||
# All that for this: | ||
Rails.boot! |
Oops, something went wrong.