yass 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73f51cc4416ff0b4de87b02a74f586f0896ad4ee1bf7f1825d19076229fc528a
4
- data.tar.gz: 3da6e3a3b8ea3e0a6e45edaef4813f8ec83ada084daac8bfe6f83cf624b083d8
3
+ metadata.gz: 7f845ee6ace64cb353bbf781b6af133b55c6d4005a2a88ae9c98388aa04ee44c
4
+ data.tar.gz: f24b5f5c7eb66aa796b2f8f07ae1a8d54902f83c22a01d3deb59ee35bee7d221
5
5
  SHA512:
6
- metadata.gz: a1760594401b2db23db4bc0b1fe8333b9d7b77ede41291ee5ace23c3a407d432b5360941570bb13eb1ea3f61f37f7c3d36e2d6da856561b0278e418380b37e00
7
- data.tar.gz: 2911add8f4767f6aedd2ceb6c2708d966d05961161671d0eedc735f28ae6147379b6da142c7d6fce3162c9ee94cca4cd29d20bbe0f3275104dfdba85bd16710a
6
+ metadata.gz: 1e3082454ea333e73485c381ab7a55d5abc3a3238a65e7c81a1d3e9cdbd0ca7d45adbce075a0a5ebc640b4b62e15e17ce58df4b3c99801e526f7afb7a923e7b1
7
+ data.tar.gz: 55adcbf2291390aa8b47c10cd335e8b56aa612bb9407fc9bf7fa3c532ebed0e9472ae059bad94e629d5ea1205297c8318856a1186a5607b96776251e540d44bd
data/README.md CHANGED
@@ -2,15 +2,7 @@
2
2
 
3
3
  Yet Another Static Site (generator)
4
4
 
