Giter Site home page Giter Site logo

srid / emanote Goto Github PK

View Code? Open in Web Editor NEW
737.0 15.0 66.0 6.16 MB

Emanate a structured view of your plain-text notes

Home Page: https://emanote.srid.ca

License: Other

Nix 7.25% Haskell 72.80% HTML 17.18% CSS 2.53% Just 0.23%
ema zettelkasten static-site markdown pandoc haskell orgmode obsidian-md

emanote's Introduction

emanote

AGPL built with nix Matrix Harmeless Code of Conduct

Emanote emanates1 a structured view of your plain-text notes.

Create beautiful websites -- such as personal webpage, blog, wiki, Zettelkasten, notebook, knowledge-base, documentation, etc. from future-proof plain-text notes and arbitrary data -- with live preview that updates in real-time.

Emanote is spiritual successor to neuron based on Ema.

Installing and using

https://emanote.srid.ca/start/install

Examples

https://emanote.srid.ca/examples

Developing

Emanote is a Haskell software.2 Thanks to Nix, this repository is pre-configured to provide a delightful development experience with full IDE support in Visual Studio Code.

See https://srid.ca/haskell-template/start for complete instructions, but briefly: Install Nix and run nix develop -c just run.

See architecture for a high-level overview of the codebase.

PR contribution guidelines

You may want to run nix run github:srid/nixci before opening a PR, but the CI will run it as well.

Discussion

To discuss the emanote project, join Matrix or post in GitHub Discussions.

Footnotes

  1. emanate: (of something abstract but perceptible) issue or spread out from (a source)

  2. Emanote uses software and resources that are licensed differently, viz.:

emanote's People

Contributors

applejag avatar bolt12 avatar bors[bot] avatar carliros avatar cwhy avatar edrex avatar fieldstrength avatar illustratedman-code avatar j-steinbach avatar jfpedroza avatar kukimik avatar maralorn avatar mnaoumov avatar ners avatar omasanori avatar reptee avatar roberth avatar rvl avatar shivaraj-bh avatar srid avatar tristancacqueray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emanote's Issues

Overlay vs configuration file

Moved comment from @hi-learn-triz-and-usit at #35 (comment) to here

# Run emanote live server on current directory, using common themes and public notes (3 layers)
cd ~/MyPrivateNotes
emanote run ~/myemanotethemes ~/MyPublicNotes ./

When wouldn't we want to include public notes and common themes when running emanote in MyPrivateNotes? Because if the answer is "never", and in fact if it doesn't even make sense to do so (because some links or themes will be broken) shouldn't the first two layers be part of the configuration file of the third layer?

Basically, I'm suggesting that the overlay graph should be expressed using an implicit linked list (or more generally a dag) in the configuration files of the layers (each layer has the option to point to layers it depends on). This handles the common use case, where a site is built up of pieces, without complicating the interface. This does not handle the case where we want to easily be able to swap the pieces; my question is whether this is actually a thing users will want to do.

Originally posted by @hi-learn-triz-and-usit in #35 (comment)

Pandoc: complete table formatting

There is a TODO here that should be done

B.Table attr _captions _colSpec (B.TableHead _ hrows) tbodys _tfoot ->
-- TODO: Apply captions, colSpec, etc.
H.table ! rpAttr attr $ do

Ref: https://github.com/jgm/commonmark-hs/blob/4f7d8b7b37dcc672d46f6bf967afbd47c589e050/commonmark-extensions/test/pipe_tables.md

commonmark-hs doesn't do captions, so we can just apply what's available - like colspecs, etc.

Unable to install on macOS

MacOS 11.3.1
Build from master.

I got the error message during the installation:

Preprocessing test suite 'example-test' for ap-normalize-0.1.0.0..
Building test suite 'example-test' for ap-normalize-0.1.0.0..
[1 of 1] Compiling Main             ( test/example.hs, dist/build/example-test/example-test-tmp/Main.o, dist/build/example-test/example-test-tmp/Main.dyn_o )
test/example.hs:49:1: traverseNormal === traverseNaive failed expectedly.
test/example.hs:50:1: traverseNormal === traverseAN passed.
test/example.hs:51:1: traverseNormal === traverseTree passed.
inspection testing successful
      expected successes: 2
       expected failures: 1
