blogdown 0.1.2 → 0.2.0

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +23 -23
  3. data/.travis.yml +5 -0
  4. data/1.PNG +0 -0
  5. data/2.PNG +0 -0
  6. data/Gemfile +3 -3
  7. data/LICENSE.txt +22 -22
  8. data/README.md +53 -54
  9. data/Rakefile +13 -2
  10. data/blogdown.gemspec +33 -31
  11. data/lib/blogdown.rb +13 -13
  12. data/lib/blogdown/app.rb +7 -27
  13. data/lib/blogdown/cli.rb +0 -13
  14. data/lib/blogdown/file_pipeline.rb +5 -3
  15. data/lib/blogdown/publisher.rb +22 -21
  16. data/lib/blogdown/version.rb +1 -1
  17. data/lib/public/css/blogdown.css +131 -0
  18. data/lib/public/css/bootstrap-theme.css +347 -0
  19. data/lib/public/css/bootstrap-theme.css.map +1 -0
  20. data/lib/public/css/bootstrap-theme.min.css +7 -0
  21. data/lib/public/css/bootstrap.css +5785 -0
  22. data/lib/public/css/bootstrap.css.map +1 -0
  23. data/lib/public/css/bootstrap.min.css +7 -0
  24. data/lib/public/css/prettify.css +30 -0
  25. data/lib/public/fonts/glyphicons-halflings-regular.eot +0 -0
  26. data/lib/public/fonts/glyphicons-halflings-regular.svg +229 -0
  27. data/lib/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  28. data/lib/public/fonts/glyphicons-halflings-regular.woff +0 -0
  29. data/lib/public/js/blogdown.js +8 -0
  30. data/lib/public/js/bootstrap.js +1951 -0
  31. data/lib/public/js/bootstrap.min.js +6 -0
  32. data/lib/public/js/jquery.js +9154 -0
  33. data/lib/views/index.erb +29 -0
  34. data/lib/views/layout.erb +36 -0
  35. data/spec/blogdown/blogdown_spec.rb +3 -14
  36. data/spec/fixtures/hello.md +1 -0
  37. data/spec/spec_helper.rb +7 -0
  38. metadata +42 -40
  39. data/features/server.feature +0 -8
  40. data/features/step_definitions/blogdown_steps.rb +0 -15
  41. data/features/support/env.rb +0 -2
  42. data/lib/public/images/body-bg.png +0 -0
  43. data/lib/public/images/highlight-bg.jpg +0 -0
  44. data/lib/public/images/hr.png +0 -0
  45. data/lib/public/images/octocat-icon.png +0 -0
  46. data/lib/public/images/tar-gz-icon.png +0 -0
  47. data/lib/public/images/zip-icon.png +0 -0
  48. data/lib/public/javascripts/main.js +0 -0
  49. data/lib/public/stylesheets/print.css +0 -226
  50. data/lib/public/stylesheets/pygment_trac.css +0 -69
  51. data/lib/public/stylesheets/stylesheet.css +0 -371
  52. data/lib/views/base.erb +0 -42
  53. data/lib/views/home.erb +0 -18
  54. data/lib/views/post.erb +0 -438
  55. data/spec/fixtures/posts/hello.md +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d81cd06eac2832629d42bd77ff6a816098d4679
4
- data.tar.gz: e5d6a7e75944bcacccd67ede28ac0556778f24be
3
+ metadata.gz: 885b01ce2126bc63a1cfbd7043146d4882420246
4
+ data.tar.gz: b1376f914ae814507e524b5d557a3067a694501f
5
5
  SHA512:
