Permalink
Browse files

Adding direct searching to allow sharing urls.

  • Loading branch information...
1 parent 54ed084 commit 009f3e94d5852baac2ef03914d12b8046ad74ede @cjstewart88 committed Aug 31, 2011
Showing 319 changed files with 58,789 additions and 3 deletions.
View
@@ -43,7 +43,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.16)
pg (0.11.0)
- polyglot (0.3.1)
+ polyglot (0.3.2)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
@@ -64,9 +64,10 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.8.7)
- rdoc (3.8)
+ rdoc (3.9.4)
thor (0.14.6)
- treetop (1.4.9)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.29)
@@ -1,3 +1,13 @@
+<% if request.path == "/just" %>
+ <script type="text/javascript">
+ just('<%= params[:artist_band] %>');
+ </script>
+<% elsif request.path == "/similar" %>
+ <script type="text/javascript">
+ similarTo('<%= params[:artist_band] %>');
+ </script>
+<% end %>
+
<% if @no_playlist %>
<section id="no_playlist">
There dosnt seem to be a playlist with the ID of '<%= @no_playlist %>'. Feel free to <a href='/playlist'>create</a> a new one!
View
@@ -7,6 +7,9 @@
get "/similar/:artist_band.json" => "api#similar"
get "/playlist/:playlist_id.json" => "api#playlist"
+ get "/just/:artist_band" => ""
+ get "/similar/:artist_band" => ""
+
get "/playlist" => "playlist#create"
get "/playlist/:playlist_id" => "playlist#init"
get "/playlist/video/:playlist_id/:video_id/:video_title" => "playlist#addVideo"
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,72 @@
+== 0.3.2 2011-07-27
+
+* 1 minor fix:
+ * Load file without extension if found exactly as required
+
+== 0.3.1 2010-02-29
+
+* 1 minor fix:
+ * Enumerable strings are deprecated in Ruby 1.8.8
+
+== 0.3.0 2010-02-14
+
+* 1 minor fix:
+ * Compatibility with Rails 3
+
+== 0.2.9 2009-09-13
+
+* 1 minor fix:
+ * Use to_s on Pathname to support Ruby 1.9
+
+== 0.2.8 2009-08-18
+
+* 1 minor fix:
+ * Previous fix for LoadErrors failed for cucumber.
+
+== 0.2.7 2009-08-17
+
+* 1 minor fix:
+ * Fix Polyglot catching LoadErrors not raised in Polyglot.find and re-raising the
+ wrong message.
+
+== 0.2.6 2009-06-21
+
+* 1 significant fix:
+ * Require using absolute pathname now works correctly on Ruby 1.8
+
+== 0.2.5 2009-03-04
+
+* 1 significant fix:
+ * Polyglot's require may be called with a Pathname, or other object allowed by Kernel#require that doesn't support [] (Kernel#require uses to_str apparently)
+
+== 0.2.4 2008-05-29
+
+* 1 significant fix:
+ * Previous LoadError change is checked in this time (oops!)
+
+== 0.2.3 2008-05-29
+
+* 2 minor enhancements:
+ * Raise MissingSourceFile exception instead of LoadError if ActiveSupport is loaded
+ * Re-raise original exception new one on require load fail
+
+== 0.2.2 2008-05-12
+
+* 2 minor enhancements:
+ * Doesn't search $: when asked to load an absolute path
+ * Adds a helpful exception message on LoadError
+
+== 0.2.1 2008-03-05
+
+* 1 minor defect:
+ * code to raise LoadError itself raised an exception
+
+== 0.2.0 2008-02-13
+
+* 1 major enhancement:
+ * Doesn't reload on every require
+
+== 0.1.0 2007-10-22
+
+* 1 major enhancement:
+ * Initial release
@@ -0,0 +1,20 @@
+Copyright (c) 2007 Clifford Heath
+
+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.
@@ -0,0 +1,87 @@
+= polyglot
+
+* http://github.com/cjheath/polyglot
+
+== DESCRIPTION:
+
+Author: Clifford Heath, 2007
+
+The Polyglot library allows a Ruby module to register a loader
+for the file type associated with a filename extension, and it
+augments 'require' to find and load matching files.
+
+This supports the creation of DSLs having a syntax that is most
+appropriate to their purpose, instead of abusing the Ruby syntax.
+
+Files are sought using the normal Ruby search path.
+
+== EXAMPLE:
+
+In file rubyglot.rb, define and register a file type handler:
+
+ require 'polyglot'
+
+ class RubyglotLoader
+ def self.load(filename, options = nil, &block)
+ File.open(filename) {|file|
+ # Load the contents of file as Ruby code:
+ # Implement your parser here instead!
+ Kernel.eval(file.read)
+ }
+ end
+ end
+
+ Polyglot.register("rgl", RubyglotLoader)
+
+In file test.rb:
+
+ require 'rubyglot' # Create my file type handler
+ require 'hello' # Can add extra options or even a block here
+ puts "Ready to go"
+ Hello.new
+
+In file hello.rgl (this simple example uses Ruby code):
+
+ puts "Initializing"
+ class Hello
+ def initialize()
+ puts "Hello, world\n"
+ end
+ end
+
+Run:
+
+ $ ruby test.rb
+ Initializing
+ Ready to go
+ Hello, world
+ $
+
+== INSTALL:
+
+sudo gem install polyglot
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2007 Clifford Heath
+
+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.
@@ -0,0 +1,41 @@
+require 'rubygems'
+require 'rake'
+require 'yaml'
+require 'jeweler'
+require './lib/polyglot/version'
+
+Jeweler::Tasks.new do |gem|
+ gem.name = "polyglot"
+ gem.version = Polyglot::VERSION::STRING
+ gem.homepage = "http://github.com/cjheath/polyglot"
+ gem.license = "MIT"
+ gem.summary = %Q{Augment 'require' to load non-Ruby file types}
+ gem.description = %Q{
+The Polyglot library allows a Ruby module to register a loader
+for the file type associated with a filename extension, and it
+augments 'require' to find and load matching files.}
+ gem.email = %w[clifford.heath@gmail.com]
+ gem.authors = ["Clifford Heath"]
+end
+Jeweler::RubygemsDotOrgTasks.new
+
+require 'rdoc/task'
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "polyglot #{Polyglot::VERSION::STRING}"
+ rdoc.rdoc_files.include('README.txt')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+desc 'Generate website files'
+task :website_generate do
+ sh %q{ruby script/txt2html website/index.txt > website/index.html}
+end
+
+desc 'Upload website files via rsync'
+task :website_upload do
+ rfconfig = YAML.load_file("#{ENV['HOME']}/.rubyforge/user-config.yml")
+ ENV['RSYNC_PASSWORD'] = rfconfig['password']
+ sh %{rsync -aCv website #{rfconfig['username']}@rubyforge.org:/var/www/gforge-projects/polyglot}
+end
+
@@ -0,0 +1,74 @@
+require 'pathname'
+
+module Polyglot
+ @registrations ||= {} # Guard against reloading
+ @loaded ||= {}
+
+ class PolyglotLoadError < LoadError; end
+
+ class NestedLoadError < LoadError
+ def initialize le
+ @le = le
+ end
+ def reraise
+ raise @le
+ end
+ end
+
+ def self.register(extension, klass)
+ extension = [extension] unless Array === extension
+ extension.each{|e|
+ @registrations[e] = klass
+ }
+ end
+
+ def self.find(file, *options, &block)
+ is_absolute = Pathname.new(file).absolute?
+ (is_absolute ? [""] : $:).each{|lib|
+ base = is_absolute ? "" : lib+File::SEPARATOR
+ # In Windows, repeated SEPARATOR chars have a special meaning, avoid adding them
+ matches = Dir["#{base}#{file}{,.#{@registrations.keys*',.'}}"]
+ # Revisit: Should we do more do if more than one candidate found?
+ $stderr.puts "Polyglot: found more than one candidate for #{file}: #{matches*", "}" if matches.size > 1
+ if path = matches[0]
+ return [ path, @registrations[path.gsub(/.*\./,'')]]
+ end
+ }
+ return nil
+ end
+
+ def self.load(*a, &b)
+ file = a[0].to_str
+ return if @loaded[file] # Check for $: changes or file time changes and reload?
+ begin
+ source_file, loader = Polyglot.find(file, *a[1..-1], &b)
+ if (loader)
+ begin
+ loader.load(source_file)
+ @loaded[file] = true
+ rescue LoadError => e
+ raise Polyglot::NestedLoadError.new(e)
+ end
+ else
+ raise PolyglotLoadError.new("Failed to load #{file} using extensions #{(@registrations.keys+["rb"]).sort*", "}")
+ end
+ end
+ end
+end
+
+module Kernel
+ alias polyglot_original_require require
+
+ def require(*a, &b)
+ polyglot_original_require(*a, &b)
+ rescue LoadError => load_error
+ begin
+ Polyglot.load(*a, &b)
+ rescue Polyglot::NestedLoadError => e
+ e.reraise
+ rescue LoadError
+ # Raise the original exception, possibly a MissingSourceFile with a path
+ raise load_error
+ end
+ end
+end
@@ -0,0 +1,9 @@
+module Polyglot #:nodoc:
+ module VERSION #:nodoc:
+ MAJOR = 0
+ MINOR = 3
+ TINY = 2
+
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ end
+end
Oops, something went wrong.

0 comments on commit 009f3e9

Please sign in to comment.