isola 0.2.1 → 0.3.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 +4 -4
- data/README.md +10 -5
- data/USAGE.ja.md +39 -1
- data/USAGE.md +61 -1
- data/lib/isola/site.rb +5 -5
- data/lib/isola/source.rb +4 -2
- data/lib/isola/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78a20d7d0b5cf6c979a08cd3cb3180713278bef47ac3fdd9d318da746d437d70
|
|
4
|
+
data.tar.gz: f92155399e18243068cd270778684e5ef9ff6a7482118fa7d1dfe7ce863f355a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7c7a4c8c0c2f17c7bfc7f19f56d9b64449968510f449f4bcabbba1336f485b633035a130e00945b5e22e14abd22499216b709797918fae5534cbf3312fc1f0d
|
|
7
|
+
data.tar.gz: f9d0abda752892015b7daac37fb8fe6766bda464c6e3201b7f167fef5636fca2f2445445c67ddc41df6984956ae82db6f81ce25aa2860661cf66556b4b504ecb
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# isola
|
|
2
|
+
[](https://badge.fury.io/rb/isola)
|
|
2
3
|
|
|
3
|
-
Super simple static site generator using
|
|
4
|
+
Super simple static site generator using eRuby as a template engine. Supports a multilingual website. Blogging features are not yet implemented.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ Super simple static site generator using erb.
|
|
|
8
9
|
bundle add isola
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
If
|
|
12
|
+
If you are not using Bundler to manage dependencies, install the gem by executing:
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
15
|
gem install isola
|
|
@@ -16,14 +17,18 @@ gem install isola
|
|
|
16
17
|
|
|
17
18
|
## Usage
|
|
18
19
|
|
|
19
|
-
1.
|
|
20
|
+
1. Place markdown files in your directory.
|
|
20
21
|
2. `isola build`
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Refer to the [Usage Guide](USAGE.md) / [使い方ガイド](USAGE.ja.md) for more information.
|
|
24
|
+
|
|
25
|
+
## Websites Built with Isola
|
|
26
|
+
|
|
27
|
+
* [群島舎/Guntosha](https://skoji.dev) ([source](https://github.com/skoji/skoji-dev-web))
|
|
23
28
|
|
|
24
29
|
## Development Policy
|
|
25
30
|
|
|
26
|
-
This project does not use Agentic Coding
|
|
31
|
+
This project does not use Agentic Coding for development. AI assistance in code reviews is not avoided.
|
|
27
32
|
|
|
28
33
|
## License
|
|
29
34
|
|
data/USAGE.ja.md
CHANGED
|
@@ -101,7 +101,7 @@ port: 4444
|
|
|
101
101
|
|
|
102
102
|
## ファイルの処理
|
|
103
103
|
|
|
104
|
-
Isola
|
|
104
|
+
Isolaは **ERB**(`.erb`)と **Markdown**(`.md`, `.markdown`, `.mkd`)をビルトインのテンプレートエンジンとしてサポートしています。
|
|
105
105
|
|
|
106
106
|
拡張子の末尾から順に処理します。例えば `page.md.erb` の場合、まずERBを処理し、次にMarkdownを処理します。
|
|
107
107
|
|
|
@@ -117,6 +117,44 @@ Isolaが処理するテンプレートエンジンは現在 **ERB**(`.erb`)
|
|
|
117
117
|
|
|
118
118
|
`_`や`.`で始まるファイル・ディレクトリは自動的に除外されます(`_layouts/`と`_includes/`を除く)。
|
|
119
119
|
|
|
120
|
+
### Tilt拡張
|
|
121
|
+
|
|
122
|
+
[Tilt](https://github.com/rtomayko/tilt)がサポートするテンプレートエンジンを、`_config.yaml`の`tilt_extensions`で追加できます。対応するライブラリが利用可能である必要があります(例: `Gemfile`に追加)。
|
|
123
|
+
|
|
124
|
+
#### SCSS / Sass
|
|
125
|
+
|
|
126
|
+
`tilt_extensions`に`.scss`や`.sass`を追加します:
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
tilt_extensions:
|
|
130
|
+
- .scss
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
SCSS/Sassファイルは自動的にCSSに変換されます。ファイル名に出力用の拡張子を追加する必要はありません。
|
|
134
|
+
|
|
135
|
+
| ソース | 処理 | 出力 |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `style.scss` | SCSS → CSS | `style.css` |
|
|
138
|
+
|
|
139
|
+
`sass-embedded` gemも必要です。`Gemfile`に追加してください:
|
|
140
|
+
|
|
141
|
+
```ruby
|
|
142
|
+
gem "sass-embedded"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### その他のTilt拡張
|
|
146
|
+
|
|
147
|
+
その他のTilt対応エンジン(例: `.nokogiri`)では、出力拡張子は自動推定されません。ファイル名に出力したい拡張子を含めてください:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
tilt_extensions:
|
|
151
|
+
- .nokogiri
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| ソース | 処理 | 出力 |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `data.xml.nokogiri` | Nokogiriテンプレート → XML | `data.xml` |
|
|
157
|
+
|
|
120
158
|
## 多言語対応
|
|
121
159
|
|
|
122
160
|
Isolaは多言語サイトの構築をサポートしています。デフォルト言語のページはサイトルートに、その他の言語は言語コード名のサブディレクトリに配置します。
|
data/USAGE.md
CHANGED
|
@@ -101,7 +101,7 @@ The server watches for file changes and automatically rebuilds the site. HTML pa
|
|
|
101
101
|
|
|
102
102
|
## File Processing
|
|
103
103
|
|
|
104
|
-
Isola
|
|
104
|
+
Isola supports **ERB** (`.erb`) and **Markdown** (`.md`, `.markdown`, `.mkd`) as built-in template engines.
|
|
105
105
|
|
|
106
106
|
Extensions are processed from right to left. For example, `page.md.erb` is first processed as ERB, then as Markdown.
|
|
107
107
|
|
|
@@ -117,6 +117,44 @@ If an extension remains after processing, it is kept as-is. If no extension rema
|
|
|
117
117
|
|
|
118
118
|
Files and directories starting with `_` or `.` are excluded automatically (except `_layouts/` and `_includes/`).
|
|
119
119
|
|
|
120
|
+
### Tilt Extensions
|
|
121
|
+
|
|
122
|
+
You can add additional template engines supported by [Tilt](https://github.com/rtomayko/tilt) via `tilt_extensions` in `_config.yaml`. The corresponding library must be available in your environment (e.g. added to your `Gemfile`).
|
|
123
|
+
|
|
124
|
+
#### SCSS / Sass
|
|
125
|
+
|
|
126
|
+
Add `.scss` or `.sass` to `tilt_extensions`:
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
tilt_extensions:
|
|
130
|
+
- .scss
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
SCSS/Sass files are automatically converted to CSS. No extra extension is needed in the filename.
|
|
134
|
+
|
|
135
|
+
| Source | Processing | Output |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `style.scss` | SCSS → CSS | `style.css` |
|
|
138
|
+
|
|
139
|
+
You also need the `sass-embedded` gem. Add it to your `Gemfile`:
|
|
140
|
+
|
|
141
|
+
```ruby
|
|
142
|
+
gem "sass-embedded"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Other Tilt Extensions
|
|
146
|
+
|
|
147
|
+
For other Tilt-supported engines (e.g. `.nokogiri`), the output extension is not inferred automatically. Include the desired output extension in the filename:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
tilt_extensions:
|
|
151
|
+
- .nokogiri
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| Source | Processing | Output |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `data.xml.nokogiri` | Nokogiri template → XML | `data.xml` |
|
|
157
|
+
|
|
120
158
|
## Multi-Language Support
|
|
121
159
|
|
|
122
160
|
Isola supports building multi-language sites. Pages for the default language live at the site root, while other languages are placed in subdirectories named by language code.
|
|
@@ -161,6 +199,8 @@ In addition to the standard template variables, multi-language sites provide:
|
|
|
161
199
|
|
|
162
200
|
- `page[:lang]` — the language of the current page (e.g. `:ja`, `:en`)
|
|
163
201
|
- `page[:translations]` — a hash of `{lang: url_path}` (URL paths starting with `/`, suitable for `href` attributes) for all available translations of the current page
|
|
202
|
+
- `site.language_label(lang)` — returns the `label` string for the given language (e.g. `site.language_label(:ja)` → `"日本語"`). Returns `nil` if `languages` is not configured.
|
|
203
|
+
- `lang_path(path)` — returns the URL path for the given page path localized to the current page's language (e.g. `lang_path("foo.html")` → `"/en/foo.html"` when rendered in an English page)
|
|
164
204
|
|
|
165
205
|
#### Generating hreflang Links
|
|
166
206
|
|
|
@@ -172,6 +212,26 @@ Use `page[:translations]` to output alternate-language links:
|
|
|
172
212
|
<% end %>
|
|
173
213
|
```
|
|
174
214
|
|
|
215
|
+
#### Language Switcher
|
|
216
|
+
|
|
217
|
+
Use `site.language_label` and `page[:translations]` to build a language switcher:
|
|
218
|
+
|
|
219
|
+
```erb
|
|
220
|
+
<ul>
|
|
221
|
+
<% page[:translations].each do |lang, url| %>
|
|
222
|
+
<li><a href="<%= url %>"><%= site.language_label(lang) %></a></li>
|
|
223
|
+
<% end %>
|
|
224
|
+
</ul>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Generating Localized Links
|
|
228
|
+
|
|
229
|
+
Use `lang_path` to generate links to other pages within the same language:
|
|
230
|
+
|
|
231
|
+
```erb
|
|
232
|
+
<a href="<%= lang_path("about.html") %>">About</a>
|
|
233
|
+
```
|
|
234
|
+
|
|
175
235
|
### Output
|
|
176
236
|
|
|
177
237
|
The output mirrors the source structure:
|
data/lib/isola/site.rb
CHANGED
|
@@ -12,8 +12,8 @@ module Isola
|
|
|
12
12
|
host: "127.0.0.1",
|
|
13
13
|
languages: {},
|
|
14
14
|
port: 4444}.freeze
|
|
15
|
-
|
|
16
|
-
EXT_MAP = {".md" => ".html", ".mkd" => ".html", ".markdown" => ".html", ".html" => ".html", "" => ".html"}
|
|
15
|
+
SUPPORTED_TILT_EXTS = [".erb", ".md", ".markdown", ".mkd", ".html"]
|
|
16
|
+
EXT_MAP = Hash.new("").merge({".md" => ".html", ".mkd" => ".html", ".markdown" => ".html", ".html" => ".html", ".scss" => ".css", ".sass" => ".css", "" => ".html"})
|
|
17
17
|
def initialize(config)
|
|
18
18
|
@config = DEFAULT_CONFIG.merge(YAML.safe_load(config, symbolize_names: true) || {})
|
|
19
19
|
@config[:default_language] = @config[:default_language].to_sym
|
|
@@ -23,6 +23,7 @@ module Isola
|
|
|
23
23
|
default_language: default_language,
|
|
24
24
|
languages: languages.keys
|
|
25
25
|
)
|
|
26
|
+
@supported_tilt_exts = SUPPORTED_TILT_EXTS.union(@config[:tilt_extensions] || [])
|
|
26
27
|
collect_files
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -43,7 +44,7 @@ module Isola
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def ext_to_process_with_tilt? ext
|
|
46
|
-
|
|
47
|
+
@supported_tilt_exts.include? ext
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def process_extensions(path)
|
|
@@ -76,7 +77,6 @@ module Isola
|
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
def url_path_for(path)
|
|
79
|
-
# will support base_url for the future.
|
|
80
80
|
File.join("/", path)
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -152,7 +152,7 @@ module Isola
|
|
|
152
152
|
return nil unless p
|
|
153
153
|
if ext_to_process_with_tilt?(File.extname(p))
|
|
154
154
|
translations = translations_for(resolved, store)
|
|
155
|
-
Source.new(p, read_in_site(p), lang: lang, translations: translations)
|
|
155
|
+
Source.new(p, read_in_site(p), root_dir: @config[:root_dir], lang: lang, translations: translations)
|
|
156
156
|
else
|
|
157
157
|
StaticFile.new(p)
|
|
158
158
|
end
|
data/lib/isola/source.rb
CHANGED
|
@@ -3,8 +3,9 @@ require "yaml"
|
|
|
3
3
|
module Isola
|
|
4
4
|
class Source
|
|
5
5
|
attr_reader :filepath, :meta, :content
|
|
6
|
-
def initialize filepath, text, lang:, translations: {}
|
|
6
|
+
def initialize filepath, text, lang:, root_dir: "", translations: {}
|
|
7
7
|
@filepath = filepath
|
|
8
|
+
@root_dir = root_dir
|
|
8
9
|
@meta, @content = if (m = text.match(/\A---\s*\n(.+?)^---\s*\n(.*)\z/m))
|
|
9
10
|
[YAML.safe_load(m[1], symbolize_names: true) || {}, m[2]]
|
|
10
11
|
else
|
|
@@ -21,7 +22,8 @@ module Isola
|
|
|
21
22
|
def render(context, site, params = {})
|
|
22
23
|
rendered = @content.dup
|
|
23
24
|
output_path = site.process_extensions(@filepath) do |current_path, _ext|
|
|
24
|
-
|
|
25
|
+
path = File.join(@root_dir, current_path)
|
|
26
|
+
rendered = Tilt.new(path) { rendered }.render(context, params)
|
|
25
27
|
end
|
|
26
28
|
[rendered, output_path]
|
|
27
29
|
end
|
data/lib/isola/version.rb
CHANGED