* [PATCH] Add about-formatting filter for org-mode.
@ 2015-07-14 1:50 r
2015-07-14 1:58 ` r
2015-07-14 16:20 ` jamie.couture
0 siblings, 2 replies; 3+ messages in thread
From: r @ 2015-07-14 1:50 UTC (permalink / raw)
Hi list, I have two patches for your consideration.
The first just adds an about-filter for .org files.
It depends on Emacs and Org-mode[0].
I may have formatted this mail correctly. Please let me know otherwise.
Kind regards,
Ruben
[0] http://orgmode.org/
---
filters/about-formatting.sh | 1 +
filters/html-converters/org2html | 2 ++
filters/html-converters/resources/org2html.el | 43 +++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100755 filters/html-converters/org2html
create mode 100755 filters/html-converters/resources/org2html.el
diff --git a/filters/about-formatting.sh b/filters/about-formatting.sh
index d024204..5801d8e 100755
--- a/filters/about-formatting.sh
+++ b/filters/about-formatting.sh
@@ -21,6 +21,7 @@ cd "$(dirname $0)/html-converters/"
case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in
*.markdown|*.mdown|*.md|*.mkd) exec ./md2html; ;;
*.rst) exec ./rst2html; ;;
+ *.org) exec ./org2html; ;;
*.[1-9]) exec ./man2html; ;;
*.htm|*.html) exec cat; ;;
*.txt|*) exec ./txt2html; ;;
diff --git a/filters/html-converters/org2html b/filters/html-converters/org2html
new file mode 100755
index 0000000..62fd136
--- /dev/null
+++ b/filters/html-converters/org2html
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec "$(dirname "$0")/resources/org2html.el" 2>/dev/null
diff --git a/filters/html-converters/resources/org2html.el b/filters/html-converters/resources/org2html.el
new file mode 100755
index 0000000..8cac096
--- /dev/null
+++ b/filters/html-converters/resources/org2html.el
@@ -0,0 +1,43 @@
+#!/usr/bin/emacs --script
+;;; org2html.el ---
+
+;; Copyright (C) 2015 Ruben Maher <r at rkm.id.au>
+
+;; Author: Ruben Maher <r at rkm.id.au>
+;; Keywords: tools
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License
+;; as published by the Free Software Foundation; either version 3
+;; of the License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Read an org file from stdin, convert it to html, and dump it on stdout.
+;; You need a recent version of org-mode's htmlize if you want source code
+;; highlighting in font blocks. Requires Emacs and Org-mode.
+;; Example usage: ./org2html.el < README.org 2>/dev/null
+
+;;; Code:
+
+(require 'org)
+
+(condition-case nil
+ (let (line)
+ (with-output-to-temp-buffer "*org2html*"
+ (set-buffer-file-coding-system 'utf-8)
+ (while (setq line (read-from-minibuffer ""))
+ (princ (concat line "\n")))))
+ (error nil))
+
+(when (get-buffer "*org2html*")
+ (set-buffer "*org2html*")
+ (princ (org-export-as 'html nil t t)))
--
2.4.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Add about-formatting filter for org-mode.
2015-07-14 1:50 [PATCH] Add about-formatting filter for org-mode r
@ 2015-07-14 1:58 ` r
2015-07-14 16:20 ` jamie.couture
1 sibling, 0 replies; 3+ messages in thread
From: r @ 2015-07-14 1:58 UTC (permalink / raw)
The second patch adds a regex to the filter replacing links to binary
blobs in org files. I've included it as a separate patch because I'm
not sure if it is considered desirable here.
You can see it in action here[0] and here[1], for each repo the .org
file is in the repository along with the screenshot.
Sometimes repositories on Github have a screenshot checked in and linked
to from the about page. If there is such a link found in the org file,
replace it with the path to the resource being hosted by cgit.
Org image links look like this: [[./something.png]]
This regex will find matches and replace the "./" with a URL constructed
from $HTTPS, $HTTP_HOST and $CGIT_REPO_URL.
Thanks for your work on cgit.
Kind regards,
Ruben
[0] https://code.rkm.id.au/websockets-fighter/about/
[1] https://code.rkm.id.au/circe-notifications/about/
---
filters/html-converters/resources/org2html.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/filters/html-converters/resources/org2html.el b/filters/html-converters/resources/org2html.el
index 8cac096..5fcd6bf 100755
--- a/filters/html-converters/resources/org2html.el
+++ b/filters/html-converters/resources/org2html.el
@@ -40,4 +40,10 @@
(when (get-buffer "*org2html*")
(set-buffer "*org2html*")
+ (goto-char (point-min))
+ (replace-regexp
+ "\\[\\[\\.\\/\\([^.]+\\)\\.\\(\\w+\\)\\]\\]"
+ (concat "[[" (if (string-equal "on" (getenv "HTTPS")) "https://" "http://")
+ (getenv "HTTP_HOST") "/" (getenv "CGIT_REPO_URL")
+ "/plain/\\1.\\2]]"))
(princ (org-export-as 'html nil t t)))
--
2.4.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Add about-formatting filter for org-mode.
2015-07-14 1:50 [PATCH] Add about-formatting filter for org-mode r
2015-07-14 1:58 ` r
@ 2015-07-14 16:20 ` jamie.couture
1 sibling, 0 replies; 3+ messages in thread
From: jamie.couture @ 2015-07-14 16:20 UTC (permalink / raw)
On Tue, Jul 14, 2015 at 11:20:08AM +0930, Ruben Maher wrote:
> Hi list, I have two patches for your consideration.
>
> The first just adds an about-filter for .org files.
>
> It depends on Emacs and Org-mode[0].
>
> I may have formatted this mail correctly. Please let me know otherwise.
>
> Kind regards,
>
> Ruben
>
> [0] http://orgmode.org/
Had do play with the patch a bit to apply it. But managed to get it
running.
Would be best to use git-format-patch / git-send-email.
Jason can decide to squash it all, if he prefers, and fixup the commit
messages.
I think it would also help to update the cgitrc5.txt as well, in case anyone
wants to include this, they would also need to update their cgitrc.
-- 8< --
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index e21ece9..add40ef 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -861,6 +861,8 @@ readme=:README.htm
readme=:readme.htm
readme=:README.txt
readme=:readme.txt
+readme=:README.org
+readme=:readme.org
readme=:README
readme=:readme
readme=:INSTALL.md
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-14 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 1:50 [PATCH] Add about-formatting filter for org-mode r
2015-07-14 1:58 ` r
2015-07-14 16:20 ` jamie.couture
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).