syntropy 0.33.0 → 0.34.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/cmd/console.rb +18 -7
- data/cmd/serve.rb +26 -18
- data/cmd/test.rb +37 -24
- data/examples/blog/.gitignore +1 -0
- data/examples/blog/app/_lib/database.rb +13 -0
- data/examples/blog/app/_lib/{post_store.rb → posts.rb} +3 -1
- data/examples/blog/app/posts/[id]/edit.rb +2 -2
- data/examples/blog/app/posts/[id]/index.rb +4 -4
- data/examples/blog/app/posts/index.rb +4 -4
- data/examples/blog/app/posts/new.rb +1 -1
- data/examples/blog/config/development.rb +5 -0
- data/examples/blog/config/production.rb +4 -0
- data/examples/blog/config/test.rb +5 -0
- data/examples/blog/test/test_posts.rb +65 -0
- data/examples/mcp-oauth/app/oauth/token.rb +1 -1
- data/lib/syntropy/app.rb +48 -40
- data/lib/syntropy/applets/builtin/auto_refresh/watch.sse.rb +1 -1
- data/lib/syntropy/db/schema.rb +1 -1
- data/lib/syntropy/db/store.rb +2 -0
- data/lib/syntropy/errors.rb +6 -2
- data/lib/syntropy/http/client.rb +1 -0
- data/lib/syntropy/http/server_connection.rb +0 -4
- data/lib/syntropy/json_api.rb +27 -1
- data/lib/syntropy/logger.rb +81 -27
- data/lib/syntropy/markdown.rb +61 -32
- data/lib/syntropy/mime_types.rb +9 -5
- data/lib/syntropy/module_loader.rb +20 -9
- data/lib/syntropy/papercraft_extensions.rb +2 -2
- data/lib/syntropy/request/mock_adapter.rb +10 -8
- data/lib/syntropy/request/request_info.rb +91 -0
- data/lib/syntropy/request/response.rb +1 -12
- data/lib/syntropy/request/validation.rb +1 -0
- data/lib/syntropy/request.rb +51 -19
- data/lib/syntropy/routing_tree.rb +27 -28
- data/lib/syntropy/session.rb +198 -0
- data/lib/syntropy/side_run.rb +25 -2
- data/lib/syntropy/test.rb +105 -10
- data/lib/syntropy/utils.rb +53 -18
- data/lib/syntropy/version.rb +1 -1
- data/lib/syntropy.rb +44 -10
- data/test/bm_router_proc.rb +4 -4
- data/test/fixtures/app/class_instance.rb +5 -0
- data/test/fixtures/app/http.rb +5 -0
- data/test/fixtures/app/post_ct.rb +5 -0
- data/test/fixtures/app/singleton.rb +3 -0
- data/test/test_app.rb +13 -52
- data/test/test_caching.rb +2 -2
- data/test/test_db_schema.rb +1 -1
- data/test/test_http_server_connection.rb +3 -3
- data/test/test_module_loader.rb +5 -2
- data/test/test_response.rb +0 -19
- data/test/test_routing_tree.rb +69 -69
- data/test/test_server.rb +5 -9
- data/test/test_test.rb +70 -0
- metadata +52 -42
- data/examples/blog/app/_setup.rb +0 -4
- data/lib/syntropy/request/session.rb +0 -113
- /data/test/{app → fixtures/app}/.well-known/foo.rb +0 -0
- /data/test/{app → fixtures/app}/_hook.rb +0 -0
- /data/test/{app → fixtures/app}/_layout/default.rb +0 -0
- /data/test/{app → fixtures/app}/_lib/callable.rb +0 -0
- /data/test/{app → fixtures/app}/_lib/dep.rb +0 -0
- /data/test/{app → fixtures/app}/_lib/env.rb +0 -0
- /data/test/{app → fixtures/app}/_lib/klass.rb +0 -0
- /data/test/{app → fixtures/app}/_lib/missing-export.rb +0 -0
- /data/test/{app → fixtures/app}/_lib/self.rb +0 -0
- /data/test/{app → fixtures/app}/about/_error.rb +0 -0
- /data/test/{app → fixtures/app}/about/foo.md +0 -0
- /data/test/{app → fixtures/app}/about/index.rb +0 -0
- /data/test/{app → fixtures/app}/about/raise.rb +0 -0
- /data/test/{app → fixtures/app}/api+.rb +0 -0
- /data/test/{app → fixtures/app}/assets/style.css +0 -0
- /data/test/{app → fixtures/app}/bad_mod.rb +0 -0
- /data/test/{app → fixtures/app}/bar.rb +0 -0
- /data/test/{app → fixtures/app}/baz.rb +0 -0
- /data/test/{app → fixtures/app}/by_method.rb +0 -0
- /data/test/{app → fixtures/app}/deps.rb +0 -0
- /data/test/{app → fixtures/app}/index.html +0 -0
- /data/test/{app → fixtures/app}/mod/bar/index+.rb +0 -0
- /data/test/{app → fixtures/app}/mod/foo/index.rb +0 -0
- /data/test/{app → fixtures/app}/mod/path/a.rb +0 -0
- /data/test/{app → fixtures/app}/mod/path/b.rb +0 -0
- /data/test/{app → fixtures/app}/params/[foo].rb +0 -0
- /data/test/{app → fixtures/app}/rss.rb +0 -0
- /data/test/{app → fixtures/app}/tmp.rb +0 -0
- /data/test/{app_custom → fixtures/app_custom}/_site.rb +0 -0
- /data/test/{app_multi_site → fixtures/app_multi_site}/_site.rb +0 -0
- /data/test/{app_multi_site → fixtures/app_multi_site}/bar.baz/index.html +0 -0
- /data/test/{app_multi_site → fixtures/app_multi_site}/foo.bar/index.html +0 -0
- /data/test/{app_setup → fixtures/app_setup}/_setup.rb +0 -0
- /data/test/{app_setup → fixtures/app_setup}/index.rb +0 -0
- /data/test/{app_with_schema → fixtures/app_with_schema}/_schema/2026-01-02-foo.rb +0 -0
- /data/test/{app_with_schema → fixtures/app_with_schema}/_schema/2026-05-30-bar.rb +0 -0
- /data/test/{schema → fixtures/schema}/2026-01-02-foo.rb +0 -0
- /data/test/{schema → fixtures/schema}/2026-05-30-bar.rb +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'base64'
|
|
4
|
-
require 'json'
|
|
5
|
-
require 'securerandom'
|
|
6
|
-
|
|
7
|
-
module Syntropy
|
|
8
|
-
class Session
|
|
9
|
-
def initialize(request)
|
|
10
|
-
@request = request
|
|
11
|
-
@data = nil
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def [](key)
|
|
15
|
-
@data ||= load
|
|
16
|
-
@data[key]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def []=(key, value)
|
|
20
|
-
@data ||= load
|
|
21
|
-
@data[key] = value
|
|
22
|
-
save(@data)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def delete(key)
|
|
26
|
-
@data ||= load
|
|
27
|
-
@data.delete(key)
|
|
28
|
-
save(@data.empty? ? nil : @data)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def discard
|
|
32
|
-
save(nil)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def flash
|
|
36
|
-
@data ||= load
|
|
37
|
-
@flash ||= Flash.new(self)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
class NowFlash
|
|
43
|
-
def initialize
|
|
44
|
-
@data = {}
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def [](key)
|
|
48
|
-
@data[key.to_s]
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def []=(key, value)
|
|
52
|
-
@data[key.to_s] = value
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def each(&block)
|
|
56
|
-
@data.each { |k, v| block.(k.to_sym, v) }
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
class Flash
|
|
61
|
-
def initialize(session)
|
|
62
|
-
@session = session
|
|
63
|
-
@current_flash_data = @session['_flash']
|
|
64
|
-
@session.delete('_flash') if @current_flash_data
|
|
65
|
-
@current_flash_data ||= {}
|
|
66
|
-
@future_flash_data = {}
|
|
67
|
-
@now_flash_data = NowFlash.new
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def [](key)
|
|
71
|
-
key = key.to_s
|
|
72
|
-
@now_flash_data[key] || @current_flash_data[key]
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def []=(key, value)
|
|
76
|
-
key = key.to_s
|
|
77
|
-
@future_flash_data[key] = value
|
|
78
|
-
@session['_flash'] = @future_flash_data
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def each(&block)
|
|
82
|
-
@now_flash_data.each { |k, v| block.(k.to_sym, v) }
|
|
83
|
-
@current_flash_data.each_pair { |k, v| block.(k.to_sym, v) }
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def keep
|
|
87
|
-
@future_flash_data = @current_flash_data.merge!(@future_flash_data)
|
|
88
|
-
@session['_flash'] = @future_flash_data
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def now
|
|
92
|
-
@now_flash_data
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Loads session data from
|
|
97
|
-
def load
|
|
98
|
-
data = @request.cookies['__syntropy_session__']
|
|
99
|
-
return {} if !data
|
|
100
|
-
|
|
101
|
-
JSON.parse(Base64.decode64(data))
|
|
102
|
-
rescue JSON::ParserError
|
|
103
|
-
{}
|
|
104
|
-
ensure
|
|
105
|
-
@loaded = true
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def save(data)
|
|
109
|
-
cookie = data ? "#{Base64.strict_encode64(JSON.dump(data))}; Path=/; HttpOnly" : nil
|
|
110
|
-
@request.set_cookie('__syntropy_session__', cookie)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|