Permalink
Browse files

Merge branch 'master' into jruby-1.7

Conflicts:
	README.markdown
  • Loading branch information...
tka committed Nov 22, 2013
2 parents 5fcb133 + ab87ffa commit 6c097f53ee28d46c396b82c5852128b95990700a
Showing 3,507 changed files with 270,859 additions and 81,491 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
View
@@ -30,7 +30,7 @@
<key>JVMVersion</key>
<string>1.6*</string>
<key>MainClass</key>
- <string>com.handlino.fireapp.Main</string>
+ <string>com.kkbox.fireapp.Main</string>
<key>ClassPath</key>
<array>
<string>$JAVAROOT/fire-app.jar</string>
View
@@ -1,4 +1,4 @@
-![Fire.app](https://github.com/handlino/FireApp/raw/master/lib/images/icon/256.png)
+![Fire.app](https://github.com/kkbox/FireApp/raw/master/lib/images/icon/256.png)
# Fire.app
@@ -32,8 +32,8 @@ If you want to build your own copy, you will need Java 7, [JRuby](http://jruby.o
## License
-Copyright (c) 2012 Handlino Inc.
+Copyright (c) 2012 KKBOX Inc.
Licensed under GPL v2.
-[fireapp]: http://fireapp.handlino.com/
-[fireapp-github]: http://github.com/handlino/fireapp
+[fireapp]: http://fireapp.kkbox.com/
+[fireapp-github]: http://github.com/kkbox/fireapp
View
@@ -22,7 +22,7 @@
# The fully-qualified name of the main Java file used to initiate the application.
# default value: "org.monkeybars.rawr.Main"
#
- c.main_java_file = "com.handlino.fireapp.Main"
+ c.main_java_file = "com.kkbox.fireapp.Main"
# A list of directories where source files reside
# default value: ["src"]
@@ -1,74 +0,0 @@
-func! CompassCompl(st,base)
- if a:st
- let line = getline('.')
- let start = col('.') - 1
- while start > 0 && line[start - 1] =~ '[a-z0-9\$@]'
- let start -= 1
- endwhile
- return start
- else
-
- let basefilename='~/.compass-ui/autocomplete_cache/'. substitute( expand('%:p'), '[^a-z0-9]', '_','g')
- if a:base[0] == "$"
- let wordfile=basefilename. "_variable"
- let get_word_cmd='test -f '. wordfile .' && cat '. wordfile .'|tr "\n" ,'
- exe 'let wordlist=['. system(get_word_cmd) . ']'
-
- " add variable in current file
- let file = getline(1, '$')
- let jfile = join(file, ' ')
- let int_vals = split(jfile, '\ze\$')
- let int_vars = {}
- for i in int_vals
- let val = matchstr(i, '^\$[a-z_][a-z_\-0-9]*')
- if val != ''
- call add(wordlist, val)
- endif
- endfor
-
- else
- let line = getline('.')
- if line =~ '@include'
- let wordfile=basefilename. "_mixin"
- let get_word_cmd='test -f '. wordfile .' && cat '. wordfile .'|tr "\n" ,'
- exe 'let wordlist=['. system(get_word_cmd) . ']'
-
- " add mixin in current file
- let int_vals = getline(1, '$')
- let int_vars = {}
- for i in int_vals
- let val = matchlist(i, '^@mixin \([a-z0-9\_]*[^{]*\)')
- if len(val) > 0 && val[1] != ''
- call add(wordlist, val[1])
- endif
- endfor
-
- " if you need complete mixin args, comment below 5 lines
- let clean_wordlist = []
- for i in wordlist
- call add(clean_wordlist, matchstr(i, "^[a-z0-9\-_]*"))
- endfor
- let wordlist = clean_wordlist
-
- endif
- endif
-
- " if we got scss words
- if exists('wordlist')
- let res = []
- for m in wordlist
- if m =~ '^' . a:base
- call add(res, m)
- endif
- endfor
-
- return res
- end
-
- " default match csscomplete#CompleteCSS
- return csscomplete#CompleteCSS(0, a:base)
- endif
-endfunc
-autocmd BufNewFile,BufRead *.scss set ft=scss.css iskeyword+=- ofu=CompassCompl
-autocmd BufNewFile,BufRead *.sass set ft=sass.css iskeyword+=- ofu=CompassCompl
-
View
@@ -10,7 +10,7 @@ require 'redis'
require 'yaml'
require 'json'
-DOMAIN = "the-hold.handlino.com"
+DOMAIN = "the-hold.kkbox.com"
module Rack
module Session
@@ -22,7 +22,11 @@ module Rack
patten = Regexp.new("(?<version>\\d{8}-\\d{6})?\\.?(?<project>.+?)\\.(?<login>.+)\\.#{DOMAIN}$")
project_route = request.host.match(patten)
- cookie[:domain] = ".#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ if project_route
+ cookie[:domain] = ".#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ else
+ cookie[:domain] = request.host
+ end
Utils.set_cookie_header!(headers, @key, cookie)
end
@@ -45,8 +49,12 @@ class TheHoldApp
patten = Regexp.new("(?<version>\\d{8}-\\d{6})?\\.?(?<project>.+?)\\.(?<login>.+)\\.#{DOMAIN}$")
project_route = req.host.match(patten)
-
- site_key = "site-#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ if project_route
+ site_key = "site-#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ else
+ site_key = "site-#{req.host}"
+ project_route={version: nil}
+ end
site = @redis.hgetall(site_key)
return not_found if !( site["login"] && site["project"] )
@@ -282,8 +290,8 @@ EOL
cname = params["cname"]
begin
dns = Resolv::DNS.new
- target_name = dns.getresources(cname, Resolv::DNS::Resource::IN::CNAME).first.try(:name)
- if target_name && target_name.to_s == project_hostname
+ target_record = dns.getresources(cname, Resolv::DNS::Resource::IN::CNAME).first
+ if target_record && target_record.name.to_s == project_hostname
@redis.hmset("site-#{cname}", :login, params["login"], :project, params["project"] );
end
end
@@ -302,7 +310,7 @@ EOL
end
def not_found
- [404, {'Content-Type' => 'text/plain' }, ["Not Fonud"]]
+ [404, {'Content-Type' => 'text/plain' }, ["Not Found"]]
end
def forbidden
@@ -3,7 +3,7 @@ Install Compass Extension
Fire.app uses Compass extension as project template. If you put Compass extensions inside this folder, Fire.app will try to load it when the application starts.
-For more detailed information, please refer: https://github.com/handlino/FireApp/wiki/Use-compass-extensions
+For more detailed information, please refer: https://github.com/kkbox/FireApp/wiki/Use-compass-extensions
Create Your Own Project Template
@@ -25,4 +25,4 @@ If you do not have a manifest.rb, Compass will use "easy mode" and put everythin
For more detailed information, please refer: http://compass-style.org/help/tutorials/extensions/
-You can also download our sample project template and give it a try: https://github.com/handlino/compass-handlino
+You can also download our sample project template and give it a try: https://github.com/kkbox/compass-handlino
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
@@ -0,0 +1,3 @@
+[submodule "spec/ext/commonjs"]
+ path = spec/ext/commonjs
+ url = https://github.com/kriskowal/commonjs.git
@@ -0,0 +1,10 @@
+rvm:
+ - 1.9.3
+ - 1.9.2
+ - 1.8.7
+ - jruby-18mode
+ - jruby-19mode
+notifications:
+ recipients:
+ - cowboyd@thefrontside.net
+before_install: git submodule update --init
@@ -0,0 +1,7 @@
+source 'http://rubygems.org'
+
+# Specify your gem's dependencies in commonjs.gemspec
+gemspec
+
+gem "therubyracer", :platforms => :ruby
+gem "therubyrhino", "~> 1.73.3", :platforms => :jruby
@@ -0,0 +1,44 @@
+
+# CommonJS [![Build Status](https://secure.travis-ci.org/cowboyd/commonjs.rb.png)](http://travis-ci.org/cowboyd/commonjs.rb)
+
+Host CommonJS JavaScript environments in Ruby
+
+## Why?
+
+The internet is now awash with non-browser JavaScript code. Much of this code conforms to some
+simple conventions that let you use it anywhere you have a JavaScript interpreter available. These
+conventions are collectively called "commonjs"
+
+We have several JavaScript interpreters available to us from Ruby. Therefore, why shouldn't we be
+able to use commonjs applications and libraries?
+
+## Using common JS from Ruby.
+
+`CommonJS` now passes all of the Modules 1.0 unit tests
+
+ env = CommonJS::Environment.new(:path => '/path/to/lib/dir')
+ env.require('foo.js')
+
+
+
+## Future directions
+
+By default, all you get with a bare commonjs environment is the Modules API
+
+The plan however, is to allow you to extend your commonjs environment to have whatever native
+interfaces you want in it. So for example, if you want to allow filesystem access, as well as
+access to the process information, you would say:
+
+ env.modules :filesystem, :process
+
+## Supported runtimes
+
+### Current
+
+* The Ruby Racer (V8) - [https://github.com/cowboyd/therubyracer]
+* The Ruby Rhino (JRuby) - [https://github.com/cowboyd/therubyrhino]
+
+### Desired
+
+* Johnson (TraceMonkey) - [https://github.com/jbarnette/johnson]
+* Lyndon (MacRuby) - [https://github.com/defunkt/lyndon]
@@ -0,0 +1,9 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
+
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new('spec') do |spec|
+ spec.rspec_opts = ['--color', "--format documentation"]
+end
+
+task :default => :spec
@@ -0,0 +1,20 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/commonjs/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Charles Lowell"]
+ gem.email = ["cowboyd@thefrontside.net"]
+ gem.description = "Host CommonJS JavaScript environments in Ruby"
+ gem.summary = "Provide access to your Ruby and Operating System runtime via the commonjs API"
+ gem.homepage = "http://github.com/cowboyd/commonjs.rb"
+
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ gem.files = `git ls-files`.split("\n")
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.name = "commonjs"
+ gem.require_paths = ["lib"]
+ gem.version = CommonJS::VERSION
+
+ gem.add_development_dependency "rake"
+ gem.add_development_dependency "rspec"
+end
@@ -0,0 +1,6 @@
+require "commonjs/version"
+
+module CommonJS
+ autoload :Environment, 'commonjs/environment'
+ autoload :Module, 'commonjs/module'
+end
@@ -0,0 +1,39 @@
+require 'pathname'
+module CommonJS
+ class Environment
+
+ attr_reader :runtime
+
+ def initialize(runtime, options = {})
+ @runtime = runtime
+ @paths = [options[:path]].flatten.map {|path| Pathname(path)}
+ @modules = {}
+ end
+
+ def require(module_id)
+ unless mod = @modules[module_id]
+ filepath = find(module_id) or fail LoadError, "no such module '#{module_id}'"
+ load = @runtime.eval("(function(module, require, exports) {#{File.read(filepath)}})", filepath.expand_path.to_s)
+ @modules[module_id] = mod = Module.new(module_id, self)
+ load.call(mod, mod.require_function, mod.exports)
+ end
+ return mod.exports
+ end
+
+ def native(module_id, impl)
+ @modules[module_id] = Module::Native.new(impl)
+ end
+
+ def new_object
+ @runtime['Object'].new
+ end
+
+ private
+
+ def find(module_id)
+ if loadpath = @paths.find { |path| path.join("#{module_id}.js").exist? }
+ loadpath.join("#{module_id}.js")
+ end
+ end
+ end
+end
@@ -0,0 +1,49 @@
+module CommonJS
+ class Module
+
+ attr_reader :id
+ attr_accessor :exports
+
+ def initialize(id, env)
+ @id = id
+ @env = env
+ @exports = env.new_object
+ @segments = id.split('/')
+ end
+
+ def require_function
+ @require_function ||= lambda do |*args|
+ this, module_id = *args
+ module_id ||= this #backwards compatibility with TRR < 0.10
+ @env.require(expand(module_id))
+ end
+ end
+
+ private
+
+ def expand(module_id)
+ return module_id unless module_id =~ /(\.|\..)/
+ module_id.split('/').inject(@segments[0..-2]) do |path, element|
+ path.tap do
+ if element == '.'
+ #do nothing
+ elsif element == '..'
+ path.pop
+ else
+ path.push element
+ end
+ end
+ end.join('/')
+ end
+
+
+ class Native
+
+ attr_reader :exports
+
+ def initialize(impl)
+ @exports = impl
+ end
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 6c097f5

Please sign in to comment.