Linking dist/build/example-test/example-test ...
Preprocessing test suite 'assoc-test' for ap-normalize-0.1.0.0..
Building test suite 'assoc-test' for ap-normalize-0.1.0.0..
[1 of 1] Compiling Main             ( test/assoc.hs, dist/build/assoc-test/assoc-test-tmp/Main.o, dist/build/assoc-test/assoc-test-tmp/Main.dyn_o )

test/assoc.hs:51:151: error:
    • Not in scope: ‘assoc1'Aps’
      Perhaps you meant one of these:
        ‘assoc2'Aps’ (line 51), ‘assoc1'NAME’ (line 51)
    • In the Template Haskell quotation 'assoc1'Aps
   |
51 | TEST_ASSOC_(Aps,Aps f,=/=,Applicative f =>)
   |                                                                                                                                                       ^^^^^^^^^^^

builder for '/nix/store/mgykywgffhw2fc80zh7lv98ygglws07q-ap-normalize-0.1.0.0.drv' failed with exit code 1
cannot build derivation '/nix/store/33wp4ndx99i1p2lm2vs9asyyzkf8nasz-generic-data-0.9.2.0.drv': 1 dependencies couldn't be built
building '/nix/store/kkda0zf90dz306mrc1c2n0lvhscnmrsr-pandoc-link-context-1.0.2.0.drv'...
cannot build derivation '/nix/store/4wwn0n70pi3gkm68wk5lkpn9bys1rxnc-safecopy-0.10.4.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/rhsd4hvrhnc95gyd5rf5pbm17smnns34-ixset-typed-0.5.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/nv8701z7dcjr9ibk4c9rf2nlhalm7b3s-emanote-0.1.0.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/nv8701z7dcjr9ibk4c9rf2nlhalm7b3s-emanote-0.1.0.0.drv' failed

Allow overriding base URL in CLI

Emanote's default template hardcodes <base href="/"> via reading the "/" from index.yaml (templates.baseUrl: /). The default works in live server. But its value differs in certain deployment environments, like GitHub Pages. We should provide a way to override this when generating the static HTML (i.e., outside of live server).

emanote --override-index-data='{"template": {"baseUrl": "srid.github.io/mynotes"} }' gen

Note that this command itself is general, and allows overriding anything in the "index data" (which currently is represented by the top-level index.yaml). We can leverage the existing Data.Aeson.Extra.Merge to do this.

Goal: continue to use / as baseUrl in live server mode, but something else during deployment.

Allow inline embedding images

The following works,

Para 1

![[Foo.jpeg]]

Para 2

But the following does not,

A paragraph that contains an image: ![[Foo.jpeg]]

See #97 for background

Allow non-pretty URLs (for Gitlab, etc..)

Some places like GitLab don't support .html-less URLs. Allow disabling prettyfying of URLs in index.yaml using a setting like,

template:
  emaUrlStrategy: direct

Depends on srid/ema#48 ... then modify flake.nix (followed by re-run of bin/run) to use a custom branch of Ema for hacking on Emanote, to implement this feature.

Updates are slow on large notebooks

On a notebook with mere 300 notes, updating a .md file causes several seconds delay in emanote actually updating its own internal state (prior to hot reload). Something gone awry somewhere.

Use custom fonts from nixpkgs

For reference, see https://git.maralorn.de/blog/tree

We can use fonts from one of the nixpkgs font packages, and then add its directory as an Emanote layer (in addition to ./default), treating those fonts as a static file, and linking to them from CSS.

Stretch goal: allow specifying the nixpkgs font in index.yaml so the user can pick whatever they want.

Hot reload is not refreshing image files

srid/ema#42

One solution to this is to have emanote append all links to static files with a ?t=currenttime. When the hot reload event is fired for HTML (because an image file got modified), that will have the effect the changing the URL to it, due to the new timestamp query param, and so the browser will have to refresh it after morphdom patches it.

