staticky 0.1.0 → 0.2.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/README.md +374 -14
  4. data/lib/staticky/application.rb +36 -0
  5. data/lib/staticky/builder.rb +1 -1
  6. data/lib/staticky/cli/commands/build.rb +13 -0
  7. data/lib/staticky/cli/commands/generate.rb +67 -0
  8. data/lib/staticky/cli/commands/version.rb +13 -0
  9. data/lib/staticky/cli/commands.rb +13 -0
  10. data/lib/staticky/cli.rb +0 -60
  11. data/lib/staticky/deps.rb +1 -1
  12. data/lib/staticky/filesystem.rb +0 -3
  13. data/lib/staticky/phlex/view_helpers.rb +7 -2
  14. data/lib/staticky/pluggable.rb +35 -0
  15. data/lib/staticky/resource.rb +14 -15
  16. data/lib/staticky/resources/plugins/phlex.rb +42 -0
  17. data/lib/staticky/resources/plugins/prelude.rb +74 -0
  18. data/lib/staticky/resources/plugins.rb +9 -0
  19. data/lib/staticky/router.rb +13 -15
  20. data/lib/staticky/routing/plugins/prelude.rb +97 -0
  21. data/lib/staticky/routing/plugins.rb +9 -0
  22. data/lib/staticky/server.rb +3 -3
  23. data/lib/staticky/version.rb +1 -1
  24. data/lib/staticky.rb +20 -10
  25. data/site_template/.gitignore +14 -0
  26. data/site_template/.ruby-version +1 -1
  27. data/site_template/Dockerfile +3 -3
  28. data/site_template/Gemfile +4 -3
  29. data/site_template/Procfile.dev +2 -2
  30. data/site_template/README.md +31 -7
  31. data/site_template/Rakefile +31 -2
  32. data/site_template/app/views/layouts/site.rb +4 -3
  33. data/site_template/app/views/ui/navbar.rb +1 -1
  34. data/site_template/bin/{lint → setup} +8 -2
  35. data/site_template/config/boot.rb +2 -0
  36. data/site_template/config/puma.rb +11 -0
  37. data/site_template/config/staticky.rb +6 -0
  38. data/site_template/lib/icon.rb +1 -1
  39. data/site_template/nginx.conf +6 -4
  40. data/site_template/package.json +1 -1
  41. data/site_template/public/site.webmanifest.erb +2 -2
  42. data/site_template/vite.config.ts +1 -1
  43. metadata +45 -7
  44. data/lib/staticky/container.rb +0 -26
  45. data/lib/staticky/router/definition.rb +0 -49
  46. data/lib/staticky/view_context.rb +0 -17
@@ -5,7 +5,8 @@ module Layouts
5
5
  include Phlex::DeferredRender
6
6
 
7
7
  def view_template
8
- html lang: "en_US", data: { theme: "onedark" } do
8
+ doctype
9
+ html lang: "en", data: { theme: "onedark" } do
9
10
  render Layouts::Head.new(&head)
10
11
 
11
12
  body do
@@ -27,11 +28,11 @@ module Layouts
27
28
  private
28
29
 
29
30
  def content
30
- @content || proc {}
31
+ @content || proc { }
31
32
  end
32
33
 
33
34
  def head
34
- @head || proc {}
35
+ @head || proc { }
35
36
  end
36
37
  end
37
38
  end
@@ -4,7 +4,7 @@ module UI
4
4
  class Navbar < Component
5
5
  def view_template
6
6
  header(**attrs) do
7
- a(href: "/", class: "btn btn-ghost") { "MyApp" }
7
+ a(href: "/", class: "btn btn-ghost") { Site.title }
8
8
  end
9
9
  end
10
10
 
@@ -13,6 +13,12 @@ FileUtils.chdir APP_ROOT do
13
13
  # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
14
  # Add necessary setup steps to this file.
15
15
 
