Commit Graph
102 Commits
Author SHA1 Message Date
Zef Hemel 8b241f9448 Rebranding LIQ to SLIQ! 2026-04-22 20:54:43 +02:00
Zef Hemel 5a9f9ed101 Std Library: remove plug-manager and legacy Library Manager
Drop the old plug-manager plug and the Space-Lua Library Manager, all superseded by the Libraries tab in the configuration manager.

Pass fallback values to config.get(...) in the Std widgets so  TOC / linked mentions / linked tasks keep rendering on a fresh  space where schema defaults haven't been indexed yet.
2026-04-21 16:59:00 +02:00
Zef Hemel 795c248a0c Set some sensible default (fallback) config options when defaults are not yet available (initial index) 2026-04-21 13:06:36 +02:00
Zef Hemel d25e98b932 Std Library: wire schema defaults and UI categories
Registers UI categories and moves default values from `config.set` blocks into schema `default` fields, so the configuration manager can drive everything directly from the schema. Only `actionButtons`, whose entries hold function bodies, stays in `config.set`.

Also adds a schema for `github.*` settings so the integration shows  up in the configuration UI (later commit)
2026-04-21 10:06:52 +02:00
Zef Hemel ea2ad9a732 Add actionButton.define "command" attribute
This automatically triggers a command bound to an actionButton, and
notably also shows the keyboard shortcut connected to it (if any)
2026-04-16 14:23:54 +02:00
Zef Hemel 338c78f806 Iterating on the CLI
* Renamed 'lua' to 'eval'
* Renamed 'luascript' to 'script'
* Added 'describe' to describe LIQ and lists tags that have defined
  schemas

