markdown-server 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README.mkd +46 -0
  2. data/Rakefile +28 -0
  3. data/bin/markdown-server +73 -0
  4. metadata +75 -0
@@ -0,0 +1,46 @@
1
+ markdown-server
2
+ ===============
3
+
4
+ A very simple server that runs files through markdown before serving them.
5
+
6
+
7
+ Requirements
8
+ ------------
9
+
10
+ * ruby
11
+ * rdiscount
12
+
13
+
14
+ Installation
15
+ ------------
16
+
17
+ $ sudo gem install markdown-server
18
+
19
+
20
+ License
21
+ -------
22
+
23
+ Copyright (c) 2009 Pablo Flouret <quuxbaz@gmail.com>
24
+ All rights reserved.
25
+
26
+ Redistribution and use in source and binary forms, with or without modification,
27
+ are permitted provided that the following conditions are met: Redistributions of
28
+ source code must retain the above copyright notice, this list of conditions and
29
+ the following disclaimer. Redistributions in binary form must reproduce the
30
+ above copyright notice, this list of conditions and the following disclaimer in
31
+ the documentation and/or other materials provided with the distribution.
32
+ Neither the name of the software nor the names of its contributors may be
33
+ used to endorse or promote products derived from this software without specific
34
+ prior written permission.
35
+
36
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
37
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
40
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
+
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+
3
+ require 'date'
4
+ require 'rake'
5
+
6
+ begin
7
+ gem 'jeweler', '>= 0.11.0'
8
+ require 'jeweler'
9
+
10
+ Jeweler::Tasks.new do |s|
11
+ s.name = 'markdown-server'
12
+ s.version = '0.1.1'
13
+ s.date = Time.now.to_s
14
+ s.summary = "A simple server that runs files through markdown before serving them."
15
+ s.description = s.summary
16
+ s.executables = ['markdown-server']
17
+ s.add_dependency("rdiscount")
18
+ s.author = "Pablo Flouret"
19
+ s.email = "quuxbaz@gmail.com"
20
+ s.homepage = "http://github.com/palbo/markdown-server"
21
+ end
22
+ rescue LoadError
23
+ puts "Jeweler not available. Install it with: sudo gem install jeweler --version '>= 0.11.0'"
24
+ exit(1)
25
+ end
26
+
27
+ task :default => :build
28
+
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems' rescue nil
4
+
5
+ require 'optparse'
6
+ require 'rdiscount'
7
+
8
+ module MarkdownServer
9
+ VERSION = "0.1"
10
+ end
11
+
12
+ help = <<HELP
13
+ A simple server that runs files through markdown before serving them.
14
+
15
+ #{$0} [-p|--port PORT] [--version] [-h] [DIRECTORY]
16
+
17
+ HELP
18
+
19
+ options = {:port => 8000}
20
+
21
+ opts = OptionParser.new do |opts|
22
+ opts.banner = help
23
+
24
+ opts.on("--port PORT", "server port (default 8000)") do |port|
25
+ options[:port] = port unless port.nil?
26
+ end
27
+
28
+ opts.on("--version", "Display current version") do
29
+ puts "#{$0}" + MarkdownServer::VERSION
30
+ exit 0
31
+ end
32
+ end
33
+
34
+ opts.parse!
35
+
36
+ require 'webrick'
37
+ include WEBrick
38
+
39
+ class MarkdownizerFileHandler < HTTPServlet::FileHandler
40
+ def do_GET(req, res)
41
+ unless exec_handler(req, res)
42
+ return set_dir_list(req, res)
43
+ end
44
+
45
+ res.body = RDiscount.new(res.body.read).to_html
46
+ end
47
+ end
48
+
49
+ def create_server(err, dir, port)
50
+ dir = File.expand_path(dir)
51
+ err.puts "server in http://#{Socket.gethostname}:#{port} docroot in #{File.expand_path(dir)}"
52
+
53
+ s = HTTPServer.new(
54
+ :Port => port,
55
+ :Logger => WEBrick::Log.new(err),
56
+ :AccessLog => [[ err, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
57
+ [ err, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
58
+ [ err, WEBrick::AccessLog::AGENT_LOG_FORMAT ]]
59
+ )
60
+ s.mount("/", MarkdownizerFileHandler, dir, :FancyIndexing=>true)
61
+ s
62
+ end
63
+
64
+ s = create_server(STDERR, ARGV[0] || ".", options[:port])
65
+ t = Thread.new { s.start }
66
+
67
+ trap(:INT) do
68
+ s.shutdown
69
+ t.join
70
+ exit
71
+ end
72
+ sleep
73
+
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: markdown-server
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - Pablo Flouret
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-05 00:00:00 +01:00
18
+ default_executable: markdown-server
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rdiscount
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: A simple server that runs files through markdown before serving them.
33
+ email: quuxbaz@gmail.com
34
+ executables:
35
+ - markdown-server
36
+ extensions: []
37
+
38
+ extra_rdoc_files:
39
+ - README.mkd
40
+ files:
41
+ - README.mkd
42
+ - Rakefile
43
+ - bin/markdown-server
44
+ has_rdoc: true
45
+ homepage: http://github.com/palbo/markdown-server
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.6
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: A simple server that runs files through markdown before serving them.
74
+ test_files: []
75
+