Skip to content

Commit

Permalink
Example jsus application, with middleware and puppies
Browse files Browse the repository at this point in the history
  • Loading branch information
markiz committed Apr 17, 2011
0 parents commit 04e4883
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public/javascripts/jsus
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/js/mootools-ckeditor"]
path = vendor/js/mootools-ckeditor
url = git://github.com/Inviz/mootools-ckeditor.git
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
source :rubygems

# Use local clones if possible.
def custom_gem(name, options = Hash.new)
local_path = File.expand_path("../../#{name}", __FILE__)
if ENV["USE_JSUS_CUSTOM_GEMS"] && File.directory?(local_path)
gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }
else
gem name, options
end
end

gem "rack"
gem "sinatra"
custom_gem "jsus"
31 changes: 31 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
PATH
remote: /Users/mark/Code/jsus
specs:
jsus (0.2.7)
activesupport
json_pure
rgl

GEM
remote: http://rubygems.org/
specs:
activesupport (3.0.6)
json_pure (1.5.1)
rack (1.2.2)
rake (0.8.7)
rgl (0.4.0)
rake
stream (>= 0.5)
sinatra (1.2.3)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
stream (0.5)
tilt (1.2.2)

PLATFORMS
ruby

DEPENDENCIES
jsus!
rack
sinatra
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Description
===========

Live example for [jsus](https://github.com/markiz/jsus) rack middleware.

Installation
============

1. `bundle install`
2. `rackup`
3. Go to [http://localhost:4567/jsus/javasacripts/require/CKEditor](http://localhost:4567/jsus/javasacripts/require/CKEditor)
and see the file being built
4. Experiment with urls. E.g.: /jsus/javascripts/require/CKEditor:plugins.about.plugin+CKEditor:plugins.adobeair.plugin.js


Things to notice
================

Caching is on by default, but sinatra lets middleware do its work before serving
static files. This leads to regeneration per request. Use caching proxy, like
kick-ass [nginx](http://nginx.org/) before your sinatra in order to succeed.


License
=======

Application and libraries: UNLICENSE, same as jsus.

CKEditor and other files: look in the respective sources.
25 changes: 25 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rubygems'
require 'bundler'
Bundler.setup(:default, :development)
require 'jsus'
require 'sinatra/base'

Jsus::Middleware.settings = {
:cache => true,
:cache_path => File.expand_path("../public/javascripts/jsus/require", __FILE__),
:packages_dir => File.expand_path("../vendor/js", __FILE__)
}

class JsusApplication < Sinatra::Base
use Jsus::Middleware
set :static, true
get '/' do
[
200, {"Content-Type" => "text/plain"},
"Ping! Use jsus urls to see some magic.\n\n" <<
"E.g.: /javascripts/jsus/require/CKEditor.js\n" <<
"/javascripts/jsus/require/CKEditor~CKEditor:core.config~CKEditor:core.command.js\n" <<
"/javascripts/jsus/require/CKEditor:plugins.div.plugin+CKEditor:plugins.domiterator.plugin.js"
]
end
end # class JsusApplication
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require './app.rb'
run JsusApplication
Binary file added public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions vendor/js/mootools-ckeditor
Submodule mootools-ckeditor added at 97e566

0 comments on commit 04e4883

Please sign in to comment.