Add Readme.org & customizations for render-link & taxonomy

This commit is contained in:
constantinos 2024-12-20 12:15:23 +02:00
parent 7580d64fb7
commit 01780aab50
3 changed files with 230 additions and 0 deletions

View file

@ -0,0 +1,38 @@
{{- $text_link := .Text -}}
{{- $sup := "" -}} <!-- prefix for links -->
{{ $_ := newScratch }} <!-- Get triads -->
{{- range $k, $v := .Page.Site.Data.sandpointsnamegraph -}}
{{ $_.Add "triads" $k }}
{{- end -}}
<!-- TODO add URLs to scratch -->
<!-- Internal links to MD files (.md suffix) -->
{{ if strings.HasSuffix .Destination ".md" }}
{{ if in ($_.Get "triads") (index (split .Destination "/") 0) }}
<!-- Obsidian replaces filename spaces with '%20'. For Hugo we replace that with "-" -->
{{ $destNoSpaces := strings.Replace .Destination "%20" "-" }}
<!-- if page exists -->
<!--TODO check for links to subheadings #-->
{{ if $.Page.Site.GetPage $destNoSpaces }}
{{ $session := $.Page.Site.GetPage $destNoSpaces }}
{{ .Page.Scratch.Add "links" (slice $session) }}
<a class="triadlink" repoid="{{- $session.File.UniqueID -}}" printhref="#ph-{{- $session.File.UniqueID -}}" href="{{- $session.RelPermalink -}}{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}"{{- with .Title}} title="{{- . -}}"{{- end -}}><span class="sup">{{- index (split $destNoSpaces "/") 0 -}}</span>{{- $text_link -}}</a>
{{ else }}
<highlight>MD ENTRY DOES NOT EXIST: {{ .Destination }}</highlight>
{{ end }}
{{ else }}
<highlight>TRIAD DOES NOT EXIST: {{ .Destination }}</highlight>
{{ end }}<!-- END is in Triads -->
{{ else }} <!-- END MD suffix -->
<!-- HTTP LINKS -->
{{ if strings.HasPrefix .Destination "http" }}
{{ $sup = "www" }}
<!-- TODO add classes -->
<!-- Subheadings LINKS (starting with #) -->
{{ else if strings.HasPrefix .Destination "#" }}
{{ $sup = "§" }}
<!-- TODO add CLASSES -->
{{ end }}
<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}><span class="sup">{{ $sup }}</span>LINK</a>
{{ end }}

View file

@ -0,0 +1,23 @@
{{/*
ANY EDIT
(07.11.23) - Removed Author and Date from Keyword taxonomy list (/keywords/). Pages provided by reverse date
(01.11.24) - Pages in Keyword list sorted in alphabetic order (not .ByDate.Reverse, but .ByTitle)
*/}}
{{ define "keywords" }}
{{ $p := split (trim .RelPermalink "/") "/" }}
{{ if eq (len $p) 1 }}
<div class="coretitle"><span class="supt">{{ index $p 0 }}</span>All</div>
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
{{ if eq (index $p 0) $taxonomyname }}
{{ range $key, $value := $taxonomy }}
<span> <a href="/{{ index $p 0 }}/{{ $key }}/{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ $key }}</a>({{ len (index (index $.Site.Taxonomies $taxonomyname) $key) }})</span>
{{ end }}
{{ end }}
{{ end }}
{{ else }}
<div class="coretitle"><span class="supt">{{ index $p 0 }}</span>{{ index $p 1 }}</div>
{{ range .Pages.ByTitle }}
<div class="blog-title"><a href="{{ .RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ .Title }}</a></div>
{{ end }}
{{ end }}
{{ end }}

169
readme.org Normal file
View file