16
- puts "== Running rubocop =="
17
- system! "bundle exec rubocop --autocorrect-all --fail-level error"
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ system! "bundle binstubs --force bundler rubocop rspec-core vite_ruby rake"
21
+
22
+ puts "\n== Installing javascript dependencies =="
23
+ system! "yarn install"
18
24
  end
@@ -5,6 +5,8 @@ ENV["RACK_ENV"] ||= "development"
5
5
  require "bundler"
6
6
  Bundler.require(:default, ENV.fetch("RACK_ENV", nil))
7
7
 
8
+ require_relative "staticky"
9
+
8
10
  loader = Zeitwerk::Loader.new
9
11
  loader.inflector.inflect("ui" => "UI")
10
12
  loader.push_dir("lib")
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run in single threaded mode
4
+ threads 0, 1
5
+
6
+ # Specifies the `port` that Puma will listen on to receive requests; default is
7
+ # 3000.
8
+ port 3000
9
+
10
+ # Only use a pidfile when requested
11
+ pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Staticky.configure do |config|
4
+ config.build_path = Pathname.new("build")
5
+ config.root_path = Pathname(__dir__).join("..")
6
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Icon < Component
4
4
  param :name, reader: false
5
- option :variant, reader: false, default: -> {}
5
+ option :variant, reader: false, default: -> { }
6
6
  option :size, default: -> { :md }, reader: false
7
7
 
8
8
  def template
@@ -1,6 +1,7 @@
1
1
  worker_processes 1;
2
2
  error_log stderr;
3
3
  pid nginx.pid;
4
+ daemon off;
4
5
 
