blogdown 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9eba8d10ef0fb358e045c00490ded930e13cbba0
4
- data.tar.gz: 3f5508967a15fbae4a3bfa7d7089432947e94a47
3
+ metadata.gz: e19d427da983e276121f038c43dd14e56bc3dd4d
4
+ data.tar.gz: c7e73cf46279b3227f78c05542695252c314a204
5
5
  SHA512:
6
- metadata.gz: 9d6cfe69b98cecc9e6af56223a000b137aefa1837cf1591f021914ef8a48066d4c78c27e5a612348f5f88cc952d0af64e50ce888c89e6c3a852b19b2c1a07d8a
7
- data.tar.gz: 8bd6b80c4b8d9ad3823893e3fce3abfddc685c23abd80a534196311996abb521afbe330bdbdb17c44847b15840449d9a5fb8142c984b5065621920b7bfa945d9
6
+ metadata.gz: c979718291944fbd040060d4c9547ab4c6d77caab593399f6665ae84065fc953fb68e2b50d2ea64021f6074c01c57f5226d38375866a28035c991dcc88dd2e1d
7
+ data.tar.gz: 3c119d2dc2bfa8a78ae686820f979d3717e6e737d50f25c8a000ffdb1b47d3cbc82e00ce18a8d7fbeed60c7460ff5e3e4890b5840a6c78ebdd43c5138a31d635
data/README.md CHANGED
@@ -1,53 +1,54 @@
1
1
  # Blogdown
2
2
 
3
3
  ## Features
4
- * syntax highlighting
5
- * easy to use
6
4
 
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'blogdown'
12
-
13
- And then execute:
5
+ * Generates html from markdown files
6
+ * Syntax highlighting with coderay
7
+ * Built in server
8
+ * Simple and beautiful UI
14
9
 
15
- $ bundle
10
+ ## Installation
16
11
 
17
- Or install it yourself as:
12
+ Run:
18
13
 
19
14
  $ gem install blogdown
20
15
 
21
-
22
- ## What it does
23
-
24
- This gem converts markdown files to html files
25
-
26
-
27
16
  ## Usage
28
17
 
29
18
  Create a directory for your project
30
19
 
31
- mkdir blogdown
20
+ $ mkdir blogdown
32
21
 
33
22
  Inside your freshly created folder create another folder "posts"
34
23
 
35
- cd blogdown
36
- mkdir posts
24
+ $ cd blogdown
25
+ $ mkdir posts
37
26
 
38
- Now, put all your markdown files inside this "posts" folder, remember to use the `.md` extendion
27
+ Now, put all your markdown files inside this "posts" folder, remember to use the `.md` extension
39
28
  eg. `hello.md`
40
29
 
