Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: Support org-file parsing to hiccup content #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

the-alex
Copy link

@the-alex the-alex commented Nov 17, 2020

Opening this PR so you can see where I'm at here. Turns out there's a library that exposes an org->hiccup function -- wondrous! Sadly, it only takes a string, so I tried slurping it and realized sci doesn't support we didn't expose slurp in the injected namespaces. Ok, understood. Looks like I'll need to do it in core.clj or something.

Basically just putting this up so I have a place to talk it.

We really only need one function from this module --
`clj-org.org/parse-org`

This function takes a string and returns a map, with one key `:content`
mapping to a hiccup structure. Exactly what I need!
@the-alex the-alex changed the title feat: Support org-file parsing to hiccup content [WIP] feat: Support org-file parsing to hiccup content Nov 17, 2020
@rschmukler
Copy link
Member

I haven't tried yet, but you might be able to directly add slurp to the map on core.clj#L101.

example/site.clj Outdated
(def-asset home-page
{:path "/index.html"
:type :html
:data (page "Hello world" [:p "This is magic"])})
:data (page "Hello world" [:a {:href "/about.html"} "This is a blog link."])})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using the built in asset-path function instead of manually writing the path. Eg:

(page "Hello world" [:a {:href (asset-path about-page)} "This is a blog link"])

@the-alex
Copy link
Author

Appreciate the comments! And apologies, I think if this were anyone else's project I wouldn't have opened a WIP PR like this.

@rschmukler
Copy link
Member

I don't mind! Reminds me of the good ol' days!

This is done by calling a parse-org function, the result of composing
slurp and another function by the same name from clj-org.org. This lets
us easily call parse-org on a path in the site.clj and get the hiccup
content back.
@the-alex the-alex force-pushed the ac/support-org-asset branch from d3bac48 to b013a6f Compare November 24, 2020 20:48
@the-alex
Copy link
Author

Okay, I was giving this thought today:

The spirit of this project seems to be getting up to speed with a singe statik page as fast as possible. This means that anything adding complexity or extending functionality should be either dirt cheap at the top level, or explicitly supported as something nice in the DLS.

I will argue that consuming markup and generating an html asset from it is pretty inline with the project, so the question is how much explicitly to support it in the DSL. Adding a helper function to return the title and content of a given org file is alright, but I want to think about whether this makes sense as it's own asset type, or at least a better top-level function. One can imagine applying a directory of org files to a template function, generating the equivalent of an explicit def-assets for each one.

@the-alex the-alex requested a review from rschmukler November 24, 2020 21:14
@the-alex the-alex marked this pull request as draft November 24, 2020 21:14
@rschmukler
Copy link
Member

Sorry on the delay on this. The parse-org function looks good. I would look into also adding tree-seq which would allow someone to grab all the files in a provided directory path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants