slimdown 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/README.md +32 -24
- data/lib/slimdown/page.rb +13 -11
- data/lib/slimdown/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e671937e7916385a1feec7b84f7cf86d18514d9d
|
4
|
+
data.tar.gz: 8f60d40358a09a4cdf795b190b82a4adb023b045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a1d57e1f8e984498afa4056851096bddbf137e75871d2a0d78f74a8a4c9048ae3e59e9d80a23a20f40f8ef46458b07675d8dce4cd2868716eed46f266d97638
|
7
|
+
data.tar.gz: 5cc03ddfd79fa58717cada275c5ca589ebd468adebca8240b3877de1a72742d146586857eab65b0488ab23ad2499bd30098685dead9a9d9dd3a4c50be5f5add3
|
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-03-13)
|
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,49 @@ 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
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
|
|
63
|
-
|
64
|
-
|
65
|
-
|
69
|
+
```ruby
|
70
|
+
Slimdown.config do |c|
|
71
|
+
c.location = Rails.root.join('lib/pages')
|
72
|
+
end
|
73
|
+
```
|
66
74
|
|
67
75
|
## Testing
|
68
76
|
|
data/lib/slimdown/page.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
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
|
@@ -61,25 +60,28 @@ module Slimdown
|
|
61
60
|
# @return [Array<Slimdown::Page>] a list of child pages.
|
62
61
|
def children
|
63
62
|
# Check to see whether dir exists.
|
64
|
-
|
65
|
-
|
63
|
+
Slimdown::Folder.new(@absolute_path.chomp('.md')).pages
|
64
|
+
end
|
66
65
|
|
67
|
-
|
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)
|
68
75
|
end
|
69
76
|
|
70
77
|
# The relative path for this document.
|
71
78
|
#
|
72
79
|
# @return [String] the relative path, e.g. 'about/contact'
|
73
80
|
def path
|
74
|
-
|
75
|
-
relative = @absolute_path
|
76
|
-
relative.slice! "#{loc}/"
|
77
|
-
relative.slice! '.md'
|
78
|
-
|
79
|
-
relative
|
81
|
+
@absolute_path.sub(%r{^#{Slimdown.config.location}/(.*)\.md}, '\1')
|
80
82
|
end
|
81
83
|
|
82
|
-
|
84
|
+
private
|
83
85
|
|
84
86
|
def load_headers
|
85
87
|
@headers = @parsed_page.headers
|
data/lib/slimdown/version.rb
CHANGED
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: 1.0
|
4
|
+
version: 1.1.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: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -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
|
@@ -154,8 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
requirements: []
|
156
157
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.6.11
|
158
159
|
signing_key:
|
159
160
|
specification_version: 4
|
160
161
|
summary: A system for using static Markdown for pages.
|
161
162
|
test_files: []
|
163
|
+
has_rdoc:
|