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

Images and other files support #15

Open
geeklhem opened this issue Oct 20, 2018 · 3 comments
Open

Images and other files support #15

geeklhem opened this issue Oct 20, 2018 · 3 comments

Comments

@geeklhem
Copy link

Right now when I add an image in a post via org-mode markup:

#+name: Drawing
#+caption: Test figure
[[file:drawing.svg]]

I get:

<figure id="org25aec15">
<object type="image/svg+xml" data="drawing.svg" class="org-svg">
Sorry, your browser does not support SVG.</object>

<figcaption><span class="figure-number">Figure 1: </span>Test figure</figcaption>
</figure>

Which is... broken because the path is relative to org-static-blog-posts-directory and not org-static-blog-publish-directory.

I do not want to write my blog post with relative links to org-static-blog-publish-directory because it would break the file search to insert files as well as image previews.

A simple way to solve this (by no mean the only one nor the best) would be to copy (or link ?) files from org-static-blog-post-directory to org-static-blog-publish-directory if they match a given patttern (*.png, *.jpg, *.svg... we make the exact pattern a customize option).

What do you think ?

@bastibe
Copy link
Owner

bastibe commented Oct 21, 2018

This is tough, since org-static-blog currently does not care about static files at all. I usually use relative paths, and don't care about them being broken in org-mode.

Maybe we should add an org-static-blog-assets-directory, and auto-copy linked files there on export? I am not sure about the best way to proceed, either.

Or maybe it would be best to just handle this locally, by symlinking your assets directory into both, the posts directory and the publish directory. This should work, and would not require a change in org-static-blog.

@neeasade
Copy link
Contributor

neeasade commented Mar 9, 2019

Or maybe it would be best to just handle this locally, by symlinking your assets directory into both, the posts directory and the publish directory. This should work, and would not require a change in org-static-blog

currently what I'm doing FWIW

@justinabrahms
Copy link
Contributor

If someone runs into this w/ static files that need copying, this is what I'm doing.

I have a few things like css files, favicons, etc that I need moved. The tangle of the main emacs.org will output my blog settings as elisp as well as some static files (like css). Then I use that to actually do the publish.

help:
	@echo "You want to pick one of the options. publish or tangle"

tangle:
	emacs --no-init-file --batch \
                --eval "(require 'package)"\
                --eval "(add-to-list 'package-archives '(\"melpa\" . \"http://melpa.org/packages/\") t)"\
                --eval "(package-initialize)"\
                --eval "(package-refresh-contents nil)"\
                --eval "(package-install 'org)"\
                --eval "(package-install 'lua-mode)" \
                --eval "(package-install 'toml-mode)" \
                --eval '(setq comment-start "#")' \
                --eval "(require 'org)" \
                --eval "(require 'lua-mode)" \
                --eval "(require 'toml-mode)" \
                --eval '(org-babel-tangle-file "./_posts/dotfiles/emacs.org")'

publish: tangle
	emacs --batch --no-init-file \
		--eval "(setq blog-root \"`pwd`\")" \
		--load ~/.config/emacs/static-blog.el  \
		--eval '(message "publishing...")' \
		--eval '(org-static-blog-publish t)' \
		--eval '(message "...done")'
	./copy-static-dirs.sh

copy-static-dirs.sh

#!/usr/bin/env bash
set -x
# Used to copy files over to the blog publishing location b/c org-static-blog
# doesn't support static blog-specific files

PUBLISH_DIR=$(emacs --batch --no-init-file --load ~/.config/emacs/static-blog.el --eval "(princ org-static-blog-publish-directory)" 2>/dev/null)
cp -vR ./static/ $PUBLISH_DIR/

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

No branches or pull requests

4 participants