Skip to content

Instantly share code, notes, and snippets.

View timriley's full-sized avatar
🇺🇦
Standing with Ukraine

Tim Riley timriley

🇺🇦
Standing with Ukraine
View GitHub Profile
get "/stylesheets/screen.css" do
content_type 'text/css'
# Use views/stylesheets & blueprint's stylesheet dirs in the Sass load path
sass :"stylesheets/screen", { :sass => { :load_paths => (
[ File.join(File.dirname(__FILE__), 'views', 'stylesheets') ] +
Compass::Frameworks::ALL.map { |f| f.stylesheets_directory })
} }
end
def sass(template, options={}, &block)
require 'sass' unless defined? ::Sass
options[:layout] = false
render :sass, template, options
end
def render_sass(template, data, options, &block)
engine = ::Sass::Engine.new(data, options[:sass] || {})
engine.render
end
get "/stylesheets/screen.css" do
content_type 'text/css'
sass :"stylesheets/screen"
end
get "/stylesheets/screen.css" do
content_type 'text/css'
response['Expires'] = (Time.now + 60*60*24*356*3).httpdate
sass :"stylesheets/screen"
end
helpers do
def versioned_stylesheet(stylesheet)
"/stylesheets/#{stylesheet}.css?" + File.mtime(File.join(Sinatra::Application.views, "stylesheets", "#{stylesheet}.sass")).to_i.to_s
end
def versioned_js(js)
"/javascripts/#{js}.js?" + File.mtime(File.join(Sinatra::Application.public, "javascripts", "#{js}.js")).to_i.to_s
end
end
!!! Strict
%html{:xmlns =>'http://www.w3.org/1999/xhtml', 'xml:lang' => 'en', :lang => 'en'}
%head
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}/
%title My Sinatra App
%link{:href => versioned_stylesheet('screen'), :media => 'screen', :rel => 'stylesheet', :type => 'text/css'}/
%script{:src => versioned_javascript('application'), :type => 'text/javascript'}/
helpers do
def cycle
@_cycle ||= reset_cycle
@_cycle = [@_cycle.pop] + @_cycle
@_cycle.first
end
def reset_cycle
@_cycle = %w(even odd)
end
%table.tickets{:cellpadding => 0, :cellspacing => 0}
%thead
%tr
%th No.
%th Summary
%th Reporter
%th Assignee
%th Updated
%tbody
- reset_cycle
gem 'chriseppstein-compass', '~> 0.4'
require 'compass'
configure do
Compass.configuration do |config|
config.project_path = File.dirname(__FILE__)
config.sass_dir = File.join('views', 'stylesheets')
end
end
# 1. Create dirs for unpacking your source code and installing your apps
mkdir $HOME/src
mkdir $HOME/apps
# 2. Install the latest version of git
cd $HOME/src
wget http://kernel.org/pub/software/scm/git/git-1.6.1.3.tar.gz
tar zxvf git-1.6.1.3.tar.gz
cd git-1.6.1.3
./configure --prefix=$HOME/apps NO_MMAP=1