5
- Yass is an incredibly un-opinionated static site generator. Here's how it works:
6
-
7
- * Write everything by hand under `site/`.
8
- * Everything under `site/` is copied to `dist/`.
9
- * [Markdown](https://commonmark.org/) (`.md`) and [Liquid](https://shopify.github.io/liquid/) (`.liquid`) files are processed.
10
- * Liquid layouts and templates can be placed into `layouts/` and `templates/`.
11
- * Helpers are available in addition to Liquid's standard functionality.
12
- * Syntax highlighting via [Highlight.js](https://highlightjs.org/).
13
- * Want to preview your site? Build it and open `dist/index.html` in your browser.
5
+ Yass is an incredibly un-opinionated static site generator. [Learn more!](https://jhollinger.github.io/yass/)
14
6
 
15
7
  ## Getting started
16
8
 
@@ -20,11 +12,10 @@ Starting from an empty page isn't fun, so `yass init` will create a skeleton sit
20
12
  $ gem install yass
21
13
  $ yass init blog
22
14
  Creating blog/layouts/default.html.liquid
23
- Creating blog/site/assets/highlight-default.css
15
+ Creating blog/site/assets/highlight.min.css
24
16
  Creating blog/site/assets/highlight.min.js
25
17
  Creating blog/site/index.html.liquid
26
- Creating blog/templates/css_links.liquid
27
- Creating blog/templates/js_scripts.liquid
18
+ Creating blog/templates/asset_tags.liquid
28
19
  $ cd blog
29
20
  ```
30
21
 
@@ -48,114 +39,10 @@ Use the `watch` command to continually build your site as files change.
48
39
  yass watch # also supports --no-skip-index
49
40
  ```
50
41
 
51
- ## Layouts
52
-
53
- Layouts live in `layouts/` and will be applied to files with matching names. The `content` variable contains the data to render in the layout.
54
-
55
- ```html
56
- <!DOCTYPE html>
57
- <html lang="en">
58
- <head>
59
- <title>{{ page.title }}</title>
60
- </head>
61
- <body>{{ content }}</body>
62
- </html>
63
- ```
64
-
65
- If the above layout is named *page.html.liquid*, it will match any file named `*.page.html*`. Examples:
66
-
67
- * `foo.page.html`
68
- * `foo.page.html.*`
69
- * `foo.page.md` (because *.md* converts to *.html*)
70
- * `foo.page.md.*`
71
-
72
- The name of the layout (e.g. `page`) is removed from the final filename, resulting in `foo.html`.
73
-
74
- ### Default layouts
75
-
76
- If you create a layout named `default.<ext>.liquid`, Yass will apply it to any `.<ext>` files without layouts. For example, a layout named `default.html.liquid` will match `foo.html` or `foo.not-a-layout.md.liquid`.
77
-
78
- ## Templates
79
-
80
- Templates live in `templates/` and can be used in any `.liquid` files.
81
-
82
- *templates/greeting.liquid*
83
-
84
- ```html
85
- <p>Hi, my name is {{ name }}</p>
86
- ```
87
-
88
- Render the above template with `{% render "greeting", name: "Pleck" %}`.
89
-
90
- NOTE: Liquid is pretty strict about template filenames. They must match `^[a-zA-Z0-9_]\.liquid$`.
91
-
92
- ## Liquid variables
93
-
94
- ### page
95
-
96
- An object representing the current page. Properties:
97
-
98
- * `title` A titleized version of the filename (e.g. *My File* from *my-file.html*)
99
- * `src_path` Path with the original filename (e.g. *foo/bar/zorp.md.liquid*)
100
- * `path` URL path relative to the relative root (e.g. *foo/bar/zorp.html*)
101
- * `dirname` Directory file is in (e.g. *foo/bar* from *foo/bar/zorp.html*)
102
- * `filename` Name of file (e.g. *zorp.html* from *foo/bar/zorp.html*)
103
- * `extname` File extension (e.g. *.html* from *foo/bar/zorp.html*)
104
-
105
- ### files
106
-
107
- Any array of all files that will be written `dist/`. Same properties as `page`.
108
-
109
- ## Liquid filters
110
-
111
- ### relative
112
-
113
- Modifies a path to be relative to the current file. Useful in layouts and template that need to refer to other files.
114
-
115
- ```html
116
- <script src="{{ "assets/main.js" | relative }}"</script>
117
- ```
118
-
119
- If the above HTML was in `a/b/c.html.liquid`, the script source would be `../../assets/main.js`.
120
-
121
- ### strip_index
122
-
123
- Removes trailing `index.html`s from URLs, on the assumption that web servers will handle that. Can be disabled with the `--no-strip-index` option (useful for development builds).
124
-
125
- ### match
126
-
127
- Returns true if the string matches the regex.
128
-
129
- ```liquid
130
- {% assign is_asset = page.path | match: "\.(css|js|jpe?g)$"
131
- ```
132
-
133
- ## Liquid tags
134
-
135
- ### highlight
136
-
137
- Converts the given code into something useable by [Highlight.js](https://highlightjs.org/).
138
-
139
- ```liquid
140
- {% highlight ruby %}
141
- puts "Yass!"
142
- {% endhighlight %}
143
- ```
144
-
145
- Hightlight.js CSS and JS files with common languages are included by default with `yass init`. [Download](https://highlightjs.org/download) your own versions if you want different languages or themes.
146
-
147
- ### render_content
148
-
149
- Renders a template, passing the block as a variable named `content`.
150
-
151
- ```html
152
- {% render_content "my_template", other_var: "other var" %}
153
- <p>This will be passed to "my_template" as "content"</p>
154
- {% endrender_content %}
155
- ```
156
-
157
- ## Legal
42
+ ## License
158
43
 
159
44
  MIT License. See LICENSE for details.
160
45
 
46
+ ## Copyright
47
+
161
48
  Copyright (c) 2025 Jordan Hollinger.
@@ -51,6 +51,7 @@ yass <command> [options] [path/to/dir]
51
51
  Options:
52
52
  ).strip
53
53
  opts.on("--clean", "Remove unknown files from dist/ when bulding") { config.clean = true }
54
+ opts.on("--dest=", "Build to a different directory") { |d| config.dest = d }
54
55
  opts.on("--no-strip-index", "Disable the strip_index Liquid filter") { config.strip_index = false }
55
56
  opts.on("--debug", "Print stack traces") { config.debug = true }
56
57
  opts.on("-h", "--help", "Prints this help") { config.stdout.puts opts; exit }
@@ -59,7 +60,7 @@ yass <command> [options] [path/to/dir]
59
60
 
60
61
  def self.default_config
61
62
  Config.new({
62
- root: Pathname.new(Dir.pwd),
63
+ cwd: Pathname.new(Dir.pwd),
63
64
  src: "site",
64
65
  layouts: "layouts",
65
66
  templates: "templates",
@@ -7,7 +7,7 @@ module Yass
7
7
 
8
8
  def self.build(config, argv:)
9
9
  args = Helpers.get_args!(argv, max: 1)
10
- config.root = Pathname.new(args[0] || Dir.pwd)
10
+ config.cwd = Pathname.new(args[0] || Dir.pwd)
11
11
  Generator.new(config).generate!
12
12
  return 0
13
13
  rescue => e
@@ -18,10 +18,10 @@ module Yass
18
18
 
19
19
  def self.init(config, argv:)
20
20
  args = Helpers.get_args!(argv, max: 1)
21
- config.root = Pathname.new(args[0] || Dir.pwd)
21
+ config.cwd = Pathname.new(args[0] || Dir.pwd)
22
22
 
23
23
  Dir[INIT_DIR.join("**/*.*")].each do |path|
24
- dest = config.root.join Pathname.new(path).relative_path_from(INIT_DIR)
24
+ dest = config.cwd.join Pathname.new(path).relative_path_from(INIT_DIR)
25
25
  config.stdout.puts "Creating #{dest}"
26
26
  FileUtils.mkdir_p dest.dirname unless dest.dirname.exist?
27
27
  FileUtils.cp(path, dest) unless dest.exist?
@@ -41,7 +41,7 @@ module Yass
41
41
 
42
42
  Yass::CLI::Runner.build(config, argv: argv)
43
43
  watcher.watch do |changes|
44
- files = changes.map { |f, _| Pathname.new(f).relative_path_from(config.root).to_s }.reject { |f| Dir.exist? f }
44
+ files = changes.map { |f, _| Pathname.new(f).relative_path_from(config.cwd).to_s }.reject { |f| Dir.exist? f }
45
45
  # TODO use \r?
46
46
  config.stdout.puts "Building #{files.join ", "}"
47
47
  config.clear_cache!
data/lib/yass/config.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Yass
2
- Config = Struct.new(:root, :src, :dest, :layouts, :templates, :clean, :strip_index, :stdin, :stdout, :stderr, :debug, keyword_init: true) do
3
- def src_dir = root.join src
4
- def dest_dir = root.join dest
5
- def template_dir = root.join templates
6
- def layout_dir = root.join layouts
2
+ Config = Struct.new(:cwd, :src, :dest, :layouts, :templates, :clean, :strip_index, :stdin, :stdout, :stderr, :debug, keyword_init: true) do
3
+ def src_dir = @src_dir ||= get_dir(src)
4
+ def dest_dir = @dest_dir ||= get_dir(dest)
5
+ def template_dir = @template_dir ||= get_dir(templates)
6
+ def layout_dir = @layout_dir ||= get_dir(layouts)
7
7
 
8
8
  def clear_cache!
9
9
  @sources = nil
@@ -34,5 +34,12 @@ module Yass
34
34
  env.register_tag 'render_content', LiquidTags::RenderContent
35
35
  end
36
36
  end
37
+
38
+ private
39
+
40
+ def get_dir(dir)
41
+ dir = Pathname.new(dir)
42
+ dir.absolute? ? dir : cwd.join(dir)
43
+ end
37
44
  end
38
45
  end
data/lib/yass/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yass
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.5.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-10 00:00:00.000000000 Z
11
+ date: 2025-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: filewatcher
@@ -77,11 +77,11 @@ files:
77
77
  - site-template/site/assets/highlight.min.js
78
78
  - site-template/site/index.html.liquid
79
79
  - site-template/templates/asset_tags.liquid
80
- homepage: https://github.com/jhollinger/yass/
80
+ homepage: https://jhollinger.github.io/yass/
81
81
  licenses:
82
82
  - MIT
83
83
  metadata:
84
- homepage_uri: https://github.com/jhollinger/yass/
84
+ homepage_uri: https://jhollinger.github.io/yass/
85
85
  source_code_uri: https://github.com/jhollinger/yass/
86
86
  post_install_message:
87
87
  rdoc_options: []