code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module AlbumsHelper
end
| Ruby |
module NotesHelper
end
| Ruby |
module EventsHelper
def days_array(time, fill_blank=false)
returning [] do |arr|
0.upto(time.beginning_of_month.wday-1) { arr << nil } if fill_blank
1.upto(Time.days_in_month(time.month)) { |day| arr << day }
end.flatten
end
def taggings_for(time, day, events=[])
unless day.nil?
tim... | Ruby |
module UsersHelper
#
# Use this to wrap view elements that the user can't access.
# !! Note: this is an *interface*, not *security* feature !!
# You need to do all access control at the controller level.
#
# Example:
# <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> ... | Ruby |
module EntriesHelper
end
| Ruby |
module BlogHelper
end
| Ruby |
module PhotosHelper
def photo_thumbnail(photo)
if photo
image_tag photo.public_filename(:thumb), :title => photo.title
else
image_tag 'photo_thumb_70.png'
end
end
def lightbox(photo)
#<a href="#{photo.public_filename}" class="lightbox" title="#{photo.title || '제목 없음'}">
#<img sr... | Ruby |
module MenuHelper
end
| Ruby |
module SessionsHelper
end | Ruby |
module AssetsHelper
end
| Ruby |
module Admin::UsersHelper
def role_list
Role.all.map { |role| role.name[0..2] }.join('/')
end
def check_roles(user)
returning([]) do |arr|
Role.all.each do |role|
arr << check_box_tag("role", "1", user.has_role?(role), :onclick => toggle_value(user, role) )
end
end.join(' / ')
... | Ruby |
module Admin::BoardsHelper
end
| Ruby |
module PostsHelper
def markitup(selector='textarea', type='textile')
<<-HERE
<script type="text/javascript" src="/markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="/markitup/sets/#{type}/set.js"></script>
<link rel="stylesheet" type="text/css" href="/markitup/skins/simple/styl... | Ruby |
module CommentsHelper
def display_comments(comments, parent_id, commentable_id)
ret = "\n<ul class=\"comments\" id=\"comment_#{commentable_id}_#{parent_id || 0 }\">"
comments.each do |comment|
if comment.parent_id == parent_id
ret += "\n\t<li>"
ret += yield comment
ret += displa... | Ruby |
module PasswordsHelper
end
| Ruby |
module PagesHelper
def wikilize(text)
text.gsub(/\[\[(.*?)\]\]/, '<a href="/pages?title=\1" class="wikiword">\1</a>')
end
def strip_wiki(text)
text.gsub(/\[\[(.*?)\]\]/, '\1')
end
def strip_tags_and_wiki(text)
strip_wiki(strip_tags(text))
end
# def intelli_path(page)
# if page.... | Ruby |
class Album < Board
belongs_to :user
has_many :photos, :foreign_key => 'board_id', :order => 'id DESC' # Do not use timestamp!!
end
| Ruby |
class OpenLevel
PRIVATE=0
LIST_ONLY=2
READ_ONLY=3
PUBLIC=999
def self.options
[['비공개', PRIVATE], ['목록만 공개', LIST_ONLY], ['내용 공개', READ_ONLY], ['완전공개', PUBLIC]]
end
end | Ruby |
class Page < ActiveRecord::Base
simply_versioned :keep => 10 #, :automatic => false
acts_as_viewed
acts_as_textiled :body
belongs_to :user
has_many :comments, :as => :commentable
has_and_belongs_to_many :titles
has_many :assets, :foreign_key => 'page_id', :conditions => "type = 'Asset'"
validates_pre... | Ruby |
class UserMailer < ActionMailer::Base
def signup_notification(user)
setup_email(user)
@subject << '가입하신 계정을 활성화하세요!'
@body[:url] = "#{APP_CONFIG[:site_url]}/activate/#{user.activation_code}"
end
def activation(user)
setup_email(user)
@subject << '계정이 성공적으로 활성화되었습니다!'
@body[:url] = APP_C... | Ruby |
class Event < Page
named_scope :month, lambda { |time| {
:conditions => ['started_at BETWEEN ? AND ?', time.beginning_of_month, time.end_of_month],
:order => 'started_at'
}}
def date; started_at end
end | Ruby |
class Photo < Asset
belongs_to :album, :foreign_key => 'board_id', :counter_cache => :assets_count, :dependent => :destroy
has_many :comments, :as => :commentable
has_attachment :content_type => :image,
:storage => :file_system,
:path_prefix => 'public/photos',
... | Ruby |
class Board < ActiveRecord::Base
has_many :posts
validates_presence_of :title
named_scope :pure_boards, { :conditions => "type = 'Board'" }
def is_public?
self.open_level == OpenLevel::PUBLIC
end
end
| Ruby |
class Title < ActiveRecord::Base
has_and_belongs_to_many :pages
named_scope :of, lambda { |text| { :conditions => ['REPLACE(text, " ", "") = ?', text.gsub(' ', '')] }}
end
| Ruby |
class Note < ActiveRecord::Base
belongs_to :user, :counter_cache => true
belongs_to :board, :counter_cache => true
has_many :comments, :as => :commentable
acts_as_textiled :body
validates_presence_of :body
named_scope :recent, lambda { |*args| { :limit => args.first || 5, :order => 'created_at DESC', :... | Ruby |
require 'digest/sha1'
class Password < ActiveRecord::Base
belongs_to :user
attr_accessor :email
validates_presence_of :email, :user
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => 'is not a valid email address'
protected
def before_create
self.reset_code =... | Ruby |
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true, :counter_cache => true, :dependent => :destroy
belongs_to :user
#acts_as_textiled :text
acts_as_nested_set :scope => :commentable_id
def commentable_name
(commentable.has_attribute?(:type) ? commentable[:type] : comm... | Ruby |
class Role < ActiveRecord::Base
def to_s; name end
end | Ruby |
class Asset < ActiveRecord::Base
belongs_to :page, :foreign_key => 'page_id', :counter_cache => true, :dependent => :destroy
has_attachment :storage => :file_system,
:path_prefix => 'assets',
:max_size => 100.megabytes
validate :attachment_valid?
named_scope :recent, lambd... | Ruby |
class PasswordMailer < ActionMailer::Base
def forgot_password(password)
setup_email(password.user)
@subject << '비밀번호 변경을 요청하셨습니다.'
@body[:url] = "#{APP_CONFIG[:site_url]}/change_password/#{password.reset_code}"
end
def reset_password(user)
setup_email(user)
@subject << '비밀번호가 초기화되었습니다.'
end... | Ruby |
class PostObserver < ActiveRecord::Observer
def after_save(post)
PostMailer.deliver_notify(post) if post.noti? && !post.do_not_apply_callback
end
end
| Ruby |
class Menu
MENU_FILE = "#{RAILS_ROOT}/config/menu.textile"
@@html = nil
def self.html; @@html || refresh end
def self.textile; File.new(MENU_FILE).read end
def self.refresh(text=nil)
File.open(MENU_FILE, 'w') {|f| f.write(text) } unless text.blank?
@@html = RedCloth.new(textile).to_html
end
end
| Ruby |
class PostMailer < ActionMailer::Base
def notify(post)
subject post.title
from APP_CONFIG[:admin_email]
recipients User.all.map(&:email)
sent_on post.updated_at
body :post => post,
:post_url => make_post_url(post)
content_type "text/html"
end
priv... | Ruby |
class UserObserver < ActiveRecord::Observer
def after_create(user)
UserMailer.deliver_signup_notification(user)
end
def after_save(user)
UserMailer.deliver_activation(user) if user.recently_activated?
end
end
| Ruby |
class Post < Page
belongs_to :board, :counter_cache => true
# self-referential replies
has_many :replies, :class_name => "Post", :foreign_key => "parent_id", :order => 'created_at'
belongs_to :post, :class_name => "Post", :foreign_key => "parent_id", :counter_cache => 'replies_count', :dependent => :destroy
... | Ruby |
class PhotosController < ApplicationController
before_filter :login_required
def show
@album = Album.find(params[:album_id])
@photo = @album.photos.find(params[:id])
end
def update
@photo = Photo.find(params[:id])
respond_to do |format|
if @photo.update_attributes(params[:photo])
... | Ruby |
class AlbumsController < ApplicationController
before_filter :login_required
PER_PAGE = 7
PHOTO_PER_PAGE = 12
def index
@albums = Album.paginate :page => params[:page], :per_page => PER_PAGE, :order => 'updated_at DESC'
@albums_count = Album.count
end
def show
@album = Album.find(params[:id])
... | Ruby |
class RolesController < ApplicationController
require_role "admin"
def update
@user = User.find_by_login(params[:user_id])
@role = Role.find(params[:id])
if params[:role] == true
@user.roles << @role
else
@user.roles.delete @role
end
respond_to do |format|
format.js { he... | Ruby |
class RepliesController < ApplicationController
before_filter :login_required
before_filter :find_post
def create
@reply = @post.replies.build(params[:reply])
@reply.user = current_user
@reply.save
redirect_to :back
end
def destroy
@reply = current_user.replies.find(params[:id])
@rep... | Ruby |
class PasswordsController < ApplicationController
def new
@password = Password.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @password }
end
end
def create
@password = Password.new(params[:password])
@password.user = User.find_by_email(@p... | Ruby |
class AssetsController < ApplicationController
before_filter :login_required
def show
@asset = Asset.find(params[:id])
send_file @asset.full_filename, :filename => @asset.filename, :type => @asset.content_type, :disposition => 'inline'
end
def download
send_file @asset.full_filename, :filename... | Ruby |
class PostsController < ApplicationController
#before_filter :login_required, :except => [:home]
before_filter :find_board, :except => [:home]
before_filter :check_open_level, :except => [:home]
PER_PAGE = 10
def home
@posts = Post.pure_posts.recent
@popular_posts = Post.popular_posts.all :limit... | Ruby |
class CommentsController < ApplicationController
#before_filter :login_required
include PolymorphicParent
parent_resources :note, :photo, :page, :event
# HTML tagging conventions for adding comments (in view)
# ...
# <%= link_to_function "댓글", "add_comment('#{note_comments_path(note)}')" if logged_in? %... | Ruby |
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# render new.rhtml
def new
end
def create
logout_keeping_session!
user = User.authenticate(params[:login], params[:password])
if user
# Protects against session fixation attack... | Ruby |
class Admin::BoardsController < ApplicationController
require_role "admin"
def index
@boards = Board.pure_boards
end
def show
@board = Board.find(params[:id])
end
def new
@board = Board.new
end
def edit
@board = Board.find(params[:id])
end
def create
@board = Board.new(par... | Ruby |
class Admin::MenuController < ApplicationController
require_role "admin"
def edit
@text = Menu.textile
end
def save
Menu.refresh(params[:menu_text])
redirect_to :back
end
end
| Ruby |
class Admin::UsersController < ApplicationController
require_role "admin"
def index
@users = User.all :order => 'created_at DESC'
end
end
| Ruby |
class EventsController < ApplicationController
before_filter :login_required
make_resourceful do
actions :all
end
def create
@event = Event.new(params[:event])
@event.user = current_user
if @event.save
redirect_to @event
else
render :action => 'new'
end
end
priva... | Ruby |
class NotesController < ApplicationController
before_filter :login_required #, :except => [:index]
PER_PAGE = 15
def index
@notes = Note.paginate :page => params[:page], :per_page => PER_PAGE,
:order => 'created_at DESC', :include => [:user, {:comments => [:user, :commentable]}]... | Ruby |
class PagesController < ApplicationController
before_filter :login_required, :except => [:show]
def index
if title = params[:title]
pages = Page.titled(title)
if pages.empty?
new
@page.title = title
render :action => 'new'
elsif pages.size > 1
@pages = Page.t... | Ruby |
class BlogsController < ApplicationController
def show
@pages = Page.bloggings.recent
end
end
| Ruby |
class EntriesController < ApplicationController
# just a concept(customizing is required)
def show
@page = Page.find(params[:id])
render :template => 'pages/show'
end
end
| 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
include ExceptionNotifiable
include AuthenticatedSystem
include RoleRequirementSystem
# HTTP Basic Auth ... | Ruby |
class UsersController < ApplicationController
PER_PAGE = 20
# Protect these actions behind an admin login
require_role "admin", :only => [:suspend, :unsuspend, :destroy, :purge, :activate]
before_filter :login_required, :except => [:new, :create, :activate]
before_filter :find_user, :only => [:activate, :... | 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/dbconsole'
| 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/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/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/plugin'
| 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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| 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/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/inspector'
| 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/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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :string, ... | Ruby |
class AddAttachableToBoard < ActiveRecord::Migration
def self.up
add_column :boards, :attachable, :boolean, :default => false
end
def self.down
remove_column :boards, :attachable
end
end
| Ruby |
class AddVisitorToPage < ActiveRecord::Migration
def self.up
add_column :pages, :visitor, :string
end
def self.down
remove_column :pages, :visitor
end
end
| Ruby |
class AddStartedAtToPage < ActiveRecord::Migration
def self.up
add_column :pages, :started_at, :datetime
end
def self.down
remove_column :pages, :started_at
end
end
| Ruby |
class CreateBoards < ActiveRecord::Migration
def self.up
create_table :boards do |t|
t.string :title
t.string :name
t.string :description
t.integer :posts_count, :default => 0
t.timestamps
end
add_column :posts, :board_id, :integer
end
def self.down
drop_table :boar... | Ruby |
class RenamePostToPageForSti < ActiveRecord::Migration
def self.up
rename_table :posts, :pages
add_column :pages, :type, :string
end
def self.down
remove_column :pages, :type
rename_table :pages, :posts
end
end
| Ruby |
class AddSomeProfileToUser < ActiveRecord::Migration
def self.up
add_column :users, :nickname, :string
add_column :users, :homepage, :string
add_column :users, :messenger, :string
add_column :users, :phone, :string
add_column :users, :memo, :text
end
def self.down
remove_column :users, :n... | Ruby |
class CreatePasswords < ActiveRecord::Migration
def self.up
create_table "passwords" do |t|
t.integer :user_id
t.string :reset_code
t.datetime :expiration_date
t.timestamps
end
end
def self.down
drop_table "CreatePasswords"
end
end
| Ruby |
class AddAssetsCountAndPageIdToPage < ActiveRecord::Migration
def self.up
add_column :pages, :assets_count, :integer, :default => 0
add_column :assets, :page_id, :integer
end
def self.down
remove_column :pages, :assets_count
remove_column :assets, :page_id
end
end
| Ruby |
class AddCollaborableToPage < ActiveRecord::Migration
def self.up
add_column :pages, :collaborable, :boolean, :default => false
end
def self.down
remove_column :pages, :collaborable
end
end
| Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.text :text
t.integer :user_id
t.column :commentable_id, :integer
t.column :commentable_type, :string
t.timestamps
end
end
def self.down
drop_table :comments
end
end
| Ruby |
class AddAvatarColumnsToUser < ActiveRecord::Migration
def self.up
add_column :users, :avatar_file_name, :string
add_column :users, :avatar_content_type, :string
add_column :users, :avatar_file_size, :integer
add_column :users, :avatar_updated_at, :datetime
end
def self.down
remove_co... | Ruby |
class CreateNotes < ActiveRecord::Migration
def self.up
create_table :notes do |t|
t.text :body
t.integer :user_id
t.integer :comments_count, :default => 0
t.timestamps
end
add_column :users, :notes_count, :integer, :default => 0
add_column :boards, :notes_count, :integer, :de... | Ruby |
class AddTypeToAsset < ActiveRecord::Migration
def self.up
add_column :assets, :type, :string, :default => 'Asset'
end
def self.down
remove_column :assets, :type
end
end
| Ruby |
class AddLastLoginAtToUser < ActiveRecord::Migration
def self.up
add_column :users, :last_login_at, :datetime
end
def self.down
remove_column :users, :last_login_at
end
end
| Ruby |
class AddNameAndBloggingToPage < ActiveRecord::Migration
def self.up
add_column :pages, :name, :string
add_column :pages, :blogging, :boolean, :default => false
end
def self.down
remove_column :pages, :name
remove_column :pages, :blogging
end
end
| Ruby |
class AddCommentsCountToPage < ActiveRecord::Migration
def self.up
add_column :pages, :comments_count, :integer, :default => 0
end
def self.down
remove_column :pages, :comments_count
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.