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

Add support for publishing org-roam file nodes via :input-source #57

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
15 changes: 15 additions & 0 deletions examples/org-roam/.emacs/straight/versions/default.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(("dash.el" . "da167c51e9fd167a48d06c7c0ee8e3ac7abd9718")
("el-get" . "960f3fb962c35d3196bab20b2a3f6d6228119277")
("emacsmirror-mirror" . "482c86b64ed225212475c7e65102b2c860a949cf")
("emacsql" . "9dca5996168c4963eb67e61c7f17fdcb8228e314")
("f.el" . "50af874cd19042f17c8686813d52569b1025c76a")
("gnu-elpa-mirror" . "98cfebcc05fd018121d943916e9d86189125e3d2")
("magit" . "1eb183e7672bf25fa77ea06d97b3d9c502a698ae")
("melpa" . "e75a21c91d8aa1a07ba274b56fe8cf96119f22a4")
("org" . "8908fba11334190c1a344159273320c5b2358b9e")
("org-roam" . "7068d63e966c0ca8d098ac4f7a90434f4c9b6822")
("s.el" . "08661efb075d1c6b4fa812184c1e5e90c08795a9")
("straight.el" . "af5437f2afd00936c883124d6d3098721c2d306c")
("templatel" . "b52349948b6927f7a5da4e54a89e01c794f2095a")
("use-package" . "a7422fb8ab1baee19adb2717b5b47b9c3812a84c"))
:beta
8 changes: 8 additions & 0 deletions examples/org-roam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
org-id-locations
org-roam.db
.emacs/*
!.emacs/straight
.emacs/straight/*
!.emacs/straight/versions
.emacs/straight/versions/*
!.emacs/straight/versions/default.el
51 changes: 51 additions & 0 deletions examples/org-roam/init.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
;;; init.el --- Initialize emacs environment
;;; Commentary:
;;
;; Installation and configuration and dependent packages.
;;
;;; Code:

(setq user-emacs-directory (expand-file-name ".emacs"))

;; Boostrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))

;; Bootstrap use-package.
(straight-use-package 'use-package)

(use-package org
:straight t
:config
;; This is not necessary and is only used for this example to avoid polluting
;; the local user's id locations file with the org files from this example.
(setq org-id-locations-file (expand-file-name "./org-id-locations")))
(use-package org-roam
:straight t
:after org
:init
(setq org-roam-v2-ack t)
:config
(setq org-roam-directory (expand-file-name "./org")
org-roam-file-extensions '("org")
;; This is not necessary and is only used for this example to avoid
;; polluting the local user's org-roam db with the org files from this
;; example.
org-roam-db-location (expand-file-name "./org-roam.db")))

(use-package templatel :straight t)

(add-to-list 'load-path "../../")
(require 'weblorg)
(require 'weblorg-org-roam)
;;; init.el ends here
7 changes: 7 additions & 0 deletions examples/org-roam/org/private.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:PROPERTIES:
:ID: 8de1fa5e-7fed-4893-b7d1-0a2ca1c49840
:END:
#+title: Private
#+filetags: :private:

This is a private note that should not be published.
7 changes: 7 additions & 0 deletions examples/org-roam/org/public_1.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:PROPERTIES:
:ID: ff7ef0a2-8988-4634-b7fa-40664c3da8e4
:END:
#+title: Public 1
#+filetags: :public:

This is public note #1.
9 changes: 9 additions & 0 deletions examples/org-roam/org/public_2.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:PROPERTIES:
:ID: a850226a-01fc-4b14-abdd-525e93906090
:END:
#+title: Public 2
#+filetags: :public:

This is public note #2.

Link to [[id:ff7ef0a2-8988-4634-b7fa-40664c3da8e4][Public 1]].
29 changes: 29 additions & 0 deletions examples/org-roam/output/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en-ca">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example org-roam site</title>
</head>


<body>
<main>


<h1>Org Notes</h1>
<ul>

<li>
[2021-12-12] <a href="http://localhost:8000/public-1/">Public 1</a>
</li>

<li>
[2021-12-12] <a href="http://localhost:8000/public-2/">Public 2</a>
</li>

</ul>

</main>
</body>
44 changes: 44 additions & 0 deletions examples/org-roam/output/public-1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en-ca">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Public 1</title>
</head>


<body>
<main>

<h1 class="title">Public 1</h1>
<div class="meta">
<span class="mtime">2021-12-12</span>
<ul class="filetags">

<li>public</li>

</ul>
</div>

<p>
This is public note #1.
</p>



<section class="org-roam-backlinks">
<h2>Backlinks</h2>
<ul>

<li>
<a href="http://localhost:8000/public-2/">Public 2</a>
</li>

</ul>
</section>



</main>
</body>
37 changes: 37 additions & 0 deletions examples/org-roam/output/public-2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en-ca">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Public 2</title>
</head>


<body>
<main>

<h1 class="title">Public 2</h1>
<div class="meta">
<span class="mtime">2021-12-12</span>
<ul class="filetags">

<li>public</li>

</ul>
</div>

<p>
This is public note #2.
</p>

<p>
Link to <a href="http://localhost:8000/public-1/">Public 1</a>.
</p>





</main>
</body>
35 changes: 35 additions & 0 deletions examples/org-roam/publish.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;; publish.el --- Export org roam file nodes
;;; Commentary:
;;
;; Example configuration for generating a static site from org-roam file nodes.
;;
;;; Code:

(add-to-list 'load-path ".")
(load "init")

(org-roam-db-sync)

(let* ((site (weblorg-site
:default-route "org-nodes"
:theme nil))
(org-roam-nodes-filter (lambda (node)
(member "public" (org-roam-node-tags node)))))
(weblorg-route
:name "index"
:input-source (lambda () (weblorg-input-source-org-roam-nodes-agg org-roam-nodes-filter))
:template "index.html"
:output "output/index.html"
:url "/"
:site site)
(weblorg-route
:name "org-nodes"
:input-source (lambda () (weblorg-input-source-org-roam-nodes org-roam-nodes-filter))
:template "org-node.html"
:output "output/{{ slug }}/index.html"
:url "/{{ slug }}/"
:site site)

(setq debug-on-error t)
(weblorg-export))
;;; publish.el ends here
15 changes: 15 additions & 0 deletions examples/org-roam/theme/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "layout.html" %}

{% block title %}Example org-roam site{% endblock %}

{% block main %}

<h1>Org Notes</h1>
<ul>
{% for node in nodes %}
<li>
[{{ node.mtime | strftime("%Y-%m-%d") }}] <a href="{{ url_for("org-nodes", slug=node.slug) }}">{{ node.title }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}
15 changes: 15 additions & 0 deletions examples/org-roam/theme/templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en-ca">
{% block head %}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{{ title }}{% endblock %}</title>
</head>
{% endblock %}

<body>
<main>
{% block main %}{% endblock %}
</main>
</body>
31 changes: 31 additions & 0 deletions examples/org-roam/theme/templates/org-node.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends "layout.html" %}

{% block title %}{{ node.title }}{% endblock %}

{% block main %}
<h1 class="title">{{ node.title }}</h1>
<div class="meta">
<span class="mtime">{{ node.mtime | strftime("%Y-%m-%d") }}</span>
<ul class="filetags">
{% for tag in node.tags %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
</div>

{{ node.html | safe }}

{% if node.backlinks %}
<section class="org-roam-backlinks">
<h2>Backlinks</h2>
<ul>
{% for link in node.backlinks %}
<li>
<a href="{{ url_for("org-nodes", slug=link.slug) }}">{{ link.title }}</a>
</li>
{% endfor %}
</ul>
</section>
{% endif %}

{% endblock %}
Loading
Loading