hubdown 0.0.2 → 0.0.3
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.
- data/bin/hubdown +36 -52
- data/hubdown.gemspec +0 -1
- data/lib/hubdown/cli_parser.rb +22 -0
- data/lib/hubdown/page_builder.rb +53 -0
- data/lib/hubdown/version.rb +1 -1
- metadata +4 -18
data/bin/hubdown
CHANGED
@@ -1,56 +1,40 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'github/markdown'
|
3
|
+
require 'hubdown/cli_parser'
|
4
|
+
require 'hubdown/page_builder'
|
5
|
+
require 'bcat'
|
6
|
+
|
7
|
+
def init
|
8
|
+
@file_name = ARGV.shift
|
9
|
+
output = ""
|
10
|
+
parser = CliParser.new
|
11
|
+
parser.run ARGV
|
12
|
+
mdown = create_mdown
|
13
|
+
|
14
|
+
if parser.config[:output] || parser.config[:wrap]
|
15
|
+
p = Hubdown::PageBuilder.new mdown
|
16
|
+
page_data = p.get_page
|
17
|
+
if parser.config[:output]
|
18
|
+
File.open( parser.config[:output], "w" ) { |f| f.write page_data }
|
19
|
+
end
|
20
|
+
if parser.config[:wrap]
|
21
|
+
output = page_data
|
22
|
+
end
|
23
|
+
else
|
24
|
+
output = mdown
|
25
|
+
end
|
26
|
+
|
27
|
+
if output != ""
|
28
|
+
puts output
|
29
|
+
end
|
30
|
+
|
3
31
|
|
4
|
-
file_name = ARGV[0]
|
5
|
-
#output_file_name = ARGV[1] ||"#{file_name.split('.')[0]}.html"
|
6
|
-
output_file_name = ARGV[1]
|
7
|
-
|
8
|
-
css_links = [];
|
9
|
-
css_links << "https://a248.e.akamai.net/assets.github.com/assets/github-8dd5c1a834790ecb6b900ff7b2d9a1377fd5aef1.css"
|
10
|
-
css_links << "https://a248.e.akamai.net/assets.github.com/assets/github2-4591451faf42b997173d752065f048736e6f9872.css"
|
11
|
-
|
12
|
-
opening = <<EOF
|
13
|
-
<!DOCTYPE html>
|
14
|
-
<html>
|
15
|
-
<head>
|
16
|
-
<title>#{output_file_name}</title>
|
17
|
-
<link href="https://a248.e.akamai.net/assets.github.com/assets/github-8dd5c1a834790ecb6b900ff7b2d9a1377fd5aef1.css" media="screen" rel="stylesheet" type="text/css" />
|
18
|
-
<link href="https://a248.e.akamai.net/assets.github.com/assets/github2-4591451faf42b997173d752065f048736e6f9872.css" media="screen" rel="stylesheet" type="text/css" />
|
19
|
-
<style>
|
20
|
-
#wrapper {
|
21
|
-
width: 920px;
|
22
|
-
margin: 20px auto;
|
23
|
-
}
|
24
|
-
</style>
|
25
|
-
</head>
|
26
|
-
|
27
|
-
<body>
|
28
|
-
<div id="wrapper">
|
29
|
-
<div id="slider">
|
30
|
-
<div class="frames">
|
31
|
-
<div class="frame">
|
32
|
-
<div id="readme" class="clearfix announce instapaper_body md">
|
33
|
-
<span class="name">#{file_name}</span>
|
34
|
-
<article class="markdown-body entry-content">
|
35
|
-
EOF
|
36
|
-
|
37
|
-
closing = <<EOF
|
38
|
-
</article>
|
39
|
-
</div>
|
40
|
-
</div>
|
41
|
-
</div>
|
42
|
-
</div>
|
43
|
-
</div>
|
44
|
-
</body>
|
45
|
-
</html>
|
46
|
-
EOF
|
47
|
-
|
48
|
-
readme = GitHub::Markdown.render_gfm File.read(file_name)
|
49
|
-
file_contents = "#{opening}#{readme}#{closing}"
|
50
|
-
|
51
|
-
if (output_file_name)
|
52
|
-
File.open( output_file_name, "w") { |f| f.write file_contents }
|
53
|
-
puts "... created: #{output_file_name}"
|
54
|
-
else
|
55
|
-
puts file_contents
|
56
32
|
end
|
33
|
+
|
34
|
+
def create_mdown
|
35
|
+
md = GitHub::Markdown.render_gfm File.read(@file_name)
|
36
|
+
md
|
37
|
+
end
|
38
|
+
|
39
|
+
init
|
40
|
+
|
data/hubdown.gemspec
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mixlib/cli'
|
3
|
+
|
4
|
+
class CliParser
|
5
|
+
include Mixlib::CLI
|
6
|
+
|
7
|
+
option :output,
|
8
|
+
:short => "-o OUTPUT",
|
9
|
+
:long => "--output OUTPUT",
|
10
|
+
:description => "Name of the file to write the converted markdown into"
|
11
|
+
|
12
|
+
option :wrap,
|
13
|
+
:short => "-w",
|
14
|
+
:long => "--wrap",
|
15
|
+
:description => "Wrap the markdown in html and add styles",
|
16
|
+
:boolean => true
|
17
|
+
|
18
|
+
|
19
|
+
def run(argv=ARGV)
|
20
|
+
parse_options(argv)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Hubdown
|
2
|
+
class PageBuilder
|
3
|
+
|
4
|
+
def initialize body
|
5
|
+
@body = body
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_page
|
9
|
+
page = "#{get_head}#{@body}#{get_closing}"
|
10
|
+
page
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_head
|
14
|
+
opening = <<EOF
|
15
|
+
<!DOCTYPE html>
|
16
|
+
<html>
|
17
|
+
<head>
|
18
|
+
<title>OUTPUT</title>
|
19
|
+
<link href="https://a248.e.akamai.net/assets.github.com/assets/github-8dd5c1a834790ecb6b900ff7b2d9a1377fd5aef1.css" media="screen" rel="stylesheet" type="text/css" />
|
20
|
+
<link href="https://a248.e.akamai.net/assets.github.com/assets/github2-4591451faf42b997173d752065f048736e6f9872.css" media="screen" rel="stylesheet" type="text/css" />
|
21
|
+
<style>
|
22
|
+
#wrapper {
|
23
|
+
width: 920px;
|
24
|
+
margin: 20px auto;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
</head>
|
28
|
+
|
29
|
+
<body>
|
30
|
+
<div id="wrapper">
|
31
|
+
<div id="slider">
|
32
|
+
<div class="frames">
|
33
|
+
<div class="frame">
|
34
|
+
<div id="readme" class="clearfix announce instapaper_body md">
|
35
|
+
<span class="name">FILE_NAME</span>
|
36
|
+
<article class="markdown-body entry-content">
|
37
|
+
EOF
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_closing
|
41
|
+
closing = <<EOF
|
42
|
+
</article>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
</body>
|
49
|
+
</html>
|
50
|
+
EOF
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/hubdown/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: github-markdown
|
@@ -43,22 +43,6 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: paint
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
46
|
description: CLI for GitHub Flavored markdown to html convervsion
|
63
47
|
email:
|
64
48
|
- knomedia@gmail.com
|
@@ -75,6 +59,8 @@ files:
|
|
75
59
|
- bin/hubdown
|
76
60
|
- hubdown.gemspec
|
77
61
|
- lib/hubdown.rb
|
62
|
+
- lib/hubdown/cli_parser.rb
|
63
|
+
- lib/hubdown/page_builder.rb
|
78
64
|
- lib/hubdown/version.rb
|
79
65
|
homepage: https://github.com/knomedia/hubdown
|
80
66
|
licenses: []
|