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 'sinatra/base' | |
require 'sinatra/cloudkit' | |
class MyApp < Sinatra::Base | |
register Sinatra::CloudKit | |
set :admin_openid, 'http://joncrosby.me' | |
mount :todos, :groups, :archives | |
get '/myurl' do |
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
Embracing Collaboration with JRuby and JavaScript | |
Description | |
As web developers, we live in an arranged marriage with JavaScript. What is a Rubyist to do? Use | |
JavaScript as a compile target? Abstract it away on the server? With JRuby, we can embrace the shared | |
language of the web in a compelling way, building reusable libraries that work across the client | |
server boundary. By bridging Ruby to JavaScript using Rhino, we gain shared databases, including their | |
indexing strategies. We gain remote model discovery and shared client/server validation. We gain a | |
shared query language. And because it is JavaScript, we gain the entire web community as |
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
var store = $.cloudkit; | |
store.boot({ | |
// booting the store reads the metadata on the server, | |
// loads existing data, and configures the local store | |
// for use | |
success: function() { |
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
// Assuming a CloudKit app hosting "notes" and "things" collections: | |
var store = $.cloudkit; | |
store.boot({ | |
success: function() { | |
// insert a 'thing' | |
store.collection('things').insert({name:"box"}, { | |
success: function(index) { | |
// do something with your data | |
} |
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 'cloudkit' | |
# use the default in-memory store | |
CloudKit.setup_storage_adapter | |
# create a resource in the 'items' collection | |
resource = CloudKit::Resource.create( | |
CloudKit::URI.new('/items'), | |
JSON.generate({:foo => 'bar'})) | |
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
# A Sinatra App as a Rails Plugin | |
# | |
# In your Edge Rails app: | |
# | |
# ruby script/plugin install git://gist.github.com/50625.git | |
require 'sinatra/base' | |
class SinatraRailsPlugin < Sinatra::Base | |
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 CloudKit 0.9.x way to list resources in a collection -- | |
# Still valid and useful... | |
$ curl -i http://localhost:9292/notes | |
HTTP/1.1 200 OK | |
Last-Modified: Sat, 10 Jan 2009 00:12:52 GMT | |
ETag: "c01f6230a8c40a2576b6f35f32f966ab" | |
Link: <http://localhost:9292/notes/_resolved>; rel="http://joncrosby.me/cloudkit/1.0/rel/resolved" | |
Cache-Control: proxy-revalidate | |
Content-Type: application/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
require 'cloudkit' | |
contain :notes, :projects |
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
thin -R config.ru start |
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 'cloudkit' | |
expose :notes, :projects |
NewerOlder