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
module FilterableResource | |
def acts_as_filterable(options = {}) | |
cattr_accessor :testing | |
self.testing = 'testing' | |
self.named_scope :filtered_from, lambda { |params| | |
puts('!!![' + self.testing.to_s + ']!!!') | |
nil | |
} | |
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
module FilterableResource | |
# to test {:filter => {:users => .. } | |
# {:method => 'any', :terms => ['first', 'second'], :fields => 'all'} | |
# {:method => 'any', :terms => 'first second', :fields => 'all'} | |
# {:method => 'any', :terms => 'first', :fields => ['first_name', 'last_name']} | |
# {:method => 'any', :terms => 'first', :fields => 'first_name last_name'} | |
# {:method => 'all', :terms => ['first', 'second'], :fields => 'all'} | |
# {:method => 'all', :terms => 'first second', :fields => 'all'} | |
# {:method => 'all', :terms => 'first', :fields => 'first_name'} | |
# {:method => 'all', :terms => 'first', :fields => ['first_name', 'last_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
module Kernel | |
def the(a, b) | |
Exception.new | |
end | |
def roof | |
end | |
def yo! | |
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
// Custom Rails routing/resource handling for ajax requests.. | |
(function() { | |
var methods = ['get', 'put', 'post', 'delete'], | |
actions = ['index', 'show', 'new', 'create', 'edit', 'update', 'destroy']; | |
function parseUrl(url) { | |
var urlParts = url.match(/^((http[s]?|ftp):\/\/)?(((.+)@)?([^:\/\?#\s]+)(:(\d+))?)?(\/?[^\?#\.]+)?(\.([^\?#]+))?(\?([^#]?))?(#(.*))?$/i) || []; | |
var pathParts = (urlParts[9]) ? urlParts[9].match(/(\/.*)\/+(\w+)$/i) || [] : []; |
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
CollectionBase = Class.create({ | |
resource: null, | |
resourceName: '', | |
resourceHandler: null, | |
collection: null, | |
initialize: function(resource) { | |
this.collection = {}; | |
this.resource = resource; | |
this.resourceName = resource.prototype.resourceName; |
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 rails application | |
require File.expand_path('../application', __FILE__) | |
# Initialize the rails application | |
Footnotes::Application.initialize! | |
# Start the websocket server | |
Footnotes::WebSocketServer.new(10081) |
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
require 'rack' | |
module Middleware | |
class Jammit | |
ROOT = '/app/javascripts' | |
def initialize(app, options = {}) | |
@app = app | |
@file_server = ::Rack::File.new(Protosite::Engine.root) | |
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
<script type="text/javascript"> | |
window['midas_setup_container'] = function() { | |
$('midas_container_selector').childElements().each(function(element) { | |
Event.observe(element, 'click', function(event) { | |
event.stop(); | |
this.execute('insertHTML', {action:'insertHTML', value: '<div class="' + element.getAttribute('data-class') + '"><br/></div>'}); | |
}.bind(this)); | |
}.bind(this)); | |
} | |
</script> |
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
// version 1: working, but not providing what's being sent | |
// we need to have full posts come through so rails can get the info | |
xhr.open(this.method, this.action, true); | |
xhr.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*'); | |
xhr.setRequestHeader('Content-Type', 'multipart/form-data'); | |
xhr.setRequestHeader('X-Version', '1'); | |
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | |
xhr.setRequestHeader('X-CSRF-Token', this.token); | |
xhr.setRequestHeader("X-File-Name", this.file.name); | |
xhr.setRequestHeader("X-File-Size", this.file.size); |
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
# The following allows us to have a nested directory structure of specs. With | |
# a lot of specs this is needed. | |
module Evergreen | |
class Suite | |
def specs | |
Dir.glob(File.join(root, Evergreen.spec_dir, '**', '*_spec.{js,coffee}')).map do |path| | |
Spec.new(self, path.gsub(File.join(root), '')) | |
end | |
end |
OlderNewer