Tests for all of this
2026-04-16 10:58:20 +02:00
Zef Hemel 2229a11160 Fix tag stripping for page templates 2026-04-08 20:03:46 +02:00
Zef Hemel 49229c1608 Add pageLastModified to item and task, similar to link 2026-03-31 15:43:21 +02:00
Zef Hemel dc4e701ddf syntax.define refinements 2026-03-31 15:01:16 +02:00
Zef Hemel 7d4f4312d1 Move home button outside of dropdown as well (default) 2026-03-26 17:39:47 +01:00
Zef Hemel 03971a462f Fix rendering of TOC when headers contain a numbered list item 2026-03-26 11:35:11 +01:00
Matouš Jan FialkaandGitHub baeb688ddc Fix: template.each returns nil on empty results (#1899)
* Fix: `template.each` returns nil on empty results

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix typo

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-19 16:26:32 +01:00
Matouš Jan FialkaandGitHub 9170627d27 Add tests for aggregates and few useful aggregates (#1897)
* [LIQ] Add more tests for builtin aggregates

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* [LIQ] Add `first`, `last`, `mode` and `median` aggregates and `group_concat` alias

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-19 12:34:58 +01:00
Matouš Jan FialkaandGitHub 6cbb61c7db [LIQ] Add new aggregate functions, aliases, and queryable aggregate registry (#1891)
* [LIQ] Add new aggregate functions, aliases, and queryable aggregate registry

* Extend with 13 new built-in aggregates: `product`, `string_agg`,
  `yaml_agg`, `json_agg`, `bit_and`, `bit_or`, `bit_xor`, `bool_and`,
  `bool_or`, `stddev_pop`, `stddev_samp`, `var_pop` and `var_samp`.

* Introduce `aggregate.alias` API allowing users to define custom
  aliases for any aggregate. Standard aliases (`every`, `std`, `stddev`
  and `variance`) are now defined via this API rather than hardcoded.

* Add `index.aggregates` queryable collection so users can discover
  all available aggregates directly from LIQ queries.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix config pass through query path so custom aggregates work

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Preserve `LuaTable`/`LuaFunction` values in aggregate config storage

`config.set` uses `LuaNativeJSFunction` which calls `luaValueToJS` on
all arguments. This converted the aggregate `LuaTable` to a plain JS
object and wrapped `LuaFunction` callbacks in JS functions that also
converted their returned values via `luaValueToJS`. The result was that
state returned by initialize (a `LuaTable`) got converted to a plain JS
object before being passed to `iterate`. Therefor Lua operations like
`table.insert` on that were failing because they expected a `LuaTable`
and not a plain JS array.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix formatting

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Improve aggregate functions descriptions, fix `sum` divergence

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Align `product` with `sum`

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: extract `alias` from `LuaTable` via `rawGet` in `aggregates()` registry

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Rename `alias` in `aggregates()` to `target` for clarity

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Add a null guard at the top of `jsToLuaValue`

This preserves `null`/`undefined` as-is (both map to Lua nil) and
prevents them from falling through to the `typeof` "object" branch.

For this PR it means that null `target` in our `aggregates` entries will
correctly show as empty/`nil` in query results rather than `{}`.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Documentation reflects recent changes

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: make `sum`/`product` return null on empty input; stop `LIQ_NULL` leaks

* `sum(`) and` product(`) now return null when no rows match (matching
  Postgres semantics) instead of returning 0 and 1 respectively.

* Query result columns that hold null are internally preserved using
  a `LIQ_NULL` sentinel so that column keys survive in `LuaTable`
  storage.  This sentinel was leaking into Lua code as "userdata"
  through three read paths:

  * `luaIndexValue`: `rawGet` returned the sentinel directly to Lua when
    accessing table fields,

  * `rawget` (stdlib): the builtin `rawget` function exposed the
    sentinel without converting it back to `nil`,

  * `createAugmentedEnv`: string interpolation unpacked table values via
    `rawGet` into local variables, making the sentinel visible in
    template expressions like `${var}`.

  All three now convert `LIQ_NULL` to `nil` at the read boundary,
  keeping the sentinel internal to table storage where it belongs.

* Update affected test expectations accordingly.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Remove duplicated LIQ_NULL hazard, add guard for all builtin aggregate `iterate`s

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: `array_agg` preserves NULL positions

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Add symbol guard to `json_agg`

`JSON.stringify(Symbol(...))` in an array produces null by accident.
That is a JS implementation detail we **MUST NOT** rely on. Explicit
null push makes intent clear and avoids surprises if the `Symbol`
representation ever changes.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Add symbol guard to `yaml_agg` (ditto)

`js-yaml` has no knowledge of the `LIQ_NULL` symbol. Passing null makes
it emit YAML null (or `~`), which is the correct YAML representation of
a missing value and matches standard `json_agg`/`yaml_agg`
NULL-inclusion semantics.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Add intra-aggregate ordering null guards

Without this, `LIQ_NULL` sort keys would fall through to `valA < valB`
which is always false for `Symbol`s which is breaking the `nulls
first`/`nulls last` contract...

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Ditto, but for `order by` null comparisons

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Guard `luaTypeName`, `luaTypeOf` and `luaToString` against `LIQ_NULL` sentinel

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Guard presentation layer against `LIQ_NULL` sentinel leaking as visible text

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix: Evaluate extra args per-item in `executeAggregate`; add new aggregates

Extra arguments (2nd, 3rd, etc.) to aggregate functions were evaluated
against the outer query environment where the object variable is not
bound. This caused multi-argument aggregates like `covar_samp(data.y,
data.x)` to fail with nil reference errors. This commit addresses this
by evaluating extra args per-item inside the iterate loop using the item
environment so all arguments resolve correctly.

We also add few common aggregates:

- `covar_pop`, `covar_samp`, `corr`: population/sample covariance and
  correlation coefficient using online co-moment algorithm.

- `quantile(value, q, method)`: general quantile with interpolation
  methods: lower, higher, nearest, midpoint and default linear.

- `percentile_cont(value, q)`: continuous percentile (linear)

- `percentile_disc(value, q)`: discrete percentile (lower)

Note: `percentile_cont` and `percentile_disc` share the `quantile`
implementation through `ctx.name` at initialize time.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Update docs

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Make the ordering for quantile aggregates explicit

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Update docs

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Improve docs

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-19 09:37:09 +01:00
Matouš Jan FialkaandGitHub 6d52350640 Fix extended task rendering in widgets (#1882)
* Fix extended task rendering in widgets

This patch addresses several issues.

1. Extended tasks like `[PLANNED]` or `[TODO]` were not rendering
   correctly when generated via widgets. The HTML renderer was producing
   plain text without brackets or proper styling, while simple `[x]`
   tasks worked fine.  The fix produces the same DOM structure as
   CodeMirror producing coherent styling everywhere.

2. Widget checkboxes are not interactive now. Since widget tasks have no
   backing state handler clicking them only caused a misleading visual
   toggle with no effect. The `disabled` attribute prevents this
   confusion and the dimmed appearanceit signals to the user that the
   checkbox is read-only in this context which is the truth.

To see it in action try the following Markdown snippet in SilverBullet:

```
- [x] #foo [att: i]
- [PLANNED] bar #bar [att: i]

${'- [x] #foo [att: i]\n- [PLANNED] bar #bar [att: i]'}
```

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Revert and just prevent widget checkboxes from toggling visually

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Support custom task states in widgets and indexer

Custom task states like `[PLANNED]` or `[IN PROGRESS]` now render
correctly in *widgets*, matching the same DOM structure as CodeMirror
uses in the editor. Widget-rendered tasks that reference a real task
(via `page@pos`) are fully interactive — clicking an extended state
cycles it through the configured states and updates the source task.
Tasks without a reference are disabled to prevent misleading visual
feedback.

The task indexer now respects the `done` flag on custom states defined
via `taskState.define`, so queries like `where not t.done` correctly
exclude tasks in states marked as done. Previously only the built-in
simple tasks (`- [x]` or `- [X]`) states were treated as completed. The
`Task: Remove Completed` command already handled custom done states and
continues to work unchanged.

State cycling now preserves the definition order from `taskState.define`
calls instead of sorting alphabetically. A new `order` field allows
explicit control over the cycle sequence. Without it, states cycle in
definition order. With it, states are sorted by the `order` field value.
This gives users full control over the progression, for example:

    PLANNED --> IN PROGRESS --> FINISHED

The `taskState.define` API now validates its input against a schema:
`name` (string, required), `done` (boolean, optional), and `order`
(number, optional).

The `expandMarkdown` no longer injects "fake" `page@pos` references into
tasks rendered via `widget.markdownBlock` or `widget.new` which was
causing broken links and unwanted interactivity on static task content.

The `task:stateChange` event is dispatched when toggling tasks from
widgets, ensuring Lua listeners (such as some custom completed timestamp
management) fire correctly regardless of where the toggle originates.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-13 13:32:26 +01:00
Zef Hemel f6308c788c Adds back "lock" button on mobile
This can be used to toggle between read-only mode, useful for mobile
users that are primarily navigating, not editing
2026-03-13 09:14:52 +01:00
Zef Hemel b60496f30e Move forward/backward action buttons to drop-down on mobile 2026-03-13 08:39:20 +01:00
Zef Hemel 3aea9a8112 Fixes #1872 2026-03-13 08:32:04 +01:00
Zef Hemel 1b0ba027b3 Add standalone option to action buttons
When `standalone` is set to true, this action button will only appear in
"standalone PWA" mode (e.g. home-screen mobile apps, or installed PWA on
desktop). Useful to e.g. only show forward and backward buttons. These
forward and backward buttons are now also added to the default action
button config.
2026-03-12 14:51:31 +01:00
Zef Hemel 6bc12bc00f Add support for opting out action buttons from the drop down on mobile
+ by default making the page picker opt out
2026-03-12 14:27:20 +01:00
Zef HemelandGitHub 3df11ccf3d Implements custom markdown syntax extensions (EXPERIMENTAL) (#1881)
Alternative implemention of #1727
2026-03-12 13:40:20 +01:00
Matouš Jan Fialka bc5c3c8bda [LIQ] Implement intra-aggregate order by (5: documentation)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-11 08:52:33 +01:00
Zef HemelandGitHub c02594f20c Merge pull request #1865 from Dobli/collapsible-toc
Make ToC widget collapsible
2026-03-10 08:42:01 +01:00
Dobli 30a1356db8 Set default state of toc to open 2026-03-05 23:31:59 +01:00
Dobli 7a3ff21419 Align new toc widget style with existing widgets 2026-03-05 22:22:24 +01:00
Zef Hemel e1daa7204d CHANGELOG and Space Overview updates reflecting new space-lua ordering 2026-03-05 08:20:43 +01:00
Zef Hemel 59c271131b Big website content iteration 2026-03-04 13:31:27 +01:00
Dobli 50ed0500e9 Use space-style for toc widget styling 2026-03-03 23:11:27 +01:00
Dobli 3a6a88755f Make toc widget collapsible 2026-03-02 18:34:52 +01:00
Laurence TanandGitHub c8e541250b Fix typo in Library Manager documentation 2026-02-27 19:12:03 +11:00
Zef Hemel f29f043ff3 Fixes #1846: bring back virtual pages
Was misusing Lua pattern matching before
2026-02-26 09:48:15 +01:00
13c61ebab7 [LIQ] Extend with group by and having with aggregators (#1843)
* [LIQ] Extend with `group by` and `having` support

Also update documentation with extensive examples and add some parser
tests.

Note: `make generate` JS files included.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Merge `liq-add-support-for-aggregators` branch

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix link, remove `_` example

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Wrap example LIQ queries inside `query [[ .. ]]` and replace `sql` code block type to `lua`

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Example self-consistency fix

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fixed some queries

* Add experimental tags to LIQ aggregation/grouping

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Co-authored-by: Zef Hemel <zef@zef.me>
2026-02-25 10:35:31 +01:00
rktjmpandGitHub 9dc6ed2193 Honor openIfExists: true when using Page: From Template command (#1831)
* Improve Page Template option behaviour documentation

* Check pageName == nil or "" when getting page template name from prompt

* Honor `openIfExists: true` when using `Page: From Template` command
2026-02-12 11:18:03 +01:00
rktjmpandGitHub d285288add Support embedding youtube shorts (#1824) 2026-02-06 16:03:06 +01:00
Zef Hemel f6d2e37d25 Reduce logging noise 2026-02-05 11:09:05 +01:00
Zef Hemel 8712d33b4a Optimize linked tasks query slightly 2026-02-05 09:06:35 +01:00
Zef Hemel 01a14d4e58 Add range attribute to built-in tag schemas 2026-02-05 09:05:57 +01:00
Zef Hemel 0773df31e2 Add validation and error handling for object indexing
- Introduced a new `validate` callback for `tag.define`
- Added `index.validateObjects` API to validate and transform objects before indexing.
- Updated relevant documentation and examples to reflect these changes.
2026-02-03 15:59:04 +01:00
Zef Hemel c2f87f259f Fix page template schema 2026-02-03 11:34:00 +01:00
Zef Hemel ed7ccaa216 Schemas for page templates and slash templates 2026-02-03 10:52:18 +01:00
Zef Hemel 85ac15546f Update LIQ query slash commands to use from o = syntax (performance,
better practice)
2026-01-30 08:36:03 +01:00
Zef Hemel 13b17110eb Order Linked Mentions by page last modified (desc)
* Adds `pageLastModified` to `link` objects, and use it for Linked
  Mentions
2026-01-30 08:33:32 +01:00
Zef Hemel d63a679657 Navigate to library page after install 2026-01-29 12:18:40 +01:00
Zef Hemel d14695abf4 Iterations on tag.define
* Now also supports setting a custom metatable (replacement of
  index.defineTag)
* Load tag.define API on boot so can be used for initial client index
  from CONFIG
* Docs and examples
2026-01-29 11:07:28 +01:00
Zef Hemel 4d54d05f88 Schema-based attribute completion for frontmatter and LIQ queries
Experimental and rudamentary, will not cover all cases.
2026-01-27 16:38:48 +01:00
Zef Hemel bd03a406f0 Renamed postIndex to transform for tag.define API (experimental). 2026-01-27 09:33:00 +01:00
Zef Hemel 812dee8537 Lua/LIQ: added from p in <<expr>> as a syntax variant (and preferred
option) for `from p = <<expr>>`. Updated docs accordingly.
2026-01-27 09:15:07 +01:00
Zef Hemel 9b05beba16 First pass of custom tag behavior (schema and postProcess) support
See API/tag.md for explanations and examples.
2026-01-22 15:32:01 +01:00
Zef Hemel fb10fd65b8 shortWikiLinks config option 2026-01-22 08:42:30 +01:00
Zef Hemel a89ab96438 Expose _G global variable in Space Lua 2026-01-21 14:32:41 +01:00