slimview 0.2.1 → 0.2.2

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: 2dedf9869b30963a26ede0f0321d8306ca389bb7689726ad6e56b5dac0956cb6
4
- data.tar.gz: 2d38bf535f127f9aac501c4f5be967314cec3643445ee2b5d0b353170a718c4b
3
+ metadata.gz: 0aa3ca8b36a79be2250688b865b106e9dd39661f23f356b58a16fb66ee1992f6
4
+ data.tar.gz: a149f31b69c9d97d8cf651499197ece2f59aaf6fe03e16a5039d8c658d89282f
5
5
  SHA512:
6
- metadata.gz: 4182b5be878c07f1150418342d3fd9c589a580ed3660a45b995d7d17a95095df918a0381ea37e6f6d15e66ee4cc34bce495835f6dc0a832fd249968e9ea90cd7
7
- data.tar.gz: 32d63537999fedce6a8edfe9dd1072776386e89a3407152d0080acc6b415b464bc1e1b8398dc1388013764223b3bd303a39607973f533cb7d66ac1dbb77292a7
6
+ metadata.gz: 23067f0a79d9f69fb2846ef9139bbfe45d08db67483baeaddfe6bc197788f3bd5e9b670644485c07c7bcb06e2022ff14d9869353a2e864991dda2e58661f7fdb
7
+ data.tar.gz: 5d3a0cecc4178cb0c060c7fd919a7152243f9893a59b3f40ccde205eb3365581c6f079ade74aecc1fe8588dd184b882826f99f4945e9c0d4abaec11727018b1f
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Slimview
2
2
 