5
6
  events {
6
7
  worker_connections 768;
@@ -17,17 +18,18 @@ http {
17
18
  gzip_proxied any;
18
19
  gzip_vary on;
19
20
 
21
+ error_page 404 /404.html;
22
+
20
23
  server {
21
- listen 80 default_server;
22
- listen [::]:80 default_server;
24
+ listen 5000;
23
25
  server_name _;
24
26
  root /usr/share/nginx/html;
25
- index index.html index.htm;
27
+ index index.html;
26
28
  port_in_redirect off;
27
29
  add_header X-Content-Type-Options "nosniff";
28
30
 
29
31
  location / {
30
- try_files $uri $uri.html =404;
32
+ try_files $uri $uri/ =404;
31
33
  expires 1h;
32
34
  }
33
35
 
@@ -27,5 +27,5 @@
27
27
  "optionalDependencies": {
28
28
  "@rollup/rollup-linux-arm64-musl": "4.20.0"
29
29
  },
30
- "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
30
+ "packageManager": "yarn@4.5.0"
31
31
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": <%= title %>,
3
- "short_name": <%= title %>,
2
+ "name": "<%= title %>",
3
+ "short_name": "<%= title %>",
4
4
  "icons": [
5
5
  {
6
6
  "src":"/android-chrome-192x192.png",
@@ -8,7 +8,7 @@ export default defineConfig({
8
8
  RubyPlugin(),
9
9
  FullReload(
10
10
  "build/index.html",
11
- { delay: 0 }
11
+ { delay: 500 }
12
12
  ),
13
13
  ],
14
14
  })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan J Tait
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-18 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dry-container
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.11'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.11'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: dry-events
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dry-inflector
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: dry-logger
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -166,21 +194,29 @@ files:
166
194
  - Rakefile
167
195
  - bin/staticky
168
196
  - lib/staticky.rb
197
+ - lib/staticky/application.rb
169
198
  - lib/staticky/builder.rb
170
199
  - lib/staticky/cli.rb
171
- - lib/staticky/container.rb
200
+ - lib/staticky/cli/commands.rb
201
+ - lib/staticky/cli/commands/build.rb
202
+ - lib/staticky/cli/commands/generate.rb
203
+ - lib/staticky/cli/commands/version.rb
172
204
  - lib/staticky/deps.rb
173
205
  - lib/staticky/environment.rb
174
206
  - lib/staticky/error.rb
175
207
  - lib/staticky/filesystem.rb
176
208
  - lib/staticky/generator.rb
177
209
  - lib/staticky/phlex/view_helpers.rb
210
+ - lib/staticky/pluggable.rb
178
211
  - lib/staticky/resource.rb
212
+ - lib/staticky/resources/plugins.rb
213
+ - lib/staticky/resources/plugins/phlex.rb
214
+ - lib/staticky/resources/plugins/prelude.rb
179
215
  - lib/staticky/router.rb
180
- - lib/staticky/router/definition.rb
216
+ - lib/staticky/routing/plugins.rb
217
+ - lib/staticky/routing/plugins/prelude.rb
181
218
  - lib/staticky/server.rb
182
219
  - lib/staticky/version.rb
183
- - lib/staticky/view_context.rb
184
220
  - site_template/.dockerignore
185
221
  - site_template/.gitignore
186
222
  - site_template/.prettierrc
@@ -203,12 +239,14 @@ files:
203
239
  - site_template/app/views/ui/navbar.rb
204
240
  - site_template/bin/console
205
241
  - site_template/bin/dev
206
- - site_template/bin/lint
242
+ - site_template/bin/setup
207
243
  - site_template/bin/staticky
208
244
  - site_template/config.ru
209
245
  - site_template/config/boot.rb
246
+ - site_template/config/puma.rb
210
247
  - site_template/config/routes.rb
211
248
  - site_template/config/site.erb
249
+ - site_template/config/staticky.rb
212
250
  - site_template/config/vite.json
213
251
  - site_template/content/.keep
214
252
  - site_template/content/demo.md
@@ -266,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
304
  - !ruby/object:Gem::Version
267
305
  version: '0'
268
306
  requirements: []
269
- rubygems_version: 3.5.11
307
+ rubygems_version: 3.5.16
270
308
  signing_key:
271
309
  specification_version: 4
272
310
  summary: Static site
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Staticky
4
- class Container < Dry::System::Container
5
- use :env
6
- use :zeitwerk
7
- use :monitoring
8
-
9
- configure do |config|
10
- config.root = Pathname(__dir__).join("..").join("..")
11
- config.inflector = Dry::Inflector.new do |inflections|
12
- inflections.acronym("CLI")
13
- end
14
- config.component_dirs.add "lib" do |dir|
15
- dir.add_to_load_path = false
16
- dir.auto_register = false
17
- dir.namespaces.add "staticky", key: nil
18
- end
19
- end
20
-
21
- register(:files, Staticky::Filesystem.real)
22
- register(:router, Staticky::Router.new)
23
- register(:builder, Staticky::Builder.new)
24
- register(:generator, Staticky::Generator.new)
25
- end
26
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Staticky
4
- class Router
5
- class Definition
6
- attr_reader :resources
7
-
8
- def initialize
9
- @routes_by_path = {}
10
- @routes_by_component = {}
11
- @resources = []
12
- end
13
-
14
- def match(path, to:)
15
- component = to.then do |object|
16
- object.is_a?(Class) ? object.new : object
17
- end
18
-
19
- @resources << resource = Resource.new(url: path, component:)
20
- @routes_by_path[path] = resource
21
- @routes_by_component[component.class] = resource
22
- end
23
-
24
- def root(to:)
25
- match("/", to:)
26
- end
27
-
28
- def resolve(path)
29
- @routes_by_path.fetch(path) { @routes_by_component.fetch(path) }
30
- end
31
-
32
- def delete(path)
33
- @routes.delete(path)
34
- end
35
-
36
- def filepaths
37
- @resources.map { |resource| rename_key(resource.url) }
38
- end
39
-
40
- private
41
-
42
- def rename_key(key)
43
- return "index.html" if key == "/"
44
-
45
- "#{key}.html"
46
- end
47
- end
48
- end
49
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Staticky
4
- class ViewContext
5
- def initialize(resource)
6
- @resource = resource
7
- end
8
-
9
- def root?
10
- @resource.root?
11
- end
12
-
13
- def current_path
14
- @resource.url
15
- end
16
- end
17
- end