code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# 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 |
# 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 =~ /(:?mswin|mingw)/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
... | Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... | Ruby |
module AdminHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# Similar to ActionView::Helpers::FormHelper#form_for, but automatically sets
# the :url and :html => :method options so that the same form can be easily
# used for creating and editing a model controll... | Ruby |
module StylesheetsHelper
end
| Ruby |
module ImagesHelper
end
| Ruby |
module UsersHelper
end | Ruby |
module SessionsHelper
end | Ruby |
module PostsHelper
def render_post(post, options = {})
render(:partial => 'viewer', :locals => {:post => post})
end
end
| Ruby |
module BlogsHelper
end
| Ruby |
class System
def self.default_blog
default_blog_id = global_setting('default_blog')
if default_blog_id
Blog.find(default_blog_id)
else
Blog.find(:all).first
end
end
# Convenience method for retrieving a setting for a given blog.
# The blog argument can be a numeric blog ID, a... | Ruby |
class Privilege < ActiveRecord::Base
end
| Ruby |
class Blog < ActiveRecord::Base
has_many :privileges
has_many :users, :through => :privileges
has_many :settings
has_many :tags
def skin
Skin.find(setting('skin') || 'yarbo')
end
def setting(name)
System.blog_setting(self, name)
end
end
| Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
has_many :privileges
has_many :blogs, :through => :privileges
has_many :posts,
:foreign_key => 'author_id',
:dependent => :nullify
# Virtual attribute for the unencrypted password
attr_accessor :password
validates_presence_of :login, :em... | Ruby |
class Tag < ActiveRecord::Base
end
| Ruby |
# Join model for the Tag-Post relation.
# In other words, this designates a Post that has been tagged by some Tag.
#
# The relationship is a full model rather than just a a relation table
# in case we want to implement more sophisticated tagging functionality
# at some point in the future.
class TagPost < ActiveRecord... | Ruby |
class Setting < ActiveRecord::Base
belongs_to :blog
# True if this is a global, system-wide setting (i.e. if the setting doesn't
# belong to any particular Blog).
def global?
blog_id.nil?
end
end
| Ruby |
require 'active_support'
# Represents a skin (a look & feel for the front-end of the website), which is
# essentially a directory of templates under <tt>/vendor/skins/</tt>.
# The interface is vaguely ActiveRecord-like (but read-only).
class Skin
cattr_accessor :skin_path
@@skin_path = "#{RAILS_ROOT}/vendor/sk... | Ruby |
gem 'acts_as_taggable', '>= 2.0.2'
gem 'coderay', '>= 0.7.4'
gem 'RedCloth'
require 'taggable'
require 'coderay'
require 'redcloth'
require 'ostruct'
class Post < ActiveRecord::Base
belongs_to :user, :foreign_key => 'author_id'
belongs_to :blog
acts_as_taggable :join_class_name => 'TagPost'
def body
Bo... | Ruby |
class ImagesController < ApplicationController
def show
if name = params[:filename]
render(:file => current_skin.image(filename),
:content_type => "text/css", :disposition => 'inline',
:filename => "#{name}.css")
else
render(:nothing => true, :status => 404)
end
end
end
| Ruby |
class PostsController < ApplicationController
include Skinning
before_filter :login_required, :except => [:index, :show]
before_filter :blog_required
# GET /posts
# GET /posts.xml
def index
@posts = Post.find(:all, :conditions => ["blog_id = ?", current_blog.id])
respond_to do |format|
... | Ruby |
class AdminController < ApplicationController
before_filter :login_required
def index
end
end
| Ruby |
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
include Skinning
# If you want "remember me" functionality, add this before_filter to Application Controller
before_filter :login_from_cookie
# render new.rhtml
def new
end
def create
... | Ruby |
class BlogsController < ApplicationController
before_filter :login_required
# GET /blogs
# GET /blogs.xml
def index
@blogs = Blog.find(:all)
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @blogs.to_xml }
end
end
# GET /blogs/1
# GET /blogs/1.xml
... | Ruby |
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# include authentication subsystem from restful_authentication plugin
include AuthenticatedSystem
be... | Ruby |
class UsersController < ApplicationController
include Skinning
# If you want "remember me" functionality, add this before_filter to Application Controller
before_filter :login_from_cookie
# render new.rhtml
def new
end
def create
@user = User.new(params[:user])
@user.save!
self.current_u... | Ruby |
class StylesheetsController < ApplicationController
def show
if name = params[:name]
render(:file => current_skin.stylesheet(name),
:content_type => "text/css", :disposition => 'inline',
:filename => "#{name}.css")
else
render(:nothing => true, :status => 404)
end
end
end
| 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/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'
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/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'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin' | Ruby |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.column :author_id, :integer
t.column :blog_id, :integer, :null => false
t.column :title, :string
t.column :created_on, :datetime
t.column :body, :text
t.column :posted, :boolean, :null => false... | Ruby |
class CreateSettings < ActiveRecord::Migration
def self.up
create_table :settings do |t|
t.column :blog_id, :integer
t.column :name, :string, :null => false
t.column :value, :string, :null => false
end
add_index :settings, [:blog_id, :name, :value], :unique => true
end
def self... | Ruby |
class CreatePrivileges < ActiveRecord::Migration
def self.up
create_table :privileges do |t|
t.column :user_id, :integer, :null => false
t.column :blog_id, :integer, :null => false
t.column :read, :boolean, :null => false, :default => true
t.column :write, :boolean, :null => false, ... | Ruby |
class CreateTagPosts < ActiveRecord::Migration
def self.up
create_table :tag_posts do |t|
t.column :post_id, :integer, :null => false
t.column :tag_id, :integer, :null => false
t.column :created_on, :datetime
t.column :tagged_by, :string # user_id of the user who did the tagging
end
... | Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :login, :string, :null => false
t.column :crypted_password, :string, :limit => 40
t.column :display, :string
t.column :email, :string
t.column :salt, :string, :limit => 40
t.column :crea... | Ruby |
class CreateTags < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.column :name, :string, :null => false
t.column :created_on, :datetime
t.column :created_by, :integer # user_id of the user who created this tag
t.column :blog_id, :integer # null if this is a global tag
... | Ruby |
class CreateBlogs < ActiveRecord::Migration
def self.up
create_table :blogs do |t|
t.column :name, :string
t.column :title, :string
t.column :subtitle, :string
end
add_index :blogs, [:name], :unique => true
end
def self.down
drop_table :blogs
end
end
| Ruby |
class PopulateWithDefaultBlog < ActiveRecord::Migration
def self.up
Blog.create(:name => 'myblog', :title => "My Blog", :subtitle => "Configure this blog to change this subtitle!")
User.create(:login => 'blogger', :password => 'yarbo!', :password_confirmation => 'yarbo!')
end
def self.down
Blog.find_... | Ruby |
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
(@current_user ||= session[:user] ? User.find_by_id(session[:user]) : :false).is_a?(User)
end
# Accesses the current u... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = user ? users(user).id : nil
end
def content_type(type)
@request.env['Content-Type'] = type
end
def accept(accept)
@request.env["HTTP_ACCEPT"] = accept
en... | Ruby |
# Adds skinning support when included in a controller.
#
# This works by overriding the controller's render method so that a template
# from the current skin is used (if the skin template is present, otherwise
# the default template is used as normal).
#
# Note that by default this also adds :layout => 'blog' to ever... | Ruby |
# do better error highlighting
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
msg = instance.error_message
error_class = "fieldWithErrors"
if html_tag =~ /<(input|textarea|select)[^>]+class=/
class_attribute = html_tag =~ /class=['"]/
html_tag.insert(class_attribute + 7, "#{error_cla... | 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
re... | 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
re... | Ruby |
#!/usr/bin/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
# an... | 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
re... | 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
re... | Ruby |
#!/usr/bin/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
# an... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#
# setup.rb
#
# Copyright (c) 2000-2005 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
#
unless Enumerable.method_defined?(:map) # Ruby 1.4.6
module Enumerable
alias map collect
end
end
un... | Ruby |
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'fileutils'
require 'hoe'
include FileUtils
require File.join(File.dirname(__FILE__), 'lib', 'yarbo', 'version... | Ruby |
# Misc utility function used throughout by Yarbo.
module Yarbo
module Utils
def random_string
"#{Time.now.to_i}r%X" % rand(10**32)
end
module_function :random_string
class Logger < ::Logger
def initialize(logdev, shift_age = 0, shift_size = 1048576)
begin
super
... | Ruby |
module Fluxr #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 0
TINY = 1
STRING = [MAJOR, MINOR, TINY].join('.')
end
end
| Ruby |
require 'camping/db'
gem 'acts_as_taggable'
require 'taggable'
module Yarbo::Models
class Tag < Base
end
class TagPost < Base
end
class Post < Base
acts_as_taggable :tag_class_name => "Yarbo::Models::Tag",
:join_class_name => 'TagPost'
def body
Body.new(super)
end
... | Ruby |
# load configuration
begin
if $CONFIG_FILE
conf_file = $CONFIG_FILE
else
conf_file = etc_conf = "/etc/yarbo/config.yml"
unless File.exists? conf_file
# can use local config.yml file in case we're running non-gem installation
conf_file = File.dirname(File.expand_path(__FILE__))+"/../../confi... | Ruby |
module Yarbo::Controllers
class Blog < R '/'
def get
end
def post
end
end
class Themes < R '/themes/(.+)'
MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript',
'.jpg' => 'image/jpeg', '.png' => 'image/png',
'.... | Ruby |
Markaby::Builder.set(:indent, 2)
module Yarbo::Views
def layout
xhtml_strict do
head do
title { @title }
link(:rel => "stylesheet", :type => "text/css", :href => "/themes/yarbo.css")
link(:rel => "stylesheet", :type => "text/css", :href => "/themes/#{current_theme}/theme.css")
... | Ruby |
#!/usr/bin/env ruby
# change to current directory when invoked on its own
Dir.chdir(File.dirname(File.expand_path(__FILE__))) if __FILE__ == $0
# add current directory to load path
$FLUXR_HOME = File.dirname(File.expand_path(__FILE__))
$: << $FLUXR_HOME
require 'rubygems'
gem 'camping', '~> 1.5'
require 'camping'
r... | Ruby |
#!/usr/bin/env ruby
# change to current directory when invoked on its own
Dir.chdir(File.dirname(File.expand_path(__FILE__))) if __FILE__ == $0
# add current directory to load path
$FLUXR_HOME = File.dirname(File.expand_path(__FILE__))
$: << $FLUXR_HOME
require 'rubygems'
gem 'camping', '~> 1.5'
require 'camping'
r... | Ruby |
require 'test/unit'
require File.dirname(__FILE__) + '/../lib/yarbo'
| Ruby |
require 'net/http'
require 'uri'
require 'mechanize'
class Hub
attr_reader :endpoint
def initialize(endpoint)
@endpoint = URI.parse(endpoint)
@endpoint.path = '/' if @endpoint.path.empty?
# This is for a hack to deal with non-auto running tasks on App Engine!?
@is_gae = Net::HTTP.get(@endp... | Ruby |
require 'webrick'
class Subscriber
PORT = 8089
VERIFY_TOKEN = 'qfwef9'
attr_reader :callback_url
attr_accessor :onrequest
def initialize(hub)
@hub = hub
@server = WEBrick::HTTPServer.new(:Port => PORT, :Logger => WEBrick::Log.new(nil, 0), :AccessLog => WEBrick::Log.new(nil, 0))
@callback_ur... | Ruby |
ActiveRecord::Base.establish_connection(
:adapter => ENV['YAPTESTFE_DBTYPE'],
:host => ENV['YAPTESTFE_DBIP'],
:port => ENV['YAPTESTFE_DBPORT'].to_i,
:username => ENV['YAPTESTFE_DBUSER'],
:password => ENV['YAPTESTFE_DBPASS'],
:database => ENV['... | 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 |
# 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... | 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 |
ActionController::Routing::Routes.draw do |map|
map.resources :icmps
map.resources :hosts_to_mac_addresses
map.resources :mac_addresses
map.resources :db
map.resources :help
map.resources :host_keys
map.resources :topologys
map.resources :host_info_keys
map.resources :tablen
map.resources :... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def filter_icon (tool_tip, param_v, link_opts={})
# If we aren't currely filtering on this field, print the filter icon
if param_v.nil?
return link_to(image_tag("filter.png", :align => 'absmiddle')... | Ruby |
module PortsHelper
end
| Ruby |
module TransportProtocolsHelper
end
| Ruby |
module MacAddressesHelper
end
| Ruby |
module IcmpsHelper
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.