From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: change JS & CSS paths when publishing? Date: Thu, 13 Mar 2014 23:01:17 -0400 Message-ID: References: <87wqfyozvm.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOIN5-0006fK-G6 for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 23:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOIN4-0006tn-9H for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 23:01:19 -0400 Received: from mail-qg0-x22a.google.com ([2607:f8b0:400d:c04::22a]:32901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOIN4-0006tD-2K for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 23:01:18 -0400 Received: by mail-qg0-f42.google.com with SMTP id q107so5709485qgd.1 for ; Thu, 13 Mar 2014 20:01:17 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode Ooops, forgot to send to the list! Forwarding my last reply to Bastien, and then answering my own question below, sort of: On Thu, Mar 13, 2014 at 1:29 PM, Matt Price wrote: > On Thu, Mar 13, 2014 at 11:57 AM, Bastien wrote: >> Hi Matt, >> >> Matt Price writes: >> >>> I would like to provide those lectures on the web for my students. >>> (Ideally, in fact, I would like to provide a couple of versions of >>> each lecture: one deck slideshow, one plain html, and maybe one pdf >>> or odt version.) Howver, the deck publish ocmmand writes paths to the >>> local copies of deck's css and js files. I would like to rewrite these >>> paths in the published files, to use the version of deck on my server >>> instead. >> >> IIUC, you can use something like this in your file: >> >> #+DECK_BASE_URL: http://some/server/url.js > > I would like to use the local copies of the deck.js files when I > simply export to deck; but server copies when I publish. So I think I > would need a simple function like this that modifies the buffer before > (or, I guess after!) it gets written to a *published* (but not > *exported*) file: > > > (defun mwp-update-published-paths () > (interactive) > (let ((case-fold-search t)) > (goto-char (point-min)) > (while (search-forward "/home/matt/src/deck.js" nil t) > (replace-match "http://sandbox.hackinghistory.ca/Tools/deck.js" t t)))) > > > I just am not quite sure how and when to run it, and what argument to > pass it (like, can I do normal buffer operations, or do I need to > operate on the file contents as a string or something?). > I found an easy way around my problem, by writing my own trivial publishing function: ----------------------- (defun mwp-org-deck-publish-to-html (plist filename pub-dir) "Publish an org file to deck.js HTML Presentation. FILENAME is the filename of the Org file to be published. PLIST is the property list for the given project. PUB-DIR is the publishing directory. Returns output file name." (let ((org-deck-base-url "http://sandbox.hackinghistory.ca/Tools/deck.js/")) (org-publish-org-to 'deck filename ".html" plist pub-dir)) ) ----------------------- Then I just set :org-publishing-function to mwp-org-deck-publish-to-html, and I'm all set. There are doubtless more elegant ways to do this but this will do for now. Now I just need to figure out a better way to manage images -- I like to keep them all in the same place, and I need to keep my course lectures in different directories, so it would be nice to be able to use absolute file links. But there's probably a way around that as well. For now I'm pretty happy! Thanks again, matt >> >> -- >> Bastien