mippin 0.6.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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/CHANGELOG.md +114 -0
- data/LICENSE +23 -0
- data/README.md +70 -0
- data/Rakefile +26 -0
- data/demo/404.md +11 -0
- data/demo/_config.yml +5 -0
- data/demo/_layouts/default.html +15 -0
- data/demo/_layouts/post.html +7 -0
- data/demo/_posts/2015-11-05-hello-world.md +8 -0
- data/demo/about/index.md +10 -0
- data/demo/config.ru +4 -0
- data/demo/css/site.css +6 -0
- data/demo/index.md +18 -0
- data/lib/mippin/application.rb +118 -0
- data/lib/mippin/backports.rb +18 -0
- data/lib/mippin/router.rb +69 -0
- data/lib/mippin/version.rb +5 -0
- data/lib/mippin.rb +119 -0
- data/sig/mippin.rbs +4 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3f967bec91c709dda8dc7a3f2b5e5d6d1ef0fb2c5cff77c2cb02fbf42fc7954b
|
4
|
+
data.tar.gz: ae815ccf55d05894c2a305590043769a8912fa81aca2584e4e75142935b8e4aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39fd0d4a3b0fb2504611e65bcf87b723ceca82f9de6afa741edc972a4c372aa0d4699c3462e43be8712631d2b95b532e6cd7eb4a9ed3f65284c4da4627827d64
|
7
|
+
data.tar.gz: 58f2c235d42e6454c669068f6cf3a03b14d1a3fe076318dd52d34253648263f9a055d101a679eb69ac62ee78dd595731a54460bfa7c930b035a48e34244a6842
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.1
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
Max: 1024
|
8
|
+
|
9
|
+
Metrics/MethodLength:
|
10
|
+
Max: 1024
|
11
|
+
|
12
|
+
Style/StringLiterals:
|
13
|
+
EnforcedStyle: double_quotes
|
14
|
+
|
15
|
+
Style/StringLiteralsInInterpolation:
|
16
|
+
EnforcedStyle: double_quotes
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a
|
6
|
+
Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
7
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
8
|
+
|
9
|
+
Versions 0.6.0 and above were released by Rory D. under the [mippin
|
10
|
+
gem](https://rubygems.org/gems/mippin)(https://git.grovest.io/rory/mippin).
|
11
|
+
|
12
|
+
Versions 0.5.0 and under were realesed by [Marcus Stollsteimer] under
|
13
|
+
the [lanyon
|
14
|
+
gem](https://rubygems.org/gems/lanyon)(https://github.com/stomar/lanyon).
|
15
|
+
|
16
|
+
This file used to be called `History.md`.
|
17
|
+
|
18
|
+
## [0.6.0] - 2025-04-09
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- Support for the latest versions of
|
23
|
+
[rack](https://rubygems.org/gems/rack).
|
24
|
+
|
25
|
+
### Fixed
|
26
|
+
|
27
|
+
- A failing test, that was expecting 'application/javascript' instead of
|
28
|
+
'text/javascript'.
|
29
|
+
- Various linter errors.
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- Forked mippin (https://rubygems.org/gems/mippin,
|
34
|
+
https://git.grovest.io/rory/mippin) from lanyon
|
35
|
+
(https://rubygems.org/gems/lanyon, https://github.com/stomar/lanyon).
|
36
|
+
See README.md for more details.
|
37
|
+
- Updated any references from Lanyon/lanyon to Mippin/mippin.
|
38
|
+
|
39
|
+
## 0.5.0
|
40
|
+
|
41
|
+
- Require Ruby 3.1 or newer.
|
42
|
+
- Improve code style.
|
43
|
+
- Update README.
|
44
|
+
|
45
|
+
## 0.4.4
|
46
|
+
|
47
|
+
- Improve code style.
|
48
|
+
- Update README.
|
49
|
+
- Add CI workflow.
|
50
|
+
- Move development dependencies from gemspec to Gemfile.
|
51
|
+
- Add WEBrick as development dependency (for Ruby 3.0).
|
52
|
+
|
53
|
+
## 0.4.3
|
54
|
+
|
55
|
+
- Use Rack::ContentLength middleware to fix missing.
|
56
|
+
Content-Length headers for rack 2.1.0 and later.
|
57
|
+
- Update development dependencies.
|
58
|
+
|
59
|
+
## 0.4.2
|
60
|
+
|
61
|
+
- Avoid deprecation warnings for minitest expectations.
|
62
|
+
- Improve code style.
|
63
|
+
|
64
|
+
## 0.4.1
|
65
|
+
|
66
|
+
- Drop pessimistic constraint on Jekyll version.
|
67
|
+
- Remove Jekyll cache directory after tests.
|
68
|
+
- Let "clean" task remove Jekyll cache directory.
|
69
|
+
- Add Jekyll cache directory to .gitignore.
|
70
|
+
- Add magic comments for frozen string literals.
|
71
|
+
|
72
|
+
## 0.4.0
|
73
|
+
|
74
|
+
- Support .html extension stripping.
|
75
|
+
|
76
|
+
## 0.3.4
|
77
|
+
|
78
|
+
- Allow Rack 2.
|
79
|
+
- Use Rack::Utils.unescape_path with Rack 2.
|
80
|
+
- Update development dependencies.
|
81
|
+
|
82
|
+
## 0.3.3
|
83
|
+
|
84
|
+
- Use a nicer progress output format.
|
85
|
+
|
86
|
+
## 0.3.2
|
87
|
+
|
88
|
+
- Flush progress output before starting build.
|
89
|
+
|
90
|
+
## 0.3.1
|
91
|
+
|
92
|
+
- Do not set a Cache-Control header.
|
93
|
+
|
94
|
+
## 0.3.0
|
95
|
+
|
96
|
+
- Use ETag instead of Last-Modified for caching.
|
97
|
+
- Allow Jekyll 3.
|
98
|
+
- Provide a Lanyon.build method.
|
99
|
+
|
100
|
+
## 0.2.3
|
101
|
+
|
102
|
+
- Handle URLs with percent-encoded characters.
|
103
|
+
|
104
|
+
## 0.2.2
|
105
|
+
|
106
|
+
- Prevent CRLF conversion for served files by using File.binread.
|
107
|
+
|
108
|
+
## 0.2.1
|
109
|
+
|
110
|
+
- Sanitize path info to properly handle directory traversal.
|
111
|
+
|
112
|
+
## 0.2.0
|
113
|
+
|
114
|
+
- First gem release.
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-2024 Marcus Stollsteimer
|
4
|
+
Copyright (c) 2025 Rory Dudley
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
7
|
+
copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included
|
15
|
+
in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
18
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# mippin
|
2
|
+
|
3
|
+
Serve your [Jekyll](https://jekyllrb.com/) site as a
|
4
|
+
[rack](https://github.com/rack/rack) application.
|
5
|
+
|
6
|
+
This is a soft fork of [lanyon](https://github.com/stomar/lanyon), as
|
7
|
+
that gem is, seemingly, no longer maintained (see:
|
8
|
+
https://github.com/stomar/lanyon/issues/5).
|
9
|
+
|
10
|
+
A huge thank you to [Marcus Stollsteimer](https://github.com/stomar) for
|
11
|
+
creating all the code underpinning this fork!
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Install the gem and add to the application's Gemfile by executing:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
bundle add mippin
|
19
|
+
```
|
20
|
+
|
21
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
gem install mippin
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Once the the gem is installed in your Jekyll project, create a rackup
|
30
|
+
file (`config.ru`) in the root of your project directory with the
|
31
|
+
following:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "mippin"
|
35
|
+
run Mippin.application
|
36
|
+
```
|
37
|
+
|
38
|
+
Now, build the site with:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
jekyll build
|
42
|
+
```
|
43
|
+
|
44
|
+
Finally run the folling to start serving your site via rack:
|
45
|
+
|
46
|
+
```shell
|
47
|
+
bundle exec rackup config.ru
|
48
|
+
```
|
49
|
+
|
50
|
+
For more info, take a look at the demo site, inside the `demo/`
|
51
|
+
directory of this repository. You can also use `rake demo` to serve the
|
52
|
+
demo site (and `rake rm` in order to remove the files that `rake demo`
|
53
|
+
generates).
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
58
|
+
Then, run `rake` to run the tests and linter. You can also run
|
59
|
+
`bin/console` for an interactive prompt that will allow you to
|
60
|
+
experiment.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake
|
63
|
+
install`. To release a new version, update the version number in
|
64
|
+
`version.rb`, and then run `bundle exec rake release`, which will create
|
65
|
+
a git tag for the version, push git commits and the created tag, and
|
66
|
+
push the `.gem` file to [rubygems.org](https://rubygems.org).
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
Please email your diffs inline to `rory AT mailbox DOT cat`.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "minitest/test_task"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
Minitest::TestTask.create
|
8
|
+
|
9
|
+
require "rubocop/rake_task"
|
10
|
+
|
11
|
+
RuboCop::RakeTask.new
|
12
|
+
|
13
|
+
task default: %i[test rubocop]
|
14
|
+
|
15
|
+
desc "Serve the demo site"
|
16
|
+
task :demo do
|
17
|
+
Dir.chdir("demo") do
|
18
|
+
sh "rackup -p 4000 -I ../lib"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Remove files generated by 'rake demo'"
|
23
|
+
task :rm do
|
24
|
+
FileUtils.rm_rf("demo/_site")
|
25
|
+
FileUtils.rm_rf("demo/.jekyll-cache")
|
26
|
+
end
|
data/demo/404.md
ADDED
data/demo/_config.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<link rel="stylesheet" type="text/css" href="/css/site.css">
|
6
|
+
{% if page.title != null %}
|
7
|
+
<title>{{ page.title }}</title>
|
8
|
+
{% else %}
|
9
|
+
<title>mippin demo</title>
|
10
|
+
{% endif %}
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
{{ content }}
|
14
|
+
</body>
|
15
|
+
</html>
|
data/demo/about/index.md
ADDED
data/demo/config.ru
ADDED
data/demo/css/site.css
ADDED
data/demo/index.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
---
|
4
|
+
|
5
|
+
# mippin demo
|
6
|
+
|
7
|
+
demo page for the mippin gem [read more...](about/)
|
8
|
+
|
9
|
+
blog posts:
|
10
|
+
|
11
|
+
<ul>
|
12
|
+
{% for post in site.posts %}
|
13
|
+
<li>
|
14
|
+
<span class="date">{{ post.date | date_to_string }}:</span>
|
15
|
+
<a href="{{ post.url }}">{{ post.title }}</a>
|
16
|
+
</li>
|
17
|
+
{% endfor %}
|
18
|
+
</ul>
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rack/mime"
|
4
|
+
require "rack/request"
|
5
|
+
require "rack/response"
|
6
|
+
require "time"
|
7
|
+
|
8
|
+
module Mippin
|
9
|
+
# Rack application that serves the Jekyll site.
|
10
|
+
#
|
11
|
+
# Not to be instantiated directly, use Mippin.application instead.
|
12
|
+
class Application
|
13
|
+
attr_reader :router
|
14
|
+
|
15
|
+
def initialize(router)
|
16
|
+
@router = router
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
request = Rack::Request.new(env)
|
21
|
+
endpoint = router.endpoint(request.path_info)
|
22
|
+
|
23
|
+
case endpoint
|
24
|
+
when :not_found
|
25
|
+
not_found_response
|
26
|
+
when :must_redirect
|
27
|
+
redirect_to_dir_response(request.path_info)
|
28
|
+
else
|
29
|
+
case request.request_method
|
30
|
+
when "HEAD", "GET"
|
31
|
+
response(endpoint)
|
32
|
+
when "OPTIONS"
|
33
|
+
[200, { "Allow" => "GET,HEAD,OPTIONS", "Content-Length" => "0" }, []]
|
34
|
+
else
|
35
|
+
not_allowed_response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def response(filename) # :nodoc:
|
43
|
+
response = Rack::Response.new(File.binread(filename))
|
44
|
+
response["Content-Type"] = media_type(filename)
|
45
|
+
|
46
|
+
response.finish
|
47
|
+
end
|
48
|
+
|
49
|
+
def html_response(body, status, headers = {}) # :nodoc:
|
50
|
+
response = Rack::Response.new(body, status, headers)
|
51
|
+
response["Content-Type"] = "text/html"
|
52
|
+
|
53
|
+
response.finish
|
54
|
+
end
|
55
|
+
|
56
|
+
def media_type(filename) # :nodoc:
|
57
|
+
extension = ::File.extname(filename)
|
58
|
+
|
59
|
+
Rack::Mime.mime_type(extension)
|
60
|
+
end
|
61
|
+
|
62
|
+
def html_wrap(title, content) # :nodoc:
|
63
|
+
<<~DOCUMENT
|
64
|
+
<!DOCTYPE html>
|
65
|
+
<html lang="en">
|
66
|
+
<head>
|
67
|
+
<meta charset="utf-8">
|
68
|
+
<title>#{title}</title></head>
|
69
|
+
<body>
|
70
|
+
#{content}
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
DOCUMENT
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_404_body # :nodoc:
|
77
|
+
html_wrap("Error", "<p>404: Not Found</p>")
|
78
|
+
end
|
79
|
+
|
80
|
+
def custom_404_body # :nodoc:
|
81
|
+
router.custom_404_body
|
82
|
+
end
|
83
|
+
|
84
|
+
def not_found_response # :nodoc:
|
85
|
+
body = custom_404_body || default_404_body
|
86
|
+
|
87
|
+
html_response(body, 404)
|
88
|
+
end
|
89
|
+
|
90
|
+
def not_allowed_response # :nodoc:
|
91
|
+
body = html_wrap("Error", "<p>405: Method Not Allowed</p>")
|
92
|
+
|
93
|
+
html_response(body, 405)
|
94
|
+
end
|
95
|
+
|
96
|
+
def redirect_body(to_path) # :nodoc:
|
97
|
+
message = %(<p>Redirecting to <a href="#{to_path}">#{to_path}</a>.</p>)
|
98
|
+
|
99
|
+
html_wrap("Redirection", message)
|
100
|
+
end
|
101
|
+
|
102
|
+
def redirect_to_dir_response(from_path) # :nodoc:
|
103
|
+
location = from_path.dup
|
104
|
+
location << "/" unless location.end_with?("/")
|
105
|
+
|
106
|
+
cache_time = 3600
|
107
|
+
|
108
|
+
body = redirect_body(location)
|
109
|
+
headers = {
|
110
|
+
"Location" => location,
|
111
|
+
"Cache-Control" => "max-age=#{cache_time}, must-revalidate",
|
112
|
+
"Expires" => (Time.now + cache_time).httpdate
|
113
|
+
}
|
114
|
+
|
115
|
+
html_response(body, 301, headers)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module Mippin # :nodoc:
|
6
|
+
module Backports # :nodoc:
|
7
|
+
class Router
|
8
|
+
# Backport for Rack 1.x
|
9
|
+
module UnescapePath
|
10
|
+
def unescape_path(path)
|
11
|
+
URI::Parser.new.unescape(path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Router.prepend Backports::Router::UnescapePath if Rack.release.start_with?("1.")
|
18
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rack/utils"
|
4
|
+
|
5
|
+
module Mippin
|
6
|
+
# Router class for Mippin applications.
|
7
|
+
class Router
|
8
|
+
attr_reader :root
|
9
|
+
|
10
|
+
# Creates a Router for the given root directory.
|
11
|
+
def initialize(root)
|
12
|
+
@root = File.expand_path(root)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns the full file system path of the file corresponding to
|
16
|
+
# the given URL +path+, or
|
17
|
+
#
|
18
|
+
# - +:must_redirect+ if the request must be redirected to +path/+,
|
19
|
+
# - +:not_found+ if no corresponding file exists.
|
20
|
+
#
|
21
|
+
# The return value is found as follows:
|
22
|
+
#
|
23
|
+
# 1. a +path/+ with a trailing slash is changed to +path/index.html+,
|
24
|
+
# 2. then, the method checks for an exactly corresponding file,
|
25
|
+
# 3. when +path+ does not exist but +path/index.html+ does,
|
26
|
+
# a redirect will be indicated,
|
27
|
+
# 4. finally, when no exactly corresponding file or redirect
|
28
|
+
# can be found, +path.html+ is tried.
|
29
|
+
def endpoint(path)
|
30
|
+
normalized = normalize_path_info(path)
|
31
|
+
fullpath = File.join(@root, normalized)
|
32
|
+
|
33
|
+
if FileTest.file?(fullpath)
|
34
|
+
fullpath
|
35
|
+
elsif needs_redirect_to_dir?(fullpath)
|
36
|
+
:must_redirect
|
37
|
+
elsif FileTest.file?(fullpath_html = "#{fullpath}.html")
|
38
|
+
fullpath_html
|
39
|
+
else
|
40
|
+
:not_found
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the body of the custom 404 page or +nil+ if none exists.
|
45
|
+
def custom_404_body
|
46
|
+
filename = File.join(root, "404.html")
|
47
|
+
|
48
|
+
File.exist?(filename) ? File.binread(filename) : nil
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def needs_redirect_to_dir?(fullpath) # :nodoc:
|
54
|
+
!fullpath.end_with?("/") && FileTest.file?("#{fullpath}/index.html")
|
55
|
+
end
|
56
|
+
|
57
|
+
def unescape_path(path) # :nodoc:
|
58
|
+
Rack::Utils.unescape_path(path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def normalize_path_info(path_info) # :nodoc:
|
62
|
+
path = unescape_path(path_info)
|
63
|
+
|
64
|
+
path << "index.html" if path.end_with?("/")
|
65
|
+
|
66
|
+
Rack::Utils.clean_path_info(path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/mippin.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# = mippin.rb
|
4
|
+
#
|
5
|
+
# See Mippin module for documentation.
|
6
|
+
|
7
|
+
require "jekyll"
|
8
|
+
require "rack"
|
9
|
+
|
10
|
+
require "mippin/application"
|
11
|
+
require "mippin/router"
|
12
|
+
require "mippin/version"
|
13
|
+
require "mippin/backports"
|
14
|
+
|
15
|
+
# Mippin serves your Jekyll site as a Rack application.
|
16
|
+
#
|
17
|
+
# See Mippin.application for available initialization options.
|
18
|
+
#
|
19
|
+
# Further information on the Mippin library is available in the README file
|
20
|
+
# or on the project home page: <https://git.grovest.io/rory/mippin>.
|
21
|
+
#
|
22
|
+
# This project is a soft fork of <https://github.com/stomar/lanyon>. I
|
23
|
+
# have taken it over, because, seemingly, it is no longer maintained
|
24
|
+
# (and there are issues with the allowed dependency versions with the
|
25
|
+
# latest Jekyll updates). I would like to thank Marcus Stollsteimer for
|
26
|
+
# their efforts, as they contributed basically all the code in this
|
27
|
+
# repository. If Marcus ever comes back to update the package, I will
|
28
|
+
# likely abandon this fork.
|
29
|
+
#
|
30
|
+
# https://github.com/stomar/lanyon/issues/5
|
31
|
+
#
|
32
|
+
# The only things I have done are:
|
33
|
+
# - update the name Lanyon/lanyon to Mippin/mippin,
|
34
|
+
# - bump the allowed versions for the rack dependency,
|
35
|
+
# - fix various linting errors,
|
36
|
+
# - fix a broken test case,
|
37
|
+
# - and, added this comment.
|
38
|
+
module Mippin
|
39
|
+
# Builds the Jekyll site, prepares the middleware stack,
|
40
|
+
# and returns the Rack application.
|
41
|
+
#
|
42
|
+
# Options:
|
43
|
+
#
|
44
|
+
# +:config+:: use given config file (default: "_config.yml")
|
45
|
+
#
|
46
|
+
# +:skip_build+:: whether to skip site generation at startup
|
47
|
+
# (default: +false+)
|
48
|
+
#
|
49
|
+
# Other options are passed on to Jekyll::Site.
|
50
|
+
#
|
51
|
+
# Returns a Rack application.
|
52
|
+
def self.application(options = {})
|
53
|
+
skip_build = options.fetch(:skip_build, default_options[:skip_build])
|
54
|
+
|
55
|
+
config = jekyll_config(options)
|
56
|
+
|
57
|
+
if skip_build
|
58
|
+
puts skip_build_warning
|
59
|
+
else
|
60
|
+
process(config)
|
61
|
+
end
|
62
|
+
|
63
|
+
destination = config["destination"]
|
64
|
+
router = Router.new(destination)
|
65
|
+
|
66
|
+
Rack::Builder.new do
|
67
|
+
use Rack::Head
|
68
|
+
use Rack::ContentLength
|
69
|
+
use Rack::ConditionalGet
|
70
|
+
use Rack::ETag, nil, nil
|
71
|
+
|
72
|
+
run Application.new(router)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Builds the Jekyll site.
|
77
|
+
#
|
78
|
+
# Accepts the same options as ::application,
|
79
|
+
# except for the +:skip_build+ option which is ignored.
|
80
|
+
def self.build(options = {})
|
81
|
+
config = jekyll_config(options)
|
82
|
+
|
83
|
+
process(config)
|
84
|
+
end
|
85
|
+
|
86
|
+
# @private
|
87
|
+
def self.default_options # :nodoc:
|
88
|
+
{ skip_build: false }
|
89
|
+
end
|
90
|
+
|
91
|
+
# @private
|
92
|
+
def self.jekyll_config(overrides = {}) # :nodoc:
|
93
|
+
overrides = overrides.dup
|
94
|
+
default_options.each_key { |key| overrides.delete(key) }
|
95
|
+
|
96
|
+
::Jekyll.configuration(overrides)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @private
|
100
|
+
def self.skip_build_warning # :nodoc:
|
101
|
+
"Build warning: Skipping the initial build."
|
102
|
+
end
|
103
|
+
|
104
|
+
# @private
|
105
|
+
#
|
106
|
+
# Wraps Jekyll::Site's process method that builds the site.
|
107
|
+
#
|
108
|
+
# Takes a Jekyll configuration hash as argument.
|
109
|
+
def self.process(config) # :nodoc:
|
110
|
+
site = ::Jekyll::Site.new(config)
|
111
|
+
puts " Source: #{site.source}"
|
112
|
+
puts " Destination: #{site.dest}"
|
113
|
+
puts " Generating site..."
|
114
|
+
$stdout.flush
|
115
|
+
site.process
|
116
|
+
puts " done."
|
117
|
+
$stdout.flush
|
118
|
+
end
|
119
|
+
end
|
data/sig/mippin.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mippin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rory Dudley
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-04-09 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: jekyll
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '2.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '2.0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rack
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.6'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.6'
|
40
|
+
description: |-
|
41
|
+
This is a fork of
|
42
|
+
https://rubygems.org/gems/lanyon, since it looks like it is no
|
43
|
+
longer being maintained.
|
44
|
+
email:
|
45
|
+
- rory@netc.lu
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".rspec"
|
51
|
+
- ".rubocop.yml"
|
52
|
+
- CHANGELOG.md
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- demo/404.md
|
57
|
+
- demo/_config.yml
|
58
|
+
- demo/_layouts/default.html
|
59
|
+
- demo/_layouts/post.html
|
60
|
+
- demo/_posts/2015-11-05-hello-world.md
|
61
|
+
- demo/about/index.md
|
62
|
+
- demo/config.ru
|
63
|
+
- demo/css/site.css
|
64
|
+
- demo/index.md
|
65
|
+
- lib/mippin.rb
|
66
|
+
- lib/mippin/application.rb
|
67
|
+
- lib/mippin/backports.rb
|
68
|
+
- lib/mippin/router.rb
|
69
|
+
- lib/mippin/version.rb
|
70
|
+
- sig/mippin.rbs
|
71
|
+
homepage: https://git.grovest.io/rory/mippin
|
72
|
+
licenses: []
|
73
|
+
metadata:
|
74
|
+
allowed_push_host: https://rubygems.org
|
75
|
+
homepage_uri: https://git.grovest.io/rory/mippin
|
76
|
+
source_code_uri: https://git.grovest.io/rory/mippin
|
77
|
+
changelog_uri: https://git.grovest.io/rory/mippin/src/branch/main/CHANGELOG.md
|
78
|
+
rubygems_mfa_required: 'true'
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 3.1.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.6.2
|
94
|
+
specification_version: 4
|
95
|
+
summary: Serve your Jekyll site as a rack application
|
96
|
+
test_files: []
|