mirror of
https://git.sr.ht/~magic_rb/website
synced 2024-11-22 16:14:20 +01:00
Add org extra blocks support
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
9a678533ce
commit
ce02550fb5
85
flake.nix
85
flake.nix
|
@ -8,6 +8,14 @@
|
||||||
web-mode = { url = "github:fxbois/web-mode"; flake = false; };
|
web-mode = { url = "github:fxbois/web-mode"; flake = false; };
|
||||||
hcl-mode = { url = "github:purcell/emacs-hcl-mode"; flake = false; };
|
hcl-mode = { url = "github:purcell/emacs-hcl-mode"; flake = false; };
|
||||||
yaml-mode = { url = "github:yoshiki/yaml-mode"; flake = false; };
|
yaml-mode = { url = "github:yoshiki/yaml-mode"; flake = false; };
|
||||||
|
nix-mode = { url = "github:NixOS/nix-mode"; flake = false; };
|
||||||
|
magit = { url = "github:magit/magit"; flake = false; };
|
||||||
|
compat = { url = "github:emacs-straight/compat"; flake = false; };
|
||||||
|
dash = { url = "github:magnars/dash.el"; flake = false; };
|
||||||
|
s-el = { url = "github:magnars/s.el"; flake = false; };
|
||||||
|
dockerfile-mode = { url = "github:spotify/dockerfile-mode"; flake = false; };
|
||||||
|
org-special-block-extras = { url = "github:alhassy/org-special-block-extras"; flake = false; };
|
||||||
|
lf = { url = "github:alhassy/lf"; flake = false; };
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self
|
outputs = { self
|
||||||
|
@ -19,11 +27,47 @@
|
||||||
, web-mode
|
, web-mode
|
||||||
, hcl-mode
|
, hcl-mode
|
||||||
, yaml-mode
|
, yaml-mode
|
||||||
|
, nix-mode
|
||||||
|
, magit
|
||||||
|
, compat
|
||||||
|
, dash
|
||||||
|
, s-el
|
||||||
|
, dockerfile-mode
|
||||||
|
, org-special-block-extras
|
||||||
|
, lf
|
||||||
, ...
|
, ...
|
||||||
}@inputs:
|
}@inputs:
|
||||||
let
|
let
|
||||||
|
inherit (nixpkgs.lib)
|
||||||
|
genAttrs
|
||||||
|
concatMapStringsSep;
|
||||||
|
|
||||||
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
forAllSystems = f: genAttrs supportedSystems (system: f system);
|
||||||
|
packages = [
|
||||||
|
"modus-themes"
|
||||||
|
"org-thtml"
|
||||||
|
"emacs-htmlize"
|
||||||
|
"web-mode"
|
||||||
|
"hcl-mode"
|
||||||
|
"modus-themes"
|
||||||
|
"yaml-mode"
|
||||||
|
"nix-mode"
|
||||||
|
"magit"
|
||||||
|
"compat"
|
||||||
|
"dash"
|
||||||
|
"s-el"
|
||||||
|
"dockerfile-mode"
|
||||||
|
"org-special-block-extras"
|
||||||
|
"lf"
|
||||||
|
];
|
||||||
|
loadPackages = pkgs:
|
||||||
|
pkgs.writeText "packages.el"
|
||||||
|
(concatMapStringsSep "\n" (x: ''
|
||||||
|
(if (file-exists-p "${inputs.${x}}/lisp")
|
||||||
|
(add-to-list 'load-path "${inputs.${x}}/lisp")
|
||||||
|
(add-to-list 'load-path "${inputs.${x}}"))
|
||||||
|
'') packages);
|
||||||
site = pkgs: which:
|
site = pkgs: which:
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
name = which;
|
name = which;
|
||||||
|
@ -33,16 +77,13 @@
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
export TMPDIR="$(mktemp -d)" HOME=$(pwd)/tmp
|
export TMPDIR="$(mktemp -d)" HOME=$(pwd)/tmp
|
||||||
emacs -nw --fg-daemon &
|
emacs -nw --fg-daemon --debug-init &
|
||||||
|
|
||||||
timeout 10 bash -c 'until [ -e $TMPDIR/emacs$(id -u) ] ; do sleep 0.1 ; done'
|
timeout 10 bash -c 'until [ -e $TMPDIR/emacs$(id -u) ] ; do sleep 0.1 ; done'
|
||||||
|
|
||||||
emacsclient -e $'(add-to-list \'load-path "${org-thtml}")'
|
emacsclient -e $'(load-file "${loadPackages pkgs}")'
|
||||||
emacsclient -e $'(add-to-list \'load-path "${modus-themes}")'
|
|
||||||
emacsclient -e $'(add-to-list \'load-path "${emacs-htmlize}")'
|
emacsclient -e $'(add-to-list \'load-path "'"$(pwd)"'/lisp")'
|
||||||
emacsclient -e $'(add-to-list \'load-path "${web-mode}")'
|
|
||||||
emacsclient -e $'(add-to-list \'load-path "${hcl-mode}")'
|
|
||||||
emacsclient -e $'(add-to-list \'load-path "${yaml-mode}")'
|
|
||||||
|
|
||||||
emacsclient -e '(load-file "./make.el")'
|
emacsclient -e '(load-file "./make.el")'
|
||||||
emacsclient -e '(magic_rb/publish-website "${which}")'
|
emacsclient -e '(magic_rb/publish-website "${which}")'
|
||||||
|
@ -90,15 +131,23 @@
|
||||||
|
|
||||||
script = pkgs.writeText "init.el"
|
script = pkgs.writeText "init.el"
|
||||||
''
|
''
|
||||||
(add-to-list 'load-path "${modus-themes}")
|
(load-file "${loadPackages pkgs}")
|
||||||
(add-to-list 'load-path "${emacs-htmlize}")
|
|
||||||
|
(require 'nix-mode)
|
||||||
|
(require 'web-mode)
|
||||||
|
(require 'hcl-mode)
|
||||||
|
(require 'yaml-mode)
|
||||||
|
|
||||||
(require 'org)
|
(require 'org)
|
||||||
(require 'ox)
|
(require 'ox)
|
||||||
(require 'ox-html)
|
(require 'ox-html)
|
||||||
(require 'modus-themes)
|
(require 'modus-themes)
|
||||||
|
|
||||||
(load-theme 'modus-operandi t nil)
|
(defface modus-themes-cyan-subtle
|
||||||
|
'((t :inherit modus-themes-subtle-cyan))
|
||||||
|
"")
|
||||||
|
|
||||||
|
(load-theme 'modus-vivendi t nil)
|
||||||
|
|
||||||
(org-html-htmlize-generate-css)
|
(org-html-htmlize-generate-css)
|
||||||
(with-current-buffer "*html*"
|
(with-current-buffer "*html*"
|
||||||
|
@ -112,7 +161,7 @@
|
||||||
export PATH=$PATH:${pkgs.emacs}/bin
|
export PATH=$PATH:${pkgs.emacs}/bin
|
||||||
|
|
||||||
export OUTFILE="$(mktemp)" TMPDIR="$(mktemp -d)" HOME=$TMPDIR
|
export OUTFILE="$(mktemp)" TMPDIR="$(mktemp -d)" HOME=$TMPDIR
|
||||||
emacs -l ${script}
|
emacs -l ${builtins.trace "modus: ${modus-themes}" script} --debug-init
|
||||||
|
|
||||||
mv $OUTFILE ./assets/css/org.css
|
mv $OUTFILE ./assets/css/org.css
|
||||||
|
|
||||||
|
@ -123,5 +172,17 @@
|
||||||
defaultPackage = forAllSystems (system:
|
defaultPackage = forAllSystems (system:
|
||||||
self.website.${system}
|
self.website.${system}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
devShells = forAllSystems (system:
|
||||||
|
let pkgs = import nixpkgs { inherit system; };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
httplz
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
- Discord: =Magic_RB#6785=
|
- Discord: =magic_rb.#0=
|
||||||
|
- Matrix: =@magic_rb:matrix.redalder.org=
|
||||||
- PGP: =0F49 1A57 B4DF 4313 6CD4 AB6B F07E 558C D1E6 999F=
|
- PGP: =0F49 1A57 B4DF 4313 6CD4 AB6B F07E 558C D1E6 999F=
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
#+ATTR_CTAG: project
|
#+begin_card NixNG :link "https://github.com/nix-community/NixNG" :image "/icons/nix-ng-greener-no-gradient.svg"
|
||||||
#+ATTR_CLINK: https://github.com/MagicRB/NixNG
|
|
||||||
#+ATTR_CIMAGE: /icons/nix-ng-greener-no-gradient.svg
|
|
||||||
#+BEGIN_SRC fundamental
|
|
||||||
A NixOS derivative with simpler design, currently replacing systemd with runit,
|
A NixOS derivative with simpler design, currently replacing systemd with runit,
|
||||||
aiming to deliver lighter systems and containers.
|
aiming to deliver lighter systems and containers. TEST
|
||||||
#+END_SRC
|
#+end_card
|
||||||
|
|
37
lisp/extra-blocks.el
Normal file
37
lisp/extra-blocks.el
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
(require 'org-special-block-extras)
|
||||||
|
|
||||||
|
(org-defblock note
|
||||||
|
(title)
|
||||||
|
"Test"
|
||||||
|
(format
|
||||||
|
(pcase backend
|
||||||
|
(`html "<details class=\"note\">
|
||||||
|
<summary>
|
||||||
|
<i class=\"fa-regular fa-comment\"></i>
|
||||||
|
%s
|
||||||
|
</summary>
|
||||||
|
%s
|
||||||
|
</details>"))
|
||||||
|
title contents))
|
||||||
|
|
||||||
|
(org-defblock
|
||||||
|
card (name "Card" link "" image "")
|
||||||
|
"Card"
|
||||||
|
(cl-case backend
|
||||||
|
((html templated-html)
|
||||||
|
(concat
|
||||||
|
"<a class=\"card-link\" href=\"" link "\">"
|
||||||
|
" <div class=\"card-entry\">"
|
||||||
|
" <img src=\"" image "\" class=\"card-icon\"/>"
|
||||||
|
" <div class=\"card-separator\"></div>"
|
||||||
|
" <div class=\"card-body\">"
|
||||||
|
" <h4 class=\"card-heading\">" name "</h4>"
|
||||||
|
" <p class=\"card-content\">"
|
||||||
|
" " contents
|
||||||
|
" </p>"
|
||||||
|
" </div>"
|
||||||
|
" </div>"
|
||||||
|
"</a>"))
|
||||||
|
(t "ERROR")))
|
||||||
|
|
||||||
|
(provide 'extra-blocks)
|
58
make.el
58
make.el
|
@ -16,9 +16,14 @@
|
||||||
(unless (file-exists-p d)
|
(unless (file-exists-p d)
|
||||||
(make-directory d)))
|
(make-directory d)))
|
||||||
|
|
||||||
(require 'web-mode)
|
(require 'org-special-block-extras)
|
||||||
(require 'hcl-mode)
|
(add-hook #'org-mode-hook #'org-special-block-extras-mode)
|
||||||
(require 'yaml-mode)
|
|
||||||
|
(defun my-org--support-special-blocks-with-args (backend)
|
||||||
|
(let ((fbackend (if (equal backend '(templated-html)) 'html backend)))
|
||||||
|
`(,fbackend)))
|
||||||
|
(advice-add 'org--support-special-blocks-with-args :filter-args #'my-org--support-special-blocks-with-args)
|
||||||
|
|
||||||
(ignore-errors (require 'ox-thtml))
|
(ignore-errors (require 'ox-thtml))
|
||||||
|
|
||||||
;; https://alhassy.github.io/AlBasmala.html#Floating-TOC
|
;; https://alhassy.github.io/AlBasmala.html#Floating-TOC
|
||||||
|
@ -29,6 +34,8 @@
|
||||||
TOC
|
TOC
|
||||||
</a>"))
|
</a>"))
|
||||||
|
|
||||||
|
(require 'extra-blocks)
|
||||||
|
|
||||||
;; DOES NOT WORK https://github.com/alphapapa/unpackaged.el#export-to-html-with-useful-anchors
|
;; DOES NOT WORK https://github.com/alphapapa/unpackaged.el#export-to-html-with-useful-anchors
|
||||||
|
|
||||||
(setq org-export-with-sub-superscripts '{}
|
(setq org-export-with-sub-superscripts '{}
|
||||||
|
@ -41,51 +48,6 @@
|
||||||
(defvar magic_rb/asset-include
|
(defvar magic_rb/asset-include
|
||||||
"\\(ttf\\|svg\\|jpg\\|gif\\|png\\|css\\|js\\|el\\|nb\\|ipynb\\|pdf\\|xml\\)")
|
"\\(ttf\\|svg\\|jpg\\|gif\\|png\\|css\\|js\\|el\\|nb\\|ipynb\\|pdf\\|xml\\)")
|
||||||
|
|
||||||
(cl-defstruct (magic_rb/card (:constructor magic_rb/card-create)
|
|
||||||
(:copier nil))
|
|
||||||
link image description)
|
|
||||||
|
|
||||||
(defun magic_rb/cards-with-tag (tag)
|
|
||||||
(let ((symbol 'src-block)
|
|
||||||
(path buffer-file-name))
|
|
||||||
(mapcar
|
|
||||||
(lambda (object)
|
|
||||||
(magic_rb/card-create
|
|
||||||
:link (car (org-element-property :attr_clink object))
|
|
||||||
:image (car (org-element-property :attr_cimage object))
|
|
||||||
:description (org-element-property :value object)))
|
|
||||||
(with-temp-buffer
|
|
||||||
(insert-file-contents path)
|
|
||||||
|
|
||||||
(org-element-map (org-element-parse-buffer) symbol
|
|
||||||
(lambda (object)
|
|
||||||
(if (string-equal (car (org-element-property :attr_ctag object)) tag)
|
|
||||||
object
|
|
||||||
nil)) nil nil nil t)))))
|
|
||||||
|
|
||||||
(defun magic_rb/source-with-name (name symbol property)
|
|
||||||
""
|
|
||||||
(string-trim
|
|
||||||
(org-element-property
|
|
||||||
property
|
|
||||||
(car (let ((path buffer-file-name))
|
|
||||||
(with-temp-buffer
|
|
||||||
(insert-file-contents path)
|
|
||||||
(org-element-map (org-element-parse-buffer) symbol
|
|
||||||
(lambda (object)
|
|
||||||
(let ((block-name (org-element-property :name object)))
|
|
||||||
(if (string-equal block-name name)
|
|
||||||
object
|
|
||||||
nil))))))))))
|
|
||||||
|
|
||||||
;; (org-element-map (org-element-parse-buffer) 'paragraph
|
|
||||||
;; (lambda (paragraph)
|
|
||||||
;; (let ((parent (org-element-property :parent paragraph)))
|
|
||||||
;; (and (eq (org-element-type parent) 'section)
|
|
||||||
;; (let ((first-child (car (org-element-contents parent))))
|
|
||||||
;; (eq first-child paragraph))
|
|
||||||
;; ;; Return value.
|
|
||||||
;; paragraph))))
|
|
||||||
|
|
||||||
|
|
||||||
(defvar org-publish-project-alist)
|
(defvar org-publish-project-alist)
|
||||||
|
|
|
@ -10,20 +10,7 @@
|
||||||
Open Source and Mental Health
|
Open Source and Mental Health
|
||||||
</a>
|
</a>
|
||||||
<div class="card-toplevel">
|
<div class="card-toplevel">
|
||||||
{{:each (magic_rb/cards-with-tag "project")}}
|
{{contents}}
|
||||||
<a class="card-link" href="{{magic_rb/card-link item}}">
|
|
||||||
<div class="card-entry">
|
|
||||||
<img src="{{magic_rb/card-image item}}" class="card-icon"/>
|
|
||||||
<div class="card-separator"></div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h4 class="card-heading"> NixNG </h4>
|
|
||||||
<p class="card-content">
|
|
||||||
{{magic_rb/card-description item}}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
{{:endeach}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar"></div>
|
<div class="sidebar"></div>
|
||||||
|
|
Loading…
Reference in a new issue