The URL query addition should happen only in dev server mode (not during static site generation).

High memory usage on large notebooks

For this notebook,

~/Downloads/large 
❯ du -sh .
69M	.

~/Downloads/large 
❯ find . -name \*.md | wc -l
4561

Emanote takes ~4.7GB of resident memory. It takes a while (~1m) to load all these files at startup, and but runs fine afterwards. The @Index page is slow to render as well, but that should be addressed by use of sub-index'es as described in #50

Add <dl>, <dd> styling to markdown.tpl

The following Markdodwn

Foo
: some text
Bar
: more text

generates a HTML definition list per this extension in use ... but it doesn't look like one (given Tailwind's reset).

Allowing styling this list via the Heist template pandoc.tpl like we style, say, BlockQuote.


[This may be slightly harder, but it will make you familiarize with the Heist HTML template library]

Use BlockQuote's implementation for inspiration,

<BlockQuote>
<blockquote
class="py-0.5 px-4 italic border-l-4 bg-gray-50 text-gray-600 border-gray-400 quote">
<blocks />
</blockquote>
</BlockQuote>

B.BlockQuote bs ->
withTplTag ctx "BlockQuote" ("blocks" ## rpBlock ctx `foldMapM` bs) $
one . X.Element "blockquote" mempty <$> foldMapM (rpBlock ctx) bs

Though, footnotes list is a better source, given that we need iterate over a list,

<Note:List>
<div title="Footnotes" class="pt-2 mt-4 space-y-1 text-gray-700 transform scale-90 border-t-2">
<header class="font-semibold">Footnotes</header>
<footnote>
<div id="fn${footnote:idx}">
<header class="italic">
<footnote:idx />.
</header>
<div class="inline-block mb-2 ml-4">
<footnote:content />
</div>
</div>
</footnote>
</div>
</Note:List>

footnoteSplices :: Monad n => RenderCtx n -> Int -> [B.Block] -> H.Splices (HI.Splice n)
footnoteSplices ctx idx bs = do
let footnoteDoc = Pandoc mempty $ case bs of
[B.Para is] ->
-- Optimize for the most usual case, by discarding the paragraph,
-- which adds unnecessary styling (thus margins).
one $ B.Plain is
_ ->
bs
"footnote:idx" ## HI.textSplice (show idx)
"footnote:content" ## renderPandocWith ctx footnoteDoc

Add 'notePath' template variable

So that users can use it in their HTML templates.

This can be used to link directly to a Markdown source on GitHub (or to provide an "edit URL").

Users can also specify a template hook to inject this at a known location in the larger layout (example), without having to override the whole template.

TOC sidebar

When rendering Pandoc, provide a way to include table of contents automatically.

Inspiration / Example - https://fs.blog/mental-models/

  • Spec it out. Pandoc filter? How does Obsidian do it? etc.

Use WindiCSS in statically generated site (ideally also live-server)

Instead of twind shim (which use JS) switch to statically compiling the the CSS, using something like WindiCSS, which also gives us interesting features like more colors https://windicss.org/utilities/colors.html

Note: twind has a CLI too, https://github.com/tw-in-js/twind-cli - but I cannot get it working in Nix: srid/tailwind-nix#1

Ultimately -- once the implementation is reliably working in Emanote -- it should be upstreamed to Ema: srid/ema#20

(At minimum, we want to do this in static site; live-server would be idea; but not sure about the costs of shelling out to a nodeJS program on every http request).


Allow setting title in YAML frontmatter

Note title is inferred from,

  1. Level-1 Markdown heading if used, otherwise
  2. Filename

In addition, support title attribute from the Markdown's YAML frontmatter too, so that it overrides the above two.

Change should possibly happen here:

noteTitle :: Note -> Text
noteTitle Note {..} =
fromMaybe (R.routeBaseName . R.lmlRouteCase $ _noteRoute) $
getPandocTitle _noteDoc

Allow specifying additional notebooks in CLI

Add a way to specify additional notebook paths (they are ultimately "merged" in order).

  • Rethink Ema's -C argument (chdir behave makes no sense with multiple arguments)
  • Implement this issue

Proposed CLI:

# Does nothing; just prints --help
emanote

# Fails, because requires a path argument
emanote run

# Runs emanote live server on the given folder (the only layer)
emanote run .

# Runs emanote gen command, with the given layers in argument order
emanote gen ./.deploy/github ./

# Run emanote live server on current directory, using common themes and public notes (3 layers)
cd ~/MyPrivateNotes
emanote run ~/myemanotethemes ~/MyPublicNotes ./

Originally posted by @srid in #20 (comment)


Implementation:

Consider extending fsLayers based on the paths passed in CLI,

fsLayers <- liftIO locLayers
Mount.unionMountOnLVar
fsLayers

This may involve replacing LocUser with a LocUserProvided FilePath

-- | Location of the notebook, even if it contains a subset of files.
--
-- The order here matters. Top = higher precedence.
data Loc
= -- | This always refers to current working directory
LocUser
| -- | The location of the emanote's default files directory containing
-- templates, data, etc.
LocEmanoteDefault FilePath

Default wiki-link text should be note's title

If the note has a level-1 heading use that (over filename sans ext) as the link inner text. But do so only if level-1 heading comes as the first AST node.

(This already works for sidebar links; just not yet for pandoc links).

Of course if the user provides one explicitly (as in, [[Foo|some text]]) always use the user-provided one.

Add inline tags support

#foo in Markdown should tag that note with "foo". Equivalent to listing "foo" in "tags" field of YAML frontmatter.

Also allow a way to disable inline tags, maybe on a per-file basis. Some posts may contain excessive # in the textual context and it might be annoying to have to escape them all.

Support Math in note link titles

Requested by @bradleyharden

Basically the following note Markdown,

# $a+b^2$, a formula

Content...

Should render the Math formula wherever the note title is used (eg: in sidebar, or links).

To test this, you'll need to use either MathJax or Katex JS in here,

headHtml: |
<!-- Syntax highlighting -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism-tomorrow.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/combine/npm/[email protected]/prism.min.js,npm/[email protected]/plugins/autoloader/prism-autoloader.min.js"></script>

To implement this, see #62

Improve inline code styling

The backtick wrapped span's should be styled distinctly. Use https://jonathanlorimer.dev/posts/motivating-laziness.html as inspiration.

image

Ideally they should be consistent with code block styling (which, incidentally, is defined by prismJS in index.yaml).

Make sure that no extra padding/marging is introduced in the middle paragraph as a result of using inline code elements.


Where this change would go:

<Code class="py-0.5 bg-gray-100 text-sm" />

Duplicate footnotes when reusing the reference

If a footnote reference is used more than once, the corresponding footnote (at the bottom) will appear multiple times.

Repro,

A paragraph[^1] with footnote.

Another location[^1] reusing that footnote.

[^1]: Footnote text.

When rendered, "Footnote text" will appear twice in the footnotes list at the bottom.

--

Bug appears to arise from here:

gatherFootnotes :: Pandoc -> Footnotes
gatherFootnotes = W.query $ \case
B.Note footnote ->
[footnote]
_ ->
[]

Allow Markdown in title

Hello, I used neuron until I discovered ema today, and I have some questions, for that I will create specific discussions for each. The first one is this:

  • I sometimes use links to a footnote directly in the H1 tag on top of file, like this note:
# 202103151219 Le développement économique de la Chine a reconfiguré les inégalités au niveau mondial[^1]
#inégalités #gomart2021 

Seule l'Inde paraît en mesure de créer un résultat similaire dans le futur.

[^1]: Gomart, Thomas. 2021. _Guerres invisibles: nos prochains défis géopolitiques_. (Chapitre 4)

The problem is that this note is generated as this:

Capture d’écran 2021-06-13 à 23 19 35

The idea is to view the rendered page as something like neuron is used to do:

Capture d’écran 2021-06-13 à 23 20 13

Multiple default HTML templates (aka. themes)

Currently we have exactly one default HTML template at ./templates.

Let's move that one level down, such as to make it possible to have multiple template themes as emanote provided defaults:

  • ./templates/main/
  • ./templates/neuron/

We can "select" a template from the .yaml data. For index.yaml contains this:

template:
  # Use file "${template.name}.tpl" to render HTML
  name: templates/_default

(#26 addes the "templates/" prefix)

When implementing this I suppose we could change that to name: templates/main/_default (and may as well rename "_default.tpl" to "index.tpl" to avoid confusion). Alternative ideas?

Wiki link w/ custom text breaks lists formatting

Wiki link with alternative preview text will cause incorrect rendering in list.

Input:

- [[2021-05|202105]]
- [[2021-04|202104]]
- [[2021-03|202103]]
- [[2021-02|202102]]
- [[2021-01|202101]]

Output:

202105
- 20210
202103
- 202102
202101

image

Static site generation broken in Nix install

Regression after last PR merge,

[Info#Generate] C /nix/store/m47cxg5n63zvjdv9z4ajxa4gzz6bcydf-emanote-0.1.0.0-data/share/ghc-8.10.4/x86_64-linux-ghc-8.10.4/emanote-0.1.0.0/favicon.svg
[Info#Emanote.Source.Mount] Monitoring /nix/store/m47cxg5n63zvjdv9z4ajxa4gzz6bcydf-emanote-0.1.0.0-data/share/ghc-8.10.4/x86_64-linux-ghc-8.10.4/emanote-0.1.0.0 for changes
emanote: /nix/store/m47cxg5n63zvjdv9z4ajxa4gzz6bcydf-emanote-0.1.0.0-data/share/ghc-8.10.4/x86_64-linux-ghc-8.10.4/emanote-0.1.0.0: copyFile:atomicCopyFileContents:withReplacementFile:openBinaryTempFile: permission denied (Read-only file system)

Custom wiki-link text doesn't work if it is same as filename

  1. Create foo.md and add # Foo Title to it.
  2. In another note, link to it as [[foo]] and verify that it appears at "Foo Title".
  3. Now use a custom text, as [[foo|foo]], and notice the bug - of nothing changing.

Possible fix: compare with title instead of url in here:

if url == plainify inner -- It's a wiki-link with no custom text
then fromMaybe inner $ siteRouteDefaultInnerText r
else inner

Add highlighting Markdown extension

==Foo *bar*== should generate <mark>Foo <em>bar</em></mark>, with a corresponding pandoc.tpl node specifying how to render the <mark> node.

We would be implementing jgm/commonmark-hs#61 - but without necessarily changing pandoc AST.

  1. Find out how to approach this in Emanote (ie. with no special pandoc AST node for this syntax; see HashTag extension for reference)
  2. Implement and enable the extension by default #95

Footnotes rendering

Footnotes don't render properly right now in Emanote. Footnotes are created like this,

This is a paragraph[^1] with a citation inside.

[^]: This is a footnote.

This renders like this which is pretty ugly,

image

Getting https://edwardtufte.github.io/tufte-css/ to work would be nice.

  • Create a TailwindCSS version
  • Use it from Heist templates (markdown.tpl)
    • Might involve exposing custom tag-based customization via Pandoc splice

Open questions:

  • How would this look on mobile?

Fallback option:

If this is too difficult or complex,

  • Accumulate footnotes from Pandoc AST, and render them separately at the bottom ... like neuron does. Not as user-friendly, but it works.

Full-text search query

Now that we have #324, enable access to it from the query feature. The following,

```query
some text
```

... should list all notes containing 'some text'. Inspired by Obsidian.

See #48 (reply in thread)

We could piggyback on #338 to implement this.

Emanote live-server does not work over HTTPS

Although typically users use emanote gen to generate and serve the static content, some people just spin up emanote for its live server and expose it to the outside world through nginx with ssl certs enabled.

This wouldn't work when clicking on links due to Ema's websocket connecting to ws:/. A fix for this would go in Ema, here: srid/ema#46

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.