Skip to content

Instantly share code, notes, and snippets.

View dirkkelly's full-sized avatar

Dirk Kelly dirkkelly

View GitHub Profile
@dirkkelly
dirkkelly / gist:943585
Created April 27, 2011 01:52
.bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
vc_dirty_marker="✘"
prompt_designator_symbol="»"
prompt_designator_alternate="…"
_prompt_colour() {
echo -n '\['
if [[ "$1" = default ]]; then
echo -n "\\e[0m"
@dirkkelly
dirkkelly / 1) contact.liquid
Created March 15, 2011 00:34
Example Contact Form
{% block enquiry %}
<form id="enquiry_form" action="{{ contents.enquiries.api.create }}" method="post">
{% editable_long_text 'welcome' %}
<h3>Got an enquiry?</h3>
<p>Please fill in the form below and we will get in touch as soon as possible.</p>
{% endeditable_long_text %}
<fieldset>
<div id="error_message">No Errors</div>
<ol>
<li>
require 'rubygems'
require 'bundler/setup'
require 'bundler/capistrano'
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, 'ree-1.8.7@bluenail' # Or whatever env you want it to run in.
set :rvm_type, :system
set :user, "dk"
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
{% include 'head' %}
</head>
<body class="{{ page.slug }}">
@dirkkelly
dirkkelly / dynamic form fields
Created January 13, 2011 00:06
setting up dynamic form fields in the radiant-forms-extension
something_awesome:
extension: mail
field:
from: contact[email]
recipients: info@company.com
<form>
<input name="contact[email]" />
</form>
@dirkkelly
dirkkelly / version.rb
Created December 29, 2010 03:44
Using 2.3.x named_scopes for @mariovisic drafting question
class Version
named_scope :drafts, :conditions => { :draft => true }
named_scope :published, :conditions => { :draft => false }
end
Version.drafts # all drafts
Version.published # all published
@dirkkelly
dirkkelly / Page.rb
Created December 20, 2010 06:27
overrides the page method missing to attempt to find or update a field
module Shop
module Models
module Page
def self.included(base)
base.class_eval do
# Returns the field with the name passed.
# If a second parameter is passed the field content will be updated
def field(name,*args)
@dirkkelly
dirkkelly / product_page.rb
Created December 20, 2010 06:25
A product page has a price, line items, orders and customers.
class ProductPage < Page
cattr_accessor :allowed_children
@@allowed_children = [Page,ArchivePage]
layout 'product'
field 'price'
part 'body'
@dirkkelly
dirkkelly / _simplass.sass
Created December 10, 2010 02:52
A sass cutdown of the css framework mixins
// compass/_support ***************************************
// Usually compass hacks apply to both ie6 & 7 -- set this to false to disable support for both.
$legacy-support-for-ie: true !default
// Setting this to false will result in smaller output, but no support for ie6
$legacy-support-for-ie6: $legacy-support-for-ie !default
// Setting this to false will result in smaller output, but no support for ie7
$legacy-support-for-ie7: $legacy-support-for-ie !default
@dirkkelly
dirkkelly / gist:662624
Created November 4, 2010 15:31
Radiant (Rails) Exporter
desc "Export specific models to yaml"
task :export => :environment do
require 'fileutils'
begin
# Returns only the specified models, unless they're not defined
models = ENV['MODELS'].split(',').map { |m| m.pluralize.classify.constantize }
rescue
# Returns all models minus the subclasses of Page
models = (ActiveRecord::Base.send(:subclasses) - Page.send(:subclasses)).map { |m| m.name.constantize }
end