41
- If you are done, and wish to build your html, for your rich text editor,
42
- navigate to your project root directory (our case 1blogdown`), And Run
30
+ ## Building html
31
+
32
+ If you are only interested in getting html files, navigate to the project root directory and run the following command.
33
+
34
+ $ blogdown build
35
+
36
+ This will create `output` directory and dump all html files there. The naming convention is simple.
37
+ `hello.md` will produce `hello.md.html`.
38
+
39
+ ## Serving the files
40
+
41
+ In some cases you might be interested to see what they might be like in a browser. There is a feature for you.
42
+ Just navigate to the project root and run.
43
43
 
44
- blogdown build
44
+ $ blongdown server
45
45
 
46
- A new directory "output" will be created and the respective output files(html) will be inside the folder
46
+ Behing the scene, the command will build the project first, and run a webserver which will be available at `http://localhost:4567`
47
+ copy `http://localhost:4567` and paste into your browser to see the files and view them with much more options.
47
48
 
48
49
  ## Contributing
49
50
 
50
- 1. Fork it ( https://github.com/[my-github-username]/blogdown/fork )
51
+ 1. Fork it ( https://github.com/gernest/blogdown/fork )
51
52
  2. Create your feature branch (`git checkout -b my-new-feature`)
52
53
  3. Commit your changes (`git commit -am 'Add some feature'`)
53
54
  4. Push to the branch (`git push origin my-new-feature`)
data/blogdown.gemspec CHANGED
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "kramdown", "~> 1.4.0"
27
27
  spec.add_dependency "coderay", "~> 1.1.0"
28
28
  spec.add_dependency "thor", "~> 0.19.1"
29
+ spec.add_dependency "sinatra", "~> 1.4.5"
30
+
29
31
  end
@@ -0,0 +1,8 @@
1
+ Feature: Serving The Files
2
+ I need to preview my posts in the browser
3
+
4
+ Scenario: The index page
5
+ When I run command "server"
6
+ When I visit "/"
7
+ Then I should see an Index Page
8
+
@@ -0,0 +1,15 @@
1
+ require 'aruba/cucumber'
2
+
3
+ When(/^I run command "(.*?)"$/) do |cmd|
4
+ args=Array.new
5
+ args<<cmd
6
+ Blogdown::Cli::CommandLine.start args
7
+ end
8
+
9
+
10
+ When(/^I visit "(.*?)"$/) do |arg1|
11
+ end
12
+
13
+ Then(/^I should see an Index Page$/) do
14
+ pending # express the regexp above with the code you wish you had
15
+ end
@@ -0,0 +1,35 @@
1
+ module Blogdown
2
+ class PreviewApp<Sinatra::Application
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
+ get '/' do
18
+ erb :home, :layout => :base
19
+ end
20
+
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
+ end
35
+ end
data/lib/blogdown/cli.rb CHANGED
@@ -1,12 +1,12 @@
1
- require 'thor'
2
-
3
-
4
1
  module Blogdown
5
2
  module Cli
3
+ # Commandline app for blogdown
6
4
  class CommandLine<Thor
7
5
 
8
6
  desc "build", "builds the html files"
9
7
  def build
8
+ # Builds html files from markdown files, located in output
9
+ # and posts folders respectively
10
10
  begin
11
11
  publisher=Blogdown::Publisher.new(Dir.pwd)
12
12
  publisher.compose
@@ -14,6 +14,14 @@ module Blogdown
14
14
  puts e.message
15
15
  end
16
16
  end
17
+
18
+ desc "server", "serves the project for preview"
19
+ def server
20
+ # Runs Sinatra built in server on the project root drectory
21
+ ENV['BD']=Dir.pwd
22
+ build
23
+ Blogdown::PreviewApp.run!
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,7 +1,6 @@
1
1
  module Blogdown
2
2
  module Exceptions
3
3
  class DirectoryNotFound<Exception
4
-
5
4
  end
6
5
  end
7
6
  end
@@ -1,5 +1,7 @@
1
1
  module Blogdown
2
2
  class FilePipeline
3
+ # THis keeps track of files being processed
4
+
3
5
  attr_accessor :stack
4
6
  def initialize(root)
5
7
  @root=root
@@ -8,6 +10,7 @@ module Blogdown
8
10
  load_files
9
11
  end
10
12
 
13
+ # @return [Array] The files under posts folder
11
14
  def load_files
12
15
  base_input=@root+'/posts'
13
16
 
@@ -24,11 +27,19 @@ module Blogdown
24
27
  end
25
28
  end
26
29
 
30
+ # Writes given contents into a file with a name given as a parameter
31
+ # @param name [String] The name of the file to be written
32
+ # @param contents [String] The contents to be written on the file
27
33
  def writer(name,contents)
28
34
  file=@base.to_s+"/output/#{name}.html"
29
- file=File.new(file.to_s,"w")
30
- file.write(contents)
31
- file.close
35
+
36
+ begin
37
+ file=File.new(file.to_s,"w")
38
+ file.write(contents)
39
+ file.close
40
+ rescue Exception=>e
41
+ raise e
42
+ end
32
43
  end
33
44
  end
34
45
  end
@@ -1,3 +1,3 @@
1
- module Blogdown
2
- VERSION = "0.0.2"
3
- end
1
+ module Blogdown
2
+ VERSION = "0.1.0"
3
+ end
data/lib/blogdown.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  require 'pathname'
2
+ require 'sinatra'
3
+ require 'thor'
4
+
2
5
  require "blogdown/version"
3
6
  require 'blogdown/exceptions'
4
7
  require 'blogdown/file_pipeline'
5
8
  require 'blogdown/publisher'
9
+ require 'blogdown/app'
6
10
  require 'blogdown/cli'
7
11
 
8
12
  module Blogdown
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,226 @@
1
+ html, body, div, span, applet, object, iframe,
2
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3
+ a, abbr, acronym, address, big, cite, code,
4
+ del, dfn, em, img, ins, kbd, q, s, samp,
5
+ small, strike, strong, sub, sup, tt, var,
6
+ b, u, i, center,
7
+ dl, dt, dd, ol, ul, li,
8
+ fieldset, form, label, legend,
9
+ table, caption, tbody, tfoot, thead, tr, th, td,
10
+ article, aside, canvas, details, embed,
11
+ figure, figcaption, footer, header, hgroup,
12
+ menu, nav, output, ruby, section, summary,
13
+ time, mark, audio, video {
14
+ margin: 0;
15
+ padding: 0;
16
+ border: 0;
17
+ font-size: 100%;
18
+ font: inherit;
19
+ vertical-align: baseline;
20
+ }
21
+ /* HTML5 display-role reset for older browsers */
22
+ article, aside, details, figcaption, figure,
23
+ footer, header, hgroup, menu, nav, section {
24
+ display: block;
25
+ }
26
+ body {
27
+ line-height: 1;
28
+ }
29
+ ol, ul {
30
+ list-style: none;
31
+ }
32
+ blockquote, q {
33
+ quotes: none;
34
+ }
35
+ blockquote:before, blockquote:after,
36
+ q:before, q:after {
37
+ content: '';
38
+ content: none;
39
+ }
40
+ table {
41
+ border-collapse: collapse;
42
+ border-spacing: 0;
43
+ }
44
+ body {
45
+ font-size: 13px;
46
+ line-height: 1.5;
47
+ font-family: 'Helvetica Neue', Helvetica, Arial, serif;
48
+ color: #000;
49
+ }
50
+
51
+ a {
52
+ color: #d5000d;
53
+ font-weight: bold;
54
+ }
55
+
56
+ header {
57
+ padding-top: 35px;
58
+ padding-bottom: 10px;
59
+ }
60
+
61
+ header h1 {
62
+ font-weight: bold;
63
+ letter-spacing: -1px;
64
+ font-size: 48px;
65
+ color: #303030;
66
+ line-height: 1.2;
67
+ }
68
+
69
+ header h2 {
70
+ letter-spacing: -1px;
71
+ font-size: 24px;
72
+ color: #aaa;
73
+ font-weight: normal;
74
+ line-height: 1.3;
75
+ }
76
+ #downloads {
77
+ display: none;
78
+ }
79
+ #main_content {
80
+ padding-top: 20px;
81
+ }
82
+
83
+ code, pre {
84
+ font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal;
85
+ color: #222;
86
+ margin-bottom: 30px;
87
+ font-size: 12px;
88
+ }
89
+
90
+ code {
91
+ padding: 0 3px;
92
+ }
93
+
94
+ pre {
95
+ border: solid 1px #ddd;
96
+ padding: 20px;
97
+ overflow: auto;
98
+ }
99
+ pre code {
100
+ padding: 0;
101
+ }
102
+
103
+ ul, ol, dl {
104
+ margin-bottom: 20px;
105
+ }
106
+
107
+
108
+ /* COMMON STYLES */
109
+
110
+ table {
111
+ width: 100%;
112
+ border: 1px solid #ebebeb;
113
+ }
114
+
115
+ th {
116
+ font-weight: 500;
117
+ }
118
+
119
+ td {
120
+ border: 1px solid #ebebeb;
121
+ text-align: center;
122
+ font-weight: 300;
123
+ }
124
+
125
+ form {
126
+ background: #f2f2f2;
127
+ padding: 20px;
128
+
129
+ }
130
+
131
+
132
+ /* GENERAL ELEMENT TYPE STYLES */
133
+
134
+ h1 {
135
+ font-size: 2.8em;
136
+ }
137
+
138
+ h2 {
139
+ font-size: 22px;
140
+ font-weight: bold;
141
+ color: #303030;
142
+ margin-bottom: 8px;
143
+ }
144
+
145
+ h3 {
146
+ color: #d5000d;
147
+ font-size: 18px;
148
+ font-weight: bold;
149
+ margin-bottom: 8px;
150
+ }
151
+
152
+ h4 {
153
+ font-size: 16px;
154
+ color: #303030;
155
+ font-weight: bold;
156
+ }
157
+
158
+ h5 {
159
+ font-size: 1em;
160
+ color: #303030;
161
+ }
162
+
163
+ h6 {
164
+ font-size: .8em;
165
+ color: #303030;
166
+ }
167
+
168
+ p {
169
+ font-weight: 300;
170
+ margin-bottom: 20px;
171
+ }
172
+
173
+ a {
174
+ text-decoration: none;
175
+ }
176
+
177
+ p a {
178
+ font-weight: 400;
179
+ }
180
+
181
+ blockquote {
182
+ font-size: 1.6em;
183
+ border-left: 10px solid #e9e9e9;
184
+ margin-bottom: 20px;
185
+ padding: 0 0 0 30px;
186
+ }
187
+
188
+ ul li {
189
+ list-style: disc inside;
190
+ padding-left: 20px;
191
+ }
192
+
193
+ ol li {
194
+ list-style: decimal inside;
195
+ padding-left: 3px;
196
+ }
197
+
198
+ dl dd {
199
+ font-style: italic;
200
+ font-weight: 100;
201
+ }
202
+
203
+ footer {
204
+ margin-top: 40px;
205
+ padding-top: 20px;
206
+ padding-bottom: 30px;
207
+ font-size: 13px;
208
+ color: #aaa;
209
+ }
210
+
211
+ footer a {
212
+ color: #666;
213
+ }
214
+
215
+ /* MISC */
216
+ .clearfix:after {
217
+ clear: both;
218
+ content: '.';
219
+ display: block;
220
+ visibility: hidden;
221
+ height: 0;
222
+ }
223
+
224
+ .clearfix {display: inline-block;}
225
+ * html .clearfix {height: 1%;}
226
+ .clearfix {display: block;}
@@ -0,0 +1,69 @@
1
+ .highlight { background: #ffffff; }
2
+ .highlight .c { color: #999988; font-style: italic } /* Comment */
3
+ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
4
+ .highlight .k { font-weight: bold } /* Keyword */
5
+ .highlight .o { font-weight: bold } /* Operator */
6
+ .highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
7
+ .highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
8
+ .highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
9
+ .highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
10
+ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
11
+ .highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
12
+ .highlight .ge { font-style: italic } /* Generic.Emph */
13
+ .highlight .gr { color: #aa0000 } /* Generic.Error */
14
+ .highlight .gh { color: #999999 } /* Generic.Heading */
15
+ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
16
+ .highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
17
+ .highlight .go { color: #888888 } /* Generic.Output */
18
+ .highlight .gp { color: #555555 } /* Generic.Prompt */
19
+ .highlight .gs { font-weight: bold } /* Generic.Strong */
20
+ .highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
21
+ .highlight .gt { color: #aa0000 } /* Generic.Traceback */
22
+ .highlight .kc { font-weight: bold } /* Keyword.Constant */
23
+ .highlight .kd { font-weight: bold } /* Keyword.Declaration */
24
+ .highlight .kn { font-weight: bold } /* Keyword.Namespace */
25
+ .highlight .kp { font-weight: bold } /* Keyword.Pseudo */
26
+ .highlight .kr { font-weight: bold } /* Keyword.Reserved */
27
+ .highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
28
+ .highlight .m { color: #009999 } /* Literal.Number */
29
+ .highlight .s { color: #d14 } /* Literal.String */
30
+ .highlight .na { color: #008080 } /* Name.Attribute */
31
+ .highlight .nb { color: #0086B3 } /* Name.Builtin */
32
+ .highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
33
+ .highlight .no { color: #008080 } /* Name.Constant */
34
+ .highlight .ni { color: #800080 } /* Name.Entity */
35
+ .highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
36
+ .highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
37
+ .highlight .nn { color: #555555 } /* Name.Namespace */
38
+ .highlight .nt { color: #000080 } /* Name.Tag */
39
+ .highlight .nv { color: #008080 } /* Name.Variable */
40
+ .highlight .ow { font-weight: bold } /* Operator.Word */
41
+ .highlight .w { color: #bbbbbb } /* Text.Whitespace */
42
+ .highlight .mf { color: #009999 } /* Literal.Number.Float */
43
+ .highlight .mh { color: #009999 } /* Literal.Number.Hex */
44
+ .highlight .mi { color: #009999 } /* Literal.Number.Integer */
45
+ .highlight .mo { color: #009999 } /* Literal.Number.Oct */
46
+ .highlight .sb { color: #d14 } /* Literal.String.Backtick */
47
+ .highlight .sc { color: #d14 } /* Literal.String.Char */
48
+ .highlight .sd { color: #d14 } /* Literal.String.Doc */
49
+ .highlight .s2 { color: #d14 } /* Literal.String.Double */
50
+ .highlight .se { color: #d14 } /* Literal.String.Escape */
51
+ .highlight .sh { color: #d14 } /* Literal.String.Heredoc */
52
+ .highlight .si { color: #d14 } /* Literal.String.Interpol */
53
+ .highlight .sx { color: #d14 } /* Literal.String.Other */
54
+ .highlight .sr { color: #009926 } /* Literal.String.Regex */
55
+ .highlight .s1 { color: #d14 } /* Literal.String.Single */
56
+ .highlight .ss { color: #990073 } /* Literal.String.Symbol */
57
+ .highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
58
+ .highlight .vc { color: #008080 } /* Name.Variable.Class */
59
+ .highlight .vg { color: #008080 } /* Name.Variable.Global */
60
+ .highlight .vi { color: #008080 } /* Name.Variable.Instance */
61
+ .highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
62
+
63
+ .type-csharp .highlight .k { color: #0000FF }
64
+ .type-csharp .highlight .kt { color: #0000FF }
65
+ .type-csharp .highlight .nf { color: #000000; font-weight: normal }
66
+ .type-csharp .highlight .nc { color: #2B91AF }
67
+ .type-csharp .highlight .nn { color: #000000 }
68
+ .type-csharp .highlight .s { color: #A31515 }
69
+ .type-csharp .highlight .sc { color: #A31515 }