List for cgit developers and users
 help / color / mirror / Atom feed
From: r at rkm.id.au (Ruben Maher)
Subject: [PATCH] Add about-formatting filter for org-mode.
Date: Tue, 14 Jul 2015 11:28:39 +0930	[thread overview]
Message-ID: <87wpy3jy9c.fsf@ayanami.rkm.id.au> (raw)
In-Reply-To: <878uajld7z.fsf@ayanami.rkm.id.au> (Ruben Maher's message of "Tue, 14 Jul 2015 11:20:08 +0930")

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



  reply	other threads:[~2015-07-14  1:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14  1:50 r
2015-07-14  1:58 ` r [this message]
2015-07-14 16:20 ` jamie.couture

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wpy3jy9c.fsf@ayanami.rkm.id.au \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).