source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | AlexWayfer/flame | https://github.com/AlexWayfer/flame | spec/flame/errors/route_arguments_order_error_spec.rb | Ruby | mit | 47 | main | 364 | # frozen_string_literal: true
describe Flame::Errors::RouteArgumentsOrderError do
subject(:error) do
described_class.new(path, %w[:?third :?fourth])
end
let(:path) { '/foo/:first/:second/:?fourth/:?third' }
let(:correct_message) do
"Path '#{path}' should have ':?third' argument before ':?fourth'"
end
it_b... |
github | AlexWayfer/flame | https://github.com/AlexWayfer/flame | spec/flame/errors/argument_not_assigned_error_spec.rb | Ruby | mit | 47 | main | 326 | # frozen_string_literal: true
describe Flame::Errors::ArgumentNotAssignedError do
subject(:error) do
described_class.new(
'/foo/:first/:second',
':second'
)
end
let(:correct_message) do
"Argument ':second' for path '/foo/:first/:second' is not assigned"
end
it_behaves_like 'error with correct output... |
github | AlexWayfer/flame | https://github.com/AlexWayfer/flame | spec/flame/errors/spec_helper.rb | Ruby | mit | 47 | main | 447 | # frozen_string_literal: true
## Test controller for Errors
class ErrorsController < Flame::Controller
def foo(first, second, third = nil, fourth = nil); end
end
shared_examples 'error with correct output' do
describe '#message' do
subject { super().message }
it { is_expected.to eq correct_message }
end
des... |
github | AlexWayfer/flame | https://github.com/AlexWayfer/flame | spec/integration/crud_test_project_spec.rb | Ruby | mit | 47 | main | 2,800 | # frozen_string_literal: true
module CRUDTestProject
## Example of CRUD controller
class CRUDController < Flame::Controller
def index
'List of items'
end
def create
'Create item'
end
def show(id)
"Show item #{id}"
end
def update(id)
"Edit item #{id}"
end
def delete(id)
"Delete it... |
github | AlexWayfer/flame | https://github.com/AlexWayfer/flame | spec/integration/index_test_project_spec.rb | Ruby | mit | 47 | main | 911 | # frozen_string_literal: true
module IndexTestProject
## Example of index controller
class IndexController < Flame::Controller
def index
'This is index'
end
end
## Mount example controller to app
class Application < Flame::Application
mount :index, '/'
end
end
describe IndexTestProject do
include Rac... |
github | AlexWayfer/flame | https://github.com/AlexWayfer/flame | spec/integration/custom_test_project_spec.rb | Ruby | mit | 47 | main | 5,376 | # frozen_string_literal: true
module CustomTestProject
## Example of custom controller
class CustomController < Flame::Controller
def index; end
def foo
'This is foo'
end
def hello(name = 'world')
"Hello, #{name}!"
end
get ':?key/document',
def document(key = '')
return 'I have no documen... |
github | hadley/crantastic | https://github.com/hadley/crantastic | Gemfile | Ruby | mit | 47 | master | 1,038 | source 'https://rubygems.org'
gem 'rails', '2.3.18'
gem 'mysql', '~> 2.8.1'
gem 'passenger', '3.0.5'
gem 'authlogic', '~> 2.1.6'
gem 'bitly', '~> 0.5.3'
gem 'cancan', '~> 1.4.0'
gem 'compass', '~> 0.10.5'
gem 'couchrest', '~> 0.37'
gem 'erubis', '~> 2.6.6'
gem 'gravtastic', '~> 2.2.0'
gem 'haml', '~> 3.0.22'
gem 'hop... |
github | hadley/crantastic | https://github.com/hadley/crantastic | Rakefile | Ruby | mit | 47 | master | 303 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'tasks/rails' |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/metal/canonicalize_url.rb | Ruby | mit | 47 | master | 455 | # Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
# Redirects www.domain/* to domain/*
class CanonicalizeUrl
def self.call(env)
if env["HTTP_HOST"] =~ /^www\./ && RAILS_ENV == "production"
[301, { 'Location' => "http://#{APP_CON... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/views/versions/feed.atom.builder | Ruby | mit | 47 | master | 1,216 | atom_feed(:root_url => root_url) do |feed|
feed.title("New package versions on crantastic")
feed.subtitle("New package versions available on CRAN.")
feed.updated(@versions.first.created_at)
feed.author do |author|
author.name("crantastic.org")
end
for version in @versions
# Use created_at as the up... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/views/packages/feed.atom.builder | Ruby | mit | 47 | master | 824 | atom_feed(:root_url => packages_url) do |feed|
feed.title("New packages on crantastic")
feed.subtitle("New packages available on CRAN. " +
"Does not include new versions of existing packages.")
feed.updated(@packages.first.created_at)
feed.author do |author|
author.name("crantastic.org")
e... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/views/weekly_digests/index.atom.builder | Ruby | mit | 47 | master | 529 | atom_feed(:root_url => weekly_digests_url) do |feed|
feed.title("Weekly digests on crantastic")
feed.updated(@weekly_digests.first.updated_at)
feed.author do |author|
author.name("crantastic.org")
end
for wd in @weekly_digests
feed.entry(wd) do |entry|
entry.title(wd.title)
content = rev... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/ability.rb | Ruby | mit | 47 | master | 568 | class Ability
include CanCan::Ability
def initialize(user)
if user && !user.admin? # regular users
can :read, :all
can :manage, Review, :user_id => user.id
can :manage, ReviewComment, :user_id => user.id
can :manage, Tagging, :user_id => user.id
can :manage, User, :id => user... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/user_mailer.rb | Ruby | mit | 47 | master | 815 | class UserMailer < ActionMailer::Base
def activation_instructions(user)
setup_email(user)
@subject = 'Please activate your new crantastic account'
@body[:activation_url] = activate_url(user.perishable_token)
end
def activation_confirmation(user)
setup_email(user)
@subject = 'Your crant... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/review_comment.rb | Ruby | mit | 47 | master | 582 | # == Schema Information
#
# Table name: review_comment
#
# id :integer(4) not null, primary key
# review_id :integer(4) not null
# user_id :integer(4) not null
# title :string(45) not null
# comment :text default(""), not null
# created_at :datetime
# updated_at... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/filtered_event.rb | Ruby | mit | 47 | master | 491 | class FilteredEvent
def initialize(events)
@events = events
end
def events
@events.group_by { |e| e.event_type }
end
def actor
@events.first.actor
end
def count
@events.size
end
def package_event?
false
end
def user_event?
true
end
# Picks the most recent created... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/author.rb | Ruby | mit | 47 | master | 2,651 | # == Schema Information
#
# Table name: author
#
# id :integer(4) not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime
# updated_at :datetime
#
class Author < ActiveRecord::Base
is_gravtastic # Enables the Gravtastic plugin for the Author model
# Note... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/task_view.rb | Ruby | mit | 47 | master | 548 | # == Schema Information
#
# Table name: tag
#
# id :integer(4) not null, primary key
# name :string(255) not null
# full_name :string(255)
# description :text
# created_at :datetime
# updated_at :datetime
# type :string(25)
# version :string(10)
#
class TaskView < Tag
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/review_observer.rb | Ruby | mit | 47 | master | 219 | class ReviewObserver < ActiveRecord::Observer
# Store the version that was reviewed. Should be the latest version of the
# package.
def before_create(review)
review.version = review.package.latest
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/package.rb | Ruby | mit | 47 | master | 7,978 | # == Schema Information
#
# Table name: package
#
# id :integer(4) not null, primary key
# name :string(255)
# description :text
# created_at :datetime
# latest_version_id :integer(4)
# updated_at :datetime
# package_users_count :integer(4) de... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/weekly_digest.rb | Ruby | mit | 47 | master | 2,210 | # == Schema Information
#
# Table name: weekly_digest
#
# id :integer(4) not null, primary key
# param :string(255) not null
# created_at :datetime
# updated_at :datetime
#
# Uses the created_at attribute to determine the week in question.
# Note that the digests are quite expensive to displa... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/package_rating.rb | Ruby | mit | 47 | master | 1,542 | # == Schema Information
#
# Table name: package_rating
#
# id :integer(4) not null, primary key
# package_id :integer(4)
# user_id :integer(4)
# rating :integer(4)
# created_at :datetime
# updated_at :datetime
# aspect :string(25) default("overall"), not null
#
class PackageRating <... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/author_identity.rb | Ruby | mit | 47 | master | 476 | # == Schema Information
#
# Table name: author_identity
#
# id :integer(4) not null, primary key
# user_id :integer(4) not null
# author_id :integer(4) not null
# created_at :datetime
# updated_at :datetime
#
# Join table for identifying user accounts with authors
class AuthorIdentity <... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/daily_digest.rb | Ruby | mit | 47 | master | 1,829 | # Virtual model for daily summaries. The packages, versions, and reviews methods
# are duplicated here and in WeeklyDigest - if more duplication occurs later,
# we can use a module or maybe even switch to STI.
class DailyDigest
# Duck-typing to be perceived as ActiveRecord-like
def self.find_by_param(param)
da... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/version_observer.rb | Ruby | mit | 47 | master | 2,007 | class VersionObserver < ActiveRecord::Observer
def after_create(version)
version.description = "" if version.description.nil?
# Cache latest version and description in the package record
version.package.latest_version = version
version.package.description = version.description
# Store associati... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/tag.rb | Ruby | mit | 47 | master | 2,514 | # == Schema Information
#
# Table name: tag
#
# id :integer(4) not null, primary key
# name :string(255) not null
# full_name :string(255)
# description :text
# created_at :datetime
# updated_at :datetime
# type :string(25)
# version :string(10)
#
class Tag < ActiveRecor... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/priority.rb | Ruby | mit | 47 | master | 384 | # == Schema Information
#
# Table name: tag
#
# id :integer(4) not null, primary key
# name :string(255) not null
# full_name :string(255)
# description :text
# created_at :datetime
# updated_at :datetime
# type :string(25)
# version :string(10)
#
class Priority < Tag
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/version.rb | Ruby | mit | 47 | master | 5,496 | # == Schema Information
#
# Table name: version
#
# id :integer(4) not null, primary key
# package_id :integer(4)
# name :string(255)
# title :string(255)
# description :text
# license :text
# version ... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/log.rb | Ruby | mit | 47 | master | 1,132 | # == Schema Information
#
# Table name: log
#
# id :integer(4) not null, primary key
# message :string(255) not null
# created_at :datetime
# updated_at :datetime
#
# Simple general purpose model for logging messages
class Log < ActiveRecord::Base
validates_presence_of :message
after_crea... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/digest_mailer.rb | Ruby | mit | 47 | master | 296 | class DigestMailer < ActionMailer::Base
def weekly_digest(digest)
@recipients = "r-help@r-project.org"
@from = "Crantastic <cranatic@gmail.com>"
@sent_on = Time.now
@subject = "CRAN (and crantastic) updates this week"
@body[:digest] = digest
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/weekly_digest_observer.rb | Ruby | mit | 47 | master | 346 | # Delivers the weekly digest after it has been created,
# unless no packages or versions have been updated, as
# this indicates an error.
class WeeklyDigestObserver < ActiveRecord::Observer
def after_create(digest)
unless digest.packages.empty? && digest.versions.empty?
DigestMailer.deliver_weekly_digest(d... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/timeline_event.rb | Ruby | mit | 47 | master | 4,312 | # == Schema Information
#
# Table name: timeline_event
#
# id :integer(4) not null, primary key
# event_type :string(255)
# subject_type :string(255)
# actor_type :string(255)
# secondary_subject_type :string(255)
# subject_id :integer(4)
# a... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/review.rb | Ruby | mit | 47 | master | 1,776 | # == Schema Information
#
# Table name: review
#
# id :integer(4) not null, primary key
# package_id :integer(4)
# user_id :integer(4)
# review :text
# title :string(255)
# created_at :datetime
# updated_at :datetime
# version_id :integer(4)
# cached_rating :int... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/package_user.rb | Ruby | mit | 47 | master | 1,252 | # == Schema Information
#
# Table name: package_user
#
# id :integer(4) not null, primary key
# package_id :integer(4)
# user_id :integer(4)
# created_at :datetime
# updated_at :datetime
# active :boolean(1) default(TRUE), not null
#
# Parts of this code has been derived from the vote_fu... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/tagging.rb | Ruby | mit | 47 | master | 1,086 | # == Schema Information
#
# Table name: tagging
#
# id :integer(4) not null, primary key
# user_id :integer(4)
# package_id :integer(4)
# created_at :datetime
# updated_at :datetime
# tag_id :integer(4)
#
class Tagging < ActiveRecord::Base
has_one :timeline_event, :foreign_key => :subject_... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/models/user.rb | Ruby | mit | 47 | master | 6,049 | # == Schema Information
#
# Table name: user
#
# id :integer(4) not null, primary key
# login :string(255)
# email :string(255)
# crypted_password :string(255)
# password_salt :string(255)
# created_at :datetime
# updated_at :datetime
#... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/search_controller.rb | Ruby | mit | 47 | master | 474 | class SearchController < ApplicationController
def show
@title = 'Search'
@search_term = String(params[:q]).mb_chars.strip
@search_term.gsub!('()', '') # Not allowed in Solr search queries
@results = Package.find_by_solr(@search_term, :limit => 50).try(:results) || []
# Redirect to package if t... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/users_controller.rb | Ruby | mit | 47 | master | 1,791 | class UsersController < ApplicationController
before_filter :require_no_user, :only => [ :new, :create, :activate, :thanks ]
before_filter :require_user, :only => [ :regenerate_api_key, :edit ]
load_and_authorize_resource
def index
@users = User.all
@title = @users.length.to_s + " users"
end
def... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/tags_controller.rb | Ruby | mit | 47 | master | 822 | class TagsController < ApplicationController
authorize_resource
def index
@tags = Tag.ordered
@title = if params[:type].nil?
"Tags"
else
params[:type].split('_').map(&:capitalize).join(" ").pluralize
end
end
def show
@tag = klass.find_by_par... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/sessions_controller.rb | Ruby | mit | 47 | master | 3,015 | # This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# RPX does not pass Rails form tokens...
skip_before_filter :verify_authenticity_token, :only => [:rpx_token]
before_filter :require_no_user, :only => [ :new, :create, :rpx_token ]
before_filter :r... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/versions_controller.rb | Ruby | mit | 47 | master | 757 | class VersionsController < ApplicationController
before_filter :admin_required, :only => :create
protect_from_forgery :except => :trigger
def index
respond_to do |format|
format.html { rescue_404 }
format.xml { render :xml => Version.all }
end
end
def show
@version = Version.find(p... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/authors_controller.rb | Ruby | mit | 47 | master | 1,116 | class AuthorsController < ApplicationController
# TODO remove create method after the data import script is rewritten
before_filter :admin_required, :only => :create
def index
conditions = params.dup.delete_if { |k,v| !["name", "email"].include?(k) }
@authors = Author.all(:conditions => conditions)
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/timeline_events_controller.rb | Ruby | mit | 47 | master | 821 | class TimelineEventsController < ApplicationController
before_filter :set_atom
def index
@page = (params[:page] || 1).to_i
@page = 1 if @page == 0
respond_to do |format|
format.html { @events = TimelineEvent.paginate_filtered_events(@page) }
format.atom { @events = TimelineEvent.recent }
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/password_resets_controller.rb | Ruby | mit | 47 | master | 1,851 | class PasswordResetsController < ApplicationController
before_filter :load_user_using_perishable_token, :only => [ :edit, :update ]
before_filter :require_no_user
def new
@title = "Reset your password"
end
def create
@user = User.find_by_email(params[:email])
if @user
@user.deliver_passwo... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/weekly_digests_controller.rb | Ruby | mit | 47 | master | 982 | class WeeklyDigestsController < ApplicationController
before_filter :set_atom
def index
@weekly_digests = WeeklyDigest.all
@title = @atom[:title]
respond_to do |format|
format.html { }
format.text { }
end
end
def show
@digest = object
@title = @digest.title
respond_to ... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/reviews_controller.rb | Ruby | mit | 47 | master | 1,424 | class ReviewsController < ApplicationController
before_filter :require_user, :only => [:new, :edit]
load_and_authorize_resource
def index
@reviews = Review.recent
@package = parent_object
@title = (@package.nil?) ? "Recent reviews" : "Reviews for #{@package}"
@plural = true
respond_to do |... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/application_controller.rb | Ruby | mit | 47 | master | 2,178 | # Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# replaces the value to all keys matching /password/i with "[FILTERED]"
filter_parameter_logging :password
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/votes_controller.rb | Ruby | mit | 47 | master | 604 | class VotesController < ApplicationController
protect_from_forgery :except => :create
before_filter :require_user
def create
# Input should be a comma separated list of packages (with no superfluous
# whitespace)
packages = params[:packages].split(",")
packages.each do |pkg|
pkg = Package... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/review_comments_controller.rb | Ruby | mit | 47 | master | 800 | class ReviewCommentsController < ApplicationController
load_and_authorize_resource
def new
@review = Review.find(params[:review_id])
@review_comment = ReviewComment.new
end
def show
@review_comment = ReviewComment.find(params[:id])
respond_to do |format|
format.html { }
end
end
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/taggings_controller.rb | Ruby | mit | 47 | master | 1,749 | class TaggingsController < ApplicationController
protect_from_forgery :except => :create
before_filter :login_required, :set_object
def create
# params[:tag_name] might be a list of tags, an array of tag instances is
# returned by the following statement.
tags = Tag.parse_and_find_or_create(params[:... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/packages_controller.rb | Ruby | mit | 47 | master | 2,864 | class PackagesController < ApplicationController
before_filter :login_required, :only => :toggle_usage
before_filter :admin_required, :only => :create
def index
page_no = (params[:page] || 1).to_i
page_no = 1 if page_no == 0
@search_term = String(params[:search]) || ''
# Handle nonce values, th... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/static_controller.rb | Ruby | mit | 47 | master | 324 | # Simple controller for (semi) static pages. Each page requires a new entry
# in =routes.rb=. If we end up with many of these pages we should look into a
# more sophisticated solution.
class StaticController < ApplicationController
def about
@title = "About"
end
def error_404
end
def error_500
end
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/ratings_controller.rb | Ruby | mit | 47 | master | 862 | class RatingsController < ApplicationController
before_filter :login_required, :only => [ :create ]
def index
return rescue_404 if params[:package_id].nil?
pkg = Package.find_by_param(params[:package_id])
respond_to do |format|
format.html { redirect_to(package_path(pkg)) }
format.js do
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/controllers/author_identities_controller.rb | Ruby | mit | 47 | master | 611 | class AuthorIdentitiesController < ApplicationController
before_filter :login_required, :find_author
def new
@title = "Add new author identity"
end
def create
if verify_recaptcha
self.current_user.author_identities << AuthorIdentity.new(:author => @author)
flash[:notice] = "You are now id... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/search_helper.rb | Ruby | mit | 47 | master | 312 | module SearchHelper
def star_rating_for(package)
# The nbsp's are ugly, but it was the first technique that I got working in
# both FF, Safari, and Opera.
content_tag("span", " ".html_safe,
:class => "star-rating-on") * package.average_rating
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/timeline_events_helper.rb | Ruby | mit | 47 | master | 2,701 | module TimelineEventsHelper
def action(action_txt)
content_tag("span", action_txt, :class => "action")
end
def user_action(event_type, events, display_action=true)
case event_type
when "new_tagging" then
action("tagged") + " " +
events.map do |e|
link_to(e.secondary_subject, ... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/application_helper.rb | Ruby | mit | 47 | master | 1,593 | module ApplicationHelper
def error_message_for(object, field)
return if object.errors[field].blank?
errors = object.errors[field]
errors = errors.join(" and ") if errors.is_a? Array
content_tag :span, errors, :class => :error
end
def clear_div
content_tag(:div, nil, :class => :clear)
end
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/packages_helper.rb | Ruby | mit | 47 | master | 1,368 | module PackagesHelper
def select_rating(aspect="overall")
enabled = logged_in? # Disable the form elements if the user isn't logged in
output = [ tag(:input, :type => "hidden", :name => "aspect", :value => aspect) ]
1.upto(5) do |i|
opts = {:type => "radio", :class => "starselect", :value => i.to_... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/remote_link_renderer.rb | Ruby | mit | 47 | master | 320 | class RemoteLinkRenderer < WillPaginate::LinkRenderer
def prepare(collection, options, template)
@remote = options.delete(:remote) || {}
super
end
protected
def page_link(page, text, attributes = {})
@template.link_to_remote(text, {:url => url_for(page), :method => :post}.merge(@remote))
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/tags_helper.rb | Ruby | mit | 47 | master | 303 | module TagsHelper
def tag_cloud(tags, classes)
# Minimum 1, to prevent division by zero
max_count = [tags.sort_by(&:weight).last.weight, 1].max.to_f
tags.each do |tag|
index = ((tag.weight / max_count) * (classes.size - 1)).round
yield tag, classes[index]
end
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/versions_helper.rb | Ruby | mit | 47 | master | 429 | module VersionsHelper
def package_links(packages)
packages.collect do |p|
link_to(p.name, p)
end.join(", ").html_safe
end
def version_uses
uses = (@version.uses.map do |p|
link_to p.name, p
end + @version.suggests.map do |p|
content_tag(:em, link_to(p.na... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/feed_helper.rb | Ruby | mit | 47 | master | 1,262 | module FeedHelper
# Obj is set to nil for the main timeline feed
def latest_activity_feed(obj=nil)
xml = ::Builder::XmlMarkup.new(:indent => 2)
root = obj.nil? ? root_url : polymorphic_url(obj)
raw(atom_feed(:root_url => root) do |feed|
feed.title("Latest activity " + (obj.nil? ? "on crantastic" ... |
github | hadley/crantastic | https://github.com/hadley/crantastic | app/helpers/weekly_digests_helper.rb | Ruby | mit | 47 | master | 683 | module WeeklyDigestsHelper
def reviews(reviews)
return "" if reviews.empty?
content_tag(:h2, "Reviews") +
content_tag(:ul, reviews.map do |r|
content_tag(:li, link_to("#{r.user}'s review of #{r.package}".html_safe, r))
end.join("").html_safe)
end
def... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/environment.rb | Ruby | mit | 47 | master | 2,175 | # Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/routes.rb | Ruby | mit | 47 | master | 3,262 | ActionController::Routing::Routes.draw do |map|
map.resources :author_identities, :only => [ :new, :create ]
map.resources :authors, :only => [ :index, :show, :create, :edit, :update ]
map.resources :password_resets, :except => [ :index, :destroy, :show ]
map.resources :priorities, :only => [ :index, :show ], ... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/boot.rb | Ruby | mit | 47 | master | 3,057 | # Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/environments/development.rb | Ruby | mit | 47 | master | 832 | # Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/environments/test.rb | Ruby | mit | 47 | master | 974 | # Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/initializers/date_formats.rb | Ruby | mit | 47 | master | 302 | ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:recent => "%I:%M%p",
:pretty => "%b %d, %Y",
:pretty_long => "%b %d, %Y %I:%M%p",
:date_time12 => "%m/%d/%Y %I:%M%p",
:date_time24 => "%m/%d/%Y %H:%M",
:simple => "%Y/%m/%d"
) |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/initializers/00-load_config.rb | Ruby | mit | 47 | master | 1,220 | # Load global app configuration
APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/settings.yml")[Rails.env].symbolize_keys
# Load private configuration (API keys etc)
# If private.yml isn't available, we're falling back to using ENV variables
private_config = if File.exists?("#{RAILS_ROOT}/config/private.yml")
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/initializers/mail.rb | Ruby | mit | 47 | master | 279 | ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'crantastic.org',
:authentication => :plain,
:enable_starttls_auto => true,
:user_name => 'cranatic',
:password => ENV['GMAIL']
} |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/initializers/load_lib.rb | Ruby | mit | 47 | master | 309 | # Load some files from lib/ which aren't picked up by const_missing
require File.join(RAILS_ROOT, 'lib/string-wrap')
require File.join(RAILS_ROOT, 'lib/core_extensions')
require File.join(RAILS_ROOT, 'lib/gfm')
require File.join(RAILS_ROOT, 'lib/rails_extensions')
require File.join(RAILS_ROOT, 'lib/rfc822') |
github | hadley/crantastic | https://github.com/hadley/crantastic | config/initializers/hoptoad.rb | Ruby | mit | 47 | master | 266 | HoptoadNotifier.configure do |config|
config.api_key = ENV['HOPTOAD_API_KEY']
# Whitelist of errors that Hoptoad ignores
config.ignore_by_filter do |exception_data|
exception_data.error_message =~ "ActionController::UnknownHttpMethod: PROPFIND"
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/schema.rb | Ruby | mit | 47 | master | 8,772 | # This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your data... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090727140821_rename_package_vote_to_package_user.rb | Ruby | mit | 47 | master | 1,102 | class RenamePackageVoteToPackageUser < ActiveRecord::Migration
def self.up
remove_index :package_vote, [:package_id, :user_id]
rename_table :package_vote, :package_user
add_index :package_user, [:package_id, :user_id], :unique => true
remove_index :package, :package_votes_count
rename_column :pac... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090729182846_create_review_comments.rb | Ruby | mit | 47 | master | 456 | class CreateReviewComments < ActiveRecord::Migration
def self.up
create_table :review_comment do |t|
t.integer :review_id, :null => false
t.integer :user_id, :null => false
t.string :title, :null => false, :limit => 45
t.text :comment, :null => false
t.timestamps
end
add_in... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090629122633_package_depends_enhances_suggests.rb | Ruby | mit | 47 | master | 1,425 | class PackageDependsEnhancesSuggests < ActiveRecord::Migration
def self.up
create_table :required_package_version, :id => false do |t|
t.integer :version_id, :null => false
t.integer :required_package_id, :null => false
end
add_index :required_package_version, [:version_id, :required_package_... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/007_create_authors.rb | Ruby | mit | 47 | master | 219 | class CreateAuthors < ActiveRecord::Migration
def self.up
create_table :author do |t|
t.string :name
t.string :email
t.timestamps
end
end
def self.down
drop_table :author
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/004_create_users.rb | Ruby | mit | 47 | master | 610 | class CreateUsers < ActiveRecord::Migration
def self.up
create_table "user", :force => true do |t|
t.column :login, :string
t.column :email, :string
t.column :crypted_password, :string, :limit => 40
t.column :salt, :stri... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090811173510_cache_package_description.rb | Ruby | mit | 47 | master | 248 | class CachePackageDescription < ActiveRecord::Migration
def self.up
Package.all(:conditions => { :description => nil }).each do |p|
p.update_attribute(:description, p.latest_version.description)
end
end
def self.down
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090707114131_create_package_votes.rb | Ruby | mit | 47 | master | 316 | class CreatePackageVotes < ActiveRecord::Migration
def self.up
create_table :package_vote do |t|
t.belongs_to :package
t.belongs_to :user
t.timestamps
end
add_index :package_vote, [:package_id, :user_id], :unique => true
end
def self.down
drop_table :package_vote
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090604003520_create_user_identifiers.rb | Ruby | mit | 47 | master | 328 | class CreateUserIdentifiers < ActiveRecord::Migration
def self.up
create_table :user_identifier do |t|
t.belongs_to :user, :null => false
t.string :identifier, :null => false
end
add_index :user_identifier, :identifier, :unique => true
end
def self.down
drop_table :user_identifier
... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090622183952_add_sitemap_table.rb | Ruby | mit | 47 | master | 912 | class AddSitemapTable < ActiveRecord::Migration
def self.up
create_table "sitemap_setting", :force => true do |t|
t.string :name
t.string :description
t.string :xml_location
t.string :username
t.string :password
t.timestamps
end
create_table "sitemap_static_li... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090731172118_add_active_boolean_to_package_users.rb | Ruby | mit | 47 | master | 233 | class AddActiveBooleanToPackageUsers < ActiveRecord::Migration
def self.up
add_column :package_user, :active, :boolean, :default => true, :null => false
end
def self.down
remove_column :package_user, :active
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090702113720_rename_cache_column_for_timeline_events.rb | Ruby | mit | 47 | master | 362 | class RenameCacheColumnForTimelineEvents < ActiveRecord::Migration
def self.up
rename_column :timeline_event, :cached_rating, :cached_value
change_column :timeline_event, :cached_value, :string
end
def self.down
rename_column :timeline_event, :cached_value, :cached_rating
change_column :timeline_... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/005_add_activation.rb | Ruby | mit | 47 | master | 283 | class AddActivation < ActiveRecord::Migration
def self.up
add_column :user, :activation_code, :string, :limit => 40
add_column :user, :activated_at, :datetime
end
def self.down
delete_column :user, :activation_code
delete_column :user, :activated_at
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090703093952_add_publicized_or_packaged_to_versions.rb | Ruby | mit | 47 | master | 225 | class AddPublicizedOrPackagedToVersions < ActiveRecord::Migration
def self.up
add_column :version, :publicized_or_packaged, :datetime
end
def self.down
remove_column :version, :publicized_or_packaged
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20091207194305_add_missing_indexes_to_reviews.rb | Ruby | mit | 47 | master | 319 | class AddMissingIndexesToReviews < ActiveRecord::Migration
def self.up
add_index :review, :package_id
add_index :review, :version_id
add_index :review, :user_id
end
def self.down
remove_index :review, :package_id
remove_index :review, :version_id
remove_index :review, :user_id
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090402200300_create_package_ratings.rb | Ruby | mit | 47 | master | 317 | class CreatePackageRatings < ActiveRecord::Migration
def self.up
create_table :package_rating do |t|
t.integer :package_id
t.integer :user_id
t.integer :rating
t.timestamps
end
add_index :package_rating, :user_id
end
def self.down
drop_table :package_rating
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090620160821_remove_user_identifiers.rb | Ruby | mit | 47 | master | 266 | class RemoveUserIdentifiers < ActiveRecord::Migration
def self.up
drop_table :user_identifier
end
def self.down
create_table :user_identifier do |t|
t.belongs_to :user, :null => false
t.string :identifier, :null => false
end
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090730112829_change_user_fields.rb | Ruby | mit | 47 | master | 786 | class ChangeUserFields < ActiveRecord::Migration
def self.up
# To support the stronger crypt algorithms in authlogic
change_column :user, :crypted_password, :string, :limit => 255
change_column :user, :salt, :string, :limit => 255
rename_column :user, :salt, :password_salt
remove_column :user, :... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090615123240_add_aspect_to_package_ratings.rb | Ruby | mit | 47 | master | 469 | class AddAspectToPackageRatings < ActiveRecord::Migration
def self.up
add_column :package_rating, :aspect, :string, :null => false, :default => "overall", :limit => 25
add_index :package_rating, :aspect
# Migrate existing rows
PackageRating.all.each do |pr|
pr.update_attribute(:aspect, "overall... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090702092911_add_homepage_and_profile_to_users.rb | Ruby | mit | 47 | master | 338 | class AddHomepageAndProfileToUsers < ActiveRecord::Migration
def self.up
add_column :user, :homepage, :string
add_column :user, :profile, :text
add_column :user, :profile_html, :text
end
def self.down
remove_column :user, :homepage
remove_column :user, :profile
remove_column :user, :profi... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20091208173029_add_version_changes_to_versions.rb | Ruby | mit | 47 | master | 201 | class AddVersionChangesToVersions < ActiveRecord::Migration
def self.up
add_column :version, :version_changes, :text
end
def self.down
remove_column :version, :version_changes
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090622142843_add_cached_rating_to_timeline_event.rb | Ruby | mit | 47 | master | 442 | class AddCachedRatingToTimelineEvent < ActiveRecord::Migration
def self.up
# The ratings can change so we must cache the values
add_column :timeline_event, :cached_rating, :integer, :null => true
TimelineEvent.all(:conditions => "event_type = 'new_package_rating'").each do |e|
e.update_attribute(:ca... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090607204608_create_logs.rb | Ruby | mit | 47 | master | 207 | class CreateLogs < ActiveRecord::Migration
def self.up
create_table :log do |t|
t.string :message, :null => false
t.timestamps
end
end
def self.down
drop_table :log
end
end |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090715082452_add_authlogic_fields_to_users.rb | Ruby | mit | 47 | master | 1,107 | class AddAuthlogicFieldsToUsers < ActiveRecord::Migration
def self.up
add_column :user, :persistence_token, :string,
:limit => 128,
:default => "",
:null => false
add_column :user, :login_count, :integer, :default => 0, :null => false
add... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090804171354_create_author_version_join_table.rb | Ruby | mit | 47 | master | 436 | class CreateAuthorVersionJoinTable < ActiveRecord::Migration
def self.up
create_table :author_version, :id => false do |t|
t.integer :author_id, :null => false
t.integer :version_id, :null => false
end
add_index :author_version, [:author_id, :version_id], :unique => true
Version.all.each... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090608181912_convert_names_in_taggings_to_tags.rb | Ruby | mit | 47 | master | 493 | class ConvertNamesInTaggingsToTags < ActiveRecord::Migration
def self.up
Tagging.all.each do |tagging|
# Must use array index to avoid the "belongs_to :tag"-relation
if tagging["tag"].strip.blank?
tagging.destroy
next
end
tagging.tag = Tag.find_or_create_with_like_by_name(t... |
github | hadley/crantastic | https://github.com/hadley/crantastic | db/migrate/20090330150303_create_trigrams_table_for_package.rb | Ruby | mit | 47 | master | 444 | class CreateTrigramsTableForPackage < ActiveRecord::Migration
def self.up
create_table :package_trigram, :force => true do |t|
t.integer :package_id, :null => false
t.string :tg, :length => 3, :null => false # trigrams
t.integer :score, :default => 1, :null => false
end
add_index :packag... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.