statique 0.1.0 → 0.1.4
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 +4 -4
- data/CHANGELOG.md +16 -0
- data/Dockerfile +1 -1
- data/Gemfile +14 -12
- data/README.md +10 -9
- data/docs/assets/css/app.css +1 -0
- data/docs/content/index.md +57 -0
- data/docs/layouts/layout.slim +12 -0
- data/lib/statique/app.rb +36 -42
- data/lib/statique/cli/build.rb +13 -11
- data/lib/statique/cli/init.rb +1 -1
- data/lib/statique/cli/server.rb +6 -4
- data/lib/statique/cli.rb +10 -4
- data/lib/statique/configuration.rb +20 -0
- data/lib/statique/discover.rb +12 -9
- data/lib/statique/document.rb +6 -6
- data/lib/statique/paginator.rb +29 -20
- data/lib/statique/version.rb +1 -1
- data/lib/statique.rb +34 -42
- data/lib/templates/layout.slim +2 -2
- metadata +14 -95
- data/statique.gemspec +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca6623c907a23398e840f6d3dc056f1dbe966f747a443e7e6cced71fe462cbbb
|
4
|
+
data.tar.gz: 511a4f47f18fc755ad1f74295637047d9715ec6de95454f4b1e85022c9128da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ac4f9d6a45018021322e0cb685bde01ca682be029dc884b915237728de5a088e3232cdc6fb7a2e378fbb753e857e0bc77a99008d693a145191734c828308a4a
|
7
|
+
data.tar.gz: a1b4e20006069b4a23655b161074e087cd88d7fb22efb8d76cf8db009b16144362bfdf63c948b30f635d385767f693b60d392853b3a5ba3d963c9ac541ec2b6a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.1.4](https://github.com/pusewicz/statique/compare/v0.1.3...v0.1.4) (2022-02-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* Drop tilt direct dependency ([d893a2e](https://github.com/pusewicz/statique/commit/d893a2e847e6317e6e7b80d1179ecd966e1bfc3a))
|
9
|
+
|
10
|
+
### [0.1.3](https://github.com/pusewicz/statique/compare/v0.1.1...v0.1.3) (2022-02-16)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* Do not rewrite paths to keep relative paths ([285eaf3](https://github.com/pusewicz/statique/commit/285eaf3446d7de2dba4fc3b55e7dd87b16092a04))
|
16
|
+
* Initial values of the paginator ([3cbb0e0](https://github.com/pusewicz/statique/commit/3cbb0e0d680cae38e8cc65cde1299d0fca18a601))
|
17
|
+
* Update delegated root_url ([ca5ea27](https://github.com/pusewicz/statique/commit/ca5ea273d9e636ed0481fa36fc298769a8697e95))
|
18
|
+
|
3
19
|
## [0.1.0] - 2022-01-12
|
4
20
|
|
5
21
|
- Initial release
|
data/Dockerfile
CHANGED
@@ -7,7 +7,7 @@ ARG STATIQUE_VERSION
|
|
7
7
|
# RUN gem install statique --version $STATIQUE_VERSION
|
8
8
|
WORKDIR /pkg
|
9
9
|
COPY pkg/statique-$STATIQUE_VERSION.gem .
|
10
|
-
RUN apk add --no-cache --update --virtual .build-deps build-base
|
10
|
+
RUN apk add --no-cache --update --virtual .build-deps build-base && \
|
11
11
|
gem install /pkg/statique-$STATIQUE_VERSION.gem && rm -rf /root/.local/share/gem && rm -rf /usr/local/bundle/cache/*.gem && \
|
12
12
|
apk del .build-deps
|
13
13
|
|
data/Gemfile
CHANGED
@@ -7,15 +7,17 @@ source "https://rubygems.org"
|
|
7
7
|
# Specify your gem's dependencies in statique.gemspec
|
8
8
|
gemspec
|
9
9
|
|
10
|
-
|
11
|
-
gem "
|
12
|
-
gem "
|
13
|
-
gem "minitest
|
14
|
-
gem "
|
15
|
-
gem "
|
16
|
-
gem "
|
17
|
-
gem "
|
18
|
-
gem "rubocop-
|
19
|
-
gem "
|
20
|
-
gem "
|
21
|
-
gem "
|
10
|
+
group :development do
|
11
|
+
gem "benchmark-ips"
|
12
|
+
gem "bundle-audit", "~> 0.1.0"
|
13
|
+
gem "minitest", "~> 5.0"
|
14
|
+
gem "minitest-around", "~> 0.5.0"
|
15
|
+
gem "overcommit"
|
16
|
+
gem "rake", "~> 13.0"
|
17
|
+
gem "rbs"
|
18
|
+
gem "rubocop-minitest", "~> 0.17.0"
|
19
|
+
gem "rubocop-rake", "~> 0.6.0"
|
20
|
+
gem "solargraph"
|
21
|
+
gem "standard", "~> 1.3"
|
22
|
+
gem "typeprof"
|
23
|
+
end
|
data/README.md
CHANGED
@@ -10,15 +10,16 @@
|
|
10
10
|
# Statique
|
11
11
|
|
12
12
|

|
13
|
+
[](https://badge.fury.io/rb/statique)
|
13
14
|
|
14
|
-
Statique is a static site generator written in [Ruby](https://www.ruby-lang.org/) and utilising [Roda](https://roda.jeremyevans.net/) for the Rack middleware. By default, it comes with support for [Slim](http://slim-lang.com/)
|
15
|
+
Statique is a static site generator written in [Ruby](https://www.ruby-lang.org/) and utilising [Roda](https://roda.jeremyevans.net/) for the Rack middleware. By default, it comes with support for [Slim](http://slim-lang.com/) and [Markdown](https://daringfireball.net/projects/markdown/).
|
15
16
|
|
16
17
|
## Installation
|
17
18
|
|
18
19
|
Install it as a [Whalebrew](https://github.com/whalebrew/whalebrew) package (recommended):
|
19
20
|
|
20
21
|
$ whalebrew install pusewicz/statique
|
21
|
-
|
22
|
+
|
22
23
|
Install it as a Docker image:
|
23
24
|
|
24
25
|
$ docker pull pusewicz/statique
|
@@ -34,25 +35,25 @@ Install it as a Ruby gem:
|
|
34
35
|
#### Whalebrew package, Ruby gem
|
35
36
|
|
36
37
|
$ statique init my-website
|
37
|
-
|
38
|
+
|
38
39
|
#### Docker
|
39
40
|
|
40
41
|
$ docker run -it --rm -v "$PWD":/workdir -w /workdir pusewicz/statique init my-website
|
41
|
-
|
42
|
+
|
42
43
|
### Start the Statique server
|
43
44
|
|
44
45
|
First, change into your new Statique website directory:
|
45
46
|
|
46
47
|
$ cd my-website
|
47
|
-
|
48
|
+
|
48
49
|
#### Whalebrew package, Ruby gem
|
49
50
|
|
50
51
|
$ statique server
|
51
|
-
|
52
|
+
|
52
53
|
#### Docker
|
53
54
|
|
54
55
|
$ docker run -it --rm -p 3000:3000 -v "$PWD":/workdir -w /workdir pusewicz/statique server
|
55
|
-
|
56
|
+
|
56
57
|
### Build your Statique website
|
57
58
|
|
58
59
|
The final step before deploying your website to your preferred host is to build it. By default, the built website will be available in the `dist/` subdirectory.
|
@@ -60,11 +61,11 @@ The final step before deploying your website to your preferred host is to build
|
|
60
61
|
First, change into your new Statique website directory:
|
61
62
|
|
62
63
|
$ cd my-website
|
63
|
-
|
64
|
+
|
64
65
|
#### Whalebrew package, Ruby gem
|
65
66
|
|
66
67
|
$ statique build
|
67
|
-
|
68
|
+
|
68
69
|
#### Docker
|
69
70
|
|
70
71
|
$ docker run -it --rm -v "$PWD":/workdir -w /workdir pusewicz/statique build
|
@@ -0,0 +1 @@
|
|
1
|
+
@import url("https://cdn.jsdelivr.net/npm/water.css@2/out/water.css");
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Statique is a static site generator written in [Ruby](https://www.ruby-lang.org/) and uses [Roda](https://roda.jeremyevans.net/) for the Rack middleware. By default, it comes with support for [Slim](http://slim-lang.com/) and [Markdown](https://daringfireball.net/projects/markdown/).
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Install it as a [Whalebrew](https://github.com/whalebrew/whalebrew) package (recommended):
|
6
|
+
|
7
|
+
$ whalebrew install pusewicz/statique
|
8
|
+
|
9
|
+
Install it as a Docker image:
|
10
|
+
|
11
|
+
$ docker pull pusewicz/statique
|
12
|
+
|
13
|
+
Install it as a Ruby gem:
|
14
|
+
|
15
|
+
$ gem install statique
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Generate your new Statique website
|
20
|
+
|
21
|
+
#### Whalebrew package, Ruby gem
|
22
|
+
|
23
|
+
$ statique init my-website
|
24
|
+
|
25
|
+
#### Docker
|
26
|
+
|
27
|
+
$ docker run -it --rm -v "$PWD":/workdir -w /workdir pusewicz/statique init my-website
|
28
|
+
|
29
|
+
### Start the Statique server
|
30
|
+
|
31
|
+
First, change into your new Statique website directory:
|
32
|
+
|
33
|
+
$ cd my-website
|
34
|
+
|
35
|
+
#### Whalebrew package, Ruby gem
|
36
|
+
|
37
|
+
$ statique server
|
38
|
+
|
39
|
+
#### Docker
|
40
|
+
|
41
|
+
$ docker run -it --rm -p 3000:3000 -v "$PWD":/workdir -w /workdir pusewicz/statique server
|
42
|
+
|
43
|
+
### Build your Statique website
|
44
|
+
|
45
|
+
The final step before deploying your website to your preferred host is to build it. By default, the built website will be available in the `dist/` subdirectory.
|
46
|
+
|
47
|
+
First, change into your new Statique website directory:
|
48
|
+
|
49
|
+
$ cd my-website
|
50
|
+
|
51
|
+
#### Whalebrew package, Ruby gem
|
52
|
+
|
53
|
+
$ statique build
|
54
|
+
|
55
|
+
#### Docker
|
56
|
+
|
57
|
+
$ docker run -it --rm -v "$PWD":/workdir -w /workdir pusewicz/statique build
|
@@ -0,0 +1,12 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
meta charset="UTF-8"
|
5
|
+
meta name="generator" content="Statique #{Statique.version}"
|
6
|
+
title Statique
|
7
|
+
== assets(:css)
|
8
|
+
body
|
9
|
+
header
|
10
|
+
h1 Statique–Static Site Generator
|
11
|
+
main== yield
|
12
|
+
footer Made with Statique v#{Statique.version}
|
data/lib/statique/app.rb
CHANGED
@@ -3,69 +3,70 @@
|
|
3
3
|
require "roda"
|
4
4
|
require "slim"
|
5
5
|
require "digest/sha1"
|
6
|
-
require "rack/rewrite"
|
7
|
-
require "pagy"
|
8
|
-
require "pagy/extras/array"
|
9
6
|
|
10
7
|
class Statique
|
11
8
|
class App < Roda
|
12
9
|
extend Forwardable
|
13
|
-
include Pagy::Backend
|
14
10
|
|
15
|
-
|
16
|
-
use Rack::Rewrite do
|
17
|
-
rewrite PAGE_REGEX, "$1?page=$2"
|
18
|
-
end
|
11
|
+
@statique = Statique.instance
|
19
12
|
|
20
|
-
def_delegators
|
13
|
+
def_delegators :@statique, :url, :root_url, :statique
|
21
14
|
|
22
|
-
opts[:root] =
|
15
|
+
opts[:root] = @statique.configuration.paths.pwd
|
23
16
|
|
24
17
|
plugin :environments
|
25
18
|
plugin :static_routing
|
26
|
-
plugin :render, views:
|
27
|
-
plugin :partials, views:
|
19
|
+
plugin :render, views: @statique.configuration.paths.content.basename, engine: "slim", allowed_paths: [@statique.configuration.paths.content.basename, @statique.configuration.paths.layouts.basename]
|
20
|
+
plugin :partials, views: @statique.configuration.paths.layouts.basename
|
28
21
|
|
29
|
-
if
|
30
|
-
plugin :public, root:
|
22
|
+
if @statique.mode.server? && @statique.configuration.paths.public.exist?
|
23
|
+
plugin :public, root: @statique.configuration.paths.public.basename
|
31
24
|
end
|
32
25
|
|
33
|
-
if
|
34
|
-
css_files =
|
35
|
-
js_files =
|
36
|
-
plugin :assets, css: css_files.map { _1.basename.to_s }, js: js_files.map { _1.basename.to_s }, public:
|
26
|
+
if @statique.configuration.paths.assets.exist?
|
27
|
+
css_files = @statique.configuration.paths.assets.join("css").glob("*.{css,scss}")
|
28
|
+
js_files = @statique.configuration.paths.assets.join("js").glob("*.js")
|
29
|
+
plugin :assets, css: css_files.map { _1.basename.to_s }, js: js_files.map { _1.basename.to_s }, public: @statique.configuration.paths.destination, precompiled: @statique.configuration.paths.destination.join("assets/manifest.json"), relative_paths: true
|
37
30
|
plugin :assets_preloading
|
38
31
|
|
39
|
-
|
32
|
+
@statique.mode.build do
|
40
33
|
compiled = compile_assets
|
41
|
-
|
34
|
+
@statique.ui.info "Compiling assets", css: compiled["css"], js: compiled["js"]
|
42
35
|
end
|
43
36
|
end
|
44
37
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
route do |r|
|
39
|
+
@statique = Statique.instance
|
40
|
+
if @statique.mode.server?
|
41
|
+
r.public if @statique.configuration.paths.public.exist?
|
42
|
+
r.assets if @statique.configuration.paths.assets.exist?
|
43
|
+
end
|
44
|
+
|
45
|
+
path, page = r.env["PATH_INFO"].split("/page/")
|
46
|
+
|
47
|
+
document = @statique.discover.documents.find { _1.path == path }
|
49
48
|
|
49
|
+
r.on(proc { document }) do
|
50
50
|
locals = {
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
collections: @statique.discover.collections,
|
52
|
+
document: document,
|
53
|
+
documents: @statique.discover.documents,
|
54
|
+
statique: @statique
|
54
55
|
}
|
55
56
|
|
56
|
-
if
|
57
|
-
|
58
|
-
locals[
|
59
|
-
locals[:paginator] =
|
57
|
+
if document.meta.paginates
|
58
|
+
paginator = Paginator.new(@statique.discover.collections[document.meta.paginates].to_a, document.path, page, @statique)
|
59
|
+
locals[document.meta.paginates.to_sym] = paginator.documents
|
60
|
+
locals[:paginator] = paginator
|
60
61
|
end
|
61
62
|
|
62
63
|
options = {
|
63
|
-
engine:
|
64
|
-
inline:
|
64
|
+
engine: document.engine_name,
|
65
|
+
inline: document.content,
|
65
66
|
locals:,
|
66
67
|
layout_opts: {locals:},
|
67
|
-
cache_key: Digest::SHA1.hexdigest(
|
68
|
-
layout: "../layouts/#{
|
68
|
+
cache_key: Digest::SHA1.hexdigest(document.file.to_s + document.content),
|
69
|
+
layout: "../layouts/#{document.layout_name}"
|
69
70
|
}
|
70
71
|
|
71
72
|
if document.layout_name
|
@@ -75,12 +76,5 @@ class Statique
|
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
78
|
-
|
79
|
-
if Statique.mode.server?
|
80
|
-
route do |r|
|
81
|
-
r.public if Statique.paths.public.exist?
|
82
|
-
r.assets if Statique.paths.assets.exist?
|
83
|
-
end
|
84
|
-
end
|
85
79
|
end
|
86
80
|
end
|
data/lib/statique/cli/build.rb
CHANGED
@@ -9,25 +9,27 @@ class Statique
|
|
9
9
|
class Build
|
10
10
|
prepend MemoWise
|
11
11
|
|
12
|
-
def initialize(options)
|
12
|
+
def initialize(options, statique)
|
13
13
|
Thread.abort_on_exception = true
|
14
|
-
@
|
14
|
+
@statique = statique
|
15
|
+
@queue = Queue.new
|
15
16
|
end
|
16
17
|
|
17
18
|
def run
|
19
|
+
require "statique/app"
|
18
20
|
time = Benchmark.realtime do
|
19
|
-
create_directory(
|
21
|
+
create_directory(@statique.configuration.paths.destination)
|
20
22
|
copy_public_assets
|
21
23
|
build_pages
|
22
24
|
end
|
23
25
|
|
24
|
-
|
26
|
+
@statique.ui.success "Done!", time: time
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
28
30
|
|
29
31
|
def build_pages
|
30
|
-
|
32
|
+
@statique.discover.documents.each do |document|
|
31
33
|
@queue << document.path
|
32
34
|
|
33
35
|
if (pages = document.pagination_pages)
|
@@ -41,12 +43,12 @@ class Statique
|
|
41
43
|
path = @queue.pop
|
42
44
|
response = mock_request.get(path)
|
43
45
|
if response.successful?
|
44
|
-
destination =
|
45
|
-
|
46
|
+
destination = @statique.configuration.paths.destination.join(File.extname(path).empty? ? "./#{path}/index.html" : "./#{path}")
|
47
|
+
@statique.ui.info "Building page", path: path
|
46
48
|
create_directory(destination.dirname)
|
47
49
|
File.write(destination, response.body)
|
48
50
|
else
|
49
|
-
|
51
|
+
@statique.ui.error "Error building page", path: path, status: response.status
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -60,9 +62,9 @@ class Statique
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def copy_public_assets
|
63
|
-
assets =
|
64
|
-
|
65
|
-
FileUtils.cp_r(assets,
|
65
|
+
assets = @statique.configuration.paths.public.glob("**/*.*")
|
66
|
+
@statique.ui.info "Copying public assets", assets:
|
67
|
+
FileUtils.cp_r(assets, @statique.configuration.paths.destination)
|
66
68
|
end
|
67
69
|
|
68
70
|
private
|
data/lib/statique/cli/init.rb
CHANGED
@@ -13,7 +13,7 @@ class Statique
|
|
13
13
|
create_directory(@dest_dir)
|
14
14
|
|
15
15
|
write_file(@dest_dir.join("public/robots.txt"), "User-agent: *\nAllow: /")
|
16
|
-
write_file(@dest_dir.join("assets/css/app.
|
16
|
+
write_file(@dest_dir.join("assets/css/app.css"), %(@import url("https://cdn.jsdelivr.net/npm/water.css@2/out/water.css");))
|
17
17
|
write_file(@dest_dir.join("assets/js/app.js"), %(console.log("Hello from Statique!")))
|
18
18
|
|
19
19
|
copy_template("index.md", @dest_dir.join("content"))
|
data/lib/statique/cli/server.rb
CHANGED
@@ -24,12 +24,14 @@ class Statique
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def initialize(port: 3000)
|
27
|
+
def initialize(statique, port: 3000)
|
28
28
|
@port = port
|
29
|
+
@statique = statique
|
29
30
|
end
|
30
31
|
|
31
32
|
def run
|
32
|
-
|
33
|
+
require "statique/app"
|
34
|
+
@statique.ui.info "Starting server", port: @port
|
33
35
|
|
34
36
|
logger = LoggerWrapper.new
|
35
37
|
|
@@ -41,7 +43,7 @@ class Statique
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def stop
|
44
|
-
|
46
|
+
@statique.ui.info "Stopping server"
|
45
47
|
Rack::Handler::WEBrick.shutdown
|
46
48
|
end
|
47
49
|
|
@@ -51,7 +53,7 @@ class Statique
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def puts(message)
|
54
|
-
|
56
|
+
@statique.ui.public_send(@type, message)
|
55
57
|
end
|
56
58
|
|
57
59
|
def write(message)
|
data/lib/statique/cli.rb
CHANGED
@@ -34,14 +34,14 @@ class Statique
|
|
34
34
|
|
35
35
|
desc "server", "Start Statique server"
|
36
36
|
def server
|
37
|
-
|
38
|
-
Server.new.run
|
37
|
+
statique.mode.server!
|
38
|
+
Server.new(statique).run
|
39
39
|
end
|
40
40
|
|
41
41
|
desc "build", "Build Statique site"
|
42
42
|
def build
|
43
|
-
|
44
|
-
Build.new(options.dup).run
|
43
|
+
statique.mode.build!
|
44
|
+
Build.new(options.dup, statique).run
|
45
45
|
end
|
46
46
|
|
47
47
|
desc "version", "Prints the statique's version information"
|
@@ -50,5 +50,11 @@ class Statique
|
|
50
50
|
end
|
51
51
|
|
52
52
|
map aliases_for("version")
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def statique
|
57
|
+
Statique.instance
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Statique
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :root_url
|
6
|
+
attr_accessor :paths
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@root_url = "/"
|
10
|
+
@paths = OpenStruct.new(
|
11
|
+
pwd: Pathname.pwd,
|
12
|
+
public: Pathname.pwd.join("public"),
|
13
|
+
content: Pathname.pwd.join("content"),
|
14
|
+
layouts: Pathname.pwd.join("layouts"),
|
15
|
+
assets: Pathname.pwd.join("assets"),
|
16
|
+
destination: Pathname.pwd.join("dist")
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/statique/discover.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "set"
|
4
|
+
|
3
5
|
class Statique
|
4
6
|
class Discover
|
5
7
|
attr_reader :documents, :collections, :files
|
@@ -12,21 +14,22 @@ class Statique
|
|
12
14
|
|
13
15
|
GLOB = "**/*.{#{SUPPORTED_EXTENSIONS.join(",")}}"
|
14
16
|
|
15
|
-
def initialize(root)
|
17
|
+
def initialize(root, statique)
|
16
18
|
@root = root
|
17
19
|
@documents = []
|
18
20
|
@collections = Hashie::Mash.new { |hash, key| hash[key] = Set.new }
|
21
|
+
@statique = statique
|
19
22
|
|
20
23
|
discover_files!
|
21
24
|
discover!
|
22
25
|
|
23
|
-
|
26
|
+
@statique.mode.build do
|
24
27
|
@files.freeze
|
25
28
|
@documents.freeze
|
26
29
|
@collections.freeze
|
27
30
|
end
|
28
31
|
|
29
|
-
watch_for_changes if
|
32
|
+
watch_for_changes if @statique.mode.server?
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
@@ -34,7 +37,7 @@ class Statique
|
|
34
37
|
def discover_files!
|
35
38
|
@files = @root.glob(GLOB)
|
36
39
|
ensure
|
37
|
-
|
40
|
+
@statique.ui.debug "Discovered files", count: @files.size
|
38
41
|
end
|
39
42
|
|
40
43
|
def discover!
|
@@ -44,7 +47,7 @@ class Statique
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def process(file)
|
47
|
-
document = Document.new(file)
|
50
|
+
document = Document.new(file, @statique)
|
48
51
|
|
49
52
|
documents << document
|
50
53
|
|
@@ -56,20 +59,20 @@ class Statique
|
|
56
59
|
def watch_for_changes
|
57
60
|
require "filewatcher"
|
58
61
|
|
59
|
-
@filewatcher = Filewatcher.new([
|
62
|
+
@filewatcher = Filewatcher.new([@statique.configuration.paths.content, @statique.configuration.paths.layouts])
|
60
63
|
@filewatcher_thread = Thread.new(@filewatcher) do |watcher|
|
61
64
|
watcher.watch do |file, event|
|
62
|
-
|
65
|
+
@statique.ui.debug "File change event", file: file, event: event
|
63
66
|
discover_files!
|
64
67
|
path = Pathname.new(file)
|
65
68
|
remove_file!(path)
|
66
69
|
process(path) unless event == :deleted
|
67
70
|
end
|
68
71
|
end
|
69
|
-
|
72
|
+
@statique.ui.debug "Started file watcher", filewatcher: @filewatcher, thread: @filewatcher_thread
|
70
73
|
|
71
74
|
at_exit do
|
72
|
-
|
75
|
+
@statique.ui.debug "Closing file watcher", thread: @filewatcher_thread
|
73
76
|
@filewatcher.stop
|
74
77
|
@filewatcher.finalize
|
75
78
|
@filewatcher_thread.join
|
data/lib/statique/document.rb
CHANGED
@@ -6,9 +6,9 @@ class Statique
|
|
6
6
|
class Document
|
7
7
|
attr_reader :file, :meta, :content
|
8
8
|
|
9
|
-
def initialize(file)
|
9
|
+
def initialize(file, statique)
|
10
10
|
parsed = FrontMatterParser::Parser.parse_file(file)
|
11
|
-
@file, @meta, @content = file.freeze, Hashie::Mash.new(parsed.front_matter).freeze, parsed.content.freeze
|
11
|
+
@file, @meta, @content, @statique = file.freeze, Hashie::Mash.new(parsed.front_matter).freeze, parsed.content.freeze, statique
|
12
12
|
end
|
13
13
|
|
14
14
|
def path
|
@@ -16,7 +16,7 @@ class Statique
|
|
16
16
|
when "index.slim" then "/"
|
17
17
|
when "index.md" then "/"
|
18
18
|
else
|
19
|
-
"/#{meta.permalink || basename.delete_suffix(extname).delete_prefix(
|
19
|
+
"/#{meta.permalink || basename.delete_suffix(extname).delete_prefix(@statique.configuration.paths.content.to_s)}"
|
20
20
|
end.freeze
|
21
21
|
end
|
22
22
|
|
@@ -41,9 +41,9 @@ class Statique
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def pagination_pages
|
44
|
-
return unless
|
45
|
-
collection =
|
46
|
-
(collection.size.to_f /
|
44
|
+
return unless @statique.discover.collections.key?(meta.paginates)
|
45
|
+
collection = @statique.discover.collections[meta.paginates]
|
46
|
+
(collection.size.to_f / Paginator.per_page).ceil
|
47
47
|
end
|
48
48
|
|
49
49
|
def published_at
|
data/lib/statique/paginator.rb
CHANGED
@@ -2,42 +2,51 @@
|
|
2
2
|
|
3
3
|
class Statique
|
4
4
|
class Paginator
|
5
|
-
attr_reader :documents
|
5
|
+
attr_reader :page, :documents, :total_pages, :total_documents
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
7
|
+
def self.per_page
|
8
|
+
@per_page ||= 10
|
9
9
|
end
|
10
10
|
|
11
|
-
def page
|
12
|
-
@
|
13
|
-
|
11
|
+
def initialize(documents, path, page, statique = Statique.instance)
|
12
|
+
@path, @page = path, [page.to_i, 1].max
|
13
|
+
|
14
|
+
@statique = statique
|
14
15
|
|
15
|
-
|
16
|
-
@
|
16
|
+
@total_documents = documents.size
|
17
|
+
@offset = (self.class.per_page * (@page - 1))
|
18
|
+
@total_pages = (@total_documents.to_f / self.class.per_page).ceil
|
19
|
+
@documents = documents[@offset, self.class.per_page]
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
20
|
-
|
22
|
+
def per_page
|
23
|
+
self.class.per_page
|
21
24
|
end
|
22
25
|
|
23
26
|
def previous_page
|
24
|
-
@
|
27
|
+
page = [1, @page - 1].max
|
28
|
+
if page == @page
|
29
|
+
nil
|
30
|
+
else
|
31
|
+
page
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
def previous_page_path
|
28
|
-
page_path(
|
36
|
+
page_path(previous_page)
|
29
37
|
end
|
30
38
|
|
31
39
|
def next_page
|
32
|
-
@
|
40
|
+
page = [@total_pages, @page + 1].min
|
41
|
+
if page == @page
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
page
|
45
|
+
end
|
33
46
|
end
|
34
47
|
|
35
48
|
def next_page_path
|
36
|
-
page_path(
|
37
|
-
end
|
38
|
-
|
39
|
-
def per_page
|
40
|
-
@pagy.items
|
49
|
+
page_path(next_page)
|
41
50
|
end
|
42
51
|
|
43
52
|
private
|
@@ -46,9 +55,9 @@ class Statique
|
|
46
55
|
return unless page
|
47
56
|
|
48
57
|
if page == 1
|
49
|
-
|
58
|
+
@statique.url(File.join(@path))
|
50
59
|
else
|
51
|
-
|
60
|
+
@statique.url(File.join(@path, "page", page.to_s))
|
52
61
|
end
|
53
62
|
end
|
54
63
|
end
|
data/lib/statique/version.rb
CHANGED
data/lib/statique.rb
CHANGED
@@ -3,66 +3,58 @@
|
|
3
3
|
require "front_matter_parser"
|
4
4
|
require "hashie"
|
5
5
|
require "pathname"
|
6
|
-
require "
|
7
|
-
require "rack"
|
6
|
+
require "singleton"
|
8
7
|
require "tty-logger"
|
9
|
-
require "dry-configurable"
|
10
8
|
|
11
9
|
::FrontMatterParser::SyntaxParser::Builder = FrontMatterParser::SyntaxParser::MultiLineComment["=begin", "=end"]
|
12
10
|
|
13
11
|
$LOAD_PATH.unshift(File.expand_path("..", __FILE__))
|
14
|
-
require "zeitwerk"
|
15
12
|
|
16
|
-
|
17
|
-
loader.inflector.inflect(
|
18
|
-
"cli" => "CLI"
|
19
|
-
)
|
20
|
-
loader.setup
|
13
|
+
require "statique/cli"
|
21
14
|
|
22
15
|
class Statique
|
23
|
-
|
16
|
+
include Singleton
|
17
|
+
extend Forwardable
|
24
18
|
|
25
19
|
class Error < StandardError; end
|
26
20
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
setting :destination, default: Pathname.pwd.join("dist"), constructor: -> { Statique.pwd.join(_1) }
|
34
|
-
end
|
35
|
-
setting :root_url, default: "/", reader: true
|
21
|
+
autoload :Configuration, "statique/configuration"
|
22
|
+
autoload :Discover, "statique/discover"
|
23
|
+
autoload :Document, "statique/document"
|
24
|
+
autoload :Mode, "statique/mode"
|
25
|
+
autoload :Paginator, "statique/paginator"
|
26
|
+
autoload :VERSION, "statique/version"
|
36
27
|
|
37
|
-
|
38
|
-
def discover
|
39
|
-
@discover ||= Discover.new(paths.content)
|
40
|
-
end
|
28
|
+
def_delegators :configuration, :root_url
|
41
29
|
|
42
|
-
|
43
|
-
@mode ||= Mode.new
|
44
|
-
end
|
30
|
+
attr_reader :configuration, :discover, :mode, :pwd, :build_queue
|
45
31
|
|
46
|
-
|
47
|
-
|
48
|
-
|
32
|
+
def initialize
|
33
|
+
@mode = Mode.new
|
34
|
+
@configuration = Configuration.new
|
35
|
+
@discover = Discover.new(configuration.paths.content, self)
|
36
|
+
@pwd = Pathname.pwd.freeze
|
37
|
+
end
|
49
38
|
|
50
|
-
|
51
|
-
|
52
|
-
|
39
|
+
def statique
|
40
|
+
self.class.instance
|
41
|
+
end
|
53
42
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
43
|
+
def version
|
44
|
+
VERSION
|
45
|
+
end
|
59
46
|
|
60
|
-
|
61
|
-
|
62
|
-
|
47
|
+
def ui
|
48
|
+
self.class.ui
|
49
|
+
end
|
63
50
|
|
64
|
-
|
65
|
-
|
51
|
+
def self.ui
|
52
|
+
@ui ||= TTY::Logger.new(output: $stdout) do |config|
|
53
|
+
config.level = :debug if ENV["DEBUG"] == "true"
|
66
54
|
end
|
67
55
|
end
|
56
|
+
|
57
|
+
def url(document_or_path)
|
58
|
+
File.join(configuration.root_url, document_or_path.is_a?(Document) ? document_or_path.path : document_or_path)
|
59
|
+
end
|
68
60
|
end
|
data/lib/templates/layout.slim
CHANGED
@@ -2,7 +2,7 @@ doctype html
|
|
2
2
|
html
|
3
3
|
head
|
4
4
|
meta charset="UTF-8"
|
5
|
-
meta name="generator" content="Statique #{
|
5
|
+
meta name="generator" content="Statique #{statique.version}"
|
6
6
|
title Statique Website
|
7
7
|
== assets(:css)
|
8
8
|
== assets(:js)
|
@@ -10,4 +10,4 @@ html
|
|
10
10
|
header
|
11
11
|
h1 Statique Website
|
12
12
|
main== yield
|
13
|
-
footer Made with Statique v#{
|
13
|
+
footer Made with Statique v#{statique.version}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statique
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Usewicz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.23.2
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: dry-configurable
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.14.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.14.0
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: filewatcher
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,62 +94,20 @@ dependencies:
|
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: 1.6.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pagy
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 5.9.3
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 5.9.3
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rack-rewrite
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.5.1
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.5.1
|
139
97
|
- !ruby/object:Gem::Dependency
|
140
98
|
name: roda
|
141
99
|
requirement: !ruby/object:Gem::Requirement
|
142
100
|
requirements:
|
143
101
|
- - "~>"
|
144
102
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3.
|
103
|
+
version: '3.53'
|
146
104
|
type: :runtime
|
147
105
|
prerelease: false
|
148
106
|
version_requirements: !ruby/object:Gem::Requirement
|
149
107
|
requirements:
|
150
108
|
- - "~>"
|
151
109
|
- !ruby/object:Gem::Version
|
152
|
-
version: '3.
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: sassc
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 2.4.0
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 2.4.0
|
110
|
+
version: '3.53'
|
167
111
|
- !ruby/object:Gem::Dependency
|
168
112
|
name: slim
|
169
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,20 +136,6 @@ dependencies:
|
|
192
136
|
- - "~>"
|
193
137
|
- !ruby/object:Gem::Version
|
194
138
|
version: 1.2.1
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: tilt
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - "~>"
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: 2.0.10
|
202
|
-
type: :runtime
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - "~>"
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: 2.0.10
|
209
139
|
- !ruby/object:Gem::Dependency
|
210
140
|
name: tty-logger
|
211
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,20 +164,6 @@ dependencies:
|
|
234
164
|
- - "~>"
|
235
165
|
- !ruby/object:Gem::Version
|
236
166
|
version: 1.7.0
|
237
|
-
- !ruby/object:Gem::Dependency
|
238
|
-
name: zeitwerk
|
239
|
-
requirement: !ruby/object:Gem::Requirement
|
240
|
-
requirements:
|
241
|
-
- - "~>"
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
version: 2.5.4
|
244
|
-
type: :runtime
|
245
|
-
prerelease: false
|
246
|
-
version_requirements: !ruby/object:Gem::Requirement
|
247
|
-
requirements:
|
248
|
-
- - "~>"
|
249
|
-
- !ruby/object:Gem::Version
|
250
|
-
version: 2.5.4
|
251
167
|
description: Statique is a static website generator written in Ruby using Roda
|
252
168
|
email:
|
253
169
|
- piotr@layer22.com
|
@@ -268,6 +184,9 @@ files:
|
|
268
184
|
- Rakefile
|
269
185
|
- bin/console
|
270
186
|
- bin/setup
|
187
|
+
- docs/assets/css/app.css
|
188
|
+
- docs/content/index.md
|
189
|
+
- docs/layouts/layout.slim
|
271
190
|
- exe/statique
|
272
191
|
- lib/statique.rb
|
273
192
|
- lib/statique/app.rb
|
@@ -275,6 +194,7 @@ files:
|
|
275
194
|
- lib/statique/cli/build.rb
|
276
195
|
- lib/statique/cli/init.rb
|
277
196
|
- lib/statique/cli/server.rb
|
197
|
+
- lib/statique/configuration.rb
|
278
198
|
- lib/statique/discover.rb
|
279
199
|
- lib/statique/document.rb
|
280
200
|
- lib/statique/mode.rb
|
@@ -285,15 +205,14 @@ files:
|
|
285
205
|
- sig/statique.rbs
|
286
206
|
- sig/statique/mode.rbs
|
287
207
|
- sig/statique/version.rbs
|
288
|
-
- statique.gemspec
|
289
208
|
homepage: https://github.com/pusewicz/statique
|
290
209
|
licenses:
|
291
210
|
- MIT
|
292
211
|
metadata:
|
293
212
|
homepage_uri: https://github.com/pusewicz/statique
|
294
213
|
source_code_uri: https://github.com/pusewicz/statique
|
295
|
-
changelog_uri: https://raw.githubusercontent.com/pusewicz/statique/v0.1.
|
296
|
-
post_install_message:
|
214
|
+
changelog_uri: https://raw.githubusercontent.com/pusewicz/statique/v0.1.4/CHANGELOG.md
|
215
|
+
post_install_message:
|
297
216
|
rdoc_options: []
|
298
217
|
require_paths:
|
299
218
|
- lib
|
@@ -301,15 +220,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
301
220
|
requirements:
|
302
221
|
- - ">="
|
303
222
|
- !ruby/object:Gem::Version
|
304
|
-
version:
|
223
|
+
version: 3.1.0
|
305
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
306
225
|
requirements:
|
307
226
|
- - ">="
|
308
227
|
- !ruby/object:Gem::Version
|
309
228
|
version: '0'
|
310
229
|
requirements: []
|
311
|
-
rubygems_version: 3.3.
|
312
|
-
signing_key:
|
230
|
+
rubygems_version: 3.3.3
|
231
|
+
signing_key:
|
313
232
|
specification_version: 4
|
314
233
|
summary: Static website generator
|
315
234
|
test_files: []
|
data/statique.gemspec
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/statique/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "statique"
|
7
|
-
spec.version = Statique::VERSION
|
8
|
-
spec.authors = ["Piotr Usewicz"]
|
9
|
-
spec.email = ["piotr@layer22.com"]
|
10
|
-
|
11
|
-
spec.summary = "Static website generator"
|
12
|
-
spec.description = "Statique is a static website generator written in Ruby using Roda"
|
13
|
-
spec.homepage = "https://github.com/pusewicz/statique"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.6.0"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/pusewicz/statique"
|
19
|
-
spec.metadata["changelog_uri"] = "https://raw.githubusercontent.com/pusewicz/statique/v#{spec.version}/CHANGELOG.md"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
spec.bindir = "exe"
|
29
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = ["lib"]
|
31
|
-
|
32
|
-
# Uncomment to register a new dependency of your gem
|
33
|
-
spec.add_dependency "builder", "~> 3.2.4"
|
34
|
-
spec.add_dependency "commonmarker", "~> 0.23.2"
|
35
|
-
spec.add_dependency "dry-configurable", "~> 0.14.0"
|
36
|
-
spec.add_dependency "filewatcher", "~> 1.1.1"
|
37
|
-
spec.add_dependency "front_matter_parser", "~> 1.0.1"
|
38
|
-
spec.add_dependency "hashie", "~> 5.0.0"
|
39
|
-
spec.add_dependency "memo_wise", "~> 1.6.0"
|
40
|
-
spec.add_dependency "pagy", "~> 5.9.3"
|
41
|
-
spec.add_dependency "rack-rewrite", "~> 1.5.1"
|
42
|
-
spec.add_dependency "roda", "~> 3.52"
|
43
|
-
spec.add_dependency "sassc", "~> 2.4.0"
|
44
|
-
spec.add_dependency "slim", "~> 4.1.0"
|
45
|
-
spec.add_dependency "thor", "~> 1.2.1"
|
46
|
-
spec.add_dependency "tilt", "~> 2.0.10"
|
47
|
-
spec.add_dependency "tty-logger", "~> 0.6.0"
|
48
|
-
spec.add_dependency "webrick", "~> 1.7.0"
|
49
|
-
spec.add_dependency "zeitwerk", "~> 2.5.4"
|
50
|
-
|
51
|
-
# For more information and examples about making a new gem, check out our
|
52
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
53
|
-
end
|