staticky 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41fa452e7c74ade67ffd58486af13cb4b121eda6cd51ffd5dc25105981cea0c2
4
- data.tar.gz: c8c2a3a15bc2cf0225d7763a825e8c1a34af2a0762777091e0c6c581723d485f
3
+ metadata.gz: 601e3b52395f847f7f7f57909a0063f83063dc0cf5bd02ef21e865d972f3322f
4
+ data.tar.gz: 7d8ecdd8e166359930743d01e2c955dc521a4f9d1b231d239d35aa45858cc003
5
5
  SHA512:
6
- metadata.gz: ff6e8e759028df62d4ce1a9304c2b8caa7fd38c5684e9a653445d14a46ffd4b880fd3c05bb393890d055262db28d37384c47af02ff72c1ce37dafaed33842d33
7
- data.tar.gz: 3aa63ca27344d93d99a92463e85f4cd75a547360da6682f6727cbd022b258c540df7dd39b4631f15f08f8f19bcb08bc21aedfe07736aab3267092d4d1db5ec9d
6
+ metadata.gz: c1b21ab89e9d6429b3cd3407ae84802c1739e68aa39c969f10c0d82e28ad3cdf187cd1bedcf98a22805fbe9de64c3be96d711f4f554c5addf55c744bcd11b9a6
7
+ data.tar.gz: 3695cab76d925bec1ba6e02852ac63a088c88cd2d2fb9e3942c5e33f0ef8aefb19d6c643c6e2ade7d63b438dba6d954a351efaba86939ac4ac5e56be73652343
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2024-07-08
3
+ ## [0.1.1] - 2024-08-18
4
+
5
+ - Fixes nginx and Dockerfile configs for default dokku deployments
6
+ - Improvements to site template files
7
+ - Adds ability for `link_to` helpers to take absolute paths
8
+
9
+ ## [0.1.0] - 2024-08-18
4
10
 
5
11
  - Initial release
data/README.md CHANGED
@@ -70,6 +70,8 @@ module Posts
70
70
  end
71
71
 
72
72
  def view_template
73
+ link_to "Home", "/"
74
+
73
75
  render Posts::Header.new(@post)
74
76
  render Posts::Outline.new(@post, class: css[:outline])
75
77
  render Posts::Markdown.new(@post, class: css[:post])
@@ -96,6 +98,9 @@ module Posts
96
98
  end
97
99
  ```
98
100
 
101
+ We get `link_to` from the `Staticky::Phlex::ViewHelpers` which resolves either
102
+ a URL or a phlex class from your router.
103
+
99
104
  When you are developing your site you run `bin/dev` to start your development
100
105
  server on http://localhost:9292. This will automatically reload after a short
101
106
  period when you make changes.
@@ -127,6 +132,14 @@ end
127
132
 
128
133
  This will output your site to `./build` by default.
129
134
 
135
+ During building, each definition in the router is compiled and handed a special
136
+ view context which holds information about the resource being rendered such as
137
+ the `current_path`.
138
+
139
+ These are available in your Phlex components under `helpers` (if you are using
140
+ the site template). This matches what you might expect when using Phlex in
141
+ Rails with `phlex-rails`.
142
+
130
143
  ## Configuration
131
144
 
132
145
  We can override the configuration according to the settings defined on the main
@@ -5,7 +5,8 @@ module Staticky
5
5
  module ViewHelpers
6
6
  def link_to(text, href, **, &block) # rubocop:disable Metrics/ParameterLists
7
7
  block ||= proc { text }
8
- href = Staticky.router.resolve(href).url
8
+ href = Staticky.router.resolve(href)
9
+ href = href.url unless href.is_a?(String)
9
10
 
10
11
  a(href:, **, &block)
11
12
  end
@@ -29,6 +29,9 @@ module Staticky
29
29
  end
30
30
 
31
31
  def resolve(path)
32
+ # Return absolute paths as is
33
+ return path if path.is_a?(String) && path.start_with?("http")
34
+
32
35
  @definition.resolve(path)
33
36
  end
34
37
  end
@@ -14,6 +14,7 @@ module Staticky
14
14
 
15
15
  plugin :common_logger, Staticky.server_logger, method: :debug
16
16
  plugin :render, engine: "html"
17
+ plugin :public
17
18
 
18
19
  plugin :not_found do
19
20
  raise NotFound if Staticky.env.test?
@@ -41,8 +42,7 @@ module Staticky
41
42
  end
42
43
  end
43
44
 
44
- # Need to return nil or Roda is unhappy
45
- nil
45
+ r.public
46
46
  end
47
47
  end
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Staticky
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -40,8 +40,8 @@ COPY nginx.conf /etc/nginx/nginx.conf
40
40
  # Copy the static site files to the Nginx HTML directory
41
41
  COPY --from=builder /app/build /usr/share/nginx/html/
42
42
 
43
- # Expose port 80 to the Docker host
44
- EXPOSE 80
43
+ # Expose port to the Docker host (default is 5000 for dokku)
44
+ EXPOSE 5000
45
45
 
46
46
  # Start Nginx when the container launches
47
- CMD ["nginx", "-g", "daemon off;"]
47
+ CMD ["nginx", "-c", "/etc/nginx/nginx.conf"]
@@ -96,3 +96,7 @@ The router is your definition for how to build your static site.
96
96
 
97
97
  Deployment is done through a simple Dockerfile. This setup is optimized for
98
98
  deploying onto Dokku servers.
99
+
100
+ By default Dokku expects the app to be exposed on port 5000 which we do through
101
+ our Dockerfile. Dokku will scan the Dockerfile for an `EXPOSE` directive and
102
+ automatically setup the port routing for you.
@@ -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
@@ -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
 
@@ -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,4 @@
1
+ Staticky.configure do |config|
2
+ config.build_path = Pathname.new("build")
3
+ config.root_path = Pathname(__dir__).join("..")
4
+ end
@@ -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
 
@@ -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",
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.1.1
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-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -209,6 +209,7 @@ files:
209
209
  - site_template/config/boot.rb
210
210
  - site_template/config/routes.rb
211
211
  - site_template/config/site.erb
212
+ - site_template/config/staticky.rb
212
213
  - site_template/config/vite.json
213
214
  - site_template/content/.keep
214
215
  - site_template/content/demo.md