mirror of
https://github.com/jbranchaud/til
synced 2026-10-31 16:23:27 +00:00
Compare commits
3
Commits
2b29a572bb
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
223602e525 | ||
|
|
bff11a2fee | ||
|
|
891e3453d1 |
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||||
|
|
||||||
_1893 TILs and counting..._
|
_1895 TILs and counting..._
|
||||||
|
|
||||||
See some of the other learning resources I work on:
|
See some of the other learning resources I work on:
|
||||||
|
|
||||||
@@ -59,6 +59,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
* [Kitty](#kitty)
|
* [Kitty](#kitty)
|
||||||
* [Linux](#linux)
|
* [Linux](#linux)
|
||||||
* [LLM](#llm)
|
* [LLM](#llm)
|
||||||
|
* [Logseq](#logseq)
|
||||||
* [Mac](#mac)
|
* [Mac](#mac)
|
||||||
* [Math](#math)
|
* [Math](#math)
|
||||||
* [Mise](#mise)
|
* [Mise](#mise)
|
||||||
@@ -229,6 +230,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
- [Parameterized SCSS Mixins](css/parameterized-scss-mixins.md)
|
- [Parameterized SCSS Mixins](css/parameterized-scss-mixins.md)
|
||||||
- [Prevent Invisible Elements From Being Clicked](css/prevent-invisible-elements-from-being-clicked.md)
|
- [Prevent Invisible Elements From Being Clicked](css/prevent-invisible-elements-from-being-clicked.md)
|
||||||
- [:root Has Higher Specificity Than html](css/root-has-higher-specificity-than-html.md)
|
- [:root Has Higher Specificity Than html](css/root-has-higher-specificity-than-html.md)
|
||||||
|
- [Show Full URLs With Print Styles](css/show-full-urls-with-print-styles.md)
|
||||||
- [Style A Background With A Linear Gradient](css/style-a-background-with-a-linear-gradient.md)
|
- [Style A Background With A Linear Gradient](css/style-a-background-with-a-linear-gradient.md)
|
||||||
- [Using Maps In SCSS](css/using-maps-in-scss.md)
|
- [Using Maps In SCSS](css/using-maps-in-scss.md)
|
||||||
|
|
||||||
@@ -753,6 +755,10 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
- [Translate To Canonical Tags With Small Model](llm/translate-to-canonical-tags-with-small-model.md)
|
- [Translate To Canonical Tags With Small Model](llm/translate-to-canonical-tags-with-small-model.md)
|
||||||
- [Use The llm CLI With Claude Models](llm/use-the-llm-cli-with-claude-models.md)
|
- [Use The llm CLI With Claude Models](llm/use-the-llm-cli-with-claude-models.md)
|
||||||
|
|
||||||
|
### Logseq
|
||||||
|
|
||||||
|
- [Access Daily Journal From CLI With HTTP Server](logseq/access-daily-journal-from-cli-with-http-server.md)
|
||||||
|
|
||||||
### Mac
|
### Mac
|
||||||
|
|
||||||
- [Access All Screen And Video Capture Options](mac/access-all-screen-and-video-capture-options.md)
|
- [Access All Screen And Video Capture Options](mac/access-all-screen-and-video-capture-options.md)
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Show Full URLs With Print Styles
|
||||||
|
|
||||||
|
Web pages are best experienced in a browser where you can fully interact with
|
||||||
|
them. Links, for instance, can be hovered, inspected, and clicked on to navigate
|
||||||
|
to the target location -- that's a core part of the web browser experience and
|
||||||
|
what makes the internet.
|
||||||
|
|
||||||
|
Some people have printers though and they want to be able to print off web
|
||||||
|
pages. Any web page can be printed off as is, but if your site or app is
|
||||||
|
anticipating certain pages being printed, then you may add some
|
||||||
|
`@print`-specific CSS styling to improve how it looks in print format.
|
||||||
|
|
||||||
|
Links are a prime example of lost interactivity. When printed, links render as
|
||||||
|
blue underlined text with no way to know what they are linking to. One trick
|
||||||
|
that I recently picked up from [this lobste.rs thread](https://lobste.rs/s/olnqh2/websites_should_be_printable#c_wigxfy) is to
|
||||||
|
add _after content_ that renders the actual, full URL next to the link.
|
||||||
|
|
||||||
|
```css
|
||||||
|
@media print
|
||||||
|
{
|
||||||
|
a[href]::after
|
||||||
|
{
|
||||||
|
content: " [" attr(href) "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This means that when a page has `<a href="https://still.visualmode.dev">still</a>`, the printed version will not
|
||||||
|
just render the word "still", but will be styled to render `still [https://still.visualmode.dev]`.
|
||||||
|
|
||||||
|
This will add content after links for both absolute URLs and relative paths (and
|
||||||
|
anchor tags). If I wanted to limit the after content to only show absolute URLs,
|
||||||
|
I could add a bit more specificity to the matching tag.
|
||||||
|
|
||||||
|
```css
|
||||||
|
@media print
|
||||||
|
{
|
||||||
|
a[href^="http"]::after
|
||||||
|
{
|
||||||
|
content: " [" attr(href) "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The `^=` matches the pattern of `http` on the start of the `href` string which
|
||||||
|
means it will only display absolute URLs.
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Access Daily Journal From CLI With HTTP Server
|
||||||
|
|
||||||
|
I use [logseq](https://logseq.com/) as the daily driver for my notes both inside
|
||||||
|
and outside of work. I like the organization provided by the outliner notetaking
|
||||||
|
style.
|
||||||
|
|
||||||
|
I now want to set up some automations that interact with my notes. I originally
|
||||||
|
figured this would involve reading directly from markdown files on disk.
|
||||||
|
However, they recently migrated to a SQLite storage format and I learned that
|
||||||
|
there is an HTTP server you can run for more reliable interactions.
|
||||||
|
|
||||||
|
The HTTP server needs to be enabled. To do this, I did the following (though I'm
|
||||||
|
not sure if _Developer Mode_ is required):
|
||||||
|
|
||||||
|
1. Find the `...` icon to access the app's main menu
|
||||||
|
2. Open _Settings_
|
||||||
|
3. Enable _Developer Mode_ under _Advanced_
|
||||||
|
4. Enable _HTTP API Server_ under _Features_
|
||||||
|
5. Restart the logseq app
|
||||||
|
6. Click the disabled _API_ icon that is in the upper-right next to the
|
||||||
|
navigational arrows
|
||||||
|
7. Create a new _Authorization Token_ and copy the value
|
||||||
|
8. Click _Start Server_ and it will run at `http://127.0.0.1:12315`
|
||||||
|
|
||||||
|
With all that in place, the server is running and ready to accept my first
|
||||||
|
query. I want to get a look at my notes so far today, so I'll run a `curl`
|
||||||
|
request against the `/api` path with the auth token I copied.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ curl -s -X POST http://127.0.0.1:12315/api \
|
||||||
|
-H "Authorization: Bearer $LOGSEQ_API_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"method":"logseq.Editor.getPageBlocksTree","args":["Oct 31st, 2026"]}'
|
||||||
|
[{"updatedAt":1793456696397,"createdAt":1793456670024,"parent":{"id":5943},"children":[],"id":5947,"level":1,"uuid":"6ae5fa1e-afa2-46c9-abbc-abf58b434e3e","fullTitle":"Working on setting up the HTTP server for logseq to see if I can interact with it via the CLI.","content":"Working on setting up the HTTP server for logseq to see if I can interact with it via the CLI.","order":"a0","title":"Working on setting up the HTTP server for logseq to see if I can interact with it via the CLI.","page":{"id":5943}},{"updatedAt":1793456702190,"createdAt":1793456697156,"parent":{"id":5943},"children":[{"updatedAt":1793456702212,"createdAt":1793456702212,"parent":{"id":5948},"children":[],"id":5949,"level":2,"uuid":"6ae5fa3e-0865-4713-9690-c456fb1a37ad","fullTitle":"","content":"","order":"a0","title":"","page":{"id":5943}}],"id":5948,"level":1,"uuid":"6ae5fa39-96bc-4f26-9d5f-2b3b3a366070","fullTitle":"[[6aa01dba-1b28-4540-b205-5254ee37d825]]","content":"[[6aa01dba-1b28-4540-b205-5254ee37d825]]","order":"a1","title":"[[6aa01dba-1b28-4540-b205-5254ee37d825]]","page":{"id":5943},"refs":[{"id":642}]}]%
|
||||||
|
```
|
||||||
|
|
||||||
|
The data we pass as the request body includes the `method` we are running which
|
||||||
|
is "get all the blocks for the specified page"
|
||||||
|
([`getPageBlocksTree`](https://plugins-doc.logseq.com/logseq/Editor/getPageBlocksTree)).
|
||||||
|
The `args` then specify what page we are referring to. In this case, today's
|
||||||
|
daily journal -- `"Oct 31st, 2026"` (👻). The result is that pile of JSON.
|
||||||
|
|
||||||
|
Whenever I get a long line of JSON like that, I like to use `jq` at the very
|
||||||
|
least to pretty-print it or even to dig in a bit.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ curl -s -X POST http://127.0.0.1:12315/api \
|
||||||
|
-H "Authorization: Bearer $LOGSEQ_API_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"method":"logseq.Editor.getPageBlocksTree","args":["Oct 31st, 2026"]}' | jq
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"updatedAt": 1793456696397,
|
||||||
|
"createdAt": 1793456670024,
|
||||||
|
"parent": {
|
||||||
|
"id": 5943
|
||||||
|
},
|
||||||
|
"children": [],
|
||||||
|
"id": 5947,
|
||||||
|
"level": 1,
|
||||||
|
"uuid": "6ae5fa1e-afa2-46c9-abbc-abf58b434e3e",
|
||||||
|
"fullTitle": "Working on setting up the HTTP server for logseq to see if I can interact with it via the CLI.",
|
||||||
|
"content": "Working on setting up the HTTP server for logseq to see if I can interact with it via the CLI.",
|
||||||
|
"order": "a0",
|
||||||
|
"title": "Working on setting up the HTTP server for logseq to see if I can interact with it via the CLI.",
|
||||||
|
"page": {
|
||||||
|
"id": 5943
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user