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
# Usage: _.toCSS(object) | |
# Returns properly formatted CSS. | |
# Object cannot be deeply nested as this is a simple object/CSS mapping and it reads better. | |
# If you want to do something dynamic to generate the CSS, do it in a JS function that returns the object. | |
# | |
_css = | |
toCSS: (obj) -> | |
propToCSS = (key, value) -> | |
css = '' | |
for selector of obj |
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
template = CoffeeKup.compile -> | |
div class: 'section first sources', -> | |
div id: 'sources-overview', class: 'category', -> | |
a href: '/sources/overview', -> 'Overview' | |
div class: 'section', -> | |
for source in @sources | |
div id: "sources-#{source.uuid}", class: 'category source', -> | |
span class: 'searching' | |
a href: "/sources/#{source.uuid}", -> source.name |
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
fs = require 'fs' | |
assets = require './frontend/js/assets' | |
exec = require('child_process').exec | |
task 'dev:js_lib', 'Rebuild the js libs', (options) -> | |
js = '' | |
js_local = assets.js_local | |
for key of assets.js | |
if assets.js[key] is "npm" | |
try |
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
fs = require 'fs' | |
CoffeeScript = require 'coffee-script' | |
task "build:package", "Builds the package.json from it's coffee source", (options) -> | |
js = CoffeeScript.compile "return #{fs.readFileSync('package.coffee', 'utf8')}" | |
json = JSON.stringify eval(js), null, 2 | |
fs.writeFileSync 'package.json', json | |
console.log('Successfully wrote out package.json') |
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
# Security code for a user | |
uuid = require "node-uuid" | |
crypto = require "crypto" | |
util = require("util") | |
systemSalt = "49caa18ae0d91e9ad610eba6bf6328172ae026a497ef6e79dcb0b7b1eb1ca534a047405eb8f0f05b2e513d548a3d97a0d4a2634593ac98d5e1db64212837b254" | |
# Default fingerprint function | |
fingerprint = (user) -> | |
return user.email |
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 Address < ActiveRecord::Base | |
attr_accessible :address1, :address2, :phone, :city, :state, :zip, :country, :website_url, :name | |
def validate | |
required_set = [:address1, :city, :state, :zip, :country] | |
matches = required_set.map {|my_method| self.send(my_method).present? }.reduce(0) {|a,b| a + (b == true ? 1 : 0) } | |
self.errors.add(:address1, "Must have a full address!") if matches.between?(1, 4) | |
end | |
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
# Load the remote RB db object, our connection to the backend SQLite or MongoDB | |
DNode.connect (rbdb) -> | |
RB.db = rbdb | |
# Fetch the logged in Backbone user if any | |
RB.user.fetch success: -> Backbone.history.loadUrl() | |
# Overwrite the Backbone sync method to use Dnode and rbdb | |
# The Recordbook database has a MongoDB compatible API, even if it sits on SQLite | |
Backbone.sync = (method, model, success, error) -> | |
collectionName = model.collectionName() |
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
$('.product-order a').bind("ajax:success", function(e, lineItemQuantity){ | |
var $this = $(this), | |
$confirmObj = $this.parent('.product-order').siblings('.product-image').children('.order-over'); | |
if( !$confirmObj.is('visible') && !($confirmObj.is('animated')) ){ | |
$confirmObj.fadeIn(); | |
$confirmObj.children('p').children('.order-count').text(lineItemQuantity); | |
setTimeout( function(){$confirmObj.fadeOut();}, 3000); | |
} | |
}); |
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
# | |
# Replaces Backbone.History with support for HTML5 history API if browser supports it. | |
# To use, setup your controllers as usual and try it with a browser that supports the HTML5 history API. | |
# For browsers that don't support the HTML5 API, this will fall back to using the default Backbone hash routing. | |
# | |
# I have only tested this on my project in Firefox, Safari and Chrome so let me know. | |
# | |
pushSupport = window.history? and window.history.pushState? | |
if pushSupport and Backbone? and Backbone.History? | |
rootUrl = document.location.protocol+'//'+(document.location.host or document.location.hostname) |
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
# | |
# Caches, renders, ands adds supports for partials and layout to underscore.js templating | |
# | |
# Pass in one options object to renderTemplate: | |
# dir: the root dir where all the templates are located, defaults to views. Paths are resolved as e.g dir/partial.html or dir/layout.html. | |
# partial(s): one or more partial names (without the *.html) to compile, cache, render, and optionally return. | |
# If layout is present, the partials will be passed to the layout template with keys as the partial names | |
# and the layout html will be returned. | |
# partialPrefix: (optional) a name to prepend to all partials. E.g. passing in "products." will load dir/products.partial.html | |
# layout: the name of a layout template (without the *.html). If missing the last or only partial html will be returned. |