raindown 0.18.0 → 0.21.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/lib/raindown/area.rb +88 -0
- data/lib/raindown/chart/chart.rb +5 -2
- data/lib/raindown/chart/drawing.rb +0 -2
- data/lib/raindown/chart/line.rb +1 -1
- data/lib/raindown/chart/points.rb +2 -1
- data/lib/raindown/cli.rb +2 -2
- data/lib/raindown/code.rb +37 -5
- data/lib/raindown/config.rb +11 -0
- data/lib/raindown/document.rb +8 -6
- data/lib/raindown/editing.rb +8 -4
- data/lib/raindown/endpoint/curl.rb +19 -14
- data/lib/raindown/endpoint/curl_request.rb +90 -0
- data/lib/raindown/endpoint/curl_response.rb +6 -3
- data/lib/raindown/grid.rb +154 -0
- data/lib/raindown/grid_directives.rb +43 -0
- data/lib/raindown/grid_wrapping.rb +46 -0
- data/lib/raindown/http_json.rb +45 -0
- data/lib/raindown/image.rb +44 -0
- data/lib/raindown/js/js_nodes.rb +85 -33
- data/lib/raindown/js/quickjs_host.rb +63 -0
- data/lib/raindown/js/quickjs_runtime.js +61 -0
- data/lib/raindown/js/services.js +31 -0
- data/lib/raindown/markdown_nodes.rb +2 -0
- data/lib/raindown/node_blocks.rb +22 -9
- data/lib/raindown/node_injector.rb +56 -15
- data/lib/raindown/nodes.rb +52 -15
- data/lib/raindown/outdent.rb +100 -0
- data/lib/raindown/pages/listings.rb +71 -0
- data/lib/raindown/{pages.rb → pages/pages.rb} +21 -34
- data/lib/raindown/problem.rb +12 -3
- data/lib/raindown/project/card.rb +54 -0
- data/lib/raindown/project/endpoint.rb +14 -0
- data/lib/raindown/project/project.rb +168 -0
- data/lib/raindown/project_nodes.rb +47 -0
- data/lib/raindown/projects.rb +1 -1
- data/lib/raindown/rasters.rb +98 -0
- data/lib/raindown/scene.rb +10 -0
- data/lib/raindown/services/connections.rb +65 -0
- data/lib/raindown/services/local.rb +139 -0
- data/lib/raindown/services.rb +72 -0
- data/lib/raindown/skeleton.rb +1 -1
- data/lib/raindown/table/table.rb +2 -2
- data/lib/raindown/table/table_column.rb +0 -2
- data/lib/raindown/table/table_file.rb +2 -2
- data/lib/raindown/table/written_table.rb +0 -2
- data/lib/raindown/toc/markdown_headings.rb +98 -0
- data/lib/raindown/{toc.rb → toc/toc.rb} +8 -5
- data/lib/raindown/tui/endpoints.rb +1 -1
- data/lib/raindown/tui/feelings/feelings_log.rb +2 -1
- data/lib/raindown/tui/navigator/navigator.rb +1 -1
- data/lib/raindown/watcher/project.rb +2 -2
- data/lib/raindown/weather/branch_tree.rb +129 -0
- data/lib/raindown/weather/forecast.rb +193 -0
- data/lib/raindown/weather/forecast_cache.rb +58 -0
- data/lib/raindown/weather/forecast_cards.rb +115 -0
- data/lib/raindown/weather/sky.rb +82 -0
- data/lib/raindown/weather/weather.rb +140 -0
- data/lib/raindown/wiki_links.rb +2 -6
- data/lib/raindown.rb +39 -14
- data/lib/version.rb +1 -1
- metadata +33 -9
- data/lib/raindown/js/host.mjs +0 -51
- data/lib/raindown/tui/card.rb +0 -56
- data/lib/raindown/tui/endpoint.rb +0 -16
- data/lib/raindown/tui/project.rb +0 -147
- /data/lib/raindown/{page.rb → pages/page.rb} +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Raindown
|
|
4
|
+
# The weather now as a sky for an app to paint, as how much of each kind of weather there is, from 0 to 1, so its
|
|
5
|
+
# painters blend them: cloud, how much of the sky's covered, rain and snow, how hard they're falling, fog, storm,
|
|
6
|
+
# whether there's thunder, wind, how hard it's blowing, and the temperature in °C. From Open-Meteo's current
|
|
7
|
+
# conditions, and from its weather code, which says what's falling when its amounts are small, like drizzle.
|
|
8
|
+
module Sky
|
|
9
|
+
# How much rain or snow a weather code means, at least, and fog.
|
|
10
|
+
RAIN = { 51 => 0.25, 53 => 0.35, 55 => 0.45, 56 => 0.35, 57 => 0.45, 61 => 0.4, 63 => 0.65, 65 => 0.9, 66 => 0.4,
|
|
11
|
+
67 => 0.6, 80 => 0.4, 81 => 0.65, 82 => 0.9, 95 => 0.85, 96 => 0.85, 99 => 0.9 }.freeze
|
|
12
|
+
SNOW = { 71 => 0.35, 73 => 0.6, 75 => 0.9, 77 => 0.3, 85 => 0.5, 86 => 0.85 }.freeze
|
|
13
|
+
FOG = { 45 => 0.8, 48 => 0.85 }.freeze
|
|
14
|
+
# How much each layer of cloud covers the sky, as its high cloud's thin, like cirrus, so a sky Open-Meteo calls
|
|
15
|
+
# clear can have it all over, and how much cloud there is for each weather code, so the sky's what its words say.
|
|
16
|
+
# Rain, snow, fog and storms have at least WET_CLOUD.
|
|
17
|
+
LAYERS = { cloud_cover_low: 1.0, cloud_cover_mid: 0.8, cloud_cover_high: 0.25 }.freeze
|
|
18
|
+
CLOUD = { 0 => 0.0..0.15, 1 => 0.1..0.4, 2 => 0.3..0.7, 3 => 0.8..1.0 }.freeze
|
|
19
|
+
WET_CLOUD = 0.7
|
|
20
|
+
# The rain, in mm an hour, snow, in cm an hour, wind, in km/h, and visibility, in metres, at which they're at their
|
|
21
|
+
# most.
|
|
22
|
+
HEAVIEST_RAIN = 3.0
|
|
23
|
+
HEAVIEST_SNOW = 1.5
|
|
24
|
+
STRONGEST_WIND = 50.0
|
|
25
|
+
CLEAREST = 5000.0
|
|
26
|
+
# The kinds of weather, which RAINDOWN_SKY can set, like "rain=0.8,cloud=1", to see them.
|
|
27
|
+
KINDS = %i[cloud rain snow fog storm wind temperature].freeze
|
|
28
|
+
|
|
29
|
+
module_function
|
|
30
|
+
|
|
31
|
+
# The sky from Open-Meteo's current conditions, as cloud_cover, rain, showers, snowfall, wind_speed_10m,
|
|
32
|
+
# visibility, weather_code and temperature_2m, in °C, with RAINDOWN_SKY's on top.
|
|
33
|
+
def of(conditions, overrides: ENV.fetch('RAINDOWN_SKY', ''))
|
|
34
|
+
code = conditions[:weather_code].to_i
|
|
35
|
+
sky = { cloud: cloud(conditions, code), **falling(conditions, code), fog: fog(conditions, code),
|
|
36
|
+
storm: storm(code), wind: clamp(conditions[:wind_speed_10m].to_f / STRONGEST_WIND),
|
|
37
|
+
temperature: conditions[:temperature_2m].to_f }
|
|
38
|
+
sky.merge(overridden(overrides))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# How much of the sky's covered: its layers of cloud, weighted by how thick they are, or else its cloud cover, in
|
|
42
|
+
# the range its weather code says.
|
|
43
|
+
def cloud(conditions, code)
|
|
44
|
+
layers = LAYERS.filter_map { |layer, weight| conditions[layer] && (conditions[layer].to_f / 100 * weight) }
|
|
45
|
+
cover = layers.max || (conditions[:cloud_cover].to_f / 100)
|
|
46
|
+
range = CLOUD.fetch(code) { WET_CLOUD..1.0 }
|
|
47
|
+
clamp(cover.clamp(range.begin, range.end))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# How hard rain and snow are falling, by how much falls, or at least as much as the weather code says.
|
|
51
|
+
def falling(conditions, code)
|
|
52
|
+
rain = clamp((conditions[:rain].to_f + conditions[:showers].to_f) / HEAVIEST_RAIN)
|
|
53
|
+
snow = clamp(conditions[:snowfall].to_f / HEAVIEST_SNOW)
|
|
54
|
+
{ rain: [rain, RAIN.fetch(code, 0)].max, snow: [snow, SNOW.fetch(code, 0)].max }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Whether there's thunder, as 1, or not, as 0.
|
|
58
|
+
def storm(code)
|
|
59
|
+
return 1 if code >= 95
|
|
60
|
+
|
|
61
|
+
0
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# How foggy it is, by how far it can be seen, or at least as foggy as the weather code says.
|
|
65
|
+
def fog(conditions, code) = [visibility_fog(conditions[:visibility]), FOG.fetch(code, 0)].max
|
|
66
|
+
|
|
67
|
+
# How foggy a visibility, in metres, makes it, from none at CLEAREST to most at none.
|
|
68
|
+
def visibility_fog(visibility)
|
|
69
|
+
return 0 if visibility.nil?
|
|
70
|
+
|
|
71
|
+
clamp((CLEAREST - visibility.to_f) / CLEAREST) * 0.8
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def overridden(overrides)
|
|
75
|
+
overrides.split(',').to_h { it.split('=', 2) }.filter_map do |kind, amount|
|
|
76
|
+
[kind.strip.to_sym, amount.to_f] if KINDS.include?(kind.strip.to_sym)
|
|
77
|
+
end.to_h
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def clamp(value) = value.clamp(0.0, 1.0).round(2)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cgi/escape'
|
|
4
|
+
require_relative '../config'
|
|
5
|
+
require_relative '../node'
|
|
6
|
+
require_relative '../scene'
|
|
7
|
+
require_relative 'branch_tree'
|
|
8
|
+
require_relative 'forecast'
|
|
9
|
+
|
|
10
|
+
module Raindown
|
|
11
|
+
# The node behind weather:, the weather where you are, from Open-Meteo, now and for the week, which apps draw a sky
|
|
12
|
+
# behind, like over a valley in the app. Where you are is your time zone's city, or a place you name, like
|
|
13
|
+
# weather: Brisbane:
|
|
14
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
15
|
+
# < weather:
|
|
16
|
+
# < ╭────────────╮╭────────────╮ …
|
|
17
|
+
# < │ ☁️ ││ 🌧️ │
|
|
18
|
+
# < │ Today ││ Fri │
|
|
19
|
+
# < │ 20° 10° ││ 19° 14° │
|
|
20
|
+
# < │ overcast ││ light │
|
|
21
|
+
# < │ ││ rain │
|
|
22
|
+
# < ╰────────────╯╰────────────╯
|
|
23
|
+
# In an app that draws pixels, it shows a valley behind its text, by day or by night, which the app paints itself,
|
|
24
|
+
# from the weather now it gives it, and in a code project, a constellation for each of its branches that aren't merged
|
|
25
|
+
# into main, a star a commit.
|
|
26
|
+
class Weather < Node
|
|
27
|
+
# How long its branches and weather are kept, as an app asks for its sky about once a second, and how long it waits
|
|
28
|
+
# to ask for the weather again when there's none, as Open-Meteo couldn't be reached.
|
|
29
|
+
FRESH_FOR = 5
|
|
30
|
+
RETRY_AFTER = 60
|
|
31
|
+
|
|
32
|
+
def initialize(place = nil)
|
|
33
|
+
@place = place
|
|
34
|
+
super()
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def rewrite
|
|
38
|
+
forecast_lines.join("\n")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Its valley, with its branches' names and commits for their constellations, and the weather now, with its UV index
|
|
42
|
+
# now and today's at its strongest, to a decimal place, and its sky, how much cloud, rain, snow, fog, storm and wind there is,
|
|
43
|
+
# as Sky gives it, at any size, which the app paints. Without the weather, its sky's clear, but for what RAINDOWN_SKY
|
|
44
|
+
# sets. For a place it names, it's that place's time of day too, from how far ahead of UTC its clocks are, in
|
|
45
|
+
# seconds, as utc_offset.
|
|
46
|
+
def rasterize(metadata: NoMetadata, **)
|
|
47
|
+
report = forecast_now
|
|
48
|
+
now = report && { temperature: report.temperature, unit: report.unit, code: report.code, words: report.words,
|
|
49
|
+
uv: report.uv&.round(1), uv_peak: report.uv_peak&.round(1) }
|
|
50
|
+
branches = branches(metadata).map { { name: it.name, commits: it.commits } }
|
|
51
|
+
data = { branches:, now:, sky: report&.sky || Sky.of({}) }
|
|
52
|
+
data[:utc_offset] = report.utc_offset if @place && report
|
|
53
|
+
Scene.new(name: 'valley', data:)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# The characters of its lines an app formats, as [line, from, to], its lines counted from the first it writes: its
|
|
57
|
+
# cards' borders dimmed, as quiet, so the weather stands out, their days in bold, and their emoji as large as a line
|
|
58
|
+
# is tall.
|
|
59
|
+
def formatting(**)
|
|
60
|
+
report = forecast_now
|
|
61
|
+
return {} unless report
|
|
62
|
+
|
|
63
|
+
{ quiet: report.quiet, bold: report.bold, large: report.large }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Its lines as they're written, keeping their spaces, so its cards stay as they're drawn.
|
|
67
|
+
def render
|
|
68
|
+
%(<pre class="weather">#{CGI.escapeHTML(rewrite)}</pre>)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
# The weather now and the week's, as ForecastCards draws it, or none when it can't be found.
|
|
74
|
+
def forecast_lines
|
|
75
|
+
forecast&.lines || []
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# The weather, kept FRESH_FOR seconds, or RETRY_AFTER when there's none, waiting for it when it's asked for again.
|
|
79
|
+
def forecast
|
|
80
|
+
return @forecast.last if kept?
|
|
81
|
+
|
|
82
|
+
found(fetched_report)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# The weather without waiting for it, for an app painting it, which never waits for the network: what it last had,
|
|
86
|
+
# or else what was kept, however old, while it's asked for again in the background.
|
|
87
|
+
def forecast_now
|
|
88
|
+
return @forecast.last if kept?
|
|
89
|
+
|
|
90
|
+
refresh
|
|
91
|
+
@forecast&.last || Forecast.cached(@place)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def kept?
|
|
95
|
+
found_at, report = @forecast
|
|
96
|
+
found_at && Time.now - found_at < (report ? FRESH_FOR : RETRY_AFTER)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def found(report)
|
|
100
|
+
@forecast = [Time.now, report]
|
|
101
|
+
report
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def fetched_report
|
|
105
|
+
Forecast.for(@place)
|
|
106
|
+
rescue Forecast::Error
|
|
107
|
+
nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# The weather, asked for again in a thread of its own, one at a time.
|
|
111
|
+
def refresh
|
|
112
|
+
return if @refreshing
|
|
113
|
+
|
|
114
|
+
@refreshing = true
|
|
115
|
+
Thread.new do
|
|
116
|
+
found(fetched_report)
|
|
117
|
+
ensure
|
|
118
|
+
@refreshing = false
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Its branches, found again once they're FRESH_FOR seconds old, or none in a notes project.
|
|
123
|
+
def branches(metadata)
|
|
124
|
+
root = root(metadata)
|
|
125
|
+
return [] unless Config.kind(root) == 'code'
|
|
126
|
+
|
|
127
|
+
found_at, branches = @branches
|
|
128
|
+
return branches if found_at && Time.now - found_at < FRESH_FOR
|
|
129
|
+
|
|
130
|
+
BranchTree.new(root).branches.tap { @branches = [Time.now, it] }
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# The project's folder, from the page being written, or else the current one.
|
|
134
|
+
def root(metadata)
|
|
135
|
+
return metadata.root if metadata.respond_to?(:root)
|
|
136
|
+
|
|
137
|
+
Dir.pwd
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
data/lib/raindown/wiki_links.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'code'
|
|
4
4
|
require_relative 'front_matter'
|
|
5
|
+
require_relative 'toc/markdown_headings'
|
|
5
6
|
|
|
6
7
|
module Raindown
|
|
7
8
|
# Obsidian's links between notes, which render as Markdown links to the file they name, by its path in the project,
|
|
@@ -53,14 +54,9 @@ module Raindown
|
|
|
53
54
|
def markdown_link(link, page)
|
|
54
55
|
name, heading, label = link.captures.map { it&.strip }
|
|
55
56
|
label ||= [name, heading].compact.join(' > ')
|
|
56
|
-
anchor = "##{anchor(heading)}" if heading
|
|
57
|
+
anchor = "##{MarkdownHeadings.anchor(heading)}" if heading
|
|
57
58
|
|
|
58
59
|
"[#{label.gsub(/[\[\]]/) { "\\#{it}" }}](<#{page.path}#{anchor}>)"
|
|
59
60
|
end
|
|
60
|
-
|
|
61
|
-
# A heading's id, the way Commonmarker makes it, like to-read for "To read".
|
|
62
|
-
def anchor(heading)
|
|
63
|
-
heading.downcase.gsub(/[^\p{Word}\- ]/, '').tr(' ', '-')
|
|
64
|
-
end
|
|
65
61
|
end
|
|
66
62
|
end
|
data/lib/raindown.rb
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'commonmarker'
|
|
4
3
|
require 'antlers'
|
|
5
4
|
require 'antlers/api'
|
|
6
5
|
|
|
6
|
+
# Libraries that take a while to load, loaded the first time they're used: FileUtils and URI, and unicode-display_width,
|
|
7
|
+
# which reads its tables of characters' widths as it loads.
|
|
8
|
+
autoload :FileUtils, 'fileutils'
|
|
9
|
+
autoload :URI, 'uri'
|
|
10
|
+
module Unicode
|
|
11
|
+
autoload :DisplayWidth, 'unicode/display_width'
|
|
12
|
+
end
|
|
13
|
+
|
|
7
14
|
require_relative 'elements'
|
|
8
15
|
require_relative 'raindown/bare_directives'
|
|
9
16
|
require_relative 'raindown/code'
|
|
@@ -14,7 +21,8 @@ require_relative 'raindown/fragments'
|
|
|
14
21
|
require_relative 'raindown/front_matter'
|
|
15
22
|
require_relative 'raindown/heading_ids'
|
|
16
23
|
require_relative 'raindown/node_blocks'
|
|
17
|
-
require_relative 'raindown/
|
|
24
|
+
require_relative 'raindown/outdent'
|
|
25
|
+
require_relative 'raindown/pages/pages'
|
|
18
26
|
require_relative 'raindown/pre_renderer'
|
|
19
27
|
require_relative 'raindown/table/table_formatter'
|
|
20
28
|
require_relative 'raindown/utils'
|
|
@@ -50,31 +58,39 @@ module Raindown
|
|
|
50
58
|
# Front matter keys are variables, like {title} or <{ title }>.
|
|
51
59
|
# Bare directives like "toc:" show in bold in the HTML, and the rest stay hidden, as comments.
|
|
52
60
|
# Code blocks are highlighted, unless highlight_code is false for a site that highlights code in the browser.
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
# Without commonmark, it's Markdown, not HTML, with nodes as they'd be written back, for an app to render itself, like
|
|
62
|
+
# Obsidian's reading view in the plugin, where Commonmarker, which is native, can't run.
|
|
63
|
+
def render(markdown:, metadata: NoMetadata, bare: false, highlight_code: true, commonmark: true)
|
|
64
|
+
context = Context.new(document: Outdent.unwrapped(markdown), metadata:, bare: bare || BareDirectives.front_matter?(markdown))
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
rendering(highlight_code:, commonmark:) do
|
|
57
67
|
Fragments.collect do
|
|
58
68
|
# Components' HTML goes back in, then their headings get unique ids, before nodes like the TOC see it.
|
|
59
69
|
html = Nodes.render_placeholders(assembled(context), context)
|
|
70
|
+
output = Directives.render("#{html.chomp}\n")
|
|
71
|
+
next output if commonmark
|
|
60
72
|
|
|
61
|
-
|
|
73
|
+
output.gsub(/[\u{E000}\u{E001}]/, CODE_BRACES.invert)
|
|
62
74
|
end
|
|
63
75
|
end
|
|
64
76
|
end
|
|
65
77
|
|
|
66
|
-
# Whether code is highlighted while the block runs, like one document's render,
|
|
78
|
+
# Whether code is highlighted, and Markdown made HTML, while the block runs, like one document's render,
|
|
67
79
|
# so components and endpoints rendering their own Markdown follow it too.
|
|
68
|
-
def
|
|
69
|
-
outer = Thread.current[:
|
|
70
|
-
Thread.current[:
|
|
80
|
+
def rendering(highlight_code:, commonmark: true)
|
|
81
|
+
outer = Thread.current[:raindown_rendering]
|
|
82
|
+
Thread.current[:raindown_rendering] = { highlight_code:, commonmark: }
|
|
71
83
|
yield
|
|
72
84
|
ensure
|
|
73
|
-
Thread.current[:
|
|
85
|
+
Thread.current[:raindown_rendering] = outer
|
|
74
86
|
end
|
|
75
87
|
|
|
76
88
|
def highlight_code?
|
|
77
|
-
Thread.current[:
|
|
89
|
+
Thread.current[:raindown_rendering]&.fetch(:highlight_code) != false
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def commonmark?
|
|
93
|
+
Thread.current[:raindown_rendering]&.fetch(:commonmark) != false
|
|
78
94
|
end
|
|
79
95
|
|
|
80
96
|
# The document's HTML with its components' HTML put back, and unique heading ids.
|
|
@@ -88,9 +104,18 @@ module Raindown
|
|
|
88
104
|
commonmark(PreRenderer.render(markdown, variables: context.variables, context:))
|
|
89
105
|
end
|
|
90
106
|
|
|
91
|
-
#
|
|
107
|
+
# Commonmarker's tree of the Markdown. It's only loaded here, as only rendering HTML needs it, so a build without it,
|
|
108
|
+
# like the WebAssembly one, can still write back.
|
|
109
|
+
def parse_markdown(markdown)
|
|
110
|
+
require 'commonmarker'
|
|
111
|
+
Commonmarker.parse(markdown, options: MARKDOWN_OPTIONS)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Markdown to HTML, like a document's or a component's slot, unless it's rendering Markdown.
|
|
92
115
|
def commonmark(markdown)
|
|
93
|
-
|
|
116
|
+
return markdown unless commonmark?
|
|
117
|
+
|
|
118
|
+
doc = parse_markdown(hide_directives(markdown: TableFormatter.gfm(markdown)))
|
|
94
119
|
preserve_code(doc:)
|
|
95
120
|
|
|
96
121
|
html = highlight_code? ? doc.to_html(options: HTML_OPTIONS) : unhighlighted_html(doc:)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raindown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.21.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-11-
|
|
10
|
+
date: 2026-11-14 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: antlers
|
|
@@ -210,6 +210,7 @@ files:
|
|
|
210
210
|
- lib/nodes/write_in_node.rb
|
|
211
211
|
- lib/raindown.rb
|
|
212
212
|
- lib/raindown/actions.rb
|
|
213
|
+
- lib/raindown/area.rb
|
|
213
214
|
- lib/raindown/bare_directives.rb
|
|
214
215
|
- lib/raindown/blueprints.rb
|
|
215
216
|
- lib/raindown/chart/bars.rb
|
|
@@ -228,6 +229,7 @@ files:
|
|
|
228
229
|
- lib/raindown/document.rb
|
|
229
230
|
- lib/raindown/editing.rb
|
|
230
231
|
- lib/raindown/endpoint/curl.rb
|
|
232
|
+
- lib/raindown/endpoint/curl_request.rb
|
|
231
233
|
- lib/raindown/endpoint/curl_response.rb
|
|
232
234
|
- lib/raindown/endpoint/endpoint_args.rb
|
|
233
235
|
- lib/raindown/endpoint/endpoint_runner.rb
|
|
@@ -236,22 +238,40 @@ files:
|
|
|
236
238
|
- lib/raindown/fragments.rb
|
|
237
239
|
- lib/raindown/front_matter.rb
|
|
238
240
|
- lib/raindown/gitignore.rb
|
|
241
|
+
- lib/raindown/grid.rb
|
|
242
|
+
- lib/raindown/grid_directives.rb
|
|
243
|
+
- lib/raindown/grid_wrapping.rb
|
|
239
244
|
- lib/raindown/heading_ids.rb
|
|
240
|
-
- lib/raindown/
|
|
245
|
+
- lib/raindown/http_json.rb
|
|
246
|
+
- lib/raindown/image.rb
|
|
241
247
|
- lib/raindown/js/js_nodes.rb
|
|
248
|
+
- lib/raindown/js/quickjs_host.rb
|
|
249
|
+
- lib/raindown/js/quickjs_runtime.js
|
|
250
|
+
- lib/raindown/js/services.js
|
|
242
251
|
- lib/raindown/list.rb
|
|
243
252
|
- lib/raindown/markdown_nodes.rb
|
|
244
253
|
- lib/raindown/node.rb
|
|
245
254
|
- lib/raindown/node_blocks.rb
|
|
246
255
|
- lib/raindown/node_injector.rb
|
|
247
256
|
- lib/raindown/nodes.rb
|
|
248
|
-
- lib/raindown/
|
|
249
|
-
- lib/raindown/pages.rb
|
|
257
|
+
- lib/raindown/outdent.rb
|
|
258
|
+
- lib/raindown/pages/listings.rb
|
|
259
|
+
- lib/raindown/pages/page.rb
|
|
260
|
+
- lib/raindown/pages/pages.rb
|
|
250
261
|
- lib/raindown/pre_renderer.rb
|
|
251
262
|
- lib/raindown/problem.rb
|
|
263
|
+
- lib/raindown/project/card.rb
|
|
264
|
+
- lib/raindown/project/endpoint.rb
|
|
265
|
+
- lib/raindown/project/project.rb
|
|
266
|
+
- lib/raindown/project_nodes.rb
|
|
252
267
|
- lib/raindown/projects.rb
|
|
268
|
+
- lib/raindown/rasters.rb
|
|
253
269
|
- lib/raindown/rewriter.rb
|
|
270
|
+
- lib/raindown/scene.rb
|
|
254
271
|
- lib/raindown/server.rb
|
|
272
|
+
- lib/raindown/services.rb
|
|
273
|
+
- lib/raindown/services/connections.rb
|
|
274
|
+
- lib/raindown/services/local.rb
|
|
255
275
|
- lib/raindown/skeleton.rb
|
|
256
276
|
- lib/raindown/stat.rb
|
|
257
277
|
- lib/raindown/table/file_cell.rb
|
|
@@ -263,7 +283,8 @@ files:
|
|
|
263
283
|
- lib/raindown/table/table_formatter.rb
|
|
264
284
|
- lib/raindown/table/table_formulas.rb
|
|
265
285
|
- lib/raindown/table/written_table.rb
|
|
266
|
-
- lib/raindown/toc.rb
|
|
286
|
+
- lib/raindown/toc/markdown_headings.rb
|
|
287
|
+
- lib/raindown/toc/toc.rb
|
|
267
288
|
- lib/raindown/tui.rb
|
|
268
289
|
- lib/raindown/tui/blueprints/blueprints_renderer.rb
|
|
269
290
|
- lib/raindown/tui/blueprints/blueprints_view.rb
|
|
@@ -272,10 +293,8 @@ files:
|
|
|
272
293
|
- lib/raindown/tui/blueprints/filter.rb
|
|
273
294
|
- lib/raindown/tui/blueprints/traced_code.rb
|
|
274
295
|
- lib/raindown/tui/blueprints/tracing.rb
|
|
275
|
-
- lib/raindown/tui/card.rb
|
|
276
296
|
- lib/raindown/tui/cloud.rb
|
|
277
297
|
- lib/raindown/tui/code_box.rb
|
|
278
|
-
- lib/raindown/tui/endpoint.rb
|
|
279
298
|
- lib/raindown/tui/endpoints.rb
|
|
280
299
|
- lib/raindown/tui/events.rb
|
|
281
300
|
- lib/raindown/tui/feelings/batch.rb
|
|
@@ -309,7 +328,6 @@ files:
|
|
|
309
328
|
- lib/raindown/tui/navigator/project_menu.rb
|
|
310
329
|
- lib/raindown/tui/navigator/teleport.rb
|
|
311
330
|
- lib/raindown/tui/navigator/views.rb
|
|
312
|
-
- lib/raindown/tui/project.rb
|
|
313
331
|
- lib/raindown/tui/project_box.rb
|
|
314
332
|
- lib/raindown/tui/renderers/dashboard_renderer.rb
|
|
315
333
|
- lib/raindown/tui/renderers/endpoint_renderer.rb
|
|
@@ -339,6 +357,12 @@ files:
|
|
|
339
357
|
- lib/raindown/watcher/file_watcher.rb
|
|
340
358
|
- lib/raindown/watcher/project.rb
|
|
341
359
|
- lib/raindown/watcher/supervisor.rb
|
|
360
|
+
- lib/raindown/weather/branch_tree.rb
|
|
361
|
+
- lib/raindown/weather/forecast.rb
|
|
362
|
+
- lib/raindown/weather/forecast_cache.rb
|
|
363
|
+
- lib/raindown/weather/forecast_cards.rb
|
|
364
|
+
- lib/raindown/weather/sky.rb
|
|
365
|
+
- lib/raindown/weather/weather.rb
|
|
342
366
|
- lib/raindown/wiki_links.rb
|
|
343
367
|
- lib/raindown/workers/worker.rb
|
|
344
368
|
- lib/raindown/workers/workers.rb
|
data/lib/raindown/js/host.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Runs a project's JavaScript Components for Raindown, which starts it with node -e, since inside Raindown's package
|
|
2
|
-
// the script is where NodeJS can't read it. Each line on stdin is a request, answered by one line of JSON on stdout:
|
|
3
|
-
// { op: 'load', folder } → { nodes: [{ name, render }] }
|
|
4
|
-
// { op: 'new', id, name, args, props } → {}
|
|
5
|
-
// { op: 'call', id, method, context } → { value }
|
|
6
|
-
// A request that throws is answered with { error }.
|
|
7
|
-
import { readdirSync } from 'node:fs'
|
|
8
|
-
import { join } from 'node:path'
|
|
9
|
-
import { createInterface } from 'node:readline'
|
|
10
|
-
import { pathToFileURL } from 'node:url'
|
|
11
|
-
|
|
12
|
-
// stdout carries the replies, so what nodes log goes to stderr.
|
|
13
|
-
console.log = console.info = console.error
|
|
14
|
-
|
|
15
|
-
const classes = {}
|
|
16
|
-
const nodes = {}
|
|
17
|
-
|
|
18
|
-
const requests = {
|
|
19
|
-
// Every exported class with rewrite is a node, named by its export, or by its class for a default export.
|
|
20
|
-
async load({ folder }) {
|
|
21
|
-
for (const file of readdirSync(folder).filter((file) => /\.m?js$/.test(file))) {
|
|
22
|
-
const exports = await import(pathToFileURL(join(folder, file)).href)
|
|
23
|
-
|
|
24
|
-
for (const [name, value] of Object.entries(exports)) {
|
|
25
|
-
if (typeof value?.prototype?.rewrite === 'function') classes[name === 'default' ? value.name : name] = value
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const nodes = Object.entries(classes).map(([name, node]) => ({ name, render: typeof node.prototype.render === 'function' }))
|
|
30
|
-
return { nodes }
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
new({ id, name, args, props }) {
|
|
34
|
-
nodes[id] = new classes[name](props, ...args)
|
|
35
|
-
return {}
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
async call({ id, method, context }) {
|
|
39
|
-
return { value: await nodes[id][method](context) }
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for await (const line of createInterface({ input: process.stdin })) {
|
|
44
|
-
const request = JSON.parse(line)
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
process.stdout.write(`${JSON.stringify(await requests[request.op](request))}\n`)
|
|
48
|
-
} catch (error) {
|
|
49
|
-
process.stdout.write(`${JSON.stringify({ error: String(error?.message ?? error) })}\n`)
|
|
50
|
-
}
|
|
51
|
-
}
|
data/lib/raindown/tui/card.rb
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'unicode/display_width'
|
|
4
|
-
|
|
5
|
-
module Raindown
|
|
6
|
-
module TUI
|
|
7
|
-
# A chart on the dashboard, drawn from its data by its project's Worker: a title of its file, from its project,
|
|
8
|
-
# and the heading above it, then its directive, then the chart, each line with its Layout style,
|
|
9
|
-
# in a border with rounded corners. It's as wide as the chart, so the title and directive are cut to fit it:
|
|
10
|
-
# ╭───────────────────────────────────────╮
|
|
11
|
-
# │ markdown.md › Charts │
|
|
12
|
-
# │ chart: 'data/downloads.csv' width: 30 │
|
|
13
|
-
# │ Jun ██████▊ 640 │
|
|
14
|
-
# ╰───────────────────────────────────────╯
|
|
15
|
-
class Card < Data.define(:project, :path, :line, :heading, :directive, :chart)
|
|
16
|
-
# The border's columns either side of a card's lines, "│ " and " │", and its lines above and below them.
|
|
17
|
-
BORDER_WIDTH = 4
|
|
18
|
-
BORDER_HEIGHT = 2
|
|
19
|
-
|
|
20
|
-
def title = [path.delete_prefix(File.join(project, '')), heading].compact.join(' › ')
|
|
21
|
-
|
|
22
|
-
def lines = parts.map(&:first)
|
|
23
|
-
|
|
24
|
-
# Each line, with its style.
|
|
25
|
-
def parts = [[title, :heading], [directive, :directive], *chart.map { [it, :chart] }]
|
|
26
|
-
|
|
27
|
-
# As wide as its chart.
|
|
28
|
-
def width = chart.map { Unicode::DisplayWidth.of(it) }.max || 0
|
|
29
|
-
|
|
30
|
-
def height = lines.length
|
|
31
|
-
|
|
32
|
-
# With its border, within a range of widths, like a pane's.
|
|
33
|
-
def box_width(within: nil) = within ? (width + BORDER_WIDTH).clamp(within) : width + BORDER_WIDTH
|
|
34
|
-
def box_height = height + BORDER_HEIGHT
|
|
35
|
-
|
|
36
|
-
# A line of the card in its border, as [text, style, width] parts, for a card the box width wide.
|
|
37
|
-
# The border's top is line 0, and below its bottom, the lines are blank, for a card shorter than its row.
|
|
38
|
-
# The title's style is title_style, like when the card's selected.
|
|
39
|
-
def format_line(line, box_width:, title_style: :heading)
|
|
40
|
-
width = [box_width - BORDER_WIDTH, 0].max
|
|
41
|
-
return [border(width, '╭', '╮')] if line.zero?
|
|
42
|
-
return [border(width, '╰', '╯')] if line == height + 1
|
|
43
|
-
return [['', :blank, width + BORDER_WIDTH]] if line > height + 1
|
|
44
|
-
|
|
45
|
-
text, style = parts[line - 1]
|
|
46
|
-
[['│ ', :border, 2], [text, style == :heading ? title_style : style, width], [' │', :border, 2]]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def border(width, left, right)
|
|
52
|
-
["#{left}#{'─' * (width + 2)}#{right}", :border, width + BORDER_WIDTH]
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Raindown
|
|
4
|
-
module TUI
|
|
5
|
-
# An endpoint in a project's files, listed in the nav pane by its request, like "GET httpbin.org/uuid",
|
|
6
|
-
# with its method in its style, like GET in :method_get.
|
|
7
|
-
Endpoint = Data.define(:project, :path, :line, :method, :url) do
|
|
8
|
-
def text = "#{method} #{address}"
|
|
9
|
-
|
|
10
|
-
# The URL without its scheme.
|
|
11
|
-
def address = url.sub(%r{\Ahttps?://}i, '')
|
|
12
|
-
|
|
13
|
-
def style = :"method_#{method.downcase}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|