@ -0,0 +1,169 @@
#+title: Readme
* Introduction
This repository is a guide for installing and using Sandpoints in tandem with Obsidian.
Sandpoints is a free software
* Installation Instructions
Follow the [[https://gohugo.io/getting-started/quick-start/][Hugo Quick Start guide]].
After installing Hugo, open a terminal and do:
#+begin_src bash
hugo new site mysite
cd mysite
git init
git submodule add https://dev.sandpoints.org/Drawwell/SandpointsTheme themes/sandpoints
#+end_src
The above will start a new blank side; start a git repository; and install the Sandpoints theme as a submodule.
Next we need to tell the project configuration to use the sandpoints theme:
Open =hugo.toml= and add
#+begin_src toml
theme="sandpoints"
#+end_src
Then, we can go again and start a local server to run and view the site:
#+begin_src toml
hugo server
#+end_src
** Project config: Sandpoints version
At the moment Sandpoints works properly with Hugo version 0.113 --errors have to do with library references and endnote numbering for Print PDFs.
Download [[https://github.com/gohugoio/hugo/releases/tag/v0.113.0][Hugo version 0.113 (GitHub)]].
Place the Hugo executable (=hugo.exe=, or =hugo.bin=, etc.) on the root folder of your project, and rename to, for example, =hugo-113.exe=.
To then run a local server or compile the site do:
#+begin_src bash
hugo-113.exe server
#+end_src
or
#+begin_src bash
hugo-113.exe
#+end_src
* Setup Sandpoints project
** Site config file
*** Enable keywords
Add keyword taxonomy to =hugo.toml=
and enable relative urls
#+begin_src TOML
# Relative URLS
relativeurls = true
# Taxonomy: keyword = "keywords"
[taxonomies]
keyword = "keywords"
#+end_src
*** Setup metadata
#+begin_src TOML
[params]
# Project description
description = "Project description"
## sandpointsHome renders link to predefined home if page not in triad
sandpointsHome = "package/stc.md"
# Enable backlinks for content types
sandpointsMentionedIn = ["annex", "author", "section" ,"item", "thing", "person"]
# sandpointsGiteaUrl = "https://git.sandpoints.org/we/da-component.git" # used in layouts/partials/header.html to generate links in /Preview/ UI
sandpointsCatalogPrefix = "/library/"
sandpointsCatalogName = "custom-sandpoints-project-name"
#+end_src
** Enable URLS
Create =urls/_index.md=
Open the file and add
#+begin_src Markdown
---
title: "List of Urls"
---
#+end_src
Now the site =/urls/= shows a list of internal, outgoing, and bibliographic, links, as well as backlinks.
** Prepare print directory
Crate =print/_index.md=.
Open the file and add
#+begin_src Markdown
---
title: "List of Print Items"
---
#+end_src
* Create content
Create a new entry with
#+begin_src toml
hugo new entry/entry.md
#+end_src
This will be created according to [[#archetypes][archetypes]].
* Archetypes
:PROPERTIES:
:CUSTOM_ID: archetypes
:ID: 8f382044-aeeb-4022-ac35-f7fc88d2a880
:END:
Project archetypes directory at [[file:archetypes/][/archetypes/]].
Theme archetypes directory at [[file:themes/sandpoints/archetypes/][/themes/sandpoints/archetypes/]].
* Sandpoints-Obsidian workflow
** Setup Obsidian
Open the project's =content/= directory as a Vault using Obsidian
Go to settings and:
+ *DISABLE* Wiki links
+ Set New Link Format to *Absolute path in vault*
** Customize Sandpoints theme for Obsidian
By default Sandpoints recognizes internal links in the form of
#+begin_src Markdown
![Link label](type/filename)
#+end_src
or
#+begin_src Markdown
![](type/filename)
#+end_src
In which case the link label is populated dynamically.
Using Obsidian with standard Markdown links (instead of Wiki-type links), internal links would be of the type
#+begin_src Markdown
[Link label](type/filename.md)
#+end_src
Moreover, Obsidian allows spaces in the filenames of notes (e.g. =my note.md=), and replaces space characters with =%20= (as in =my%20note.md=).
*** Create override for render-link.html
Copy =render-link= from theme/layouts
[[file:themes/sandpoints/layouts/_default/_markup/render-link.html]]
to the corresponding directory inside layouts, at the root of the project:
[[file:layouts/_default/_markup/render-link.html]]
This overrides the theme's =render-link= behavior.
*** Edit custom render-link.html
1. Add clause to replace =%20= with =-= (dash).
* Other Sandpoints theme edits
** Edit keyword view (layouts/taxonomy/list)
By default, =/keywords= lists keywords together by creation date, sorted by creation date.
This is edited in [[file:layouts/taxonomy/list.html][/layouts/taxonomy/list.html]] to remove the mention of the creation date, and sort entries alphabetically.