3
- A lightweight command-line tool and Ruby library for quickly previewing [Slim](https://slim-template.github.io/) templates in a local web server powered by [Sinatra](https://sinatrarb.com/).
3
+ ![repocard](https://repocard.dannyben.com/svg/slimview.svg)
4
+
5
+ A lightweight command-line tool and Ruby library for quickly previewing
6
+ [Slim](https://slim-template.github.io/) templates in a local web server
7
+ powered by [Sinatra](https://sinatrarb.com/).
4
8
 
5
9
  ## Features
6
10
 
@@ -8,6 +12,8 @@ A lightweight command-line tool and Ruby library for quickly previewing [Slim](h
8
12
  - Minimal setup - just point to a folder and go
9
13
  - Automatically reloads templates in development
10
14
  - Configurable port and root directory via flags or environment variables
15
+ - Automatically wraps views with `layout.slim` when present
16
+ - Render partial Slim templates via `== slim :other_template`
11
17
 
12
18
 
13
19
  ## Installation
@@ -22,6 +28,27 @@ Or add it to your `Gemfile`:
22
28
  gem 'slimview'
23
29
  ```
24
30
 
31
+ ### Docker
32
+
33
+ Slimview is also available as a docker image:
34
+
35
+ ```shell
36
+ docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/slimview
37
+ ```
38
+
39
+ or as a docker compose service:
40
+
41
+ ```yaml
42
+ services:
43
+ web:
44
+ build: .
45
+ image: dannyben/slimview
46
+ volumes: ["./:/docs"]
47
+ ports: ["3000:3000"]
48
+ ```
49
+
50
+ [View image on Docker Hub](https://hub.docker.com/r/dannyben/slimview)
51
+
25
52
 
26
53
  ## Command-Line Usage
27
54
 
@@ -31,14 +58,17 @@ $ slimview --help
31
58
  Usage: slimview [options]
32
59
 
33
60
  Options:
34
- --port PORT Set the port to run the server on (default: 3000)
35
- --root PATH Set the root templates directory (default: ./templates)
36
- --help, -h Show this help message
37
- --version, -v Print version info
61
+ --port PORT Set the port to run the server on (default: 3000)
62
+ --root PATH Set the root templates directory (default: ./templates)
63
+ --assets PATH Set the assets directory (default: <root>/assets)
64
+ --help, -h Show this help message
65
+ --version, -v Print version info
38
66
 
39
67
  Environment Variables:
40
- SLIMVIEW_PORT Set the port (default: 3000)
41
- SLIMVIEW_ROOT Set the root templates directory (default: ./templates)
68
+ SLIMVIEW_PORT Set the port
69
+ SLIMVIEW_ROOT Set the root templates directory
70
+ SLIMVIEW_ASSETS Set the assets directory
71
+
42
72
  ```
43
73
 
44
74
  Example:
@@ -49,6 +79,12 @@ slimview
49
79
 
50
80
  # Serve from another folder on port 8080
51
81
  slimview --root app/views --port 8080
82
+
83
+ # Serve with a custom assets directory
84
+ slimview --root app/views --assets public/assets
85
+
86
+ # Use environment variables instead of flags
87
+ SLIMVIEW_ASSETS=public/assets SLIMVIEW_ROOT=app/views slimview
52
88
  ```
53
89
 
54
90
  ## Ruby API Usage
@@ -65,6 +101,10 @@ Slimview::Server.new.start
65
101
  server = Slimview::Server.new port: 4000, root: 'views/slim'
66
102
  server.start
67
103
 
104
+ # Override the assets directory
105
+ server = Slimview::Server.new root: 'views/slim', assets: 'public/assets'
106
+ server.start
107
+
68
108
  # Pass locals (available as variables inside your Slim templates)
69
109
  server = Slimview::Server.new items: ['one', 'two'], title: 'Hello'
70
110
  server.start
@@ -73,12 +113,10 @@ server.start
73
113
 
74
114
  ## Notes
75
115
 
76
- - Templates are served from the directory specified by `--root` (or `SLIMVIEW_ROOT`).
77
- - Static files (images, CSS, JS) can be placed in an `assets/` subfolder.
116
+ - Templates are served from the directory specified by `--root`
117
+ (or `SLIMVIEW_ROOT`).
118
+ - Static files (images, CSS, JS) can be placed in an `assets/` directory and
119
+ overridden via `--assets` or `SLIMVIEW_ASSETS`.
78
120
  - Slim templates are automatically reloaded on each request in development mode.
79
- - The tool is intended for **local development and previewing**, not for production use.
80
-
81
-
82
- ## License
83
-
84
- MIT License © 2025
121
+ - The tool is intended for **local development and previewing**, not for
122
+ production use.
data/bin/slimview CHANGED
@@ -6,14 +6,16 @@ if args.include?('--help') || args.include?('-h')
6
6
  Usage: slimview [options]
7
7
 
8
8
  Options:
9
- --port PORT Set the port to run the server on (default: 3000)
10
- --root PATH Set the root templates directory (default: ./templates)
11
- --help, -h Show this help message
12
- --version, -v Print version info
9
+ -p, --port PORT Set the port to run the server on (default: 3000)
10
+ -r, --root PATH Set the root templates directory (default: ./templates)
11
+ -a, --assets PATH Set the assets directory (default: <root>/assets)
12
+ -h, --help Show this help message
13
+ -v, --version Print version info
13
14
 
14
15
  Environment Variables:
15
- SLIMVIEW_ROOT Set the root templates directory
16
- SLIMVIEW_PORT Set the port
16
+ SLIMVIEW_PORT Set the port
17
+ SLIMVIEW_ROOT Set the root templates directory
18
+ SLIMVIEW_ASSETS Set the assets directory
17
19
 
18
20
  HELP
19
21
  exit
@@ -28,16 +30,22 @@ end
28
30
 
29
31
  port = nil
30
32
  root = nil
31
-
32
- if (i = args.index '--port')
33
- port = args[i + 1]
33
+ assets = nil
34
+
35
+ def fetch_arg(args, *flags)
36
+ flags.each do |flag|
37
+ if (index = args.index(flag))
38
+ return args[index + 1]
39
+ end
40
+ end
41
+ nil
34
42
  end
35
43
 
36
- if (i = args.index '--root')
37
- root = args[i + 1]
38
- end
44
+ port = fetch_arg(args, '--port', '-p')
45
+ root = fetch_arg(args, '--root', '-r')
46
+ assets = fetch_arg(args, '--assets', '-a')
39
47
 
40
48
  port = port.to_i if port
41
49
 
42
- server = Slimview::Server.new port: port, root: root
50
+ server = Slimview::Server.new port: port, root: root, assets: assets
43
51
  server.start
data/lib/slimview/app.rb CHANGED
@@ -3,7 +3,7 @@ require 'slim'
3
3
 
4
4
  module Slimview
5
5
  class App < Sinatra::Base
6
- def self.configure!(root:, port:, locals:)
6
+ def self.configure!(root:, port:, assets:, locals:)
7
7
  Slim::Engine.set_options pretty: true
8
8
 
9
9
  views_path = File.expand_path(root, Dir.pwd)
@@ -12,7 +12,7 @@ module Slimview
12
12
  set :port, port
13
13
  set :views, views_path
14
14
  set :root, File.expand_path('.')
15
- set :public_folder, File.join(settings.root, 'assets')
15
+ set :public_folder, assets
16
16
  set :environment, :development
17
17
  set :reload_templates, true
18
18
  set :protection, except: :host_authorization
@@ -1,12 +1,13 @@
1
1
  module Slimview
2
2
  class Server
3
- def initialize(port: nil, root: nil, **locals)
3
+ def initialize(port: nil, root: nil, assets: nil, **locals)
4
4
  @port = port || ENV['SLIMVIEW_PORT']&.to_i || 3000
5
5
  @root = root || ENV['SLIMVIEW_ROOT'] || 'templates'
6
+ @assets = assets || ENV['SLIMVIEW_ASSETS'] || "#{@root}/assets"
6
7
  @locals = locals
7
8
  end
8
9
 
9
10
  def start = app.run!
10
- def app = App.configure!(root: @root, port: @port, locals: @locals)
11
+ def app = App.configure!(port: @port, root: @root, assets: @assets, locals: @locals)
11
12
  end
12
13
  end
@@ -1,3 +1,3 @@
1
1
  module Slimview
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
@@ -65,6 +65,20 @@ dependencies:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '5.2'
68
+ - !ruby/object:Gem::Dependency
69
+ name: coffee-script
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.4'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.4'
68
82
  description: Command-line tool and library for quickly previewing Slim templates in
69
83
  a local web server
70
84
  email: db@dannyben.com
@@ -101,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
115
  - !ruby/object:Gem::Version
102
116
  version: '0'
103
117
  requirements: []
104
- rubygems_version: 3.6.9
118
+ rubygems_version: 4.0.6
105
119
  specification_version: 4
106
120
  summary: Instant Slim Template Server
107
121
  test_files: []