6
- metadata.gz: 335919844cd0d6b76ee39314937f0e6a68ba55c5b40c2869acfb7a1e70199e4bc53499ab0ed1f2afd7c0212976c5a4c5d8f7d3f2ffbdfc7e1ed2863e9f725c00
7
- data.tar.gz: 6a114f4c632642d30c36c2c5698ec52255904dd04a819beda5d5da6e5fd85fb10dfd990c377b81f55d3bd0a7dc2be1afbeea9adc999828e7c4536d650e6c58ff
6
+ metadata.gz: 471ca516d1c92eb37546ae2e9985d9d82aab8aa2fce4ae3dc387758235a2351037e3b6f5f8717b3b173bcbe7e63649851bd18191acbe528c89dcc14f527bd3be
7
+ data.tar.gz: f5c7ac656ddc99104fcdbe438ad7476341dc6529aaf4ecc50dc141a606edc53c19e3b105e4e2164f6fcafce02f6ef437ae86968ed9ff424b16bcd1a3cf62a46a
data/.gitignore CHANGED
@@ -1,23 +1,23 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
23
- .idea
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+
5
+ script: bundle exec rake
data/1.PNG ADDED
Binary file
data/2.PNG ADDED
Binary file
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in blogdown.gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blogdown.gemspec
4
4
  gemspec
