code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
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
response = `curl #{fe... | 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@connexion-francaise.com"
when 'webmaster'
@recipients = []
@recipients << "franck.dagostini@gmail.com... | 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 HtmlNewsletter < ActiveRecord::Base
validates_presence_of :title
validates_presence_of :subject
def get_all_valid_emails
#sector.newsletter_members.get_valid_emails.flatten.compact.uniq
end
def publish
self.published_at = Time.now
self.save
end
def stripped_subject
self.subject.to_ur... | Ruby |
class Contact < ActionMailer::ARMailer
def contact_email(info)
case info['recipient']
when 'contact'
@recipients = "olivier.jacquemond@connexion-francaise.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
CampaignMonitor::CAMPAIGN_MONITOR_API_KEY = "7fc49ec9a083d6d7ee891a88f65a38cf"
def index
@articles_une = get_article_by_tags(['home_une'])
@articles_deu... | 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 |
#require 'campaign_monitor'
class NewsletterController < ApplicationController
skip_after_filter :add_google_analytics_code, :only => ["show"]
caches_page :show
CampaignMonitor::CAMPAIGN_MONITOR_API_KEY = "7fc49ec9a083d6d7ee891a88f65a38cf"
def show
@html_newsletter = HtmlNewsletter.find_by_permalink(params... | Ruby |
class AdminController < Admin::BaseController
def index
@articles_not_yet_published = Article.find(:all, :conditions => "published = 0 AND archived = 0")
end
end
| Ruby |
class LanguageController < ApplicationController
def set_lang
@session['lang'] = params[:id]
redirect_to last_request_uri
end
end
| Ruby |
class Admin::User::RolesController < Admin::User::BaseController
def index
list
render :action => :list
end
def list
@roles = Role.find(:all, :order => :title)
end
def new
@role = Role.new(params[:role])
if request.post?
if @role.save
flash[:notice] = "Role was successfully created"
redirec... | Ruby |
class Admin::User::UserController < Admin::User::BaseController
def index
list
render :action => :list
end
def list
@users = User.find(:all)
end
def show
@user = User.find(params[:id])
end
def edit
@user = User.find(params[:id])
@user.attributes = params[:user]
@user.edition_mode = true
if r... | Ruby |
require 'tab.rb'
class Admin::User::BaseController < Admin::BaseController
before_filter :tab
access_control :DEFAULT => 'admin'
private
def tab
# TABS : one tab rendered for each tabs objects in @tabs instance variable
@tabs = [
Tab.new(l('USERS'),"user","index")
]
end
end
| Ruby |
class Admin::Newsletter::NewsletterController < Admin::Newsletter::EmailsController
before_filter :set_page_title
access_control :DEFAULT => 'email'
def index
@mailings = Mailing.find(:all)
end
def show
@mailing = Mailing.find(params[:id])
end
def new
@mailing = Mailing.new params[:maili... | Ruby |
class Admin::Newsletter::HtmlNewsletterController < Admin::Newsletter::EmailsController
before_filter :set_page_title
access_control :DEFAULT => 'email'
def index
#@html_job_newsletters = HtmlJobNewsletter.find(:all)
@newsletters = HtmlNewsletter.find(:all)
end
def new
@html_newsletter = Ht... | Ruby |
require 'tab.rb'
class Admin::Newsletter::EmailsController < Admin::BaseController
before_filter :tab
access_control :DEFAULT => 'email'
private
def tab
# TABS : one tab rendered for each tabs objects in @tabs instance variable
@tabs = [
Tab.new(l('EMAILS'),"newsletter","index"),
Tab.new(l(... | Ruby |
require 'faster_csv'
class Admin::Newsletter::ImportController < Admin::Newsletter::EmailsController
before_filter :set_page_title
access_control :DEFAULT => 'email_admin'
def index
@csv_files = CsvFile.find(:all)
end
def new
@csv_file = CsvFile.new
end
def show
@csv_file = CsvFile.fi... | Ruby |
class Admin::Newsletter::ListController < Admin::Newsletter::EmailsController
before_filter :set_page_title
access_control :DEFAULT => 'email_admin'
def index
@lists = Mailinglist.find(:all)
end
def show
@list = Mailinglist.find(params[:id])
end
def new
@list = Mailinglist.new params... | Ruby |
class Admin::BaseController < ApplicationController
layout 'admin'
include AuthenticatedSystemUser
before_filter :login_required
access_control :DEFAULT => 'user'
protected
def permission_denied
redirect_to :controller => '/account', :action => 'denied'
return false
end
end
| Ruby |
require 'tab.rb'
class Admin::Cms::CmsController < Admin::BaseController
before_filter :tab
access_control :DEFAULT => 'cms'
private
def tab
# TABS : one tab rendered for each tabs objects in @tabs instance variable
@tabs = [
Tab.new(l('ARTICLES'),"pages","index"),
Tab.new(l('CATEGORIES'),... | Ruby |
class Admin::Cms::CategoriesController < Admin::Cms::CmsController
access_control [:edit, :new, :delete] => 'cms_admin'
def index
list
render_action 'list'
end
def list
@categories = Category.root
end
def show
@categories = Category.find_by_permalink(params[:id]) || Category.find(params[:id])
@ar... | Ruby |
class Admin::Cms::PagesController < Admin::Cms::CmsController
access_control [:publish, :unpublish, :archive, :unarchive, :delete ] => 'cms_admin'
cache_sweeper :article_sweeper, :only => [:new, :edit,
:tag, :publish, :unpublish, :archive, :unarchive, :delete, :upload_image, :upload_attachment]
def in... | Ruby |
class Admin::Cms::SearchController < Admin::Cms::CmsController
def index
end
def result
if request.post?
@articles = Article.private_search(params[:query])
else
redirect_to :action => :index
end
end
end
| Ruby |
class ArticlesController < ApplicationController
caches_page :show
layout "home"
before_filter :get_nav_categories, :except => :test_rss
before_filter :get_regions, :except => :test_rss
def show
@article = Article.ez_find(:first) do |article|
article.published == 1
article.permalink ... | Ruby |
class RegionController < ApplicationController
caches_page :show, :article
layout "home"
before_filter :get_nav_categories
before_filter :get_regions
before_filter :get_current_region, :except => "index"
before_filter :reaction, :only => "article"
def index
default_region = Category.find_by_perm... | Ruby |
class AccountController < ApplicationController
include AuthenticatedSystemUser
layout 'login'
observer :user_observer
def index
redirect_to(:action => 'signup') unless logged_in? or User.count > 0
end
def login
return unless request.post?
self.current_user = User.authenticate(params[:login], ... | Ruby |
class AgendaController < ApplicationController
before_filter :get_nav_categories
before_filter :get_regions
def index
@article = Article.ez_find(:first) do |article|
article.published == 1
article.permalink == "agenda"
end
if @article.nil? then
flash[:warning] = "page not fo... | Ruby |
require 'localization_settings'
require 'switch_language'
require 'lib_cms'
require 'additional_tag_functions'
require 'caboose_memcached'
class ApplicationController < ActionController::Base
include LocalizationSettings
include ExceptionNotifiable
include CabooseMemcached
include Franck::SwitchLanguage
incl... | 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 |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/breakpointer' | Ruby |
#!/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/runner' | 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/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/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/breakpointer' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate' | Ruby |
#!/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/process/reaper'
| 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/reaper'
| 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/destroy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
class CreateNewsletterMembers < ActiveRecord::Migration
def self.up
create_table :newsletter_members, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :email, :string
end
end
def self.down
drop_table :newsletter_members
end
end
| Ruby |
class AddIndexes < ActiveRecord::Migration
def self.up
add_index :articles, :published
add_index :articles, :permalink
add_index :categories, :permalink
add_index :taggings, :taggable_id
add_index :taggings, :tag_id
add_index :tags, :name
end
def self.down
remove_index :... | Ruby |
class CreateMailinglist < ActiveRecord::Migration
def self.up
create_table :mailinglists, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column "name", :string
end
create_table :ml_members, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column "email", :string
end
create_table :mai... | Ruby |
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles, :force => true, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :category_id, :integer
t.column :title, :string
t.column :author, :string
t.column :excerpt, :text
t.column :excerpt_html, :text
t.column :body... | Ruby |
class CreateEmails < ActiveRecord::Migration
def self.up
create_table :emails do |t|
t.column :from, :string
t.column :to, :string
t.column :last_send_attempt, :integer, :default => 0
t.column :mail, :text
end
end
def self.down
drop_table :emails
end
end
| Ruby |
class CreateHtmlNewsletter < ActiveRecord::Migration
def self.up
create_table :html_newsletters, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :title, :string
t.column :from, :string
t.column :subject, :string
t.column :body_head, :text
t.column :body_head_html, :text
t.column :... | Ruby |
class AddAuthenticatedTable < ActiveRecord::Migration
def self.up
create_table "users", :force => true, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :login, :string, :limit => 40
t.column :email, :string, :limit => 100
t.column :crypted_password, :string, :limit => 40... | Ruby |
class CreateMailings < ActiveRecord::Migration
def self.up
create_table :mailings do |t|
t.column :from, :string
t.column :to, :text
t.column :subject, :string
t.column :body, :text
end
end
def self.down
drop_table :mailings
end
end
| Ruby |
class CreateCsvFiles < ActiveRecord::Migration
def self.up
create_table :csv_files, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column "content_type", :string
t.column "filename", :string
t.column "size", :integer
t.column "format", :string
end
end
def self.down
drop_tab... | Ruby |
class CreateAttachments < ActiveRecord::Migration
def self.up
create_table :attachments, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :article_id, :integer
t.column :file, :string
end
end
def self.down
drop_table :attachments
end
end
| Ruby |
class CreateNewsletterMemberSectors < ActiveRecord::Migration
def self.up
create_table :newsletter_member_sectors, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :newsletter_member_id, :integer
t.column :sector_id, :integer
end
end
def self.down
drop_table :newsletter_member_sectors
... | Ruby |
class AddStructureForTaggings < ActiveRecord::Migration
def self.up
create_table :taggings, :force => true, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :taggable_id, :integer
t.column :tag_id, :integer
t.column :taggable_type, :string
end
create_table :tags, :force => true, :options => 'DEFAUL... | Ruby |
class AddSessions < ActiveRecord::Migration
def self.up
create_table :sessions, :force => true, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
add_index :sessions, :session_id
end
def self.down
... | Ruby |
class CreateImages < ActiveRecord::Migration
def self.up
create_table :images, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :article_id, :integer
t.column :name, :string
end
end
def self.down
drop_table :images
end
end
| Ruby |
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories, :force => true, :options => 'DEFAULT CHARSET=UTF8' do |t|
t.column :name, :string
t.column :parent_id, :integer
t.column :position, :integer
t.column :permalink, :string
end
db_name = ActiveRecord::Base::co... | Ruby |
module Franck
module CMS
end
end | Ruby |
module AuthenticatedSystem
protected
def logged_in?
current_user
end
# Accesses the current user from the session.
def current_user
@current_user ||= session[:user] ? User.find_by_id(session[:user]) : nil
end
# Store the given user in the session.
def current_user=(new_user)
session[:user]... | Ruby |
module CabooseMemcached
def memcache_me(key, timeout=600, &blk)
unless defined?CACHE # no memcache
return block_given? ? yield : nil
end
# no block given, just delete the cache
unless block_given?
CACHE.delete(key)
return
end
# cache hit, block was not evalua... | Ruby |
# =============================================================================
# A set of rake tasks for invoking the Capistrano automation utility.
# =============================================================================
# Invoke the given actions via Capistrano
def cap(*parameters)
begin
require 'rubyg... | Ruby |
desc 'cms init'
task :cms_init => [
:create_root_category,
:create_roles,
:create_admin_user,
:activate_all_users
]
desc "add email and email_admin roles"
task :add_email_role => :environment do
Role.find_or_create_by_title("email_admin")
Role.find_or_create_by_title("email")
end
desc 'create... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = users(user).id
end
# Assert the block redirects to the login
#
# assert_requires_login(:bob) { get :edit, :id => 1 }
#
def assert_requires_login(user = nil, ... | Ruby |
module AuthenticatedUserTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = users(user).id
end
# Assert the block redirects to the login
#
# assert_requires_login(:bob) { get :edit, :id => 1 }
#
def assert_requires_login(user = n... | Ruby |
require 'localization_settings'
module Franck
module SwitchLanguage
def locale
if not session['lang'].nil?
LocalizationSettings::CONFIG[:default_language] = session['lang']
else
session['lang'] = 'fr'
end
end
# store current uri in the session.
# we ... | Ruby |
module AuthenticatedSystemUser
protected
def logged_in?
current_user
end
# Accesses the current user from the session.
def current_user
@current_user ||= session[:user] ? User.find_by_id(session[:user]) : nil
end
# Store the given user in the session.
def current_user=(new_user)
session[:u... | Ruby |
module Franck
module AdditionalTagFunctions
def get_article_by_tags(wanted_tags)
article = []
article << Article.find_by_tag(wanted_tags)
#article << Offer.find_by_tag(wanted_tags)
article.flatten!
article.compact!
article.collect! do |a|
tags = a.tags.collect d... | Ruby |
class String
# Converts a post title to its-title-using-dashes
# All special chars are stripped in the process
def to_url
return if self.nil?
result = self.downcase
# replace quotes by nothing
result.gsub!(/['"]/, '')
# strip all non word chars
result.gsub!(/\W/, ' ')
... | Ruby |
require 'iconv'
module LocalizationSettings
LOCALIZED_STRINGS = {}
def l(symbol, *arguments)
language = CONFIG[:default_language]
symbol = symbol.to_sym if symbol.is_a? String
# translation of an LString is simply a call to to_s
return symbol.to_s if symbol.is_a? LString
# translation ... | Ruby |
#/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
req... | Ruby |
#!/usr/bin/env ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.