hubdown 0.0.4 → 0.0.5
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/README.md +6 -2
- data/bin/hubdown +12 -2
- data/hubdown.gemspec +1 -0
- data/lib/hubdown/page_builder.rb +13 -43
- data/lib/hubdown/style_scraper.rb +24 -0
- data/lib/hubdown/template.html.erb +31 -0
- data/lib/hubdown/version.rb +1 -1
- metadata +20 -2
data/README.md
CHANGED
@@ -35,7 +35,7 @@ Doing so will send converted markdown to standard output allowing you to pipe th
|
|
35
35
|
$ hubdown file.md -w
|
36
36
|
```
|
37
37
|
|
38
|
-
When passing the `-w` flag hubdown will render the markdown in an approximation of what Github provides and push it to STDOUT.
|
38
|
+
When passing the `-w` flag hubdown will render the markdown in an approximation of what Github provides and push it to STDOUT. See Scraping for CSS below.
|
39
39
|
***
|
40
40
|
### Output to a file
|
41
41
|
|
@@ -43,7 +43,11 @@ When passing the `-w` flag hubdown will render the markdown in an approximation
|
|
43
43
|
$ hubdown my_file.md -o my_file.html
|
44
44
|
```
|
45
45
|
|
46
|
-
When passing the `-o` flag with a file name, hubdown will write the full html output (as though you passed the `-w`) to the file you pass with `-o`.
|
46
|
+
When passing the `-o` flag with a file name, hubdown will write the full html output (as though you passed the `-w`) to the file you pass with `-o`. See Scraping for CSS below.
|
47
|
+
***
|
48
|
+
### Scraping for CSS
|
49
|
+
Note that when you use either the `-w` or `-o` flags, hubdown will use your network connection to scrap the currently used CSS from github.com.
|
50
|
+
|
47
51
|
***
|
48
52
|
|
49
53
|
## Contributing
|
data/bin/hubdown
CHANGED
@@ -11,8 +11,7 @@ def init
|
|
11
11
|
mdown = create_mdown
|
12
12
|
|
13
13
|
if parser.config[:output] || parser.config[:wrap]
|
14
|
-
|
15
|
-
page_data = p.get_page
|
14
|
+
page_data = create_page mdown
|
16
15
|
if parser.config[:output]
|
17
16
|
File.open( parser.config[:output], "w" ) { |f| f.write page_data }
|
18
17
|
end
|
@@ -27,9 +26,20 @@ def init
|
|
27
26
|
puts output
|
28
27
|
end
|
29
28
|
|
29
|
+
end
|
30
30
|
|
31
|
+
def create_page mdown
|
32
|
+
options = {
|
33
|
+
"body" => mdown,
|
34
|
+
"filename" => @file_name,
|
35
|
+
"uri" => 'https://github.com/knomedia/hubdown'
|
36
|
+
}
|
37
|
+
p = Hubdown::PageBuilder.new options
|
38
|
+
page_data = p.get_page
|
39
|
+
page_data
|
31
40
|
end
|
32
41
|
|
42
|
+
|
33
43
|
def create_mdown
|
34
44
|
md = GitHub::Markdown.render_gfm File.read(@file_name)
|
35
45
|
md
|
data/hubdown.gemspec
CHANGED
data/lib/hubdown/page_builder.rb
CHANGED
@@ -1,53 +1,23 @@
|
|
1
|
+
require 'hubdown/style_scraper'
|
2
|
+
require 'erb'
|
3
|
+
|
1
4
|
module Hubdown
|
2
5
|
class PageBuilder
|
3
6
|
|
4
|
-
def initialize
|
5
|
-
@body = body
|
7
|
+
def initialize args
|
8
|
+
@body = args.fetch("body"){ '' }
|
9
|
+
@uri = args.fetch("uri"){ 'https://github.com/knomedia/hubdown' }
|
10
|
+
@filename = args.fetch("filename"){ '' }
|
11
|
+
@scraper = StyleScraper.new( @uri )
|
6
12
|
end
|
7
13
|
|
8
14
|
def get_page
|
9
|
-
|
15
|
+
links = @scraper.get_css_links
|
16
|
+
body = @body
|
17
|
+
filename = @filename
|
18
|
+
template = ERB.new( File.read("lib/hubdown/template.html.erb"), nil, "-" )
|
19
|
+
page = template.result(binding)
|
10
20
|
page
|
11
21
|
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
22
|
end
|
53
23
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class StyleScraper
|
5
|
+
|
6
|
+
def initialize uri
|
7
|
+
@uri = uri
|
8
|
+
begin
|
9
|
+
@page = Nokogiri::HTML( open( @uri ) )
|
10
|
+
rescue
|
11
|
+
puts "It appears we are unable to connect to: #{@uri} for CSS scraping."
|
12
|
+
puts "Please check your internet connection"
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_css_links
|
18
|
+
links = []
|
19
|
+
links = @page.css("link").select{ |link| link['rel'] == 'stylesheet' }
|
20
|
+
links
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= filename || ''%></title>
|
5
|
+
<% links.each do |link| -%>
|
6
|
+
<%= link -%>
|
7
|
+
<% end -%>
|
8
|
+
<style>
|
9
|
+
#wrapper {
|
10
|
+
width: 920px;
|
11
|
+
margin: 20px auto;
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<div id="wrapper">
|
17
|
+
<div id="slider">
|
18
|
+
<div class="frames">
|
19
|
+
<div class="frame">
|
20
|
+
<div id="readme" class="clearfix announce instapaper_body md">
|
21
|
+
<span class="name"><%= filename || ''%></span>
|
22
|
+
<article class="markdown-body entry-content">
|
23
|
+
<%= body -%>
|
24
|
+
</article>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</body>
|
31
|
+
</html>
|
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.5
|
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-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: github-markdown
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: nokogiri
|
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'
|
46
62
|
description: CLI for GitHub Flavored markdown to html convervsion
|
47
63
|
email:
|
48
64
|
- knomedia@gmail.com
|
@@ -61,6 +77,8 @@ files:
|
|
61
77
|
- lib/hubdown.rb
|
62
78
|
- lib/hubdown/cli_parser.rb
|
63
79
|
- lib/hubdown/page_builder.rb
|
80
|
+
- lib/hubdown/style_scraper.rb
|
81
|
+
- lib/hubdown/template.html.erb
|
64
82
|
- lib/hubdown/version.rb
|
65
83
|
homepage: https://github.com/knomedia/hubdown
|
66
84
|
licenses: []
|