@@ -1,22 +1,22 @@
1
- Copyright (c) 2014 gernest
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2014 gernest
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,54 +1,53 @@
1
- # Blogdown
2
-
3
- ## Features
4
-
5
- * Generates html from markdown files
6
- * Syntax highlighting with coderay
7
- * Built in server
8
-
9
- ## Installation
10
-
11
- Run:
12
-
13
- $ gem install blogdown
14
-
15
- ## Usage
16
-
17
- Create a directory for your project
18
-
19
- $ mkdir blogdown
20
-
21
- Inside your freshly created folder create another folder "posts"
22
-
23
- $ cd blogdown
24
- $ mkdir posts
25
-
26
- Now, put all your markdown files inside this "posts" folder, remember to use the `.md` extension
27
- eg. `hello.md`
28
-
29
- ## Building html
30
-
31
- If you are only interested in getting html files, navigate to the project root directory and run the following command.
32
-
33
- $ blogdown build
34
-
35
- This will create `output` directory and dump all html files there. The naming convention is simple.
36
- `hello.md` will produce `hello.md.html`.
37
-
38
- ## Serving the files
39
-
40
- In some cases you might be interested to see what they might be like in a browser. There is a feature for you.
41
- Just navigate to the project root and run.
42
-
43
- $ blongdown server
44
-
45
- Behing the scene, the command will build the project first, and run a webserver which will be available at `http://localhost:4567`
46
- copy `http://localhost:4567` and paste into your browser to see the files and view them with much more options.
47
-
48
- ## Contributing
49
-
50
- 1. Fork it ( https://github.com/gernest/blogdown/fork )
51
- 2. Create your feature branch (`git checkout -b my-new-feature`)
52
- 3. Commit your changes (`git commit -am 'Add some feature'`)
53
- 4. Push to the branch (`git push origin my-new-feature`)
54
- 5. Create a new Pull Request
1
+ # Blogdown
2
+ [![Build Status](https://travis-ci.org/gernest/blogdown.svg?branch=master)](https://travis-ci.org/gernest/blogdown)
3
+
4
+ [![Coverage Status](https://coveralls.io/repos/gernest/blogdown/badge.png)](https://coveralls.io/r/gernest/blogdown)
5
+
6
+
7
+ ## What this is all about
8
+ Blogdown helps to view your favorite github wiki offline. I created this
9
+ project to help me, have a good source of documentation on my pc,
10
+ since I dont have the privilege of internet access. I go online once in a
11
+ while, and its frusttating when I ineed to go online to view documentation.
12
+
13
+
14
+
15
+
16
+ ## Installation
17
+
18
+ Run:
19
+
20
+ $ gem install blogdown
21
+
22
+ ## Usage
23
+
24
+ Clone your favorite wiki
25
+
26
+ $ git clone [The Wiki URL goes HERE]
27
+
28
+ Cd into your wiki directory
29
+
30
+ $cd mywiki.wiki
31
+
32
+
33
+ And, blog it down
34
+
35
+ $ blogdown server
36
+
37
+ Behing the scene, the command will build the project first, and run a webserver which will be available at `http://localhost:4567`
38
+ copy `http://localhost:4567` and paste into your browser to see the files and view them with much more options.
39
+
40
+ ## Snapshots
41
+ ![blogdown](/1.PNG?raw=true "Blogdown")
42
+
43
+ ![blogdown](/2.PNG?raw=true "Blogdown")
44
+
45
+
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/gernest/blogdown/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1,13 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc "Run RSpec"
7
+ RSpec::Core::RakeTask.new('spec')
8
+
9
+
10
+ desc "Run tests, both RSpec and Cucumber"
11
+ task :test => :spec
12
+
13
+ task :default => :test
@@ -1,31 +1,33 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'blogdown/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "blogdown"
8
- spec.version = Blogdown::VERSION
9
- spec.authors = ["gernest"]
10
- spec.email = ["geofreyernest@live.com"]
11
- spec.summary = %q{Write in markdown for your web based rich text editor}
12
- spec.description = %q{ A Simple Markdown Solution With synntax highlighing}
13
- spec.homepage = "https://github.com/gernest/blogdown"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake","~> 10.3.2"
23
- spec.add_development_dependency "rspec","~>3.0.0"
24
- spec.add_development_dependency "cucumber","~> 1.3.15"
25
-
26
- spec.add_dependency "kramdown", "~> 1.4.0"
27
- spec.add_dependency "coderay", "~> 1.1.0"
28
- spec.add_dependency "thor", "~> 0.19.1"
29
- spec.add_dependency "sinatra", "~> 1.4.5"
30
-
31
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blogdown/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "blogdown"
8
+ spec.version = Blogdown::VERSION
9
+ spec.authors = ["gernest"]
10
+ spec.email = ["geofreyernest@live.com"]
11
+ spec.summary = %q{Turning your github wiki to a nice looking offline
12
+ webpage}
13
+ spec.description = %q{ An offline github wiki viewer}
14
+ spec.homepage = "https://github.com/gernest/blogdown"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake","~> 10.3.2"
24
+ spec.add_development_dependency "rspec","~>3.0.0"
25
+ spec.add_development_dependency "coveralls"
26
+
27
+ spec.add_dependency "redcarpet"
28
+ spec.add_dependency "github-markdown"
29
+
30
+ spec.add_dependency "thor", "~> 0.19.1"
31
+ spec.add_dependency "sinatra", "~> 1.4.5"
32
+
33
+ end
@@ -1,13 +1,13 @@
1
- require 'pathname'
2
- require 'sinatra'
3
- require 'thor'
4
-
5
- require "blogdown/version"
6
- require 'blogdown/exceptions'
7
- require 'blogdown/file_pipeline'
8
- require 'blogdown/publisher'
9
- require 'blogdown/app'
10
- require 'blogdown/cli'
11
-
12
- module Blogdown
13
- end
1
+ require 'pathname'
2
+ require 'sinatra'
3
+ require 'thor'
4
+
5
+ require "blogdown/version"
6
+ require 'blogdown/exceptions'
7
+ require 'blogdown/file_pipeline'
8
+ require 'blogdown/publisher'
9
+ require 'blogdown/app'
10
+ require 'blogdown/cli'
11
+
12
+ module Blogdown
13
+ end
@@ -1,35 +1,15 @@
1
1
  module Blogdown
2
2
  class PreviewApp<Sinatra::Application
3
3
 
4
- helpers do
5
- def built_files
6
- @output=ENV['BD']+'/output'
7
- @files =[]
8
- out =Pathname(@output)
9
- out.each_child do |child|
10
- if child.extname==".html"
11
- @files<<child
12
- end
13
- end
14
- @files
15
- end
16
- end
17
4
  get '/' do
18
- erb :home, :layout => :base
5
+ @wiki_files=self.wiki_files
6
+ erb :index, :layout => :layout
7
+ end
8
+ def wiki_files
9
+ @sources=ENV['BD']
10
+ pub=Blogdown::Publisher.new(@sources)
11
+ pub.compose
19
12
  end
20
13
 
21
-
22
- # Serves generated files found in the ouput folder
23
- # It does so, by reading the files, and dumping the string to be rendered with `erb`
24
- get '/post/:name' do |file_name|
25
- @source_dir=ENV['BD']+'/output/'+file_name.gsub('-', '_')+'.md.html'
26
- @path =Pathname(@source_dir)
27
- if @path.file?
28
- @title=@path.basename.to_s.gsub('.html', '')
29
- erb @path.read, :layout => :post
30
- else
31
- halt 404
32
- end
33
- end
34
14
  end
35
15
  end
@@ -3,23 +3,10 @@ module Blogdown
3
3
  # Commandline app for blogdown
4
4
  class CommandLine<Thor
5
5
 
6
- desc "build", "builds the html files"
7
- def build
8
- # Builds html files from markdown files, located in output
9
- # and posts folders respectively
10
- begin
11
- publisher=Blogdown::Publisher.new(Dir.pwd)
12
- publisher.compose
13
- rescue Exception=>e
14
- puts e.message
15
- end
16
- end
17
-
18
6
  desc "server", "serves the project for preview"
19
7
  def server
20
8
  # Runs Sinatra built in server on the project root drectory
21
9
  ENV['BD']=Dir.pwd
22
- build
23
10
  Blogdown::PreviewApp.run!
24
11
  end
25
12
  end
@@ -12,7 +12,8 @@ module Blogdown
12
12
 
13
13
  # @return [Array] The files under posts folder
14
14
  def load_files
15
- base_input=@root+'/posts'
15
+ puts "loading files from #{@root.to_s}"
16
+ base_input=@root
16
17
 
17
18
  base=Pathname.new(base_input)
18
19
  unless base.exist?
@@ -20,11 +21,12 @@ module Blogdown
20
21
  end
21
22
  if base.exist?
22
23
  base.each_child do|child|
23
- if child.basename.to_s=~/^*.md$/
24
+ puts "loading #{child.to_s}"
24
25
  self.stack<<child
25
- end
26
+ puts "Done"
26
27
  end
27
28
  end
29
+ puts "Finished loading #{self.stack.length} files"
28
30
  end
29
31
 
30
32
  # Writes given contents into a file with a name given as a parameter
@@ -1,47 +1,48 @@
1
- require 'coderay'
2
- require 'kramdown'
1
+ require 'redcarpet'
2
+ require 'github/markdown'
3
3
 
4
4
  module Blogdown
5
5
  class Publisher
6
+ attr_accessor :renderer,:markdown
6
7
  def initialize root
7
8
  @pipeline=Blogdown::FilePipeline.new root
8
9
  @base=root
10
+ @output_stack={}
11
+ @renderer=Redcarpet::Render::HTML.new(render_options)
12
+ @markdown=Redcarpet::Markdown.new(@renderer, markdown_options)
9
13
  end
10
14
 
11
15
  def compose
12
- clean_output
13
16
  if @pipeline.stack.empty?
14
17
  raise IOError, "No file to compose"
15
18
  else
16
19
  @pipeline.stack.each do |file|
17
- htm=transform(file.read)
18
- @pipeline.writer(file.basename,htm)
20
+ if file.file?
21
+ puts "processing #{file.to_s}"
22
+ htm=transform(file.read)
23
+ @output_stack[valid_id(file)]=htm
24
+ puts "done"
25
+ end
26
+
19
27
  end
20
28
  end
21
-
29
+ @output_stack
22
30
  end
23
31
 
24
32
  def transform(txt)
25
- Kramdown::Document.new(txt,kramdown_options).to_html
33
+ self.markdown.render(GitHub::Markdown.render_gfm(txt))
26
34
  end
27
-
28
- def file_stack
29
- @pipeline.stack
35
+ def valid_id(v)
36
+ value=v.basename.to_s.gsub(/^*.([a-z]|[A-Z]){2,}$/,"")
37
+ value=value.gsub(" ","-")
30
38
  end
31
39
 
32
- def clean_output
33
- base_root=@base+'/output'
34
- base_root=Pathname base_root
35
- if base_root.exist?
36
- base_root.rmtree
37
- base_root.mkpath
38
- else
39
- base_root.mkpath
40
- end
40
+ def render_options
41
+ {:with_toc_data=>false, :hard_warp=>true, :prettify=>true}
41
42
  end
42
43
 
43
- def kramdown_options
44
- {coderay_css: "style", coderay_line_numbers: nil}
44
+ def markdown_options
45
+ {:auto_link=>true}
45
46
  end
46
47
  end
47
48
  end