porous 0.3.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +6 -6
- data/lib/porous/application.rb +1 -0
- data/lib/porous/cli/build.rb +3 -3
- data/lib/porous/cli/dev.rb +44 -0
- data/lib/porous/cli/server.rb +16 -21
- data/lib/porous/cli/template/.gitignore.tt +1 -0
- data/lib/porous/cli/template/README.md.tt +16 -2
- data/lib/porous/cli/template/pages/home.rb +1 -5
- data/lib/porous/cli/template/static/github.svg +4 -0
- data/lib/porous/cli.rb +1 -0
- data/lib/porous/server/builder.rb +10 -3
- data/lib/porous/version.rb +1 -1
- data/opal/porous.rb +3 -8
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87c6a954ddaf691739b880123048bf3345ece37389404d7a1c7163b27119c0ac
|
4
|
+
data.tar.gz: d13c2be795c751e8eb6095e0642560065e4815ff04ac17ffd7605e1092d775ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84e53a85958c58e66417eeadc77fd35332ac0f30b7b59eaef49e39ebeb1cc83d8f3dc906d848c40eb1f4ca08604e36d06efc6b72de0427911a185f705278ce95
|
7
|
+
data.tar.gz: 7e42e43664d2329d25f47999bddf7e0c28cbd2ccd36c69ce81e4e94a4e6894a5c905bc5f9ddce41b0ce6770f5f116c369b48c6d2622135e8b2e32221e7d1a6d5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
## [Planned]
|
2
2
|
|
3
|
-
- Production mode
|
4
3
|
- Data Abstraction Layer / Object Relational Model
|
5
4
|
- Event Model
|
6
5
|
- Plugin / Extension system
|
@@ -13,6 +12,20 @@
|
|
13
12
|
- Disk (file)
|
14
13
|
- Databases (SQLite, PostgreSQL)
|
15
14
|
|
15
|
+
## [Unreleased]
|
16
|
+
|
17
|
+
## [0.3.1] - 24 February 2024
|
18
|
+
|
19
|
+
- Production Mode
|
20
|
+
- `porous build production`
|
21
|
+
- `porous server`
|
22
|
+
- Needs `ssl/cert.pem` and `ssl/key.pem`
|
23
|
+
- Binds on :80 and :443
|
24
|
+
- Development Mode
|
25
|
+
- `porous dev`
|
26
|
+
- Binds on :9292
|
27
|
+
- Serves favicon from `static/favicon.svg`
|
28
|
+
|
16
29
|
## [0.3.0] - 22 February 2024
|
17
30
|
|
18
31
|
- WebSockets support
|
data/README.md
CHANGED
@@ -42,21 +42,21 @@ Porous is not a framework. You don't build an application with it as a dependenc
|
|
42
42
|
|
43
43
|
## Usage
|
44
44
|
|
45
|
-
Porous is still pre-alpha and so is not ready for usage yet, but the general idea is that you would define your application's entities, pages, components and events in Ruby scripts structured in a specific way. Then you would simply run `porous` while pointing it to that folder and it will spin up a Rack-compatible web server for you to use.
|
45
|
+
Porous is still pre-alpha and so is not ready for usage yet, but the general idea is that you would define your application's entities, pages, components and events in Ruby scripts structured in a specific way. Then you would simply run `porous server` while pointing it to that folder and it will spin up a Rack-compatible web server for you to use.
|
46
46
|
|
47
47
|
> ⚠️ Expect any and all APIs to change radically until version 1.0! Hence why it won't be documented or properly tested until things settle to a more stable state.
|
48
48
|
|
49
|
-
To start a new Porous project simply `gem install porous` using whichever Ruby environment you want to use (Ruby 3.0+). Then change to that directory and run:
|
49
|
+
To start a new Porous project simply `gem install porous` using whichever Ruby environment you want to use (Ruby 3.0+) and then `porous new` with your project name. Then change to that directory and run:
|
50
50
|
|
51
|
-
$ porous
|
51
|
+
$ porous dev
|
52
52
|
|
53
|
-
By default Porous will run at `localhost:9292`. Now you can edit `pages/home.rb` or add more pages. Files you modify will be hot-reloaded so you can simply open the page in your browser and edit the file.
|
53
|
+
By default Porous will run at `localhost:9292`. Now you can edit `pages/home.rb` or add more pages. Files you modify will be hot-reloaded, so you can simply open the page in your browser and edit the file.
|
54
54
|
|
55
55
|
### Running examples
|
56
56
|
|
57
|
-
To test out
|
57
|
+
To test out an example application using Porous you can clone the [Porous website](https://github.com/exastencil/porous.dev) and in that directory:
|
58
58
|
|
59
|
-
$ porous
|
59
|
+
$ porous dev
|
60
60
|
|
61
61
|
## Development
|
62
62
|
|
data/lib/porous/application.rb
CHANGED
data/lib/porous/cli/build.rb
CHANGED
@@ -12,10 +12,10 @@ module Porous
|
|
12
12
|
true
|
13
13
|
end
|
14
14
|
|
15
|
-
desc 'build', 'Build static assets'
|
16
|
-
def build
|
15
|
+
desc 'build ENV', 'Build static assets for environment (default: development)'
|
16
|
+
def build(env = :development)
|
17
17
|
empty_directory 'static/dist', verbose: false, force: options[:force]
|
18
|
-
Porous::Server::Builder.new.build
|
18
|
+
Porous::Server::Builder.new(env.to_sym).build
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Porous
|
4
|
+
class CLI < Thor
|
5
|
+
check_unknown_options!
|
6
|
+
|
7
|
+
namespace :dev
|
8
|
+
|
9
|
+
desc 'dev', 'Starts a Porous development server'
|
10
|
+
def dev # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
|
11
|
+
empty_directory 'static/dist', verbose: false, force: options[:force]
|
12
|
+
|
13
|
+
Agoo::Log.configure(
|
14
|
+
dir: '',
|
15
|
+
console: true,
|
16
|
+
classic: true,
|
17
|
+
colorize: true,
|
18
|
+
states: {
|
19
|
+
INFO: true,
|
20
|
+
DEBUG: false,
|
21
|
+
connect: false,
|
22
|
+
request: false,
|
23
|
+
response: false,
|
24
|
+
eval: true,
|
25
|
+
push: true
|
26
|
+
}
|
27
|
+
)
|
28
|
+
|
29
|
+
Agoo::Server.init 9292, Dir.pwd, thread_count: 1
|
30
|
+
Agoo::Server.use Rack::ContentLength
|
31
|
+
Agoo::Server.use Rack::Static, urls: ['/static']
|
32
|
+
Agoo::Server.use Rack::ShowExceptions
|
33
|
+
|
34
|
+
# Socket Communication
|
35
|
+
$socket ||= Porous::Server::Socket.new
|
36
|
+
Agoo::Server.handle nil, '/connect', Porous::Server::Connect.new
|
37
|
+
# Server-Side Rendering
|
38
|
+
Agoo::Server.handle nil, '**', Porous::Server::Application.new
|
39
|
+
Agoo::Server.start
|
40
|
+
# Live Reload Builder
|
41
|
+
Server::Builder.new.build.start
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/porous/cli/server.rb
CHANGED
@@ -6,19 +6,7 @@ module Porous
|
|
6
6
|
|
7
7
|
namespace :server
|
8
8
|
|
9
|
-
desc 'server [OPTIONS]', 'Starts Porous server'
|
10
|
-
method_option :port,
|
11
|
-
aliases: :p,
|
12
|
-
type: :numeric,
|
13
|
-
default: 9292,
|
14
|
-
desc: 'The port Porous will listen on'
|
15
|
-
|
16
|
-
method_option :host,
|
17
|
-
aliases: :h,
|
18
|
-
type: :string,
|
19
|
-
default: 'localhost',
|
20
|
-
desc: 'The host address Porous will bind to'
|
21
|
-
|
9
|
+
desc 'server [OPTIONS]', 'Starts Porous server in production mode'
|
22
10
|
def server # rubocop:todo Metrics/MethodLength
|
23
11
|
Agoo::Log.configure(dir: '',
|
24
12
|
console: true,
|
@@ -27,26 +15,33 @@ module Porous
|
|
27
15
|
states: {
|
28
16
|
INFO: true,
|
29
17
|
DEBUG: false,
|
30
|
-
connect:
|
31
|
-
request:
|
18
|
+
connect: true,
|
19
|
+
request: true,
|
32
20
|
response: false,
|
33
|
-
eval:
|
34
|
-
push:
|
21
|
+
eval: false,
|
22
|
+
push: false
|
35
23
|
})
|
36
24
|
|
37
|
-
Agoo::Server.init
|
25
|
+
Agoo::Server.init(
|
26
|
+
80, '.',
|
27
|
+
thread_count: 0,
|
28
|
+
ssl_cert: 'ssl/cert.pem',
|
29
|
+
ssl_key: 'ssl/key.pem',
|
30
|
+
bind: [
|
31
|
+
'http://127.0.0.1:80',
|
32
|
+
'https://127.0.0.1:443'
|
33
|
+
]
|
34
|
+
)
|
38
35
|
Agoo::Server.use Rack::ContentLength
|
39
36
|
Agoo::Server.use Rack::Static, urls: ['/static']
|
40
|
-
Agoo::Server.use Rack::ShowExceptions
|
41
37
|
|
42
38
|
# Socket Communication
|
43
39
|
$socket ||= Porous::Server::Socket.new
|
44
40
|
Agoo::Server.handle nil, '/connect', Porous::Server::Connect.new
|
45
41
|
# Server-Side Rendering
|
46
42
|
Agoo::Server.handle nil, '**', Porous::Server::Application.new
|
43
|
+
|
47
44
|
Agoo::Server.start
|
48
|
-
# Live Reload Builder
|
49
|
-
Server::Builder.new.build.start
|
50
45
|
end
|
51
46
|
end
|
52
47
|
end
|
@@ -1,7 +1,21 @@
|
|
1
1
|
# <%= config[:project_name] %>
|
2
2
|
|
3
|
+
## Development
|
4
|
+
|
3
5
|
```sh
|
4
|
-
$ porous
|
6
|
+
$ porous dev
|
5
7
|
```
|
6
8
|
|
7
|
-
Go to [http://localhost:
|
9
|
+
Go to [http://localhost:9292/](http://localhost:9292/)
|
10
|
+
|
11
|
+
## Production
|
12
|
+
|
13
|
+
Place your SSL certificate in `ssl`:
|
14
|
+
|
15
|
+
- `ssl/cert.pem`
|
16
|
+
- `ssl/key.pem`
|
17
|
+
|
18
|
+
```sh
|
19
|
+
$ porous build production
|
20
|
+
$ porous server
|
21
|
+
```
|
@@ -32,11 +32,7 @@ class Home
|
|
32
32
|
end
|
33
33
|
a href: 'https://github.com/exastencil/porous', target: '_blank', rel: 'noopener',
|
34
34
|
class: 'flex items-center space-x-2 text-gray-500 dark:text-gray-400' do
|
35
|
-
|
36
|
-
xmlns: 'http://www.w3.org/2000/svg' do
|
37
|
-
title 'GitHub'
|
38
|
-
path d: 'M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'
|
39
|
-
end
|
35
|
+
img class: 'w-8 h-8 text-gray-500', src: '/static/github.svg'
|
40
36
|
span 'View on GitHub'
|
41
37
|
end
|
42
38
|
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg role="img" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<title>GitHub logo</title>
|
3
|
+
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path>
|
4
|
+
</svg>
|
data/lib/porous/cli.rb
CHANGED
@@ -5,7 +5,8 @@ require 'opal/builder_scheduler/sequential'
|
|
5
5
|
module Porous
|
6
6
|
module Server
|
7
7
|
class Builder
|
8
|
-
def initialize
|
8
|
+
def initialize(environment = :development)
|
9
|
+
@environment = environment
|
9
10
|
@build_queue = Queue.new
|
10
11
|
@last_build = nil
|
11
12
|
@latest_change = Dir.glob(File.join('**', '*.rb')).map { |f| File.mtime f }.max
|
@@ -17,7 +18,8 @@ module Porous
|
|
17
18
|
@latest_change = modified if modified > @latest_change
|
18
19
|
"require '#{relative_path}'"
|
19
20
|
end
|
20
|
-
build_string = "require 'porous'; #{components.join ";"}".gsub '.rb', ''
|
21
|
+
build_string = "require 'porous'; #{components.join ";"}; ".gsub '.rb', ''
|
22
|
+
build_string << inject_socket_connection
|
21
23
|
builder = Opal::Builder.new scheduler: Opal::BuilderScheduler::Sequential, cache: false
|
22
24
|
builder.build_str build_string, '(inline)'
|
23
25
|
File.binwrite "#{Dir.pwd}/static/dist/application.js", builder.to_s
|
@@ -42,11 +44,16 @@ module Porous
|
|
42
44
|
Thread.new { build }.join
|
43
45
|
|
44
46
|
# Notify clients
|
45
|
-
$socket
|
47
|
+
$socket&.public 'build', @last_build.inspect
|
46
48
|
@build_queue.clear
|
47
49
|
end
|
48
50
|
end
|
49
51
|
# rubocop:enable Metrics/AbcSize
|
52
|
+
|
53
|
+
def inject_socket_connection
|
54
|
+
uri = @environment == :production ? 'wss://localhost/connect' : 'ws://localhost:9292/connect'
|
55
|
+
"$connection = '#{uri}'; "
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
data/lib/porous/version.rb
CHANGED
data/opal/porous.rb
CHANGED
@@ -29,7 +29,7 @@ end
|
|
29
29
|
|
30
30
|
$document.ready do
|
31
31
|
Porous::Application.mount_to($document.body)
|
32
|
-
Browser::Socket.new
|
32
|
+
Browser::Socket.new $connection do
|
33
33
|
on :open do |_e|
|
34
34
|
$console.info 'Connected to server!'
|
35
35
|
end
|
@@ -38,14 +38,9 @@ $document.ready do
|
|
38
38
|
channel, content = e.data.split '|'
|
39
39
|
case channel
|
40
40
|
when 'build'
|
41
|
-
|
42
|
-
$console.log 'New build started…'
|
43
|
-
else
|
44
|
-
$console.log 'Reloading scripts…'
|
45
|
-
$document.location.reload
|
46
|
-
end
|
41
|
+
$document.location.reload unless content == 'started'
|
47
42
|
else
|
48
|
-
$console.log
|
43
|
+
$console.log e.data
|
49
44
|
end
|
50
45
|
end
|
51
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: porous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Exa Stencil
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: agoo
|
@@ -102,11 +102,13 @@ files:
|
|
102
102
|
- lib/porous/application.rb
|
103
103
|
- lib/porous/cli.rb
|
104
104
|
- lib/porous/cli/build.rb
|
105
|
+
- lib/porous/cli/dev.rb
|
105
106
|
- lib/porous/cli/new.rb
|
106
107
|
- lib/porous/cli/server.rb
|
107
108
|
- lib/porous/cli/template/.gitignore.tt
|
108
109
|
- lib/porous/cli/template/README.md.tt
|
109
110
|
- lib/porous/cli/template/pages/home.rb
|
111
|
+
- lib/porous/cli/template/static/github.svg
|
110
112
|
- lib/porous/cli/template/static/hero.png
|
111
113
|
- lib/porous/component.rb
|
112
114
|
- lib/porous/component/class_methods.rb
|