slimdown 0.1.2 → 1.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.
- checksums.yaml +5 -5
- data/.travis.yml +3 -4
- data/CHANGELOG.md +43 -0
- data/README.md +58 -23
- data/lib/slimdown/exception.rb +1 -0
- data/lib/slimdown/page.rb +18 -14
- data/lib/slimdown/page_parser.rb +5 -2
- data/lib/slimdown/version.rb +1 -1
- data/ruby-slimdown.gemspec +3 -3
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e845fd99a6108c1c7553637a96316710d824d93df0122260490363a2d91605d
|
4
|
+
data.tar.gz: a95a0cb693ed000c5881ea6d055f218180a3617f7c6adcdb95732053719f84b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20d859648791b40e2c65276582d55f4fdc68dffc61c5620cb1b9d74faf471c2841498a2a5f3df516faa03845de9e11ecabb19b001619cce4a505b3cc110c6e0c
|
7
|
+
data.tar.gz: c0a24227009eda9d6538af0130d867d920c9ea6b120f51fa1feeb03c0fe98e8f87e23a1dedf64f928253e5909a1d07a325e31e23be16bf31b3edcd898266a71b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Ruby Slimdown Changelog
|
2
|
+
|
3
|
+
## [master]
|
4
|
+
[master]: https://github.com/APMG/ruby-slimdown/compare/1.1.0...HEAD
|
5
|
+
|
6
|
+
* Your contribution here!
|
7
|
+
|
8
|
+
## [`1.1.0`] (2017-12-04)
|
9
|
+
[`1.1.0`]: https://github.com/APMG/ruby-slimdown/compare/1.0.2...1.1.0
|
10
|
+
|
11
|
+
* [#2](https://github.com/APMG/ruby-slimdown/pull/2): Added page parent method.
|
12
|
+
* [#3](https://github.com/APMG/ruby-slimdown/pull/3): Fixed mutation of `@absolute_path` in `Page`.
|
13
|
+
|
14
|
+
## [`1.0.2`] (2017-03-13)
|
15
|
+
[`1.0.2`]: https://github.com/APMG/ruby-slimdown/compare/1.0.1...1.0.2
|
16
|
+
|
17
|
+
* Add support for arbitrary frontmatter via `Page#headers` method.
|
18
|
+
|
19
|
+
## [`1.0.1`] (2015-07-07)
|
20
|
+
[`1.0.1`]: https://github.com/APMG/ruby-slimdown/compare/1.0.0...1.0.1
|
21
|
+
|
22
|
+
* Fix for case where no frontmatter.
|
23
|
+
|
24
|
+
## [`1.0.0`] (2015-06-23)
|
25
|
+
[`1.0.0`]: https://github.com/APMG/ruby-slimdown/compare/0.1.2...1.0.0
|
26
|
+
|
27
|
+
* Same as 0.1.2, but marking as v1.0.0 to indicate SemVer support.
|
28
|
+
|
29
|
+
## [`0.1.2`] (2015-06-18)
|
30
|
+
[`0.1.2`]: https://github.com/APMG/ruby-slimdown/compare/0.1.1...0.1.2
|
31
|
+
|
32
|
+
* Support hard line breaks with `<br />`.
|
33
|
+
|
34
|
+
## [`0.1.1`] (2015-06-16)
|
35
|
+
[`0.1.1`]: https://github.com/APMG/ruby-slimdown/compare/0.1.0...0.1.1
|
36
|
+
|
37
|
+
* Don't assume files in `pages/`.
|
38
|
+
* Indicate required Ruby version.
|
39
|
+
|
40
|
+
## [`0.1.0`] (2015-06-15)
|
41
|
+
[`0.1.0`]: https://github.com/APMG/ruby-slimdown/compare/c1c7481d493c444529fe40082fc23b935f20c55b...0.1.0
|
42
|
+
|
43
|
+
* Initial release
|
data/README.md
CHANGED
@@ -28,41 +28,76 @@ Or install it yourself as:
|
|
28
28
|
To add to your app, create a controller with one action, such as `show`. In that
|
29
29
|
action, add code to pull in the action:
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
```ruby
|
32
|
+
class SlimdownController < ApplicationController
|
33
|
+
def show
|
34
|
+
@page = Slimdown::Page.find(params[:slug])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
36
38
|
|
37
39
|
Then add a view for the show action.
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
41
|
+
```erb
|
42
|
+
<%= @page.body.to_html.html_safe %>
|
43
|
+
|
44
|
+
<h2>Sibling Pages</h2>
|
45
|
+
<ul>
|
46
|
+
<% @page.siblings.each do |sibling| %>
|
47
|
+
<li><%= link_to sibling.title, "/#{sibling.path}" %></li>
|
48
|
+
<% end %>
|
49
|
+
</ul>
|
50
|
+
|
51
|
+
<h2>Child Pages</h2>
|
52
|
+
<ul>
|
53
|
+
<% @page.children.each do |child| %>
|
54
|
+
<li><%= link_to child.title, "/#{child.path}" %></li>
|
55
|
+
<% end %>
|
56
|
+
</ul>
|
57
|
+
```
|
54
58
|
|
55
59
|
Add a route to direct all unhandled requests to your controller. Make sure that
|
56
|
-
it is at the end of your routes.rb so it doesn't
|
60
|
+
it is at the end of your routes.rb so it doesn't supersede other routes.
|
57
61
|
|
58
|
-
|
62
|
+
```ruby
|
63
|
+
get '/*slug', to: 'slimdown#show'
|
64
|
+
```
|
59
65
|
|
60
66
|
Finally, add an initializer in `config/initializers/slimdown.rb` to set the path
|
61
67
|
to your pages.
|
62
68
|
|
69
|
+
```ruby
|
70
|
+
Slimdown.config do |c|
|
71
|
+
c.location = Rails.root.join('lib/pages')
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
## Testing
|
76
|
+
|
77
|
+
Testing using a controller spec is not possible because you are testing for an
|
78
|
+
arbitrary url. You can do a feature test with Capybara or friends. However,
|
79
|
+
given that you are just returning content, you can use a request spec. For
|
80
|
+
example, you have an about.md in your remote repo or lib/pages then in your
|
81
|
+
spec/requests/slimdown_request_spec.rb. Additionally, you can override the page
|
82
|
+
path for the test, allowing you to use a fixture directory.
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
RSpec.describe "Static Pages", type: :request do
|
86
|
+
before :each do
|
63
87
|
Slimdown.config do |c|
|
64
|
-
c.location = Rails.root.join
|
88
|
+
c.location = Rails.root.join '/spec/fixtures/test_pages'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "GET /" do
|
93
|
+
it "#show" do
|
94
|
+
get "/about"
|
95
|
+
expect(response).to render_template(:show)
|
96
|
+
expect(response.status).to be(200)
|
65
97
|
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
```
|
66
101
|
|
67
102
|
|
68
103
|
## General notes
|
data/lib/slimdown/exception.rb
CHANGED
data/lib/slimdown/page.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Slimdown
|
2
2
|
# The model representing a page
|
3
3
|
class Page
|
4
|
-
|
5
4
|
# The title from the document headers
|
6
5
|
attr_reader :title
|
7
6
|
# The template from the document headers
|
8
7
|
attr_reader :template
|
8
|
+
# All the document headers
|
9
|
+
attr_reader :headers
|
9
10
|
|
10
11
|
# Get new page object
|
11
12
|
#
|
@@ -59,30 +60,33 @@ module Slimdown
|
|
59
60
|
# @return [Array<Slimdown::Page>] a list of child pages.
|
60
61
|
def children
|
61
62
|
# Check to see whether dir exists.
|
62
|
-
|
63
|
-
|
63
|
+
Slimdown::Folder.new(@absolute_path.chomp('.md')).pages
|
64
|
+
end
|
64
65
|
|
65
|
-
|
66
|
+
# The parent of this document
|
67
|
+
#
|
68
|
+
# @return [<Slimdown::Page>|nil] the parent, if it exists
|
69
|
+
def parent
|
70
|
+
parent = File.expand_path('..', @absolute_path).concat('.md')
|
71
|
+
|
72
|
+
return nil unless File.file?(parent)
|
73
|
+
|
74
|
+
Slimdown::Page.new(parent)
|
66
75
|
end
|
67
76
|
|
68
77
|
# The relative path for this document.
|
69
78
|
#
|
70
79
|
# @return [String] the relative path, e.g. 'about/contact'
|
71
80
|
def path
|
72
|
-
|
73
|
-
relative = @absolute_path
|
74
|
-
relative.slice! "#{loc}/"
|
75
|
-
relative.slice! '.md'
|
76
|
-
|
77
|
-
relative
|
81
|
+
@absolute_path.sub(%r{^#{Slimdown.config.location}/(.*)\.md}, '\1')
|
78
82
|
end
|
79
83
|
|
80
|
-
|
84
|
+
private
|
81
85
|
|
82
86
|
def load_headers
|
83
|
-
headers = @parsed_page.headers
|
84
|
-
@title = headers['title']
|
85
|
-
@template = headers['template']
|
87
|
+
@headers = @parsed_page.headers
|
88
|
+
@title = @headers['title']
|
89
|
+
@template = @headers['template']
|
86
90
|
end
|
87
91
|
end
|
88
92
|
end
|
data/lib/slimdown/page_parser.rb
CHANGED
@@ -21,7 +21,10 @@ module Slimdown
|
|
21
21
|
#
|
22
22
|
# @return [Hash] document headers
|
23
23
|
def headers
|
24
|
-
|
24
|
+
head = {}
|
25
|
+
head = YAML.load @header_text unless @header_text == ''
|
26
|
+
|
27
|
+
head
|
25
28
|
end
|
26
29
|
|
27
30
|
# The parsed markdown document body.
|
@@ -48,7 +51,7 @@ module Slimdown
|
|
48
51
|
part = :body
|
49
52
|
elsif part == :header
|
50
53
|
@header_text += line
|
51
|
-
elsif part == :body
|
54
|
+
elsif part == :body || part == nil
|
52
55
|
@body_text += line
|
53
56
|
end
|
54
57
|
end
|
data/lib/slimdown/version.rb
CHANGED
data/ruby-slimdown.gemspec
CHANGED
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.required_ruby_version = '>= 1.9.3'
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'kramdown', '~>
|
24
|
+
spec.add_runtime_dependency 'kramdown', '~> 2.3'
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.9"
|
27
|
-
spec.add_development_dependency "rake", "~>
|
27
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
28
28
|
spec.add_development_dependency "guard", "~> 2.12"
|
29
29
|
spec.add_development_dependency "guard-rspec", "~> 4.5"
|
30
30
|
spec.add_development_dependency "pry", "~> 0.10"
|
31
|
-
spec.add_development_dependency "yard", "~> 0.
|
31
|
+
spec.add_development_dependency "yard", "~> 0.9.11"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.9.11
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.9.11
|
111
111
|
description: A system for using Markdown from a folder and turning it into web pages.
|
112
112
|
email:
|
113
113
|
- wjohnston@mpr.org
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".rspec"
|
120
120
|
- ".travis.yml"
|
121
121
|
- ".yardocops"
|
122
|
+
- CHANGELOG.md
|
122
123
|
- Gemfile
|
123
124
|
- Guardfile
|
124
125
|
- LICENSE.txt
|
@@ -153,10 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
- !ruby/object:Gem::Version
|
154
155
|
version: '0'
|
155
156
|
requirements: []
|
156
|
-
|
157
|
-
rubygems_version: 2.4.5
|
157
|
+
rubygems_version: 3.0.3
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: A system for using static Markdown for pages.
|
161
161
|
test_files: []
|
162
|
-
has_rdoc:
|