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

"edit this page" links #176

Closed
wants to merge 2 commits into from
Closed

"edit this page" links #176

wants to merge 2 commits into from

Conversation

edrex
Copy link
Contributor

@edrex edrex commented Oct 14, 2021

Implements an "Edit this page" link, a common feature for file-based static site gens.

I thought it would be good for me to start learning the template/view
end of the codebase so I can help myself more.

It's incomplete, but I wanted to get feedback.

Issues

  • Rather than choosing our own key (I used site.editBaseUrl) find
    what other tools use and follow/boost convention.
    Results: looking at hugo (not builtin) mkdocs.yml (concat repo_url with edit_uri), and mdbook (edit-url-template in TOML), there doesn't seem to be a convention.
  • I just dropped the link in the footer without thinking about it
    much. Where should it appear? Structurally, should it be in its own template?
  • Needs svg edit icon data. I borrowed the breadcrumb data. @srid what's
    your process for generating these?
  • I want to make this template contingent on a non-empty baseUrl meta key, but didn't see how to do that. Seems like Heist wants conditionals in Haskell, so I guess that requires some extra rendering logic?

@srid
Copy link
Owner

srid commented Oct 14, 2021

Quick response:

You can get svg icons from https://heroicons.com/

If the user doesn't specify editUrl in the yaml, I think we should just not show the edit link at all (no need for the default "edit/" hack, which wouldn't work anyway?). Heist is not great at handling optional values (see snapframework/heist#128 ) - but I wonder if we can workaround that by using lists and <with> (see how tags are rendered).

@srid
Copy link
Owner

srid commented Oct 15, 2021

I want to make this template contingent on a non-empty baseUrl meta key,

Under what situation would someone even want to do that? What I mean is: if you use /edit as editBaseUrl, and concatenate baseUrl with the editBaseUrl - you will have mysite.com/edit/... - but since Emanote generated website includes no folder "edit" it wouldn't work anyway.

@edrex
Copy link
Contributor Author

edrex commented Oct 15, 2021

I meant "nonempty editBaseUrl". Yeah the /edit path isn't useful; i put it in as a placeholder until i figure out how to omit the edit link from the output in case editBaseUrl isn't set.

@edrex
Copy link
Contributor Author

edrex commented Oct 15, 2021

I'm not sure when I'm going to have time to dig in to figure out the empty-editBaseUrl case, so feel free to finish this, otherwise I'll come back to it next week or so.

@srid
Copy link
Owner

srid commented Oct 19, 2021

By the way, @edrex, do you know there is a way to achieve what you are doing here but without changing Emanote itself? Basically add your template to templates/components/footer.tpl of your notebook, and it will be used automatically instead of the Emanote default note. The template system + layers is not documented, but see here: #131

(You can just hardcode stuff in your .tpl; and no need to define any special .yml attribute)

@edrex
Copy link
Contributor Author

edrex commented Oct 19, 2021

yeah, i just wanted to contribute something useful. I almost got this going yesterday, just needed to coax lookupAeson to return a Maybe

@srid
Copy link
Owner

srid commented Nov 28, 2021

@edrex I'm closing this in favour of #201 .. checkout the diff to see how you can use it on your notebook.

@srid srid closed this Nov 28, 2021
@RoyiAvital
Copy link

RoyiAvital commented Jun 18, 2022

This doesn't appear on the default yaml: https://github.com/srid/emanote/blob/master/default/index.yaml. Can you add an example?

Currently the EmaNote template makes the links go to the EmaNote repository.

Update: It seems to be part of after-note.tpl. I find it much less friendly.

@srid
Copy link
Owner

srid commented Jun 19, 2022

Update: It seems to be part of after-note.tpl. I find it much less friendly.

You have just discovered the undocumented HTML templating system (a powerful feature that neuron doesn't support), which allows you to override/customize any of HTML/CSS that Emanote generates. It works this way: look for any folder/file under https://github.com/srid/emanote/tree/master/default and copy it to your notebook, then make modifications.

emanote-template does it for https://github.com/srid/emanote/blob/master/default/templates/hooks/after-note.tpl - which is empty by default. It gets included here: https://github.com/srid/emanote/blob/master/default/templates/components/note-body.tpl#L4

@srid
Copy link
Owner

srid commented Jun 19, 2022

These sites make use of HTML templating:

https://blog.hemera.systems/ (view source)
https://ners.ch/ (view source)

@RoyiAvital
Copy link

The template system is amazing.
But I think that the editing base URL should be a parameter in the YAML which is used by the template.

@srid
Copy link
Owner

srid commented Jun 19, 2022

That's a good idea. Done in srid/emanote-template@8d75688

@edrex
Copy link
Contributor Author

edrex commented Jun 19, 2022

Nice, I need to get my public site up to exercise all this (still need to scrub private stuff, almost there). IIRC when I was looking at this there was some code forge whose edit URLs didn't have the form |{editBaseUrl}/{note:sourcePath}, but checking now at least Gitea (codeberg) and Gitlab do, so the complexity of making editUrl some sort of template string doesn't seem warranted.

@edrex edrex deleted the edit-link branch June 19, 2022 18:07
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.

3 participants