Skip to content

Instantly share code, notes, and snippets.

View rodriguezartav's full-sized avatar

Roberto Rodriguez rodriguezartav

View GitHub Profile
@rodriguezartav
rodriguezartav / posts.coffee
Created October 13, 2011 18:34
Spine Controller - Simple
Post = require("models/post")
class Posts extends Spine.Controller
elements:
"#post_list" : "post_list"
events:
"click #post_list" : "on_post_click"
@rodriguezartav
rodriguezartav / gist:1285147
Created October 13, 2011 18:56
Spine Folder Structure
-app
-assets
-javascripts
-app
-controllers
-models
-views
-lib
-vendor
@rodriguezartav
rodriguezartav / application.html.haml
Created October 13, 2011 18:53
Basic Layout Haml for Rails Generated Views
!!!Strict
%html{ }
%head
%title RubyConfBr2011SimpleApplication
%meta{'http-equiv'=>"Content-Type", :content=>"text/html; charset=utf-8"}/
%meta{'http-equiv'=>"Content-Language", :content=>"en-us"}/
= stylesheet_link_tag :scaffolds
%body
@rodriguezartav
rodriguezartav / post.coffee
Created October 13, 2011 18:34
Spine Model - Simple
class Post extends Spine.Model
@configure "Post", "name"
@extend Spine.Model.Ajax
module.exports = Post
@rodriguezartav
rodriguezartav / app.coffee
Created October 13, 2011 18:34
Spine Main Controller
require("spine")
require("ajax")
require("tmpl")
Posts = require("controllers/posts")
class App extends Spine.Controller
elements:
"#posts" : "postsEl"
@rodriguezartav
rodriguezartav / pages_controller.rb
Created October 13, 2011 18:47
Pages Controller
class PagesController < ApplicationController
def home
render 'home' ,:layout => 'js'
end
end
@rodriguezartav
rodriguezartav / GEM
Created October 13, 2011 18:43
Gem File for Rails 3.1 that will run a SpineJS App with stitch , mongo, sass and compass
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@rodriguezartav
rodriguezartav / routes.rb
Created October 13, 2011 18:28
config/routes.rb snipped for a simple javascript application that uses spine and stitch
[APP_NAME]::Application.routes.draw do
resources :posts
root :to => "pages#home"
match 'home' => "pages#home"
match 'apps/app.js' => Stitch::Server.new(:paths => ["app/assets/javascripts/app", "app/assets/javascripts/lib"])
@rodriguezartav
rodriguezartav / stitch.rb
Created October 13, 2011 18:26
config/initializers/stitch.rb it setups stitch to compile and include javascript applications templates in the main app file
class TmplCompiler < Stitch::Compiler
extensions :tmpl
def compile(path)
content = File.read(path)
%{var template = jQuery.template(#{content.to_json});
module.exports = (function(data){ return jQuery.tmpl(template, data); });}
end
end
@rodriguezartav
rodriguezartav / mongo.rb
Created October 13, 2011 18:25
config/initializers/mongo.rb it setups mongomapper to be used locally and in heroku with MongoHQ
MongoMapper.config = {
Rails.env => { 'uri' => ENV['MONGOHQ_URL'] ||
"mongodb://localhost/rubyconf_simple_app-#{Rails.env}-1" } }
MongoMapper.connect(Rails.env)
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect if forked
end