Skip to content

Commit

Permalink
add spine to assets
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Apr 22, 2011
1 parent 4cee17e commit c3c1cf0
Show file tree
Hide file tree
Showing 23 changed files with 17,555 additions and 0 deletions.
1 change: 1 addition & 0 deletions ch11/spine/.gitignore
@@ -0,0 +1 @@
.DS_Store
20 changes: 20 additions & 0 deletions ch11/spine/LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2011 Alex MacCaw (info@eribium.org)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 changes: 7 additions & 0 deletions ch11/spine/README.md
@@ -0,0 +1,7 @@
# Spine

__Spine is a lightwork framework for building JavaScript web applications.__ Spine gives you a MVC structure and then gets out of your way, allowing you to concentrate on the fun stuff, building awesome web applications.

Spine is tiny, the library comes in at around 500 lines of JavaScript, that's about 2K minified & compressed. However, it's not about size, it's how you use it, and Spine certainly packs a punch!

For documentation, usage, and examples, see: [http://maccman.github.com/spine](http://maccman.github.com/spine)
46 changes: 46 additions & 0 deletions ch11/spine/Rakefile
@@ -0,0 +1,46 @@
require "rdiscount"

task :generate do
text = File.read("site/site.md")
html = RDiscount.new(text).to_html
File.open("index.html", "w+") do |io|
io.write(%{
<!DOCTYPE html>
<html>
<head>
<meta name="charset" content="utf-8">
<title>Spine</title>
<link rel="stylesheet" href="site/site.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="site/highlight.css" type="text/css" charset="utf-8">
<script src="site/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="spine.js" type="text/javascript" charset="utf-8"></script>
<script src="site/highlight.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<div id="container">#{html}</div>
</body>
</html>
})
end
end

task :build do
require "yui/compressor"
require "fileutils"

compressor = YUI::JavaScriptCompressor.new(:munge => true)
File.open("spine.min.js", "w+") do |output|
File.open("spine.js", "r") do |input|
compressor.compress(input) do |compressed|
while buffer = compressed.read(4096)
output.write(buffer)
end
end
end
end
end

task :default => :generate
57 changes: 57 additions & 0 deletions ch11/spine/examples/history.html
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../spine.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/spine.history.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8">
var Users = Spine.Controller.create({
init: function(){
this.navigate("/users", 1);
},

active: function(number){
console.log("active", number)
}
});

// Add routes in App controller
var App = Spine.Controller.create({
init: function(){
this.users = Users.init();
this.routes({
"/users/:number": function(num){
this.users.active(num);
},
"/users/*glob": function(any){
console.log('any', any);
}
});
}
}).init();

// Add routes manually

// Add a group of routes
Spine.History.add({
"/groups/:id": function(id){
console.log('groups id', id)
}
});

// More generic routes added last

// Use your own regex
Spine.History.add(/\/groups(\/)?/, function(){
console.log('groups')
});

// Fire event on load
Spine.History.change();
</script>
</head>
<body>

</body>
</html>

0 comments on commit c3c1cf0

Please sign in to comment.