This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def body_tag_class(more_class = "") | |
"#{params[:controller]}_cont #{params[:action]}_action #{'logged_in' if logged_in?} #{more_class}" | |
end | |
end | |
#usage | |
%html | |
%body{:class => open_body_tag} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.user_controls { display:none; } | |
body.logged_in .user_controls { display:block; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb | |
require 'open-uri' | |
def download(from, to = from.split("/").last) | |
#run "curl -s -L #{from} > #{to}" | |
file to, open(from).read | |
rescue | |
puts "Can't get #{from} - Internet down?" | |
exit! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if page.page_type == LinkContent && page.open_link_in_new %> | |
<%= link_to page.name, page.link_url, :class => "nav_link", :target => '_blank' %> | |
<% elsif page.page_type == LinkContent %> | |
<%= link_to page.name, page.link_url, :class => "nav_link" %> | |
<% else %> | |
<%= link_to page.name, page_path(page), :class => "nav_link#{ ' dd_hidden_page' if page.hidden }#{ ' dd_has_sub_pages' if page.has_sub_pages }" %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'yajl' | |
require 'yajl/http_stream' | |
require 'uri' | |
require 'observer' | |
module Twroute | |
class Tweeter | |
include Observable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def scheme_host(url) | |
begin | |
p_uri = URI.parse(url) | |
p_uri.scheme = 'http' | |
return nil if p_uri.host == 'http' | |
p_uri.host = url if !p_uri.host | |
p_uri.select(:scheme, :host).join('://') | |
rescue URI::InvalidURIError | |
nil | |
rescue URI::InvalidComponentError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%a - The abbreviated weekday name (``Sun'') | |
%A - The full weekday name (``Sunday'') | |
%b - The abbreviated month name (``Jan'') | |
%B - The full month name (``January'') | |
%c - The preferred local date and time representation | |
%C - Century (20 in 2009) | |
%d - Day of the month (01..31) | |
%D - Date (%m/%d/%y) | |
%e - Day of the month, blank-padded ( 1..31) | |
%F - Equivalent to %Y-%m-%d (the ISO 8601 date format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
# sudo gem install tilt --source http://gemcutter.org/ | |
require 'tilt' | |
# A simple Rack middleware which makes it super easy | |
# have a shared layout rendering system used across | |
# different rails applications. | |
# | |
# Examples: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
This is quick fix for getting Rails to recognize Chrome Frame XmlHttpRequests as | |
Ajax Requests so that the following code will work. | |
respond_to do |format| | |
format.js { render :text => "chrome frame won't normally see this" } | |
end | |
Use: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoWWW | |
STARTS_WITH_WWW = /^www\./i | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if env['HTTP_HOST'] =~ STARTS_WITH_WWW |
OlderNewer