annyong 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,3 @@
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.
@@ -0,0 +1,9 @@
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
+ # Usage
6
+
7
+ $ gem install annyong
8
+ $ cd /path/you/want/to/serve
9
+ $ annyong
@@ -0,0 +1,90 @@
1
+ /* Basic # {{{ */
2
+
3
+ * {
4
+ padding: 0;
5
+ margin: 0;
6
+ }
7
+
8
+ html {
9
+ font-size: 62.5%;
10
+ }
11
+
12
+ body {
13
+ font-family: Helvetica, Arial, sans-serif;
14
+ white-space: nowrap;
15
+ font-size: 145%;
16
+ padding: 30px;
17
+ background: #fff;
18
+ color: #555;
19
+ }
20
+
21
+ a {
22
+ color: #508AD7;
23
+ }
24
+
25
+ hr {
26
+ display: none;
27
+ }
28
+
29
+ h1 {
30
+ margin: 0 0 15px;
31
+ font-size: 150%;
32
+ }
33
+
34
+ /* }}} */
35
+
36
+ /* Tables # {{{ */
37
+
38
+ table {
39
+ border-collapse: collapse;
40
+ background: #fff;
41
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
42
+ background: #fafafa;
43
+ border: 1px solid #ccc;
44
+ font-family: monospace;
45
+ }
46
+
47
+ table tr:nth-child(2) {
48
+ background: #fafafa !important;
49
+ }
50
+
51
+ table tr:nth-child(2) a {
52
+ color: #999;
53
+ }
54
+
55
+ table td, table th {
56
+ border-bottom: 1px solid #ccc;
57
+ padding: 6px 8px;
58
+ width: auto;
59
+ font-weight: normal;
60
+ text-align: left;
61
+ }
62
+
63
+ table th {
64
+ background: #eee;
65
+ color: #888;
66
+ }
67
+
68
+ table tr:hover {
69
+ background: rgba(255,255,0,0.1);
70
+ }
71
+
72
+ table td.name {
73
+ }
74
+
75
+ /* }}} */
76
+
77
+ /* Footer # {{{ */
78
+
79
+ footer {
80
+ padding: 16px 2px 6px;
81
+ text-align: right;
82
+ font-size: 90%;
83
+ color: #999;
84
+ }
85
+
86
+ footer a {
87
+ color: #aaa;
88
+ }
89
+
90
+ /* }}} */
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ use Annyong::Middleware
4
+ run Rack::Directory.new(`pwd`.chomp)
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+
5
+ require "rubygems"
6
+ require 'optparse'
7
+ require "rack"
8
+ require "annyong"
9
+
10
+ options = {
11
+ :port => 9292,
12
+ :host => "0.0.0.0"
13
+ }
14
+ opts = OptionParser.new do |opts|
15
+ opts.banner = "Usage: annyong [options]
16
+
17
+ Options:
18
+ "
19
+ opts.on("--port [PORT]", "The port to use (default: 9292)") do |port|
20
+ options[:port] = port
21
+ end
22
+
23
+ opts.on("--host [HOST]", "The port to use (default: 0.0.0.0)") do |host|
24
+ options[:host] = host
25
+ end
26
+
27
+ #opts.on("--path [PATH]", "The directory to serve") do |path|
28
+ #options[:path] = path
29
+ #end
30
+
31
+ end
32
+ opts.parse!
33
+
34
+ Rack::Server.start({
35
+ :config => File.join(File.dirname(__FILE__), "../assets/rack/config.ru"),
36
+ :Port => options[:port],
37
+ :Host => options[:host],
38
+ :AccessLog => [],
39
+ })
@@ -0,0 +1,4 @@
1
+ module Annyong
2
+ VERSION = '0.1'
3
+ autoload :Middleware, "annyong/middleware"
4
+ end
@@ -0,0 +1,31 @@
1
+ module Annyong
2
+ class Middleware
3
+
4
+ attr_reader :styles
5
+
6
+ def initialize(app) # {{{
7
+ @app = app
8
+ @styles = File.read(File.join(File.dirname(__FILE__), "../../assets/css/annyong.css"))
9
+ end # }}}
10
+
11
+ def inject(body) # {{{
12
+ body = body.sub(/<html>/, "<!doctype html>\n<html>")
13
+ body = body.sub(/<\/head>/, "<style type='text/css'>#{@styles}</style>")
14
+ body = body.sub(/<\/body>/, "<footer><code>#{`pwd`.chomp}</code>, <a target='_blank' title='Powered by annyong' href='https://github.com/remiprev/annyong'>annyong</a>!</footer></body")
15
+ body
16
+ end # }}}
17
+
18
+ def call(env) # {{{
19
+ status, headers, response = @app.call(env)
20
+
21
+ response_body = ""
22
+ response.each { |part| response_body += part }
23
+ response_body = inject(response_body)
24
+
25
+ headers["Content-Length"] = response_body.length.to_s
26
+
27
+ [status, headers, response_body]
28
+ end # }}}
29
+
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: annyong
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - "R\xC3\xA9mi Pr\xC3\xA9vost"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-03 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rack
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 19
29
+ segments:
30
+ - 1
31
+ - 1
32
+ - 0
33
+ version: 1.1.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Annyong starts a public static Web server in the current directory, allowing people in your local network to browse your files.
37
+ email: remi@exomel.com
38
+ executables:
39
+ - annyong
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - lib/annyong/middleware.rb
46
+ - lib/annyong.rb
47
+ - README.mkd
48
+ - LICENSE
49
+ - bin/annyong
50
+ - assets/css/annyong.css
51
+ - assets/rack/config.ru
52
+ has_rdoc: true
53
+ homepage: http://github.com/remiprev/annyong
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 1.6.0
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Start a public static Web server in the current directory.
86
+ test_files: []
87
+