├── .gitignore ├── assets ├── rack │ └── config.ru └── css │ └── annyong.css ├── LICENSE ├── lib ├── annyong.rb └── annyong │ └── directory.rb ├── README.mkd ├── annyong.gemspec └── bin └── annyong /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .rvmrc 3 | .local* 4 | -------------------------------------------------------------------------------- /assets/rack/config.ru: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | run Annyong::Directory.new(FileUtils.pwd.chomp) 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 Rémi Prévost. 2 | You may use this work without restrictions, as long as this notice is included. 3 | The work is provided "as is" without warranty of any kind, neither express nor implied. 4 | -------------------------------------------------------------------------------- /lib/annyong.rb: -------------------------------------------------------------------------------- 1 | module Annyong 2 | VERSION = '0.4' 3 | autoload :Directory, "annyong/directory" 4 | end 5 | 6 | unless "".respond_to?(:each) 7 | String.class_eval do 8 | def each &block 9 | self.lines &block 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /README.mkd: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Annyong starts a public static Web server in the current directory, allowing people in your local network to browse and download your files. 4 | 5 |  6 | 7 | ## Usage 8 | 9 | $ gem install annyong 10 | $ cd /path/you/want/to/serve 11 | $ annyong 12 | 13 | ## Options 14 | 15 | * `--port [PORT]` → the port to use (default: 9292) 16 | * `--host [HOST]` → the host to listen on (default: 0.0.0.0) 17 | 18 | ## Thanks 19 | 20 | * [Doug McInnes](https://github.com/dmcinnes) (to prevent injecting annyong’s code into public HTML files) 21 | -------------------------------------------------------------------------------- /annyong.gemspec: -------------------------------------------------------------------------------- 1 | spec = Gem::Specification.new do |s| 2 | s.name = "annyong" 3 | s.version = "0.4" 4 | s.platform = Gem::Platform::RUBY 5 | s.authors = "Rémi Prévost" 6 | s.email = "remi@exomel.com" 7 | s.homepage = "http://github.com/remiprev/annyong" 8 | s.summary = "Start a public static Web server in the current directory." 9 | s.description = "Annyong starts a public static Web server in the current directory, allowing people in your local network to browse your files." 10 | s.files = Dir["lib/**/*.rb", "README.mkd", "LICENSE", "bin/*", "assets/**/*"] 11 | s.require_path = "lib" 12 | 13 | s.executables << "annyong" 14 | s.add_runtime_dependency "rack", [">= 1.1.0"] 15 | end 16 | -------------------------------------------------------------------------------- /bin/annyong: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) 4 | 5 | require "rubygems" 6 | require "fileutils" 7 | require "optparse" 8 | require "rack" 9 | require "annyong" 10 | 11 | options = { 12 | :port => 9292, 13 | :host => "0.0.0.0" 14 | } 15 | opts = OptionParser.new do |opts| 16 | opts.banner = "Usage: annyong [options] 17 | 18 | Options: 19 | " 20 | opts.on("--port [PORT]", "The port to use (default: 9292)") do |port| 21 | options[:port] = port 22 | end 23 | 24 | opts.on("--host [HOST]", "The host to listen on (default: 0.0.0.0)") do |host| 25 | options[:host] = host 26 | end 27 | 28 | #opts.on("--path [PATH]", "The directory to serve") do |path| 29 | #options[:path] = path 30 | #end 31 | 32 | end 33 | opts.parse! 34 | 35 | STDOUT.puts "Now serving files in #{FileUtils.pwd.chomp} on http://#{options[:host]}:#{options[:port]}. Annyong!" 36 | 37 | Rack::Server.start({ 38 | :config => File.join(File.dirname(__FILE__), "../assets/rack/config.ru"), 39 | :Port => options[:port], 40 | :Host => options[:host], 41 | :AccessLog => [], 42 | }) 43 | -------------------------------------------------------------------------------- /lib/annyong/directory.rb: -------------------------------------------------------------------------------- 1 | module Annyong 2 | class Directory < Rack::Directory 3 | DIR_FILE = "
| Name | 18 |Size | 19 |Type | 20 |Last Modified | 21 |
|---|