Skip to content

Instantly share code, notes, and snippets.

source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'locomotive_cms', '1.0.0.beta', :require => 'locomotive/engine'
gem 'unicorn', :group => 'development'
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'locomotive_cms', :git => 'git://github.com/locomotivecms/engine.git', :require => 'locomotive/engine', :branch => 'mongoid-2.0.0.rc.6'
gem 'unicorn', :group => 'development'
@did
did / loco #1
Created February 12, 2011 23:09
looping thru asset collections
{% for feature in asset_collections.features %}
{% if feature.home %}
<li class="feature {% cycle ' ', ' ', 'last' %}">
<div class="image">
{% if feature.popup %}
<a href="{{ feature.url }}" target="_blank">
<img src="{{ feature.thumb.url }}" alt="{{ feature.name }}" />
</a>
{% else %}
<img src="{{ feature.thumb.url }}" alt="{{ feature.name }}" />
require 'spec_helper'
describe EditableElement do
before(:each) do
@site = Factory(:site)
@home = @site.pages.root.first
@home.update_attributes :raw_template => "{% block body %}{% editable_short_text 'body' %}Lorem ipsum{% endeditable_short_text %}{% endblock %}"
@sub_page_1 = Factory(:page, :slug => 'sub_page_1', :parent => @home, :raw_template => "{% extends 'parent' %}")
@did
did / locomotive & tumblr
Created February 19, 2011 00:24
I'm using tumblr as my blog engine and display the last 3 posts in my locomotive index page
{% consume blog from "http://blog.locomotiveapp.org/api/read/json?num=3&type=text", expires_in: 3000 %}
{% if blog == null %}
<p class="error">We are sorry but the Tumblr API seems to be broken now. Click <a href="http://blog.locomotiveapp.org">here</a> to see the blog.</p>
{% else %}
{% for article in blog.posts %}
<li class="article {% cycle ' ', ' ', 'last' %}">
<h3><a href="{{ article.url }}">{{ article.regular_title }}</a></h3>
<p class="date">{{ article.date_gmt | localized_date: '%A %d %B %Y', 'en' }}</p>
<div class="body">
{{ article.regular_body | strip_html | truncate: 200 }}
module Liquid::Tags
class PageBanners < ::Liquid::Tag
Syntax = /(#{::Liquid::Expression}+)\s+max\s+([0-9]+)/
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@collection_name = $1
@max_number = $2
require 'sass/scss/parser'
module Sass
module SCSS
class Parser
private
def each_directive
list = tok! STRING
@did
did / Customize Locomotive with ease !
Created March 6, 2011 22:23
put it in an initializer and you're good to go !
require 'active_support/dependencies'
module ActiveSupport::Dependencies
alias_method :require_or_load_without_multiple, :require_or_load
def require_or_load(file_name, const_path = nil)
if file_name.starts_with?(Rails.root.to_s + '/app')
relative_name = file_name.gsub(Rails.root.to_s, '')
@engine_paths ||= Rails::Application.railties.engines.collect{|engine| engine.config.root.to_s }
@engine_paths.each do |path|
engine_file = File.join(path, relative_name)
require_or_load_without_multiple(engine_file, const_path) if File.file?(engine_file)
# encoding: utf-8
require 'mongoid'
# Limit feature for embedded documents
module Mongoid #:nodoc:
module Criterion #:nodoc:
module Exclusion
@did
did / loco_tip_1.html
Created June 3, 2011 00:24
How to post a comment related to an artist
<h2>{{ artist.name }}</h2>
<div>{{ artist.bio }}</div>
{% with_scope artist: artist._id %}
{% assign comments = contents.comments %}
{% if comments == empty %}