├── .gitignore
├── README.markdown
├── Rakefile
├── app
├── controllers
│ ├── application.rb
│ ├── categories_controller.rb
│ ├── comments_controller.rb
│ ├── home_controller.rb
│ ├── items_controller.rb
│ ├── session_controller.rb
│ ├── stars_controller.rb
│ └── users_controller.rb
├── helpers
│ ├── application_helper.rb
│ ├── categories_helper.rb
│ ├── comments_helper.rb
│ ├── home_helper.rb
│ ├── items_helper.rb
│ ├── session_helper.rb
│ └── users_helper.rb
├── models
│ ├── category.rb
│ ├── comment.rb
│ ├── item.rb
│ ├── star.rb
│ └── user.rb
└── views
│ ├── categories
│ ├── _part_of_tree.html.erb
│ ├── edit.html.erb
│ ├── index.html.erb
│ ├── new.html.erb
│ └── show.html.erb
│ ├── comments
│ ├── _edit_comment.html.erb
│ ├── edit.html.erb
│ ├── index.html.erb
│ ├── new.html.erb
│ └── show.html.erb
│ ├── home
│ ├── _signup_captcha.html.erb
│ └── index.html.erb
│ ├── items
│ ├── _edit_item.html.erb
│ ├── _item.html.erb
│ ├── _paginator.html.erb
│ ├── category.html.erb
│ ├── edit.html.erb
│ ├── index.html.erb
│ ├── index.rss.builder
│ ├── list_for_tags.html.erb
│ ├── new.html.erb
│ ├── recently.html.erb
│ ├── search.html.erb
│ └── show.html.erb
│ ├── layouts
│ ├── categories.html.erb
│ ├── comments.html.erb
│ ├── items.html.erb
│ └── main.html.erb
│ ├── session
│ └── new.html.erb
│ └── users
│ ├── index.html.erb
│ └── new.html.erb
├── config
├── boot.rb
├── database.yml.dist
├── environment.rb
├── environments
│ ├── development.rb
│ ├── production.rb
│ └── test.rb
├── initializers
│ ├── inflections.rb
│ └── mime_types.rb
├── pythonflow.yml
├── routes.rb
└── rubyflow.yml
├── db
├── migrate
│ ├── 001_create_users.rb
│ ├── 002_add_admin_flag_to_users.rb
│ ├── 003_add_open_id_authentication_tables.rb
│ ├── 004_create_items.rb
│ ├── 005_change_tags_to_text_on_items.rb
│ ├── 006_create_categories.rb
│ ├── 007_create_comments.rb
│ ├── 008_add_byline_to_item.rb
│ ├── 009_add_comments_count_to_items.rb
│ ├── 010_user_approved_for_feed.rb
│ ├── 011_create_stars.rb
│ ├── 012_add_counter_cache_for_stars.rb
│ ├── 013_add_id_to_stars.rb
│ ├── 014_recreate_stars_table.rb
│ └── 015_add_last_checked_at_to_user.rb
└── schema.rb
├── lib
├── authenticated_system.rb
└── authenticated_test_helper.rb
├── log
└── .gitignore
├── public
├── .htaccess
├── 404.html
├── 422.html
├── 500.html
├── dispatch.cgi
├── dispatch.fcgi
├── dispatch.rb
├── favicon.ico
├── images
│ └── rails.png
├── javascripts
│ ├── application.js
│ ├── controls.js
│ ├── dragdrop.js
│ ├── effects.js
│ ├── jquery-ui.js
│ ├── jquery.js
│ ├── jrails.js
│ └── prototype.js
├── robots.txt
└── stylesheets
│ ├── main.css
│ └── scaffold.css
├── script
├── about
├── console
├── dbconsole
├── destroy
├── generate
├── performance
│ ├── benchmarker
│ ├── profiler
│ └── request
├── plugin
├── process
│ ├── inspector
│ ├── reaper
│ └── spawner
├── runner
└── server
├── test
├── factories
│ ├── item_factory.rb
│ ├── misc_sequences.rb
│ └── user_factory.rb
├── fixtures
│ ├── categories.yml
│ ├── comments.yml
│ ├── items.yml
│ ├── stars.yml
│ └── users.yml
├── functional
│ ├── comments_controller_test.rb
│ ├── home_controller_test.rb
│ ├── items_controller_test.rb
│ ├── session_controller_test.rb
│ └── users_controller_test.rb
├── integration
│ └── stories_test.rb
├── test_helper.rb
└── unit
│ ├── category_test.rb
│ ├── comment_test.rb
│ ├── item_test.rb
│ ├── star_test.rb
│ └── user_test.rb
├── tmp
└── .gitignore
└── vendor
└── plugins
├── acts_as_state_machine
├── CHANGELOG
├── MIT-LICENSE
├── README
├── Rakefile
├── TODO
├── init.rb
├── lib
│ └── acts_as_state_machine.rb
└── test
│ ├── acts_as_state_machine_test.rb
│ ├── database.yml
│ ├── fixtures
│ ├── conversation.rb
│ ├── conversations.yml
│ └── person.rb
│ ├── schema.rb
│ └── test_helper.rb
├── acts_as_tree
├── README
├── Rakefile
├── init.rb
├── lib
│ └── active_record
│ │ └── acts
│ │ └── tree.rb
└── test
│ ├── abstract_unit.rb
│ ├── acts_as_tree_test.rb
│ ├── database.yml
│ ├── fixtures
│ ├── mixin.rb
│ └── mixins.yml
│ └── schema.rb
├── jrails
├── CHANGELOG
├── README
├── init.rb
├── install.rb
├── javascripts
│ ├── jquery-ui.js
│ ├── jquery.js
│ ├── jrails.js
│ └── sources
│ │ └── jrails.js
├── lib
│ └── jrails.rb
└── tasks
│ └── jrails.rake
├── restful_authentication
├── README
├── Rakefile
├── generators
│ └── authenticated
│ │ ├── USAGE
│ │ ├── authenticated_generator.rb
│ │ └── templates
│ │ ├── activation.html.erb
│ │ ├── authenticated_system.rb
│ │ ├── authenticated_test_helper.rb
│ │ ├── controller.rb
│ │ ├── fixtures.yml
│ │ ├── functional_spec.rb
│ │ ├── functional_test.rb
│ │ ├── helper.rb
│ │ ├── login.html.erb
│ │ ├── mailer.rb
│ │ ├── mailer_test.rb
│ │ ├── migration.rb
│ │ ├── model.rb
│ │ ├── model_controller.rb
│ │ ├── model_functional_spec.rb
│ │ ├── model_functional_test.rb
│ │ ├── model_helper.rb
│ │ ├── observer.rb
│ │ ├── signup.html.erb
│ │ ├── signup_notification.html.erb
│ │ ├── unit_spec.rb
│ │ └── unit_test.rb
├── install.rb
└── lib
│ └── restful_authentication
│ └── rails_commands.rb
└── shoulda
├── .autotest
├── .gitignore
├── CONTRIBUTION_GUIDELINES.rdoc
├── MIT-LICENSE
├── README.rdoc
├── Rakefile
├── bin
└── convert_to_should_syntax
├── init.rb
├── lib
├── shoulda.rb
└── shoulda
│ ├── active_record_helpers.rb
│ ├── color.rb
│ ├── controller_tests
│ ├── controller_tests.rb
│ └── formats
│ │ ├── html.rb
│ │ └── xml.rb
│ ├── gem
│ ├── proc_extensions.rb
│ └── shoulda.rb
│ ├── general.rb
│ └── private_helpers.rb
├── tasks
├── list_tests.rake
└── yaml_to_shoulda.rake
└── test
├── README
├── fixtures
├── addresses.yml
├── posts.yml
├── products.yml
├── taggings.yml
├── tags.yml
└── users.yml
├── functional
├── posts_controller_test.rb
└── users_controller_test.rb
├── other
├── context_test.rb
├── convert_to_should_syntax_test.rb
├── helpers_test.rb
├── private_helpers_test.rb
└── should_test.rb
├── rails_root
├── app
│ ├── controllers
│ │ ├── application.rb
│ │ ├── posts_controller.rb
│ │ └── users_controller.rb
│ ├── helpers
│ │ ├── application_helper.rb
│ │ ├── posts_helper.rb
│ │ └── users_helper.rb
│ ├── models
│ │ ├── address.rb
│ │ ├── dog.rb
│ │ ├── flea.rb
│ │ ├── post.rb
│ │ ├── product.rb
│ │ ├── tag.rb
│ │ ├── tagging.rb
│ │ └── user.rb
│ └── views
│ │ ├── layouts
│ │ ├── posts.rhtml
│ │ └── users.rhtml
│ │ ├── posts
│ │ ├── edit.rhtml
│ │ ├── index.rhtml
│ │ ├── new.rhtml
│ │ └── show.rhtml
│ │ └── users
│ │ ├── edit.rhtml
│ │ ├── index.rhtml
│ │ ├── new.rhtml
│ │ └── show.rhtml
├── config
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ └── sqlite3.rb
│ ├── initializers
│ │ ├── new_rails_defaults.rb
│ │ └── shoulda.rb
│ └── routes.rb
├── db
│ ├── migrate
│ │ ├── 001_create_users.rb
│ │ ├── 002_create_posts.rb
│ │ ├── 003_create_taggings.rb
│ │ ├── 004_create_tags.rb
│ │ ├── 005_create_dogs.rb
│ │ ├── 006_create_addresses.rb
│ │ ├── 007_create_fleas.rb
│ │ ├── 008_create_dogs_fleas.rb
│ │ └── 009_create_products.rb
│ └── schema.rb
├── log
│ └── .keep
├── public
│ ├── .htaccess
│ ├── 404.html
│ ├── 422.html
│ └── 500.html
├── script
│ ├── console
│ └── generate
└── vendor
│ └── plugins
│ └── .keep
├── test_helper.rb
└── unit
├── address_test.rb
├── dog_test.rb
├── flea_test.rb
├── post_test.rb
├── product_test.rb
├── tag_test.rb
├── tagging_test.rb
└── user_test.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | log/*.log
3 | log/*.pid
4 | #config/development.sphinx.conf
5 | tmp/**/*
6 | config/database.yml
7 | db/*.sqlite3
8 | coverage
9 | doc/plugins/*
10 | doc/*
11 | #db/sphinx/development/*
12 | Capfile
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | RUBYFLOW
2 | ========
3 | _Developed by Peter Cooper - 2008_
4 |
5 | All code developed by Peter Cooper within this project is in the public domain.
6 | Plugins, Rails, and derivative code is licensed as it was originally (mostly MIT).
7 |
8 | This code is entirely unsupported, lacks tests, and could well make your machine
9 | explode. If you use it, you understand this and accept all the risks.
10 |
11 |
12 | Getting Started
13 | ---------------
14 | I have not tested these instructions, but from memory..
15 |
16 | 1. Rename config/database.yml.dist to database.yml and make the appropriate
17 | configuration changes.
18 |
19 | 2. Run rake db:migrate to set up your database.
20 |
21 | 3. Configure your site-specific settings (see "Multiple Sites", below).
22 |
23 | Multiple Sites
24 | --------------
25 |
26 | The RubyFlow code is designed to deal with multiple sites from one codebase (although not one installation).
27 | The settings for a particular site are in config/[sitename].yml
28 | The site name for the current installation is set on the first line of config/environment.rb
29 | Current the setting is for "rubyflow", so config/rubyflow.yml is used.
30 | Change the chosen site in config/environment.rb and create your own YML file.
31 |
32 | Note that the chosen site name is added as a class to the BODY tag. This makes it easy to use the same
33 | CSS file for multiple sites but apply site specific tweaks with BODY.sitename prefixes in the CSS!
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5 |
6 | require 'rake'
7 | require 'rake/testtask'
8 | require 'rake/rdoctask'
9 |
10 | require 'tasks/rails'
11 |
--------------------------------------------------------------------------------
/app/controllers/application.rb:
--------------------------------------------------------------------------------
1 | # Filters added to this controller apply to all controllers in the application.
2 | # Likewise, all the methods added will be available for all controllers.
3 |
4 | class ApplicationController < ActionController::Base
5 | helper :all # include all helpers, all the time
6 |
7 | # See ActionController::RequestForgeryProtection for details
8 | # Uncomment the :secret if you're not using the cookie session store
9 | protect_from_forgery # :secret => '????? you'll need to sort this out yourself!'
10 |
11 | include AuthenticatedSystem
12 |
13 | def go_404
14 | render :text => '404 Not Found', :status => 404
15 | end
16 |
17 | def items_per_page
18 | 50
19 | end
20 | helper_method :items_per_page
21 |
22 | # do_pagination is used in before_filters by actions that use pagination
23 | # If a "page" param is provided, use that to set the page, otherwise assume we're on page 1
24 | # Then set up a pagination_options hash that can be used with 'find' to sort out the SQL!
25 | # If param "all" is set, pagination is forgotten and ALL items should be returned
26 | def do_pagination
27 | @page_number = 1
28 | if params[:page] && params[:page].to_i > 0
29 | @page_number = params[:page].to_i
30 | end
31 | @pagination = true
32 | @pagination_options = { :limit => items_per_page, :offset => (@page_number - 1) * items_per_page }
33 | @pagination_options = {} if params[:all]
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/app/controllers/categories_controller.rb:
--------------------------------------------------------------------------------
1 | class CategoriesController < ApplicationController
2 | # You need to be an admin to play with categories (not actually used in this app yet)
3 | before_filter :admin_required, :except => [:show, :index]
4 |
5 | layout 'main'
6 |
7 | # GET /categories
8 | # GET /categories.xml
9 | def index
10 | @top_category = Category.find_by_parent_id(nil)
11 |
12 | respond_to do |format|
13 | format.html # index.html.erb
14 | format.xml { render :xml => Category.find(:all) }
15 | end
16 | end
17 |
18 | # GET /categories/1
19 | # GET /categories/1.xml
20 | def show
21 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id])
22 |
23 | respond_to do |format|
24 | format.html # show.html.erb
25 | format.xml { render :xml => @category }
26 | end
27 | end
28 |
29 | # GET /categories/new
30 | # GET /categories/new.xml
31 | def new
32 | @category = Category.new
33 |
34 | respond_to do |format|
35 | format.html # new.html.erb
36 | format.xml { render :xml => @category }
37 | end
38 | end
39 |
40 | # GET /categories/1/edit
41 | def edit
42 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id])
43 | end
44 |
45 | # POST /categories
46 | # POST /categories.xml
47 | def create
48 | @category = Category.new(params[:category])
49 |
50 | respond_to do |format|
51 | if @category.save
52 | flash[:notice] = 'Category was successfully created.'
53 | format.html { redirect_to(@category) }
54 | format.xml { render :xml => @category, :status => :created, :location => @category }
55 | else
56 | format.html { render :action => "new" }
57 | format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
58 | end
59 | end
60 | end
61 |
62 | # PUT /categories/1
63 | # PUT /categories/1.xml
64 | def update
65 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id])
66 |
67 | respond_to do |format|
68 | if @category.update_attributes(params[:category])
69 | flash[:notice] = 'Category was successfully updated.'
70 | format.html { redirect_to(@category) }
71 | format.xml { head :ok }
72 | else
73 | format.html { render :action => "edit" }
74 | format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
75 | end
76 | end
77 | end
78 |
79 | # DELETE /categories/1
80 | # DELETE /categories/1.xml
81 | def destroy
82 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id])
83 | @category.destroy
84 |
85 | respond_to do |format|
86 | format.html { redirect_to(categories_url) }
87 | format.xml { head :ok }
88 | end
89 | end
90 | end
91 |
--------------------------------------------------------------------------------
/app/controllers/comments_controller.rb:
--------------------------------------------------------------------------------
1 | class CommentsController < ApplicationController
2 | before_filter :admin_required, :except => [:create]
3 | before_filter :load_item
4 |
5 | layout 'main'
6 |
7 | # GET /comments/1/edit
8 | def edit
9 | @comment = Comment.find(params[:id])
10 | end
11 |
12 | # POST /comments
13 | # POST /comments.xml
14 | def create
15 | @comment = Comment.new(params[:comment])
16 | @comment.item = @item
17 |
18 | if logged_in?
19 | @comment.user = current_user
20 | else
21 | @comment.byline = "Anonymous Coward" if @comment.byline.empty?
22 | @comment.content = @comment.content.gsub(/((]*?)>)/, '\2 rel="nofollow" \3>')
23 | unless Digest::SHA1.hexdigest(params[:captcha].upcase.chomp)[0..5] == params[:captcha_guide]
24 | @item.errors.add("Word")
25 | flash.now[:notice] = "Your comment could not be posted. Scroll down, correct, and retry. Did you get the CAPTCHA right?"
26 | render :template => 'items/show'
27 | return
28 | end
29 | end
30 |
31 | respond_to do |format|
32 | if @comment.save
33 | flash[:notice] = 'Comment was successfully created.'
34 | format.html { redirect_to(@comment.item) }
35 | format.xml { render :xml => @comment, :status => :created, :location => @comment }
36 | else
37 | flash.now[:notice] = "Your comment could not be posted. Scroll down, correct, and retry."
38 | format.html { render :template => 'items/show' }
39 | format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
40 | end
41 | end
42 | end
43 |
44 | # PUT /comments/1
45 | # PUT /comments/1.xml
46 | def update
47 | @comment = Comment.find(params[:id])
48 |
49 | respond_to do |format|
50 | if @comment.update_attributes(params[:comment])
51 | flash[:notice] = 'Comment was successfully updated.'
52 | format.html { redirect_to(@comment) }
53 | format.xml { head :ok }
54 | else
55 | format.html { render :action => "edit" }
56 | format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
57 | end
58 | end
59 | end
60 |
61 | # DELETE /comments/1
62 | # DELETE /comments/1.xml
63 | def destroy
64 | @comment = Comment.find(params[:id])
65 | @comment.destroy
66 |
67 | respond_to do |format|
68 | format.html { redirect_to(comments_url) }
69 | format.xml { head :ok }
70 | end
71 | end
72 |
73 | private
74 | def load_item
75 | @item = Item.find(params[:item_id])
76 | end
77 | end
78 |
--------------------------------------------------------------------------------
/app/controllers/home_controller.rb:
--------------------------------------------------------------------------------
1 | class HomeController < ApplicationController
2 | layout 'main'
3 |
4 | end
5 |
--------------------------------------------------------------------------------
/app/controllers/session_controller.rb:
--------------------------------------------------------------------------------
1 | # This controller handles the login/logout function of the site.
2 | class SessionController < ApplicationController
3 | layout 'main'
4 |
5 | def new
6 | end
7 |
8 | def create
9 | #if using_open_id?
10 | # open_id_authentication(params[:openid_url])
11 | #else
12 | password_authentication(params[:login], params[:password])
13 | #end
14 | end
15 |
16 | def destroy
17 | self.current_user.forget_me if logged_in?
18 | cookies.delete :auth_token
19 | reset_session
20 | flash[:notice] = "You have been logged out."
21 | redirect_back_or_default('/')
22 | end
23 |
24 | protected
25 |
26 | def open_id_authentication(openid_url)
27 | authenticate_with_open_id(openid_url, :required => [:nickname, :email]) do |result, identity_url, registration|
28 | if result.successful?
29 | @user = User.find_or_initialize_by_identity_url(identity_url)
30 | if @user.new_record?
31 | @user.login = registration['nickname']
32 | @user.email = registration['email']
33 | @user.save(false)
34 | end
35 | self.current_user = @user
36 | successful_login
37 | else
38 | failed_login result.message
39 | end
40 | end
41 | end
42 |
43 | def password_authentication(login, password)
44 | self.current_user = User.authenticate(login, password)
45 | if logged_in?
46 | successful_login
47 | else
48 | failed_login
49 | end
50 | end
51 |
52 | def failed_login(message = "Authentication failed.")
53 | flash.now[:error] = message
54 | render :action => 'new'
55 | end
56 |
57 | def successful_login
58 | if params[:remember_me] == "1"
59 | self.current_user.remember_me
60 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => 1.year.from_now }
61 | end
62 | redirect_back_or_default('/')
63 | flash[:notice] = "Logged in successfully"
64 | end
65 |
66 | end
67 |
--------------------------------------------------------------------------------
/app/controllers/stars_controller.rb:
--------------------------------------------------------------------------------
1 | class StarsController < ApplicationController
2 |
3 | skip_before_filter :verify_authenticity_token
4 | before_filter :login_required
5 |
6 | def add
7 | @item = Item.find(params[:item_id])
8 | @star = Star.new(:item => @item, :user => current_user)
9 | saved = @star.save
10 | respond_to do |wants|
11 | wants.html { redirect_to :back }
12 | wants.js do
13 | stars_count = @item.stars.size + 1
14 | saved ? render(:text => "#{stars_count} #{stars_count == 1 ? "star" : "stars"}") : head(:unprocessable_entity)
15 | end
16 | end
17 | end
18 |
19 | def remove
20 | @item = Item.find(params[:item_id])
21 | @star = @item.stars.find(:first, :conditions => ["user_id = ?", current_user.id])
22 | destroyed = @star ? @star.destroy : false # If the star doesn't exist, add it
23 | respond_to do |wants|
24 | wants.html { redirect_to :back }
25 | wants.js do
26 | stars_count = @item.stars.size - 1
27 | destroyed ? render(:text => "#{stars_count} #{stars_count == 1 ? "star" : "stars"}") : head(:unprocessable_entity)
28 | end
29 | end
30 | end
31 |
32 | end
--------------------------------------------------------------------------------
/app/controllers/users_controller.rb:
--------------------------------------------------------------------------------
1 | class UsersController < ApplicationController
2 | before_filter :admin_required, :except => [:new, :create]
3 |
4 | layout 'main'
5 |
6 | def new
7 | end
8 |
9 | def create
10 | cookies.delete :auth_token
11 |
12 | @user = User.new(params[:user])
13 | unless Digest::SHA1.hexdigest(params[:captcha].upcase.chomp)[0..5] == params[:captcha_guide]
14 | @user.errors.add("Word")
15 | render :action => 'new'
16 | return
17 | end
18 |
19 | @user.save
20 | if @user.errors.empty?
21 | self.current_user = @user
22 | redirect_back_or_default('/')
23 | flash[:notice] = "Thanks for signing up! You have been logged in automagically!"
24 | else
25 | render :action => 'new'
26 | end
27 | end
28 |
29 | def index
30 | @users = User.find(:all, :order => 'id DESC', :limit => 100)
31 | end
32 |
33 | def approve
34 | user = User.find(params[:id])
35 | user.approved_for_feed = 1
36 | user.save
37 | redirect_to :back
38 | end
39 |
40 | def disapprove
41 | user = User.find(params[:id])
42 | user.approved_for_feed = 0
43 | user.save
44 | redirect_to :back
45 | end
46 |
47 | def destroy
48 | return unless request.post?
49 | User.destroy(params[:id])
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | # Methods added to this helper will be available to all templates in the application.
2 | module ApplicationHelper
3 | def editable?(item)
4 | admin? || item.user == current_user
5 | end
6 |
7 | def title
8 | if @title
9 | @title + " : " + APP_CONFIG[:app_title]
10 | else
11 | APP_CONFIG[:default_title]
12 | end
13 | end
14 |
15 | def safe(txt)
16 | sanitize(txt, :tags => %w(a p code b strong i em blockquote), :attributes => %w(href)).split("\n").join("\n <%= link_to h(category.publicly_facing_name), category %>
4 | <%= link_to('Edit', edit_category_path(category)) if admin? %>
5 | <%= link_to('Destroy', category, :confirm => 'Are you sure?', :method => :delete) if admin? %>
7 | Name
12 | Title
17 | Parent Category
22 | Query
27 | <%= f.submit "Update" %>
28 |
7 | Name
12 | Title
17 | Parent Category
22 | Query
27 | <%= f.submit "Create" %>
28 |
2 | Name:
3 | <%=h @category.name %>
4 |
7 | Title:
8 | <%=h @category.title %>
9 |
12 | Parent:
13 | <% if @category.parent %><%=h @category.parent.name %><% end %>
14 |
17 | Query:
18 | <%=h @category.query %>
19 | Posting as <%= current_user.login %> Note: If you are a registered user, <%= link_to 'log in', login_url %> to populate these fields. <%= f.text_field :byline %>
18 |
22 | If you wish, you may use these HTML tags to format your comment: <%= f.text_area :content %> <%= f.submit "Post Comment" %>
7 | Content
12 | Byline
17 | User
22 | <%= f.submit "Update" %>
23 |
")
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/app/helpers/categories_helper.rb:
--------------------------------------------------------------------------------
1 | module CategoriesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/comments_helper.rb:
--------------------------------------------------------------------------------
1 | module CommentsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/home_helper.rb:
--------------------------------------------------------------------------------
1 | module HomeHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/items_helper.rb:
--------------------------------------------------------------------------------
1 | module ItemsHelper
2 | def user_link(item)
3 | if item.user
4 | follow = item.user.approved_for_feed == 1 ? {} : {:rel => 'nofollow'}
5 | link_to(item.user.login, item.user.url, follow)
6 | else
7 | item.byline
8 | end
9 | end
10 |
11 | def star_link(item)
12 | if item.is_starred_by_user(current_user)
13 | return " – " + content_tag(:span, link_to("unstar this post", item_remove_star_path(item), :class => item.starred_class(current_user)), :class => "star")
14 | end
15 | end
16 |
17 | # Shows the time left to edit the current item, or nil if it's always allowed
18 | def edit_time_left(item)
19 | diff = Time.now - item.updated_at
20 | expire_rate = APP_CONFIG[:edit_expiration_in_minutes].to_i
21 | return expire_rate > 0 ? expire_rate - (diff.to_i / 60) : nil
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/app/helpers/session_helper.rb:
--------------------------------------------------------------------------------
1 | module SessionHelper
2 | end
--------------------------------------------------------------------------------
/app/helpers/users_helper.rb:
--------------------------------------------------------------------------------
1 | module UsersHelper
2 | end
--------------------------------------------------------------------------------
/app/models/category.rb:
--------------------------------------------------------------------------------
1 | class Category < ActiveRecord::Base
2 | acts_as_tree :order => 'name'
3 |
4 | validates_presence_of :title, :parent_id
5 | validates_length_of :title, :within => 4..255
6 |
7 | validates_uniqueness_of :name, :if => :name?
8 | validates_format_of :name, :with => /^[\w\-\_]+$/, :if => :name?, :message => 'is invalid (alphanumerics, hyphens and underscores only)'
9 | validates_length_of :name, :within => 4..255, :if => :name?
10 |
11 | def to_param
12 | self[:name] && self[:name].length > 3 ? self[:name] : self[:id]
13 | end
14 |
15 | def publicly_facing_name
16 | title && title.length > 2 ? title : name
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/app/models/comment.rb:
--------------------------------------------------------------------------------
1 | class Comment < ActiveRecord::Base
2 | belongs_to :item, :counter_cache => true
3 | belongs_to :user
4 |
5 | validates_length_of :content, :within => 1..10000
6 | end
7 |
--------------------------------------------------------------------------------
/app/models/item.rb:
--------------------------------------------------------------------------------
1 | class Item < ActiveRecord::Base
2 | belongs_to :user
3 | has_many :comments
4 | has_many :stars, :dependent => :destroy
5 |
6 | serialize :metadata
7 |
8 | attr_protected :user_id
9 |
10 | validates_length_of :title, :within => 4..255
11 | validates_uniqueness_of :name, :if => :name?
12 | validates_format_of :name, :with => /^[\w\-\_]+$/, :if => :name?, :message => 'is invalid (alphanumerics, hyphens and underscores only)'
13 | validates_length_of :name, :within => 4..255, :if => :name?
14 | validates_length_of :content, :within => 25..1200
15 | validates_format_of :tags, :with => /^[\s\w\-\_\:]+$/, :if => :tags?, :message => 'are invalid (alphanumerics, hyphens and underscores only)'
16 |
17 | def to_param
18 | self[:name] && self[:name].length > 3 ? self[:name] : self[:id]
19 | end
20 |
21 | def tags=(tag_set)
22 | self[:tags] = tag_set.split.collect { |a| " :#{a} " }.join
23 | end
24 |
25 | def tags_before_type_cast
26 | self[:tags].to_s.gsub(':', '').gsub(/[^\w\s\-\_\:].+?\s+/, ' ').gsub(/[^\w\s\-\_\:]/, '').strip.split(/\s+/).join(' ')
27 | end
28 |
29 | def tags
30 | tags_before_type_cast
31 | end
32 |
33 | def tag_array
34 | tags.split(/\s+/)
35 | end
36 |
37 | def self.find_all_for_all_tags(tags, options = {})
38 | find(:all, { :conditions => [[*tags].collect { "tags LIKE ?" }.join(" AND "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options))
39 | end
40 |
41 | def self.count_all_for_all_tags(tags, options = {})
42 | count({ :conditions => [[*tags].collect { "tags LIKE ?" }.join(" AND "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options))
43 | end
44 |
45 | def self.find_all_for_tag(tag, options = {})
46 | find(:all, { :conditions => ["tags LIKE ?", "%#{tag}%"] }.merge(options))
47 | end
48 |
49 | def self.count_all_for_tag(tag, options = {})
50 | count({ :conditions => ["tags LIKE ?", "%#{tag}%"] }.merge(options))
51 | end
52 |
53 | def self.find_all_for_tags(tags, options = {})
54 | find(:all, { :conditions => [[*tags].collect { "tags LIKE ?" }.join(" OR "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options))
55 | end
56 | def self.count_all_for_tags(tags, options = {})
57 | count({ :conditions => [[*tags].collect { "tags LIKE ?" }.join(" OR "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options))
58 | end
59 |
60 | def is_starred_by_user(user)
61 | user.starred_items.include? self
62 | end
63 |
64 | # TODO move to a helper
65 | def starred_class(user)
66 | if self.is_starred_by_user(user)
67 | return "starred"
68 | else
69 | return ""
70 | end
71 | end
72 | end
73 |
--------------------------------------------------------------------------------
/app/models/star.rb:
--------------------------------------------------------------------------------
1 | class Star < ActiveRecord::Base
2 |
3 | belongs_to :user
4 | belongs_to :item, :counter_cache => true
5 |
6 | # Prevent people starring something multiple times.
7 | validates_uniqueness_of :item_id, :scope => :user_id, :on => :create, :message => "must be unique"
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | require 'digest/sha1'
2 | class User < ActiveRecord::Base
3 | has_many :stars
4 | has_many :starred_items, :through => :stars, :source => :item
5 | # Virtual attribute for the unencrypted password
6 | attr_accessor :password
7 |
8 | validates_presence_of :login #, :email
9 | validates_presence_of :password, :if => :password_required?
10 | validates_presence_of :password_confirmation, :if => :password_required?
11 | validates_length_of :password, :within => 4..40, :if => :password_required?
12 | validates_confirmation_of :password, :if => :password_required?
13 | validates_length_of :login, :within => 3..40
14 | #validates_length_of :email, :within => 3..100
15 | validates_uniqueness_of :login, :case_sensitive => false
16 | validates_format_of :login, :with => /^\w+$/
17 | validates_format_of :url, :with => /^(|http\:\/\/.*)$/
18 | before_save :encrypt_password
19 |
20 | # prevents a user from submitting a crafted form that bypasses activation
21 | # anything else you want your user to change should be added here.
22 | attr_accessible :login, :email, :password, :password_confirmation, :identity_url, :url, :fullname
23 |
24 | # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
25 | def self.authenticate(login, password)
26 | u = find_by_login(login) # need to get the salt
27 | u && u.authenticated?(password) ? u : nil
28 | end
29 |
30 | # Encrypts some data with the salt.
31 | def self.encrypt(password, salt)
32 | Digest::SHA1.hexdigest("--#{salt}--#{password}--")
33 | end
34 |
35 | # Encrypts the password with the user salt
36 | def encrypt(password)
37 | self.class.encrypt(password, salt)
38 | end
39 |
40 | def authenticated?(password)
41 | crypted_password == encrypt(password)
42 | end
43 |
44 | def remember_token?
45 | remember_token_expires_at && Time.now.utc < remember_token_expires_at
46 | end
47 |
48 | # These create and unset the fields required for remembering users between browser closes
49 | def remember_me
50 | remember_me_for 52.weeks
51 | end
52 |
53 | def remember_me_for(time)
54 | remember_me_until time.from_now.utc
55 | end
56 |
57 | def remember_me_until(time)
58 | self.remember_token_expires_at = time
59 | self.remember_token = encrypt("#{email}--#{remember_token_expires_at}")
60 | save(false)
61 | end
62 |
63 | def forget_me
64 | self.remember_token_expires_at = nil
65 | self.remember_token = nil
66 | save(false)
67 | end
68 |
69 | protected
70 | # before filter
71 | def encrypt_password
72 | return if password.blank?
73 | self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
74 | self.crypted_password = encrypt(password)
75 | end
76 |
77 | def password_required?
78 | crypted_password.blank? || !password.blank?
79 | end
80 |
81 |
82 | end
83 |
--------------------------------------------------------------------------------
/app/views/categories/_part_of_tree.html.erb:
--------------------------------------------------------------------------------
1 | Editing category
2 |
3 | <%= error_messages_for :category %>
4 |
5 | <% form_for(@category) do |f| %>
6 |
8 | <%= f.text_field :name %>
9 |
13 | <%= f.text_field :title %>
14 |
18 | <%= select_tag "category[parent_id]", options_for_select(Category.find(:all).collect { |c| [c.publicly_facing_name + " (#{c.name})", c.id] }, @category.parent_id) %>
19 |
23 | <%= f.text_field :query %>
24 | Listing categories
2 |
3 |
4 | <%= render :partial => 'part_of_tree', :locals => { :current_category => @top_category } %>
5 |
6 |
7 |
8 | <%= link_to 'New category', new_category_path if admin? %>
9 |
--------------------------------------------------------------------------------
/app/views/categories/new.html.erb:
--------------------------------------------------------------------------------
1 | New category
2 |
3 | <%= error_messages_for :category %>
4 |
5 | <% form_for(@category) do |f| %>
6 |
8 | <%= f.text_field :name %>
9 |
13 | <%= f.text_field :title %>
14 |
18 | <%= select_tag "category[parent_id]", options_for_select(Category.find(:all).collect { |c| [c.name, c.id] }) %>
19 |
23 | <%= f.text_field :query %>
24 |
2 |
3 |
4 | <% form_for [item, comment] do |f| %>
5 |
6 |
35 |
--------------------------------------------------------------------------------
/app/views/comments/edit.html.erb:
--------------------------------------------------------------------------------
1 | Post a Comment
7 |
8 | <% if comment.errors.size > 0 %>
9 |
10 | <% end %>
11 |
12 |
13 | <% if logged_in? %>
14 |
23 |
24 | <a href="" title=""> <b> <blockquote> <code> <em> <i> <strong>
25 |
26 | Editing comment
2 |
3 | <%= error_messages_for :comment %>
4 |
5 | <% form_for(@comment) do |f| %>
6 |
8 | <%= f.text_area :content %>
9 |
13 | <%= f.text_field :byline %>
14 |
18 | <%= f.text_field :user %>
19 | Listing comments
2 |
3 |
Content | 6 |Byline | 7 |User | 8 ||||
---|---|---|---|---|---|
<%=h comment.content %> | 13 |<%=h comment.byline %> | 14 |<%=h comment.user %> | 15 |<%= link_to 'Show', comment %> | 16 |<%= link_to 'Edit', edit_comment_path(comment) %> | 17 |<%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete %> | 18 |
7 | Content
8 | <%= f.text_area :content %>
9 |
12 | Byline
13 | <%= f.text_field :byline %>
14 |
17 | <%= f.submit "Create" %> 18 |
19 | <% end %> 20 | 21 | <%= link_to 'Back', comments_path %> 22 | -------------------------------------------------------------------------------- /app/views/comments/show.html.erb: -------------------------------------------------------------------------------- 1 |2 | Content: 3 | <%=h @comment.content %> 4 |
5 | 6 |7 | Byline: 8 | <%=h @comment.byline %> 9 |
10 | 11 |12 | User: 13 | <%=h @comment.user.login %> 14 |
15 | 16 | 17 | <%= link_to 'Edit', edit_comment_path(@comment) %> | 18 | <%= link_to 'Back', comments_path %> 19 | -------------------------------------------------------------------------------- /app/views/home/_signup_captcha.html.erb: -------------------------------------------------------------------------------- 1 |2 | <% words = %w{renegade nevergonna giveyouup letyoudown runaround starla luckystiff inside an at ax al pol paypal nidd nid pin pit pragmatic astley twogirls onecup felch kwyjibo covenham kenwick grimsby warlingham cooper macbook triumph air mascot football hockey tennis shadow bullet metaphor flyer twitter yahoo google coding ruby masterplan spyhole porthole boat float granite trousers dragon tiger} %> 3 | <% post_words = %w{in ox et by rat tar al s ty ax ak an at de er ers} %> 4 |
You are logged in as <%=h current_user.login %>
5 | <%= "you are admin" if admin? %> 6 | 7 | <% else %> 8 |You are not logged in.
9 | <% end %> -------------------------------------------------------------------------------- /app/views/items/_edit_item.html.erb: -------------------------------------------------------------------------------- 1 | <% form_for(item) do |f| %> 2 | <%= error_messages_for :item %> 3 | 4 |5 | 6 | 7 | 8 | <% if logged_in? %> 9 |40 | <% end %> -------------------------------------------------------------------------------- /app/views/items/_item.html.erb: -------------------------------------------------------------------------------- 1 |Posting as <%= current_user.login %>
10 | <% else %> 11 |12 | Note: If you are a registered user, <%= link_to 'log in', login_url %> to populate these fields automatically. 13 |
14 |15 | <%= f.text_field :byline %> 16 | 17 |
18 | <% end %> 19 | 20 |21 | <%= f.text_field :title %> 22 | 23 |
24 | 25 |26 | If you wish, you may use these HTML tags to format your post:
33 | 34 |
27 |28 | <a href=""> <b> <blockquote> <code> <em> <i> <strong> 29 |
30 |
31 | Yes, you must use HTML and not Textile or Markdown for now. 32 |<%= f.text_area :content, :cols => 60, :rows => 8 %>
35 | 36 | <%= render :partial => 'home/signup_captcha' unless logged_in? %> 37 | 38 |<%= f.submit "#{method == 'post' ? 'Post' : 'Update'} Item" %>
39 |
Nothings happened in your flow recently - try starring some more stories for more activity.
7 | <% else %> 8 |This item has <%= pluralize item.comments.select { |c| c.created_at > @last_checked_at }.size, "new comment" -%> and <%= item.updated_at > @last_checked_at ? "has" : "hasn't" -%> been edited.
15 |<%= flash[:notice] %>
13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/comments.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |<%= flash[:notice] %>
13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/items.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |<%= flash[:notice] %>
13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/main.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |
5 | <%= text_field_tag 'login' %>
Note that logins are case sensitive. Use the same casing as displays on the site / you used at signup.
8 | 9 |
10 | <%= password_field_tag 'password' %>
13 | <%= check_box_tag 'remember_me' %>
14 | 15 |16 | <%= submit_tag 'Log In' %> 17 | or 18 | <%= link_to 'Signup for a new account', signup_path, :title => 'It only takes about 15 seconds.' %> 19 |
20 | <% end -%> -------------------------------------------------------------------------------- /app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 | 4 |<%= user.id %> | 8 |<%= user.login %> | 9 |<%= user.url %> | 10 |<%= user.created_at.strftime("%b %d, %Y") %> | 11 |<%= user.approved_for_feed %> | 12 |<%= link_to 'approve', :action => 'approve', :id => user.id %> | <%= link_to 'disapprove', :action => 'disapprove', :id => user.id %> | <%= link_to 'delete', :action => 'destroy', :id => user.id, :method => :post %> | 13 |
Sorry. Keeping it real bare bones for the moment, so no OpenID yet!
6 | 7 | <% form_for :user, :url => users_path do |f| -%> 8 |
9 | <%= f.text_field :login %>
Usernames are case sensitive, but you're welcome to use mixed case and underscores as necessary (e.g. BobSmith Fred_Turner bert1974)
12 | 13 |
14 | <%= f.text_field :url %>
Note that this URL is linked from your username in various places around the site.
17 | 18 |
19 | <%= f.password_field :password %>
22 | <%= f.password_field :password_confirmation %>
<%= submit_tag 'Sign up' %>
27 | <% end -%> 28 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Don't change this file! 2 | # Configure your app in config/environment.rb and config/environments/*.rb 3 | 4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 5 | 6 | module Rails 7 | class << self 8 | def boot! 9 | unless booted? 10 | preinitialize 11 | pick_boot.run 12 | end 13 | end 14 | 15 | def booted? 16 | defined? Rails::Initializer 17 | end 18 | 19 | def pick_boot 20 | (vendor_rails? ? VendorBoot : GemBoot).new 21 | end 22 | 23 | def vendor_rails? 24 | File.exist?("#{RAILS_ROOT}/vendor/rails") 25 | end 26 | 27 | def preinitialize 28 | load(preinitializer_path) if File.exist?(preinitializer_path) 29 | end 30 | 31 | def preinitializer_path 32 | "#{RAILS_ROOT}/config/preinitializer.rb" 33 | end 34 | end 35 | 36 | class Boot 37 | def run 38 | load_initializer 39 | Rails::Initializer.run(:set_load_path) 40 | end 41 | end 42 | 43 | class VendorBoot < Boot 44 | def load_initializer 45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 46 | Rails::Initializer.run(:install_gem_spec_stubs) 47 | end 48 | end 49 | 50 | class GemBoot < Boot 51 | def load_initializer 52 | self.class.load_rubygems 53 | load_rails_gem 54 | require 'initializer' 55 | end 56 | 57 | def load_rails_gem 58 | if version = self.class.gem_version 59 | gem 'rails', version 60 | else 61 | gem 'rails' 62 | end 63 | rescue Gem::LoadError => load_error 64 | $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.) 65 | exit 1 66 | end 67 | 68 | class << self 69 | def rubygems_version 70 | Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion 71 | end 72 | 73 | def gem_version 74 | if defined? RAILS_GEM_VERSION 75 | RAILS_GEM_VERSION 76 | elsif ENV.include?('RAILS_GEM_VERSION') 77 | ENV['RAILS_GEM_VERSION'] 78 | else 79 | parse_gem_version(read_environment_rb) 80 | end 81 | end 82 | 83 | def load_rubygems 84 | require 'rubygems' 85 | 86 | unless rubygems_version >= '0.9.4' 87 | $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) 88 | exit 1 89 | end 90 | 91 | rescue LoadError 92 | $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) 93 | exit 1 94 | end 95 | 96 | def parse_gem_version(text) 97 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ 98 | end 99 | 100 | private 101 | def read_environment_rb 102 | File.read("#{RAILS_ROOT}/config/environment.rb") 103 | end 104 | end 105 | end 106 | end 107 | 108 | # All that for this: 109 | Rails.boot! 110 | -------------------------------------------------------------------------------- /config/database.yml.dist: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3-ruby (not necessary on OS X Leopard) 3 | development: 4 | adapter: sqlite3 5 | database: db/development.sqlite3 6 | timeout: 5000 7 | 8 | # Warning: The database defined as "test" will be erased and 9 | # re-generated from your development database when you run "rake". 10 | # Do not set this db to the same as development or production. 11 | test: 12 | adapter: sqlite3 13 | database: db/test.sqlite3 14 | timeout: 5000 15 | 16 | production: 17 | adapter: sqlite3 18 | database: db/production.sqlite3 19 | timeout: 5000 20 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | app_name = "rubyflow" 2 | 3 | # Be sure to restart your server when you modify this file 4 | 5 | # Uncomment below to force Rails into production mode when 6 | # you don't control web/app server and can't set it the proper way 7 | # ENV['RAILS_ENV'] ||= 'production' 8 | 9 | # Specifies gem version of Rails to use when vendor/rails is not present 10 | RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION 11 | 12 | # Bootstrap the Rails environment, frameworks, and default configuration 13 | require File.join(File.dirname(__FILE__), 'boot') 14 | 15 | 16 | Rails::Initializer.run do |config| 17 | # Settings in config/environments/* take precedence over those specified here. 18 | # Application configuration should go into files in config/initializers 19 | # -- all .rb files in that directory are automatically loaded. 20 | # See Rails::Configuration for more options. 21 | 22 | # Skip frameworks you're not going to use (only works if using vendor/rails). 23 | # To use Rails without a database, you must remove the Active Record framework 24 | # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] 25 | 26 | # Only load the plugins named here, in the order given. By default, all plugins 27 | # in vendor/plugins are loaded in alphabetical order. 28 | # :all can be used as a placeholder for all plugins not explicitly named 29 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 30 | 31 | # Add additional load paths for your own custom dirs 32 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) 33 | 34 | # Force all environments to use the same logger level 35 | # (by default production uses :info, the others :debug) 36 | # config.log_level = :debug 37 | 38 | # Your secret key for verifying cookie session data integrity. 39 | # If you change this key, all old sessions will become invalid! 40 | # Make sure the secret is at least 30 characters and all random, 41 | # no regular words or you'll be exposed to dictionary attacks. 42 | config.action_controller.session = { 43 | :session_key => "_#{app_name}_session", 44 | :secret => 'youneedtochangethistosomethingelsethankyouverymuch' 45 | } 46 | 47 | # Use the database for sessions instead of the cookie-based default, 48 | # which shouldn't be used to store highly confidential information 49 | # (create the session table with 'rake db:sessions:create') 50 | # config.action_controller.session_store = :active_record_store 51 | 52 | # Use SQL instead of Active Record's schema dumper when creating the test database. 53 | # This is necessary if your schema can't be completely dumped by the schema dumper, 54 | # like if you have constraints or database-specific column types 55 | # config.active_record.schema_format = :sql 56 | 57 | # Activate observers that should always be running 58 | # config.active_record.observers = :cacher, :garbage_collector 59 | 60 | # Make Active Record use UTC-base instead of local time 61 | # config.active_record.default_timezone = :utc 62 | config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com' 63 | end 64 | 65 | APP_CONFIG = YAML::load(File.open("#{RAILS_ROOT}/config/#{app_name}.yml")).symbolize_keys -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | # Settings specified here will take precedence over those in config/environment.rb 2 | 3 | # In the development environment your application's code is reloaded on 4 | # every request. This slows down response time but is perfect for development 5 | # since you don't have to restart the webserver when you make code changes. 6 | config.cache_classes = false 7 | 8 | # Log error messages when you accidentally call methods on nil. 9 | config.whiny_nils = true 10 | 11 | # Show full error reports and disable caching 12 | config.action_controller.consider_all_requests_local = true 13 | config.action_view.debug_rjs = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send 17 | config.action_mailer.raise_delivery_errors = false -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | # Settings specified here will take precedence over those in config/environment.rb 2 | 3 | # The production environment is meant for finished, "live" apps. 4 | # Code is not reloaded between requests 5 | config.cache_classes = true 6 | 7 | # Use a different logger for distributed setups 8 | # config.logger = SyslogLogger.new 9 | 10 | # Full error reports are disabled and caching is turned on 11 | config.action_controller.consider_all_requests_local = false 12 | config.action_controller.perform_caching = true 13 | config.action_view.cache_template_loading = true 14 | 15 | # Enable serving of images, stylesheets, and javascripts from an asset server 16 | # config.action_controller.asset_host = "http://assets.example.com" 17 | 18 | # Disable delivery errors, bad email addresses will be ignored 19 | # config.action_mailer.raise_delivery_errors = false 20 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # Settings specified here will take precedence over those in config/environment.rb 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | config.cache_classes = true 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.action_controller.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Disable request forgery protection in test environment 17 | config.action_controller.allow_forgery_protection = false 18 | 19 | # Tell ActionMailer not to deliver emails to the real world. 20 | # The :test delivery method accumulates sent emails in the 21 | # ActionMailer::Base.deliveries array. 22 | config.action_mailer.delivery_method = :test 23 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /config/pythonflow.yml: -------------------------------------------------------------------------------- 1 | app_name: pythonflow 2 | app_title: PythonFlow 3 | default_title: "PythonFlow : Python Community Link Blog" 4 | sub_title: "Community-maintained Python News and Links" 5 | app_url: http://www.pythonflow.com/ 6 | rss_url: http://feeds.feedburner.com/Pythonflow 7 | meta_keywords: "python, python news, python blog, django" 8 | meta_author: "Peter Cooper" 9 | body_class: pythonflow 10 | 11 | # Set this to true for a more fancy interface, but for the cost of page load time 12 | uses_javascript: false 13 | 14 | # Edit expiration default: 60 (this means that editing ends 60 minutes after last update of item) 15 | # Set to 0 or omit to always allow editing of items by its owner 16 | edit_expiration_in_minutes: 60 17 | 18 | ga: UA-2237791-8 19 | sidebar: |- 20 |PythonFlow is an experimental community driven Python links site. Items are not added automatically, but chosen and summarized by community members, resulting in a better quality and context than social bookmarking sites can offer.
21 |Enjoy the links, comment or make a post of your own. You don't need to be signed in!
22 |Note: If you're not signed in, your byline is unlinked and your links are made "nofollow" to prevent spam. You also get CAPTCHAed!
23 |Yes, this site is influenced by MetaFilter. Matt Haughey is one of my heroes.
-------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | ActionController::Routing::Routes.draw do |map| 2 | map.root :controller => 'items' 3 | 4 | map.resources :items, :collection => {:recently => :get} do |items| 5 | items.resources :comments 6 | items.add_star '/star/add', :controller => "stars", :action => "add" 7 | items.remove_star '/star/remove', :controller => "stars", :action => "remove" 8 | end 9 | 10 | map.resources :categories 11 | 12 | map.resources :users 13 | map.resource :session, :controller => 'session' 14 | 15 | 16 | map.signup '/signup', :controller => 'users', :action => 'new' 17 | map.login '/login', :controller => 'session', :action => 'new' 18 | map.logout '/logout', :controller => 'session', :action => 'destroy' 19 | 20 | map.tag '/tag/:id', :controller => 'items', :action => 'list_for_tags' 21 | map.tags '/tags/:id', :controller => 'items', :action => 'list_for_tags' 22 | map.tags_by_folders '/tags/*id', :controller => 'items', :action => 'list_for_tags' 23 | map.search '/search/:id', :controller => 'items', :action => 'search' 24 | map.category '/category/:id', :controller => 'items', :action => 'category' 25 | 26 | map.connect '/page/:page', :controller => 'items', :action => 'index' 27 | 28 | # Install the default routes as the lowest priority. 29 | map.connect ':controller/:action/:id' 30 | map.connect ':controller/:action/:id.:format' 31 | end 32 | -------------------------------------------------------------------------------- /config/rubyflow.yml: -------------------------------------------------------------------------------- 1 | app_name: rubyflow 2 | app_title: RubyFlow 3 | default_title: "RubyFlow : Community Filtered Ruby News" 4 | sub_title: "Community-maintained Ruby News" 5 | app_url: http://www.rubyflow.com/ 6 | rss_url: http://feeds.feedburner.com/Rubyflow 7 | meta_keywords: "ruby, ruby news, ruby blog, rails, rubyonrails" 8 | meta_author: "Peter Cooper" 9 | body_class: rubyflow 10 | 11 | # Set this to true for a more fancy interface, but for the cost of page load time 12 | uses_javascript: false 13 | 14 | # Edit expiration default: 60 (this means that editing ends 60 minutes after last update of item) 15 | # Set to 0 or omit to always allow editing of items by its owner 16 | edit_expiration_in_minutes: 60 17 | 18 | # ga: UA-2237791-7 19 | sidebar: |- 20 |RubyFlow is a community driven Ruby links site. Items are not added automatically, but chosen and summarized by the community, resulting in a higher quality of links than social bookmarking sites.
21 |There is a Japanese version of RubyFlow available, thanks to Makoto Kuwata!
22 |Enjoy the links, comment or make a post of your own. You don't need to be signed in!
23 |Note: If you're not signed in, your byline is unlinked and your links are made "nofollow" to prevent spam. You also get CAPTCHAed!
24 |RubyFlow was built by Peter Cooper of Ruby Inside, but is ultimately a community site.
25 |Yes, this site is influenced by MetaFilter. I wrote a popular MetaFilter clone back in the day so it's okay!
26 | -------------------------------------------------------------------------------- /db/migrate/001_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration 2 | def self.up 3 | create_table "users", :force => true do |t| 4 | t.column :login, :string 5 | t.column :email, :string 6 | t.column :fullname, :string 7 | t.column :url, :string 8 | t.column :crypted_password, :string, :limit => 40 9 | t.column :salt, :string, :limit => 40 10 | t.column :created_at, :datetime 11 | t.column :updated_at, :datetime 12 | t.column :remember_token, :string 13 | t.column :remember_token_expires_at, :datetime 14 | 15 | 16 | end 17 | end 18 | 19 | def self.down 20 | drop_table "users" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /db/migrate/002_add_admin_flag_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddAdminFlagToUsers < ActiveRecord::Migration 2 | def self.up 3 | add_column :users, :admin, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :users, :admin 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/003_add_open_id_authentication_tables.rb: -------------------------------------------------------------------------------- 1 | class AddOpenIdAuthenticationTables < ActiveRecord::Migration 2 | def self.up 3 | create_table "open_id_authentication_associations", :force => true do |t| 4 | t.column "server_url", :binary 5 | t.column "handle", :string 6 | t.column "secret", :binary 7 | t.column "issued", :integer 8 | t.column "lifetime", :integer 9 | t.column "assoc_type", :string 10 | end 11 | 12 | create_table "open_id_authentication_nonces", :force => true do |t| 13 | t.column "nonce", :string 14 | t.column "created", :integer 15 | end 16 | 17 | create_table "open_id_authentication_settings", :force => true do |t| 18 | t.column "setting", :string 19 | t.column "value", :binary 20 | end 21 | 22 | add_column :users, :identity_url, :string 23 | end 24 | 25 | def self.down 26 | remove_column :users, :identity_url 27 | drop_table "open_id_authentication_associations" 28 | drop_table "open_id_authentication_nonces" 29 | drop_table "open_id_authentication_settings" 30 | end 31 | end -------------------------------------------------------------------------------- /db/migrate/004_create_items.rb: -------------------------------------------------------------------------------- 1 | class CreateItems < ActiveRecord::Migration 2 | def self.up 3 | create_table :items do |t| 4 | t.string :title 5 | t.string :url 6 | t.text :content 7 | t.text :metadata 8 | t.string :name 9 | t.string :tags 10 | t.references :user 11 | 12 | t.timestamps 13 | end 14 | end 15 | 16 | def self.down 17 | drop_table :items 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /db/migrate/005_change_tags_to_text_on_items.rb: -------------------------------------------------------------------------------- 1 | class ChangeTagsToTextOnItems < ActiveRecord::Migration 2 | def self.up 3 | change_column :items, :tags, :text 4 | end 5 | 6 | def self.down 7 | change_column :items, :tags, :string 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/006_create_categories.rb: -------------------------------------------------------------------------------- 1 | class CreateCategories < ActiveRecord::Migration 2 | def self.up 3 | create_table :categories do |t| 4 | t.string :name 5 | t.string :title 6 | t.references :parent 7 | t.string :query 8 | 9 | t.timestamps 10 | end 11 | end 12 | 13 | def self.down 14 | drop_table :categories 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /db/migrate/007_create_comments.rb: -------------------------------------------------------------------------------- 1 | class CreateComments < ActiveRecord::Migration 2 | def self.up 3 | create_table :comments do |t| 4 | t.text :content 5 | t.string :byline 6 | t.references :user 7 | t.references :item 8 | 9 | t.timestamps 10 | end 11 | end 12 | 13 | def self.down 14 | drop_table :comments 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /db/migrate/008_add_byline_to_item.rb: -------------------------------------------------------------------------------- 1 | class AddBylineToItem < ActiveRecord::Migration 2 | def self.up 3 | add_column :items, :byline, :string 4 | end 5 | 6 | def self.down 7 | remove_column :items, :byline 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/009_add_comments_count_to_items.rb: -------------------------------------------------------------------------------- 1 | class AddCommentsCountToItems < ActiveRecord::Migration 2 | def self.up 3 | add_column :items, :comments_count, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :items, :comments_count 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/010_user_approved_for_feed.rb: -------------------------------------------------------------------------------- 1 | class UserApprovedForFeed < ActiveRecord::Migration 2 | def self.up 3 | add_column :users, :approved_for_feed, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :users, :approved_for_feed 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/011_create_stars.rb: -------------------------------------------------------------------------------- 1 | class CreateStars < ActiveRecord::Migration 2 | def self.up 3 | create_table :stars, :id => false do |t| 4 | t.integer :item_id 5 | t.integer :user_id 6 | end 7 | end 8 | 9 | def self.down 10 | drop_table :stars 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/012_add_counter_cache_for_stars.rb: -------------------------------------------------------------------------------- 1 | class AddCounterCacheForStars < ActiveRecord::Migration 2 | def self.up 3 | add_column :items, :stars_count, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :stars_count 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/013_add_id_to_stars.rb: -------------------------------------------------------------------------------- 1 | class AddIdToStars < ActiveRecord::Migration 2 | def self.up 3 | add_column :stars, :id, :integer, :primary_key => true 4 | end 5 | 6 | def self.down 7 | remove_column :stars, :id 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/014_recreate_stars_table.rb: -------------------------------------------------------------------------------- 1 | class RecreateStarsTable < ActiveRecord::Migration 2 | def self.up 3 | drop_table(:stars) 4 | create_table :stars do |t| 5 | t.integer :user_id 6 | t.integer :item_id 7 | end 8 | end 9 | 10 | def self.down 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/015_add_last_checked_at_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddLastCheckedAtToUser < ActiveRecord::Migration 2 | def self.up 3 | add_column :users, :last_checked_at, :datetime 4 | end 5 | 6 | def self.down 7 | remove_column :users, :last_checked_at 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead of editing this file, 2 | # please use the migrations feature of Active Record to incrementally modify your database, and 3 | # then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need 6 | # to create the application database on another system, you should be using db:schema:load, not running 7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations 8 | # you'll amass, the slower it'll run and the greater likelihood for issues). 9 | # 10 | # It's strongly recommended to check this file into your version control system. 11 | 12 | ActiveRecord::Schema.define(:version => 17) do 13 | 14 | create_table "categories", :force => true do |t| 15 | t.string "name" 16 | t.string "title" 17 | t.integer "parent_id" 18 | t.string "query" 19 | t.datetime "created_at" 20 | t.datetime "updated_at" 21 | end 22 | 23 | create_table "comments", :force => true do |t| 24 | t.text "content" 25 | t.string "byline" 26 | t.integer "user_id" 27 | t.integer "item_id" 28 | t.datetime "created_at" 29 | t.datetime "updated_at" 30 | end 31 | 32 | create_table "items", :force => true do |t| 33 | t.string "title" 34 | t.string "url" 35 | t.text "content" 36 | t.text "metadata" 37 | t.string "name" 38 | t.text "tags", :limit => 255 39 | t.integer "user_id" 40 | t.datetime "created_at" 41 | t.datetime "updated_at" 42 | t.string "byline" 43 | t.integer "comments_count", :default => 0 44 | t.integer "stars_count", :default => 0 45 | t.integer "spam_reports_count", :default => 0 46 | end 47 | 48 | create_table "open_id_authentication_associations", :force => true do |t| 49 | t.binary "server_url" 50 | t.string "handle" 51 | t.binary "secret" 52 | t.integer "issued" 53 | t.integer "lifetime" 54 | t.string "assoc_type" 55 | end 56 | 57 | create_table "open_id_authentication_nonces", :force => true do |t| 58 | t.string "nonce" 59 | t.integer "created" 60 | end 61 | 62 | create_table "open_id_authentication_settings", :force => true do |t| 63 | t.string "setting" 64 | t.binary "value" 65 | end 66 | 67 | create_table "spam_reports", :force => true do |t| 68 | t.integer "item_id" 69 | t.integer "user_id" 70 | t.datetime "created_at" 71 | t.datetime "updated_at" 72 | end 73 | 74 | create_table "stars", :force => true do |t| 75 | t.integer "user_id" 76 | t.integer "item_id" 77 | end 78 | 79 | create_table "users", :force => true do |t| 80 | t.string "login" 81 | t.string "email" 82 | t.string "fullname" 83 | t.string "url" 84 | t.string "crypted_password", :limit => 40 85 | t.string "salt", :limit => 40 86 | t.datetime "created_at" 87 | t.datetime "updated_at" 88 | t.string "remember_token" 89 | t.datetime "remember_token_expires_at" 90 | t.integer "admin", :default => 0 91 | t.string "identity_url" 92 | t.integer "approved_for_feed", :default => 0 93 | t.datetime "last_checked_at" 94 | end 95 | 96 | end 97 | -------------------------------------------------------------------------------- /lib/authenticated_test_helper.rb: -------------------------------------------------------------------------------- 1 | module AuthenticatedTestHelper 2 | # Sets the current user in the session from the user fixtures. 3 | def login_as(user) 4 | @request.session[:user_id] = user ? users(user).id : nil 5 | end 6 | 7 | def authorize_as(user) 8 | @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'test') : nil 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /log/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/log/.gitignore -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | # General Apache options 2 | AddHandler fastcgi-script .fcgi 3 | AddHandler cgi-script .cgi 4 | Options +FollowSymLinks +ExecCGI 5 | 6 | # If you don't want Rails to look in certain directories, 7 | # use the following rewrite rules so that Apache won't rewrite certain requests 8 | # 9 | # Example: 10 | # RewriteCond %{REQUEST_URI} ^/notrails.* 11 | # RewriteRule .* - [L] 12 | 13 | # Redirect all requests not available on the filesystem to Rails 14 | # By default the cgi dispatcher is used which is very slow 15 | # 16 | # For better performance replace the dispatcher with the fastcgi one 17 | # 18 | # Example: 19 | # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] 20 | RewriteEngine On 21 | 22 | # If your Rails application is accessed via an Alias directive, 23 | # then you MUST also set the RewriteBase in this htaccess file. 24 | # 25 | # Example: 26 | # Alias /myrailsapp /path/to/myrailsapp/public 27 | # RewriteBase /myrailsapp 28 | 29 | RewriteRule ^$ index.html [QSA] 30 | RewriteRule ^([^.]+)$ $1.html [QSA] 31 | RewriteCond %{REQUEST_FILENAME} !-f 32 | RewriteRule ^(.*)$ dispatch.cgi [QSA,L] 33 | 34 | # In case Rails experiences terminal errors 35 | # Instead of displaying this message you can supply a file here which will be rendered instead 36 | # 37 | # Example: 38 | # ErrorDocument 500 /500.html 39 | 40 | ErrorDocument 500 "You may have mistyped the address or the page may have moved.
28 |Maybe you tried to change something you didn't have access to.
28 |We've been notified about this issue and we'll take a look at it shortly.
28 |
3 | <%%= text_field_tag 'login' %>
6 | <%%= password_field_tag 'password' %>
<%%= submit_tag 'Log in' %>
14 | <%% end -%> 15 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/mailer.rb: -------------------------------------------------------------------------------- 1 | class <%= class_name %>Mailer < ActionMailer::Base 2 | def signup_notification(<%= file_name %>) 3 | setup_email(<%= file_name %>) 4 | @subject += 'Please activate your new account' 5 | <% if options[:include_activation] %> 6 | @body[:url] = "http://YOURSITE/activate/#{<%= file_name %>.activation_code}" 7 | <% else %> 8 | @body[:url] = "http://YOURSITE/login/" <% end %> 9 | end 10 | 11 | def activation(<%= file_name %>) 12 | setup_email(<%= file_name %>) 13 | @subject += 'Your account has been activated!' 14 | @body[:url] = "http://YOURSITE/" 15 | end 16 | 17 | protected 18 | def setup_email(<%= file_name %>) 19 | @recipients = "#{<%= file_name %>.email}" 20 | @from = "ADMINEMAIL" 21 | @subject = "[YOURSITE] " 22 | @sent_on = Time.now 23 | @body[:<%= file_name %>] = <%= file_name %> 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/mailer_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require '<%= file_name %>_mailer' 3 | 4 | class <%= class_name %>MailerTest < Test::Unit::TestCase 5 | FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures' 6 | CHARSET = "utf-8" 7 | 8 | include ActionMailer::Quoting 9 | 10 | def setup 11 | ActionMailer::Base.delivery_method = :test 12 | ActionMailer::Base.perform_deliveries = true 13 | ActionMailer::Base.deliveries = [] 14 | 15 | @expected = TMail::Mail.new 16 | @expected.set_content_type "text", "plain", { "charset" => CHARSET } 17 | end 18 | 19 | def test_dummy_test 20 | #do nothing 21 | end 22 | 23 | private 24 | def read_fixture(action) 25 | IO.readlines("#{FIXTURES_PATH}/<%= file_name %>_mailer/#{action}") 26 | end 27 | 28 | def encode(subject) 29 | quoted_printable(subject, CHARSET) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb: -------------------------------------------------------------------------------- 1 | class <%= migration_name %> < ActiveRecord::Migration 2 | def self.up 3 | create_table "<%= table_name %>", :force => true do |t| 4 | t.column :login, :string 5 | t.column :email, :string 6 | t.column :crypted_password, :string, :limit => 40 7 | t.column :salt, :string, :limit => 40 8 | t.column :created_at, :datetime 9 | t.column :updated_at, :datetime 10 | t.column :remember_token, :string 11 | t.column :remember_token_expires_at, :datetime 12 | <% if options[:include_activation] %>t.column :activation_code, :string, :limit => 40 13 | t.column :activated_at, :datetime<% end %> 14 | <% if options[:stateful] %>t.column :state, :string, :null => :no, :default => 'passive' 15 | t.column :deleted_at, :datetime<% end %> 16 | end 17 | end 18 | 19 | def self.down 20 | drop_table "<%= table_name %>" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb: -------------------------------------------------------------------------------- 1 | class <%= model_controller_class_name %>Controller < ApplicationController 2 | # Be sure to include AuthenticationSystem in Application Controller instead 3 | include AuthenticatedSystem 4 | <% if options[:stateful] %> 5 | # Protect these actions behind an admin login 6 | # before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge] 7 | before_filter :find_<%= file_name %>, :only => [:suspend, :unsuspend, :destroy, :purge] 8 | <% end %> 9 | 10 | # render new.rhtml 11 | def new 12 | end 13 | 14 | def create 15 | cookies.delete :auth_token 16 | # protects against session fixation attacks, wreaks havoc with 17 | # request forgery protection. 18 | # uncomment at your own risk 19 | # reset_session 20 | @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>]) 21 | @<%= file_name %>.<% if options[:stateful] %>register! if @<%= file_name %>.valid?<% else %>save<% end %> 22 | if @<%= file_name %>.errors.empty? 23 | self.current_<%= file_name %> = @<%= file_name %> 24 | redirect_back_or_default('/') 25 | flash[:notice] = "Thanks for signing up!" 26 | else 27 | render :action => 'new' 28 | end 29 | end 30 | <% if options[:include_activation] %> 31 | def activate 32 | self.current_<%= file_name %> = params[:activation_code].blank? ? :false : <%= class_name %>.find_by_activation_code(params[:activation_code]) 33 | if logged_in? && !current_<%= file_name %>.active? 34 | current_<%= file_name %>.activate<% if options[:stateful] %>!<% end %> 35 | flash[:notice] = "Signup complete!" 36 | end 37 | redirect_back_or_default('/') 38 | end 39 | <% end %><% if options[:stateful] %> 40 | def suspend 41 | @<%= file_name %>.suspend! 42 | redirect_to <%= table_name %>_path 43 | end 44 | 45 | def unsuspend 46 | @<%= file_name %>.unsuspend! 47 | redirect_to <%= table_name %>_path 48 | end 49 | 50 | def destroy 51 | @<%= file_name %>.delete! 52 | redirect_to <%= table_name %>_path 53 | end 54 | 55 | def purge 56 | @<%= file_name %>.destroy 57 | redirect_to <%= table_name %>_path 58 | end 59 | 60 | protected 61 | def find_<%= file_name %> 62 | @<%= file_name %> = <%= class_name %>.find(params[:id]) 63 | end 64 | <% end %> 65 | end 66 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_spec.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../spec_helper' 2 | 3 | # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead 4 | # Then, you can remove it from this and the units test. 5 | include AuthenticatedTestHelper 6 | 7 | describe <%= model_controller_class_name %>Controller do 8 | fixtures :<%= table_name %> 9 | 10 | it 'allows signup' do 11 | lambda do 12 | create_<%= file_name %> 13 | response.should be_redirect 14 | end.should change(<%= class_name %>, :count).by(1) 15 | end 16 | 17 | <% if options[:stateful] %> 18 | it 'signs up user in pending state' do 19 | create_user 20 | assigns(:user).should be_pending 21 | end<% end %> 22 | 23 | <% if options[:include_activation] %> 24 | it 'signs up user with activation code' do 25 | create_user 26 | assigns(:user).activation_code.should_not be_nil 27 | end<% end %> 28 | 29 | it 'requires login on signup' do 30 | lambda do 31 | create_<%= file_name %>(:login => nil) 32 | assigns[:<%= file_name %>].errors.on(:login).should_not be_nil 33 | response.should be_success 34 | end.should_not change(<%= class_name %>, :count) 35 | end 36 | 37 | it 'requires password on signup' do 38 | lambda do 39 | create_<%= file_name %>(:password => nil) 40 | assigns[:<%= file_name %>].errors.on(:password).should_not be_nil 41 | response.should be_success 42 | end.should_not change(<%= class_name %>, :count) 43 | end 44 | 45 | it 'requires password confirmation on signup' do 46 | lambda do 47 | create_<%= file_name %>(:password_confirmation => nil) 48 | assigns[:<%= file_name %>].errors.on(:password_confirmation).should_not be_nil 49 | response.should be_success 50 | end.should_not change(<%= class_name %>, :count) 51 | end 52 | 53 | it 'requires email on signup' do 54 | lambda do 55 | create_<%= file_name %>(:email => nil) 56 | assigns[:<%= file_name %>].errors.on(:email).should_not be_nil 57 | response.should be_success 58 | end.should_not change(<%= class_name %>, :count) 59 | end 60 | 61 | <% if options[:include_activation] %> 62 | it 'activates user' do 63 | <%= class_name %>.authenticate('aaron', 'test').should be_nil 64 | get :activate, :activation_code => <%= table_name %>(:aaron).activation_code 65 | response.should redirect_to('/') 66 | flash[:notice].should_not be_nil 67 | <%= class_name %>.authenticate('aaron', 'test').should == <%= table_name %>(:aaron) 68 | end 69 | 70 | it 'does not activate user without key' do 71 | get :activate 72 | flash[:notice].should be_nil 73 | end 74 | 75 | it 'does not activate user with blank key' do 76 | get :activate, :activation_code => '' 77 | flash[:notice].should be_nil 78 | end<% end %> 79 | 80 | def create_<%= file_name %>(options = {}) 81 | post :create, :<%= file_name %> => { :login => 'quire', :email => 'quire@example.com', 82 | :password => 'quire', :password_confirmation => 'quire' }.merge(options) 83 | end 84 | end -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require '<%= model_controller_file_name %>_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class <%= model_controller_class_name %>Controller; def rescue_action(e) raise e end; end 6 | 7 | class <%= model_controller_class_name %>ControllerTest < Test::Unit::TestCase 8 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead 9 | # Then, you can remove it from this and the units test. 10 | include AuthenticatedTestHelper 11 | 12 | fixtures :<%= table_name %> 13 | 14 | def setup 15 | @controller = <%= model_controller_class_name %>Controller.new 16 | @request = ActionController::TestRequest.new 17 | @response = ActionController::TestResponse.new 18 | end 19 | 20 | def test_should_allow_signup 21 | assert_difference '<%= class_name %>.count' do 22 | create_<%= file_name %> 23 | assert_response :redirect 24 | end 25 | end 26 | 27 | def test_should_require_login_on_signup 28 | assert_no_difference '<%= class_name %>.count' do 29 | create_<%= file_name %>(:login => nil) 30 | assert assigns(:<%= file_name %>).errors.on(:login) 31 | assert_response :success 32 | end 33 | end 34 | 35 | def test_should_require_password_on_signup 36 | assert_no_difference '<%= class_name %>.count' do 37 | create_<%= file_name %>(:password => nil) 38 | assert assigns(:<%= file_name %>).errors.on(:password) 39 | assert_response :success 40 | end 41 | end 42 | 43 | def test_should_require_password_confirmation_on_signup 44 | assert_no_difference '<%= class_name %>.count' do 45 | create_<%= file_name %>(:password_confirmation => nil) 46 | assert assigns(:<%= file_name %>).errors.on(:password_confirmation) 47 | assert_response :success 48 | end 49 | end 50 | 51 | def test_should_require_email_on_signup 52 | assert_no_difference '<%= class_name %>.count' do 53 | create_<%= file_name %>(:email => nil) 54 | assert assigns(:<%= file_name %>).errors.on(:email) 55 | assert_response :success 56 | end 57 | end 58 | <% if options[:include_activation] %> 59 | def test_should_activate_user 60 | assert_nil <%= class_name %>.authenticate('aaron', 'test') 61 | get :activate, :activation_code => <%= table_name %>(:aaron).activation_code 62 | assert_redirected_to '/' 63 | assert_not_nil flash[:notice] 64 | assert_equal <%= table_name %>(:aaron), <%= class_name %>.authenticate('aaron', 'test') 65 | end 66 | 67 | def test_should_not_activate_user_without_key 68 | get :activate 69 | assert_nil flash[:notice] 70 | rescue ActionController::RoutingError 71 | # in the event your routes deny this, we'll just bow out gracefully. 72 | end 73 | 74 | def test_should_not_activate_user_with_blank_key 75 | get :activate, :activation_code => '' 76 | assert_nil flash[:notice] 77 | rescue ActionController::RoutingError 78 | # well played, sir 79 | end<% end %> 80 | 81 | protected 82 | def create_<%= file_name %>(options = {}) 83 | post :create, :<%= file_name %> => { :login => 'quire', :email => 'quire@example.com', 84 | :password => 'quire', :password_confirmation => 'quire' }.merge(options) 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb: -------------------------------------------------------------------------------- 1 | module <%= model_controller_class_name %>Helper 2 | end -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb: -------------------------------------------------------------------------------- 1 | class <%= class_name %>Observer < ActiveRecord::Observer 2 | def after_create(<%= file_name %>) 3 | <%= class_name %>Mailer.deliver_signup_notification(<%= file_name %>) 4 | end 5 | 6 | def after_save(<%= file_name %>) 7 | <% if options[:include_activation] %> 8 | <%= class_name %>Mailer.deliver_activation(<%= file_name %>) if <%= file_name %>.pending? 9 | <% end %> 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb: -------------------------------------------------------------------------------- 1 | <%%= error_messages_for :<%= file_name %> %> 2 | <%% form_for :<%= file_name %>, :url => <%= table_name %>_path do |f| -%> 3 |
4 | <%%= f.text_field :login %>
7 | <%%= f.text_field :email %>
10 | <%%= f.password_field :password %>
13 | <%%= f.password_field :password_confirmation %>
<%%= submit_tag 'Sign up' %>
16 | <%% end -%> 17 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.html.erb: -------------------------------------------------------------------------------- 1 | Your account has been created. 2 | 3 | Username: <%%= @<%= file_name %>.login %> 4 | Password: <%%= @<%= file_name %>.password %> 5 | 6 | Visit this url to activate your account: 7 | 8 | <%%= @url %> -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/install.rb: -------------------------------------------------------------------------------- 1 | puts IO.read(File.join(File.dirname(__FILE__), 'README')) -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/lib/restful_authentication/rails_commands.rb: -------------------------------------------------------------------------------- 1 | Rails::Generator::Commands::Create.class_eval do 2 | def route_resource(*resources) 3 | resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 4 | sentinel = 'ActionController::Routing::Routes.draw do |map|' 5 | 6 | logger.route "map.resource #{resource_list}" 7 | unless options[:pretend] 8 | gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| 9 | "#{match}\n map.resource #{resource_list}\n" 10 | end 11 | end 12 | end 13 | end 14 | 15 | Rails::Generator::Commands::Destroy.class_eval do 16 | def route_resource(*resources) 17 | resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 18 | look_for = "\n map.resource #{resource_list}\n" 19 | logger.route "map.resource #{resource_list}" 20 | gsub_file 'config/routes.rb', /(#{look_for})/mi, '' 21 | end 22 | end 23 | 24 | Rails::Generator::Commands::List.class_eval do 25 | def route_resource(*resources) 26 | resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 27 | logger.route "map.resource #{resource_list}" 28 | end 29 | end -------------------------------------------------------------------------------- /vendor/plugins/shoulda/.autotest: -------------------------------------------------------------------------------- 1 | Autotest.add_hook :initialize do |at| 2 | at.add_mapping(%r{^lib/\w.*\.rb}) do 3 | at.files_matching(%r{^test/*/\w.*_test\.rb}) 4 | end 5 | 6 | at.add_mapping(%r{^test/rails_root/\w.*}) do 7 | at.files_matching(%r{^test/*/\w.*_test\.rb}) 8 | end 9 | 10 | at.add_exception(%r{.svn}) 11 | at.add_exception(%r{.log$}) 12 | at.add_exception(%r{^.autotest$}) 13 | end 14 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/.gitignore: -------------------------------------------------------------------------------- 1 | test/rails_root/log/*.log 2 | doc 3 | coverage 4 | .svn/ 5 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/CONTRIBUTION_GUIDELINES.rdoc: -------------------------------------------------------------------------------- 1 | We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master] and Lighthouse[http://thoughtbot.lighthouseapp.com/projects/5807], and we've been getting any combination of github pull requests, Lighthouse tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes. 2 | 3 | * Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master]. 4 | * We prefer git branches over patches, but we can take either. 5 | * If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier. 6 | * If you're submitting patches, please cut each fix or feature into a separate patch. 7 | * There should be a Lighthouse[http://thoughtbot.lighthouseapp.com/projects/5807] ticket for any submission. If you've found a bug and want to fix it, open a new ticket at the same time. 8 | * We've got github/lighthouse integration going, so you can update tickets when you commit. {This blog post}[http://hoth.entp.com/2008/4/11/github-and-lighthouse-sitting-in-a-tree] explains the commit options pretty well. 9 | * Please don't send pull requests Just update the lighthouse ticket with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox. 10 | * Contributions without tests won't be accepted. The file /test/README explains the testing system pretty thoroughly. 11 | 12 | 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/rdoctask' 4 | 5 | # Test::Unit::UI::VERBOSE 6 | test_files_pattern = 'test/{unit,functional,other}/**/*_test.rb' 7 | Rake::TestTask.new do |t| 8 | t.libs << 'lib' 9 | t.pattern = test_files_pattern 10 | t.verbose = false 11 | end 12 | 13 | Rake::RDocTask.new { |rdoc| 14 | rdoc.rdoc_dir = 'doc' 15 | rdoc.title = "Shoulda -- Making tests easy on the fingers and eyes" 16 | rdoc.options << '--line-numbers' << '--inline-source' 17 | rdoc.template = "#{ENV['template']}.rb" if ENV['template'] 18 | rdoc.rdoc_files.include('README.rdoc', 'CONTRIBUTION_GUIDELINES.rdoc', 'lib/**/*.rb') 19 | } 20 | 21 | desc "Run code-coverage analysis using rcov" 22 | task :coverage do 23 | rm_rf "coverage" 24 | files = Dir[test_files_pattern] 25 | system "rcov --rails --sort coverage -Ilib #{files.join(' ')}" 26 | end 27 | 28 | desc 'Update documentation on website' 29 | task :sync_docs => 'rdoc' do 30 | `rsync -ave ssh doc/ dev@dev.thoughtbot.com:/home/dev/www/dev.thoughtbot.com/shoulda` 31 | end 32 | 33 | desc 'Default: run tests.' 34 | task :default => ['test'] 35 | 36 | Dir['tasks/*.rake'].each do |f| 37 | load f 38 | end 39 | 40 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/bin/convert_to_should_syntax: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | require 'tmpdir' 4 | 5 | TMP = Dir::tmpdir 6 | 7 | def usage(msg = nil) 8 | puts "Error: #{msg}" if msg 9 | puts if msg 10 | puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb" 11 | puts 12 | puts "Will convert an existing test file with names like " 13 | puts 14 | puts " def test_should_do_stuff" 15 | puts " ..." 16 | puts " end" 17 | puts 18 | puts "to one using the new syntax: " 19 | puts 20 | puts " should \"be super cool\" do" 21 | puts " ..." 22 | puts " end" 23 | puts 24 | puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up" 25 | puts 26 | exit (msg ? 2 : 0) 27 | end 28 | 29 | usage("Wrong number of arguments.") unless ARGV.size == 1 30 | usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP) 31 | 32 | file = ARGV.shift 33 | tmpfile = File.join(TMP, File.basename(file)) 34 | usage("File '#{file}' doesn't exist") unless File.exists?(file) 35 | 36 | FileUtils.cp(file, tmpfile) 37 | contents = File.read(tmpfile) 38 | contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"} 39 | contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"} 40 | File.open(file, 'w') { |f| f.write(contents) } 41 | 42 | puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'" 43 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/init.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'active_support' 3 | require 'shoulda' 4 | 5 | if defined?(RAILS_ROOT) 6 | # load in the 3rd party macros from vendorized plugins and gems 7 | Dir[File.join(RAILS_ROOT, "vendor", "{plugin,gem}", "*", "shoulda_macros", "*.rb")].each do |macro_file_path| 8 | require macro_file_path 9 | end 10 | 11 | # load in the local application specific macros 12 | Dir[File.join(RAILS_ROOT, "test", "shoulda_macros", "*.rb")].each do |macro_file_path| 13 | require macro_file_path 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda.rb: -------------------------------------------------------------------------------- 1 | require 'shoulda/gem/shoulda' 2 | require 'shoulda/private_helpers' 3 | require 'shoulda/general' 4 | require 'shoulda/active_record_helpers' 5 | require 'shoulda/controller_tests/controller_tests.rb' 6 | require 'yaml' 7 | 8 | shoulda_options = {} 9 | 10 | possible_config_paths = [] 11 | possible_config_paths << File.join(ENV["HOME"], ".shoulda.conf") if ENV["HOME"] 12 | possible_config_paths << "shoulda.conf" 13 | possible_config_paths << File.join("test", "shoulda.conf") 14 | possible_config_paths << File.join(RAILS_ROOT, "test", "shoulda.conf") if defined?(RAILS_ROOT) 15 | 16 | possible_config_paths.each do |config_file| 17 | if File.exists? config_file 18 | shoulda_options = YAML.load_file(config_file).symbolize_keys 19 | break 20 | end 21 | end 22 | 23 | require 'shoulda/color' if shoulda_options[:color] 24 | 25 | module Test # :nodoc: all 26 | module Unit 27 | class TestCase 28 | 29 | include ThoughtBot::Shoulda::General 30 | include ThoughtBot::Shoulda::Controller 31 | 32 | extend ThoughtBot::Shoulda::ActiveRecord 33 | end 34 | end 35 | end 36 | 37 | module ActionController #:nodoc: all 38 | module Integration 39 | class Session 40 | include ThoughtBot::Shoulda::General 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda/color.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit/ui/console/testrunner' 2 | 3 | # Completely stolen from redgreen gem 4 | # 5 | # Adds colored output to your tests. Specify color: true in 6 | # your ~/.shoulda.conf file to enable. 7 | # 8 | # *Bug*: for some reason, this adds another line of output to the end of 9 | # every rake task, as though there was another (empty) set of tests. 10 | # A fix would be most welcome. 11 | # 12 | module ThoughtBot::Shoulda::Color 13 | COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 } # :nodoc: 14 | def self.method_missing(color_name, *args) # :nodoc: 15 | color(color_name) + args.first + color(:clear) 16 | end 17 | def self.color(color) # :nodoc: 18 | "\e[#{COLORS[color.to_sym]}m" 19 | end 20 | end 21 | 22 | module Test # :nodoc: 23 | module Unit # :nodoc: 24 | class TestResult # :nodoc: 25 | alias :old_to_s :to_s 26 | def to_s 27 | if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/ 28 | ThoughtBot::Shoulda::Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&) 29 | end 30 | end 31 | end 32 | 33 | class AutoRunner # :nodoc: 34 | alias :old_initialize :initialize 35 | def initialize(standalone) 36 | old_initialize(standalone) 37 | @runner = proc do |r| 38 | Test::Unit::UI::Console::RedGreenTestRunner 39 | end 40 | end 41 | end 42 | 43 | class Failure # :nodoc: 44 | alias :old_long_display :long_display 45 | def long_display 46 | # old_long_display.sub('Failure', ThoughtBot::Shoulda::Color.red('Failure')) 47 | ThoughtBot::Shoulda::Color.red(old_long_display) 48 | end 49 | end 50 | 51 | class Error # :nodoc: 52 | alias :old_long_display :long_display 53 | def long_display 54 | # old_long_display.sub('Error', ThoughtBot::Shoulda::Color.yellow('Error')) 55 | ThoughtBot::Shoulda::Color.yellow(old_long_display) 56 | end 57 | end 58 | 59 | module UI # :nodoc: 60 | module Console # :nodoc: 61 | class RedGreenTestRunner < Test::Unit::UI::Console::TestRunner # :nodoc: 62 | def output_single(something, level=NORMAL) 63 | return unless (output?(level)) 64 | something = case something 65 | when '.' then ThoughtBot::Shoulda::Color.green('.') 66 | when 'F' then ThoughtBot::Shoulda::Color.red("F") 67 | when 'E' then ThoughtBot::Shoulda::Color.yellow("E") 68 | else something 69 | end 70 | @io.write(something) 71 | @io.flush 72 | end 73 | end 74 | end 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda/gem/proc_extensions.rb: -------------------------------------------------------------------------------- 1 | # Stolen straight from ActiveSupport 2 | 3 | class Proc #:nodoc: 4 | def bind(object) 5 | block, time = self, Time.now 6 | (class << object; self end).class_eval do 7 | method_name = "__bind_#{time.to_i}_#{time.usec}" 8 | define_method(method_name, &block) 9 | method = instance_method(method_name) 10 | remove_method(method_name) 11 | method 12 | end.bind(object) 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda/private_helpers.rb: -------------------------------------------------------------------------------- 1 | module ThoughtBot # :nodoc: 2 | module Shoulda # :nodoc: 3 | module Private # :nodoc: 4 | # Returns the values for the entries in the args hash who's keys are listed in the wanted array. 5 | # Will raise if there are keys in the args hash that aren't listed. 6 | def get_options!(args, *wanted) 7 | ret = [] 8 | opts = (args.last.is_a?(Hash) ? args.pop : {}) 9 | wanted.each {|w| ret << opts.delete(w)} 10 | raise ArgumentError, "Unsupported options given: #{opts.keys.join(', ')}" unless opts.keys.empty? 11 | return *ret 12 | end 13 | 14 | # Returns the model class constant, as determined by the test class name. 15 | # 16 | # class TestUser; model_class; end => User 17 | def model_class 18 | self.name.gsub(/Test$/, '').constantize 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/tasks/list_tests.rake: -------------------------------------------------------------------------------- 1 | namespace :shoulda do 2 | desc "List the names of the test methods in a specification like format" 3 | task :list do 4 | 5 | require 'test/unit' 6 | require 'rubygems' 7 | require 'active_support' 8 | 9 | # bug in test unit. Set to true to stop from running. 10 | Test::Unit.run = true 11 | 12 | test_files = Dir.glob(File.join('test', '**', '*_test.rb')) 13 | test_files.each do |file| 14 | load file 15 | klass = File.basename(file, '.rb').classify.constantize 16 | 17 | puts klass.name.gsub('Test', '') 18 | 19 | test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort 20 | test_methods.each {|m| puts " " + m } 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/tasks/yaml_to_shoulda.rake: -------------------------------------------------------------------------------- 1 | namespace :shoulda do 2 | # From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task 3 | # David.Lowenfels@gmail.com 4 | desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton" 5 | task :from_yaml do 6 | require 'yaml' 7 | 8 | def yaml_to_context(hash, indent = 0) 9 | indent1 = ' ' * indent 10 | indent2 = ' ' * (indent + 1) 11 | hash.each_pair do |context, shoulds| 12 | puts indent1 + "context \"#{context}\" do" 13 | puts 14 | shoulds.each do |should| 15 | yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash ) 16 | puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do" 17 | puts indent2 + "end" 18 | puts 19 | end 20 | puts indent1 + "end" 21 | end 22 | end 23 | 24 | puts("Please pass in a FILE argument.") and exit unless ENV['FILE'] 25 | 26 | yaml_to_context( YAML.load_file( ENV['FILE'] ) ) 27 | end 28 | end -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/README: -------------------------------------------------------------------------------- 1 | The Shoulda test suite (in particular - the tests that test shoulda) 2 | 3 | Quick overview: 4 | 5 | The test directory contains the following files and subdirectories: 6 | 7 | * rails_root - contains the stripped down rails application that the tests run against. The rails root contains: 8 | ** the models, controllers, and views defined under app/ 9 | ** the sqlite3.rb environment file 10 | ** a migration file for each model 11 | ** a shoulda initializer that simulates loading the plugin but without relying on vendor/plugins 12 | * fixtures - contain the sample DB data for each model 13 | * functional - controller tests for each of the controllers under rails_root/app 14 | * unit - model tests for each of the models under rails_root/app 15 | * other - tests for the shoulda contexts, should statements, and assertions 16 | * test_helper.rb - responsible for initializing the test environment 17 | ** sets the rails_env to sqlite3 18 | ** sets the rails_root 19 | ** runs all the migrations against the in-memory sqlite3 db 20 | ** adds some magic to load the right fixture files 21 | 22 | In order to add a new model (or controller) to the test suite: 23 | 24 | * add that model to rails_root/app/models 25 | * add a migration for that model 26 | * add a fixture file 27 | * add a test for that file under test/units 28 | 29 | Dependencies: 30 | 31 | * Rails gem installed in the host system 32 | * A working sqlite3 installation. 33 | 34 | If you have problems running these tests, please notify the mailing list: shoulda@googlegroups.com 35 | 36 | - Tammer Saleh<%= flash[:notice] %>
13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/layouts/users.rhtml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |<%= flash[:notice] %>
13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/edit.rhtml: -------------------------------------------------------------------------------- 1 |
7 | User
8 | <%= f.text_field :user_id %>
9 |
12 | Title
13 | <%= f.text_field :title %>
14 |
17 | Body
18 | <%= f.text_area :body %>
19 |
22 | <%= submit_tag "Update" %> 23 |
24 | <% end %> 25 | 26 | <%= link_to 'Show', user_post_path(@post.user, @post) %> | 27 | <%= link_to 'Back', user_posts_path(@post.user) %> 28 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/index.rhtml: -------------------------------------------------------------------------------- 1 |User | 6 |Title | 7 |Body | 8 ||||
---|---|---|---|---|---|
<%=h post.user_id %> | 13 |<%=h post.title %> | 14 |<%=h post.body %> | 15 |<%= link_to 'Show', user_post_path(post.user, post) %> | 16 |<%= link_to 'Edit', edit_user_post_path(post.user, post) %> | 17 |<%= link_to 'Destroy', user_post_path(post.user, post), :confirm => 'Are you sure?', 18 | :method => :delete %> | 19 |
7 | User
8 | <%= f.text_field :user_id %>
9 |
12 | Title
13 | <%= f.text_field :title %>
14 |
17 | Body
18 | <%= f.text_area :body %>
19 |
22 | <%= submit_tag "Create" %> 23 |
24 | <% end %> 25 | 26 | <%= link_to 'Back', user_posts_path(@user) %> 27 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/show.rhtml: -------------------------------------------------------------------------------- 1 |2 | User: 3 | <%=h @post.user_id %> 4 |
5 | 6 |7 | Title: 8 | <%=h @post.title %> 9 |
10 | 11 |12 | Body: 13 | <%=h @post.body %> 14 |
15 | 16 | 17 | <%= link_to 'Edit', edit_user_post_path(@post.user, @post) %> | 18 | <%= link_to 'Back', user_posts_path(@post.user) %> 19 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/edit.rhtml: -------------------------------------------------------------------------------- 1 |
7 | Email
8 | <%= f.text_field :email %>
9 |
12 | Age
13 | <%= f.text_field :age %>
14 |
17 | <%= submit_tag "Update" %> 18 |
19 | <% end %> 20 | 21 | <%= link_to 'Show', user_path(@user) %> | 22 | <%= link_to 'Back', users_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/index.rhtml: -------------------------------------------------------------------------------- 1 |Age | 7 |||||
---|---|---|---|---|
<%=h user.email %> | 12 |<%=h user.age %> | 13 |<%= link_to 'Show', user_path(user) %> | 14 |<%= link_to 'Edit', edit_user_path(user) %> | 15 |<%= link_to 'Destroy', user_path(user), :confirm => 'Are you sure?', :method => :delete %> | 16 |
7 | Email
8 | <%= f.text_field :email %>
9 |
12 | Age
13 | <%= f.text_field :age %>
14 |
17 | <%= submit_tag "Create" %> 18 |
19 | <% end %> 20 | 21 | <%= link_to 'Back', users_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/show.rhtml: -------------------------------------------------------------------------------- 1 |2 | Email: 3 | <%=h @user.email %> 4 |
5 | 6 |7 | Age: 8 | <%=h @user.age %> 9 |
10 | 11 | 12 | <%= link_to 'Edit', edit_user_path(@user) %> | 13 | <%= link_to 'Back', users_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Don't change this file! 2 | # Configure your app in config/environment.rb and config/environments/*.rb 3 | 4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 5 | 6 | module Rails 7 | class << self 8 | def boot! 9 | unless booted? 10 | preinitialize 11 | pick_boot.run 12 | end 13 | end 14 | 15 | def booted? 16 | defined? Rails::Initializer 17 | end 18 | 19 | def pick_boot 20 | (vendor_rails? ? VendorBoot : GemBoot).new 21 | end 22 | 23 | def vendor_rails? 24 | File.exist?("#{RAILS_ROOT}/vendor/rails") 25 | end 26 | 27 | def preinitialize 28 | load(preinitializer_path) if File.exist?(preinitializer_path) 29 | end 30 | 31 | def preinitializer_path 32 | "#{RAILS_ROOT}/config/preinitializer.rb" 33 | end 34 | end 35 | 36 | class Boot 37 | def run 38 | load_initializer 39 | Rails::Initializer.run(:set_load_path) 40 | end 41 | end 42 | 43 | class VendorBoot < Boot 44 | def load_initializer 45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 46 | Rails::Initializer.run(:install_gem_spec_stubs) 47 | end 48 | end 49 | 50 | class GemBoot < Boot 51 | def load_initializer 52 | self.class.load_rubygems 53 | load_rails_gem 54 | require 'initializer' 55 | end 56 | 57 | def load_rails_gem 58 | if version = self.class.gem_version 59 | gem 'rails', version 60 | else 61 | gem 'rails' 62 | end 63 | rescue Gem::LoadError => load_error 64 | $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.) 65 | exit 1 66 | end 67 | 68 | class << self 69 | def rubygems_version 70 | Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion 71 | end 72 | 73 | def gem_version 74 | if defined? RAILS_GEM_VERSION 75 | RAILS_GEM_VERSION 76 | elsif ENV.include?('RAILS_GEM_VERSION') 77 | ENV['RAILS_GEM_VERSION'] 78 | else 79 | parse_gem_version(read_environment_rb) 80 | end 81 | end 82 | 83 | def load_rubygems 84 | require 'rubygems' 85 | 86 | unless rubygems_version >= '0.9.4' 87 | $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) 88 | exit 1 89 | end 90 | 91 | rescue LoadError 92 | $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) 93 | exit 1 94 | end 95 | 96 | def parse_gem_version(text) 97 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ 98 | end 99 | 100 | private 101 | def read_environment_rb 102 | File.read("#{RAILS_ROOT}/config/environment.rb") 103 | end 104 | end 105 | end 106 | end 107 | 108 | # All that for this: 109 | Rails.boot! 110 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/database.yml: -------------------------------------------------------------------------------- 1 | sqlite3: 2 | :adapter: sqlite3 3 | # :dbfile: db/sqlite3.db 4 | :dbfile: ":memory:" 5 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Specifies gem version of Rails to use when vendor/rails is not present 2 | old_verbose, $VERBOSE = $VERBOSE, nil 3 | RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION 4 | $VERBOSE = old_verbose 5 | 6 | require File.join(File.dirname(__FILE__), 'boot') 7 | 8 | Rails::Initializer.run do |config| 9 | config.log_level = :debug 10 | config.cache_classes = false 11 | config.whiny_nils = true 12 | end 13 | 14 | # Dependencies.log_activity = true 15 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/environments/sqlite3.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/config/environments/sqlite3.rb -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/initializers/new_rails_defaults.rb: -------------------------------------------------------------------------------- 1 | # These settings change the behavior of Rails 2 apps and will be defaults 2 | # for Rails 3. You can remove this initializer when Rails 3 is released. 3 | 4 | # Include Active Record class name as root for JSON serialized output. 5 | ActiveRecord::Base.include_root_in_json = true 6 | 7 | # Store the full class name (including module namespace) in STI type column. 8 | ActiveRecord::Base.store_full_sti_class = true 9 | 10 | # Use ISO 8601 format for JSON serialized times and dates. 11 | ActiveSupport.use_standard_json_time_format = true 12 | 13 | # Don't escape HTML entities in JSON, leave that for the #json_escape helper. 14 | # if you're including raw json in an HTML page. 15 | ActiveSupport.escape_html_entities_in_json = false -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/initializers/shoulda.rb: -------------------------------------------------------------------------------- 1 | # This simulates loading the shoulda plugin, but without relying on 2 | # vendor/plugins 3 | 4 | shoulda_path = File.join(File.dirname(__FILE__), *%w(.. .. .. ..)) 5 | shoulda_lib_path = File.join(shoulda_path, "lib") 6 | 7 | $LOAD_PATH.unshift(shoulda_lib_path) 8 | load File.join(shoulda_path, "init.rb") 9 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/routes.rb: -------------------------------------------------------------------------------- 1 | ActionController::Routing::Routes.draw do |map| 2 | 3 | map.resources :posts 4 | map.resources :users, :has_many => :posts 5 | 6 | end 7 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/001_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration 2 | def self.up 3 | create_table :users do |t| 4 | t.column :name, :string 5 | t.column :email, :string 6 | t.column :age, :integer 7 | t.column :ssn, :string 8 | end 9 | add_index :users, :email 10 | add_index :users, :name 11 | add_index :users, :age 12 | add_index :users, [:email, :name] 13 | end 14 | 15 | def self.down 16 | drop_table :users 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/002_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration 2 | def self.up 3 | create_table :posts do |t| 4 | t.column :user_id, :integer 5 | t.column :title, :string 6 | t.column :body, :text 7 | end 8 | end 9 | 10 | def self.down 11 | drop_table :posts 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/003_create_taggings.rb: -------------------------------------------------------------------------------- 1 | class CreateTaggings < ActiveRecord::Migration 2 | def self.up 3 | create_table :taggings do |t| 4 | t.column :post_id, :integer 5 | t.column :tag_id, :integer 6 | end 7 | end 8 | 9 | def self.down 10 | drop_table :taggings 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/004_create_tags.rb: -------------------------------------------------------------------------------- 1 | class CreateTags < ActiveRecord::Migration 2 | def self.up 3 | create_table :tags do |t| 4 | t.column :name, :string 5 | end 6 | end 7 | 8 | def self.down 9 | drop_table :tags 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/005_create_dogs.rb: -------------------------------------------------------------------------------- 1 | class CreateDogs < ActiveRecord::Migration 2 | def self.up 3 | create_table :dogs do |t| 4 | t.column :owner_id, :integer 5 | end 6 | end 7 | 8 | def self.down 9 | drop_table :dogs 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/006_create_addresses.rb: -------------------------------------------------------------------------------- 1 | class CreateAddresses < ActiveRecord::Migration 2 | def self.up 3 | create_table :addresses do |t| 4 | t.column :title, :string 5 | t.column :addressable_id, :integer 6 | t.column :addressable_type, :string 7 | t.column :zip, :string 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :addresses 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/007_create_fleas.rb: -------------------------------------------------------------------------------- 1 | class CreateFleas < ActiveRecord::Migration 2 | def self.up 3 | create_table :fleas do |t| 4 | t.string :name 5 | end 6 | end 7 | 8 | def self.down 9 | drop_table :fleas 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/008_create_dogs_fleas.rb: -------------------------------------------------------------------------------- 1 | class CreateDogsFleas < ActiveRecord::Migration 2 | def self.up 3 | create_table :dogs_fleas do |t| 4 | t.integer :dog_id 5 | t.integer :flea_id 6 | end 7 | end 8 | 9 | def self.down 10 | drop_table :dogs_fleas 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/009_create_products.rb: -------------------------------------------------------------------------------- 1 | class CreateProducts < ActiveRecord::Migration 2 | def self.up 3 | create_table :products do |t| 4 | t.string :title 5 | t.integer :price 6 | t.integer :weight 7 | t.string :size 8 | t.boolean :tangible 9 | 10 | t.timestamps 11 | end 12 | end 13 | 14 | def self.down 15 | drop_table :products 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/schema.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/db/schema.rb -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/log/.keep -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/public/.htaccess: -------------------------------------------------------------------------------- 1 | # General Apache options 2 | AddHandler fastcgi-script .fcgi 3 | AddHandler cgi-script .cgi 4 | Options +FollowSymLinks +ExecCGI 5 | 6 | # If you don't want Rails to look in certain directories, 7 | # use the following rewrite rules so that Apache won't rewrite certain requests 8 | # 9 | # Example: 10 | # RewriteCond %{REQUEST_URI} ^/notrails.* 11 | # RewriteRule .* - [L] 12 | 13 | # Redirect all requests not available on the filesystem to Rails 14 | # By default the cgi dispatcher is used which is very slow 15 | # 16 | # For better performance replace the dispatcher with the fastcgi one 17 | # 18 | # Example: 19 | # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] 20 | RewriteEngine On 21 | 22 | # If your Rails application is accessed via an Alias directive, 23 | # then you MUST also set the RewriteBase in this htaccess file. 24 | # 25 | # Example: 26 | # Alias /myrailsapp /path/to/myrailsapp/public 27 | # RewriteBase /myrailsapp 28 | 29 | RewriteRule ^$ index.html [QSA] 30 | RewriteRule ^([^.]+)$ $1.html [QSA] 31 | RewriteCond %{REQUEST_FILENAME} !-f 32 | RewriteRule ^(.*)$ dispatch.cgi [QSA,L] 33 | 34 | # In case Rails experiences terminal errors 35 | # Instead of displaying this message you can supply a file here which will be rendered instead 36 | # 37 | # Example: 38 | # ErrorDocument 500 /500.html 39 | 40 | ErrorDocument 500 "You may have mistyped the address or the page may have moved.
28 |Maybe you tried to change something you didn't have access to.
28 |We've been notified about this issue and we'll take a look at it shortly.
28 |
Starred by:
7 |<%= @item.stars.map { |star| link_to star.user.login, star.user.url }.to_sentence -%>
8 | <% end %> 9 | 10 |<%= pluralize @item.comments.count, 'comment' %>
11 | <% @item.comments.each do |comment| %> 12 | 13 | <% end %> 14 | 15 | <%= render :partial => 'comments/edit_comment', :locals => {:comment => @comment, :item => @item} %> 16 |