code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
module WelcomeHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module PreferenceHelper
end
| Ruby |
module UsersHelper
end
| Ruby |
module UserSessionsHelper
end
| Ruby |
module DecoratesHelper
end
| Ruby |
module SectionHelper
end
| Ruby |
module DocumentHelper
end
| Ruby |
class UserSession < Authlogic::Session::Base
end | Ruby |
class Decorate < ActiveRecord::Base
has_many :decorate_documents, :dependent => :destroy
has_many :documents, :through => :decorate_documents
def self.javascripts
self.find :all, :conditions => { :decorate_type => "javascript" }
end
def self.stylesheets
self.find :all, :conditions => { :decorate_typ... | Ruby |
class Section < ActiveRecord::Base
has_many :documents
end
| Ruby |
class Document < ActiveRecord::Base
belongs_to :section
has_many :decorate_documents, :dependent => :destroy
has_many :decorates, :through => :decorate_documents
def before_save
self.body_html = Document.render_body_html self.body_textile
if self.code.empty?
self.code = self.subject
end
s... | Ruby |
class User < ActiveRecord::Base
include Configurator
acts_as_authentic# :crypto_provider => Authlogic::CryptoProviders::BCrypt
end
| Ruby |
class DecorateDocument < ActiveRecord::Base
belongs_to :decorate
belongs_to :document
validates_uniqueness_of :decorate_id, :scope => [:document_id]
end
| Ruby |
class DecoratesController < ApplicationController
def create
decorate = Decorate.new params[:decorate]
if decorate.save
end
end
def destroy
end
def edit
@decorate = Decorate.find params[:id]
end
def index
unless params[:decorate_type].nil?
@decorates = Decorate.find :... | Ruby |
class WelcomeController < ApplicationController
def index
@sections = Section.find :all
end
end
| Ruby |
class UsersController < ApplicationController
def create
user = User.new params[:user]
if user.save
redirect_to "/"
else
render :action => :new
end
end
def destroy
end
def edit
@user = @current_user
end
def index
end
def new
@user = User.new
end
def show
... | Ruby |
class UserSessionsController < ApplicationController
def create
@user_session = UserSession.new params[:user_session]
if @user_session.save
redirect_to "/"
else
redirect_to :action => "new"
end
end
def destroy
current_user_session.destroy
redirect_to "/"
end
def new
@... | Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details... | Ruby |
class PreferenceController < ApplicationController
def index
end
def save
temp = params[:preference]
Configurator.config[:site, :name] = temp[:site_name]
redirect_to :action => :index
end
end
| Ruby |
class SectionController < ApplicationController
before_filter :init_section
def index
@documents = Document.find :all
end
def show
@document = Document.find_by_code params[:document_code]
end
private
def init_section
@section = Section.find_by_code params[:section_code]
end
end
| Ruby |
class DocumentController < ApplicationController
before_filter :init_section
skip_before_filter :verify_authenticity_token, :only => [:preview]
def decorate
params[:docorate_type]
end
def update_decorate
work = params[:work].nil? ? nil : params[:work]
result = ""
unless work.nil?
... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person',... | Ruby |
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true
# Store the full clas... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
ActionController::Routing::Routes.draw do |map|
map.root :controller => "welcome"
map.resource :user_session
map.resource :account, :controller => "users"
map.resources :users
map.connect "/decorates/js", ... | Ruby |
# 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?
... | Ruby |
# 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.2... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Enable threaded mode
# config.threadsafe!
# Use a different logger for distributed setups
# config.... | Ruby |
# 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... | Ruby |
# 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... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
require 'mongrel_cluster/recipes'
# =============================================================================
# VARIABLES
# =============================================================================
set :svn_user, "franck"
set :user, "franck"
set :application, "cf"
set :repository, "http://svn.merrycreation.co... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... | Ruby |
# 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... | Ruby |
module LocalizationSettings
CONFIG = {
# Default language
:default_language => 'fr',
:web_charset => 'utf-8'
}
if CONFIG[:web_charset] == 'utf-8'
$KCODE = 'u'
end
end
| Ruby |
# 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... | Ruby |
# Be sure to restart your web 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 ... | Ruby |
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS... | Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# You can have the root of your site routed by hooking up ''
# -- just remember to delete public/index.html.
map.connect '', :controller => "home"
# add home_url helper
map.ho... | Ruby |
class ArticleSweeper < ActionController::Caching::Sweeper
observe Article
def after_save(record)
self.class::sweep
end
def after_destroy(record)
self.class::sweep
end
def self.sweep
cache_dir = ActionController::Base.page_cache_directory
unless cache_dir == RAILS_ROOT+"/public"
FileU... | Ruby |
module ArticlesHelper
end
| Ruby |
module AdminHelper
include Admin::CmsHelper
end
| Ruby |
require 'open-uri'
require 'rss'
module ApplicationHelper
include LocalizationSettings
def markdown(text)
BlueCloth.new(text.gsub(%r{</?notextile>}, '')).to_html
end
def filtertext(text)
RedCloth.new(text.gsub(%r{</?notextile>}, ''), [:hard_breaks]).to_html
end
def read_more(text, link, lin... | Ruby |
module CategoryHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
module Admin::BaseHelper
end
| Ruby |
module Admin::User::UserHelper
def display_roles(roles)
html = ""
roles.each do |role|
html << role.title + ', '
end
html.gsub(/,\s$/,"")
end
def display_roles_checkbox_two_columns(user)
html = ""
col = []
col[0] = "<div>"
col[1] = "<div>"
html << "<h2>#{l('Roles')}</h2>"
html << "<fieldset ... | Ruby |
module Admin::User::RolesHelper
end
| Ruby |
module Admin::CmsHelper
def link_if_permit(logicstring, name, options = {}, html_options = nil, *parameters_for_method_reference)
if permit? logicstring
result = "#{link_to name, options, html_options, *parameters_for_method_reference}"
end
end
# display categories in a tree
# options :
# controller =>... | Ruby |
module Admin::Newsletter::RegionalNewsletterHelper
end | Ruby |
module Admin::Newsletter::NewsletterHelper
end
| Ruby |
module Admin::Newsletter::EmailsHelper
end
| Ruby |
module Admin::Newsletter::ListHelper
end
| Ruby |
module Admin::Newsletter::ImportHelper
end
| Ruby |
module Admin::Cms::CategoriesHelper
include Admin::CmsHelper
end
| Ruby |
module Admin::Cms::SearchHelper
end
| Ruby |
module Admin::Cms::PagesHelper
include Admin::CmsHelper
end
| Ruby |
module AccountHelper
end | Ruby |
require 'open-uri'
require 'rss'
module RegionHelper
def read_regional_offer_rss(feed_url, region_name)
output = "<h3>Les dernieres offres d'emplois dans la région : <span class='region'>#{region_name}</span></h3>"
open("http://"+ feed_url) do |http|
response = http.read
result = RSS::Parser.p... | Ruby |
class Category < ActiveRecord::Base
acts_as_tree :order => :position
acts_as_list :scope => :parent_id
has_many :articles, :order => "published_at desc"
validates_presence_of :name
before_destroy :delete_articles
def to_param
permalink
end
def stripped_name
self.name.to_url
end
def publishe... | Ruby |
class UserNotifier < ActionMailer::Base
include LocalizationSettings
def signup_notification(user)
setup_email(user)
@subject += "#{l('Please activate your new account')}"
@body[:url] = "http://ce.merrycreation.com/account/activate/#{user.activation_code}"
@body[:url_activate] = "http://c... | Ruby |
#class Superman < ActionMailer::ARMailer
class Superman < ActionMailer::Base
def message(message)
case message['recipient']
when 'contact'
@recipients = []
@recipients << "olivier.jacquemond@connexion-emploi.com"
@recipients << "franck.dagostini@gmail.com"
when 'webmaster'
@recipi... | Ruby |
class Date
def age(base = self.class.today)
base.year - year - ((base.month * 100 + base.day >= month * 100 + day) ? 0 : 1)
end
end
| Ruby |
class Image < ActiveRecord::Base
file_column :name , :magick => { :versions => { "thumb" => "100x100" } }
belongs_to :article
end
| Ruby |
class CsvFile < ActiveRecord::Base
acts_as_attachment :storage => :file_system, :max_size => 2.megabytes, :content_type => 'text/plain'
validates_as_attachment
def get_emails
case self.format
when 'csv'
emails = FasterCSV.read(self.full_filename)
emails = emails[0]
when 'foxmail'
... | Ruby |
class Mailing < ActiveRecord::Base
validates_presence_of :subject
validates_presence_of :from
validates_presence_of :to
validates_presence_of :body
end
| Ruby |
class Email < ActiveRecord::Base
end
| Ruby |
class Contact < ActionMailer::ARMailer
def contact_email(info)
case info['recipient']
when 'contact'
@recipients = "olivier.jacquemond@connexion-emploi.com"
when 'webmaster'
@recipients = "webmaster@connexion-emploi.com"
end
@from = "site@connexion-emploi.com"
@subject = '[CE]' +... | Ruby |
class Article < ActiveRecord::Base
belongs_to :category
has_many :images
has_many :attachments
validates_presence_of :title
acts_as_taggable
def to_param
permalink
end
def stripped_title
self.title.to_url
end
def self.find_by_permalink(title)
find(:first, :conditions => ["permalink = ?", tit... | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
# Virtual attribute for the unencrypted password
attr_accessor :password
# edition mode
attr_accessor :edition_mode
# for activation
before_create :make_activation_code
validates_presence_of :login, :email
va... | Ruby |
class Batman < ActionMailer::Base
def mail_to_member(mailing, recipient)
@recipients = recipient
@from = mailing.from
@subject = mailing.subject
@body[:message_body] = mailing.body
end
end
| Ruby |
class NewsletterUserNotification < ActionMailer::ARMailer
def on_signin(message)
@recipients = message['email']
@from = "site@connexion-emploi.com"
@subject = '[CE] Confirmation Abonnement Emploi'
@body['email'] = message['email']
@body['sectors_fr'] = message['sectors_fr']
@body['sectors_de... | Ruby |
class NewsletterMemberSector < ActiveRecord::Base
belongs_to :newsletter_member
belongs_to :sector
end
| Ruby |
class NewsletterMember < ActiveRecord::Base
has_many :newsletter_member_sectors, :dependent => :destroy, :uniq => true
has_many :sectors, :through => :newsletter_member_sectors, :uniq => true
validates_presence_of :email
validates_as_email :email
validates_uniqueness_of :email, :message => "has already been ... | Ruby |
class Role < ActiveRecord::Base
has_and_belongs_to_many :users
validates_presence_of :title
validates_uniqueness_of :title, :on => :create
end
| Ruby |
class MlMember < ActiveRecord::Base
has_and_belongs_to_many :mailinglists, :uniq => true
validates_presence_of :email
validates_uniqueness_of :email
end
| Ruby |
class Tab
attr_accessor :name
attr_accessor :controller
attr_accessor :action
def initialize(name = "", controller = "", action = "index")
@name = name
@controller = controller
@action = action
end
end
| Ruby |
class Attachment < ActiveRecord::Base
file_column :file
belongs_to :article
end
| Ruby |
class RegionalNewsletter < ActiveRecord::Base
has_and_belongs_to_many :sectors
def get_all_valid_emails
self.sectors.collect{|s| s.newsletter_members.get_valid_emails }.flatten.compact.uniq
end
end
| Ruby |
class UserObserver < ActiveRecord::Observer
def after_create(user)
UserNotifier.deliver_signup_notification(user)
end
def after_save(user)
UserNotifier.deliver_activation(user) if user.recently_activated?
UserNotifier.deliver_forgot_password(user) if user.recently_forgot_password?
UserNotifier.de... | Ruby |
class Mailinglist < ActiveRecord::Base
has_and_belongs_to_many :ml_members, :uniq => true
validates_presence_of :name
end
| Ruby |
class HomeController < ApplicationController
caches_page :index
layout "home"
before_filter :get_nav_categories
before_filter :get_regions
def index
@article_une = get_article_by_tags(['home_une'])[0]
@articles_deux = get_article_by_tags(['home_deux'])
if @articles_deux.size > 4
@arti... | Ruby |
class CategoryController < ApplicationController
caches_page :show
layout "home"
before_filter :get_nav_categories
before_filter :get_regions
def show
@category = Category.find_by_permalink(params[:id])
articles = Article.ez_find(:all, :include => :category, :order => "published_at desc") do |arti... | Ruby |
class AdminController < Admin::BaseController
def index
@articles_not_yet_published = Article.find(:all, :conditions => "published = 0 AND archived = 0")
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.