emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Francesco Pizzolante <fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
To: Eric Schulte <schulte.eric-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: mailing-list-org-mode <emacs-orgmode-mXXj517/zsQ@public.gmane.org>
Subject: Re: Blorgit > SVN integration
Date: Thu, 19 Nov 2009 11:06:55 +0100	[thread overview]
Message-ID: <87fx8asu9s.fsf@missioncriticalit.com> (raw)
In-Reply-To: <m2r5s2gvyc.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> (Eric Schulte's message of "Fri, 13 Nov 2009 10:45:31 -0700")

Hi Eric,

First of all, I thank you very much for your useful tips.

Thanks to you, I think I've made a step forward. Here's how.


>> 1) Is it possible to integrate Blorgit with SVN instead of git? If yes, how
>>    can I do it?
>
> Yes, it should be possible to use any version control backend, the only
> command that will not work with svn is the option to automatically
> commit any edits to the git repository, however changing this command
> should be straightforward.  You should just have to make a change in
> backend/blog.rb line 15.

This is what I've added to blog.rb:

--8<---------------cut here---------------start------------->8---
diff --git a/backend/blog.rb b/backend/blog.rb
index 0f43728..827ec05 100644
--- a/backend/blog.rb
+++ b/backend/blog.rb
@@ -17,6 +17,20 @@ class Blog < ActiveFile::Base
     end
   end

+  # if the svn_commit option is set then add a hook to automatically
+  # commit any changes from the web interface to svn.
+  if $global_config[:config]['svn_commit']
+    puts "adding svn commit hooks Blog.after_save"
+
+    add_hooks(:save)
+
+    def after_save
+      Dir.chdir(Blog.base_directory) do
+        %x{svn add #{self.path} && svn ci -m "#{self.path} updated through the web interface" #{self.path}}
+      end
+    end
+  end
+
   def self.files(path)
     base = (File.directory?(self.expand(path)) ? self.expand(path) : File.dirname(self.expand(path)))
     self.entries(path).
--8<---------------cut here---------------end--------------->8---

You simply need to add the "svn_commit: true" options to the blorgit.yml
config file and make your blogs directory a SVN working copy for this to work.

I do a "svn add" (in case this is a new file) followed by an "svn commit".

This works very well.

One little question: is it possible to add a comment field when editing a file
through the web interface and use that comment as the log when checking in the
file in the repository?


>> 2) If I have comments in an org file, as soon as I edit the file through the
>>    web interface, the comments disappear (they're still present as * COMMENT
>>    lines in the org file though, but no longer displayed in the browser).
>>
>
> Hmm, not sure about that, are you sure that you are creating the comment
> outline headings exactly how they are created when blorgit adds them
> through the web interface?

Well, the comments were added by the web interface itself (the org file was
completely edited by the web interface) and were correctly displayed as soon
as you add them. But then, they disappeared once you edited the page. When
looking at the org file, the comments were still there but no longer displayed
through the web interface.

But, this issue went away from the moment I created a brand new blogs folder.
I cannot reproduce it. I don't have any more details about this for the
moment. I will come back to you with more details if needed. Thanks for your
help.


>> 3) I would like to add a .pdf link (next to edit .org .tex) in order to
>>    download the PDF coming from the compilation (pdflatex) of the .tex file.
>>    Is it possible?
>
> Yes, this should certainly be possible (and please let me know if you
> succeed and I would like to add that change to the main repo).  See line
> 70 in backend/acts_as_org/lib/acts_as_org.rb, it should be fairly
> straight forward to create a to_pdf command similar to the to_tex
> command defined therein.

Here's what I did for this.

First I added the .pdf link:

--8<---------------cut here---------------start------------->8---
diff --git a/blorgit.rb b/blorgit.rb
index 077b5d9..93bea47 100644
--- a/blorgit.rb
+++ b/blorgit.rb
@@ -197,6 +197,8 @@ __END__
         %a{ :href => path_for(@blog, :format => 'org'), :title => 'download as org-mode' } .org
       %li
         %a{ :href => path_for(@blog, :format => 'tex'), :title => 'download as LaTeX' } .tex
+      %li
+        %a{ :href => path_for(@blog, :format => 'pdf'), :title => 'download as PDF' } .pdf
 #title_separator

 @@ sidebar
:
--8<---------------cut here---------------end--------------->8---


I had to remove the first dot in the exported filenames as pdflatex doesn't
like it:

--8<---------------cut here---------------start------------->8---
diff --git a/Rakefile b/Rakefile
index 7c6d202..129b952 100644
--- a/Rakefile
+++ b/Rakefile
@@ -13,7 +13,7 @@ end
 Dir[File.join(File.dirname(__FILE__), "themes", "*", "*.rake")].each { |ext| load ext }

 # handle exported files
-def all_exported(dir) Dir.chdir($blogs){ Dir['**/.exported_*'].each{ |path| yield(path) } } end
+def all_exported(dir) Dir.chdir($blogs){ Dir['**/exported_*'].each{ |path| yield(path) } } end
 namespace :exported do
   desc "list all temporary exported files"
   task :list do

diff --git a/elisp/org-interaction.el b/elisp/org-interaction.el
index 2311156..78373df 100644
--- a/elisp/org-interaction.el
+++ b/elisp/org-interaction.el
@@ -23,7 +23,7 @@ evaluating BODY."
        (kill-buffer ,temp-file)
        ,temp-result)))

-(defvar org-interaction-prefix ".exported_")
+(defvar org-interaction-prefix "exported_")

 (defun org-file-to-html (file-path)
   "Open up an org file, publish it to html, and then return the
--8<---------------cut here---------------end--------------->8---


Here are the changes in acts_as_org.rb:

--8<---------------cut here---------------start------------->8---
diff --git a/lib/acts_as_org.rb b/lib/acts_as_org.rb
index 458741d..69bc12b 100644
--- a/lib/acts_as_org.rb
+++ b/lib/acts_as_org.rb
@@ -7,7 +7,7 @@ module ActiveFile
       # *note*: if you change this value, you must also change the
       # value of `org-interaction-prefix' in
       # ../elisp/org-interaction.el
-      EXP_PREFIX = ".exported_"
+      EXP_PREFIX = "exported_"

       def self.included(base)
         base.extend ActiveFile::Acts::Org::ClassMethods
@@ -20,6 +20,7 @@ module ActiveFile
         end

         def emacs_run(command) %x{#{EMACS_CMD} --eval '#{command}'} end
+        def run_command(command) %x{#{command}} end

         # convert a string of org-formatted text to html
         def string_to_html(org_string, options = {})
@@ -80,6 +81,30 @@ PREAMBLE
           l_path = self.latex_path(path)
           File.exist?(l_path) and File.mtime(l_path) > File.mtime(path)
         end
+
+        def pdf_path(path)
+          File.join(File.dirname(path),
+                    ActiveFile::Acts::Org::EXP_PREFIX + File.basename(path) + ".pdf")
+        end
+
+        def to_pdf(path, options = {})
+          p_dir = File.dirname(path)
+          p_path = self.pdf_path(path)
+          l_path = self.latex_path(path)
+          self.run_command("(cd #{p_dir};to-pdf.sh #{path} #{l_path})") unless self.clean_pdf?(path)
+          return nil unless File.exist?(p_path)
+          html = File.read(p_path)
+        end
+ #       alias :to_pdf
+
+        def clean_pdf?(path)
+          p_path = self.pdf_path(path)
+          File.exist?(p_path) and File.mtime(p_path) > File.mtime(path)
+        end
       end

       module InstanceMethods
@@ -107,6 +132,20 @@ PREAMBLE
           self.class.to_latex(self.full_path, options)
         end
         alias :to_tex :to_latex
+
+        def pdf_path
+          self.class.pdf_path(self.full_path)
+        end
+
+        def clean_pdf?
+          self.class.clean_pdf?(self.full_path)
+        end
+
+        def to_pdf(options = {})
+          self.class.to_pdf(self.full_path, options)
+        end
+
       end
     end
   end
--8<---------------cut here---------------end--------------->8---


As you can see, to compile to pdf I use an external shell script in order to
generate the .tex file with emacs client and then compile to pdf (and doing
the required iterations in order to get the right references). Here's this
to-pdf.sh script (that needs to be in you path):

--8<---------------cut here---------------start------------->8---
#!/bin/sh

# first argument is the org file
ORGFILE=$1

# second argument is the tex file
TEXFILE=$2

# Blorgit-dependent details
EMACSSOCKET=`cat /tmp/emacsclient-socket-dir`

# Output files
LOGFILE=${TEXFILE%.*}.log

# Commands
RM="rm -f"
PDFLATEX="pdflatex --interaction=batchmode"
EMACS="emacsclient -s $EMACSSOCKET/server --eval \"(org-file-to-latex \\\"$ORGFILE\\\")\""

# First part -- Generate the .tex file from .org
echo
echo "* Running \`org-mode' *"
$RM $TEXFILE
echo $EMACS
eval $EMACS

# Second part -- Generate the .pdf from .tex
if [ -f $TEXFILE ]
then
    echo
    echo "* Running \`pdfLaTeX "$TEXFILE"' *"
    $RM $LOGFILE
    $PDFLATEX $TEXFILE
    while ( grep -e "Rerun .* cross-references" $LOGFILE > /dev/null ); \
        do \
        echo; \
        echo "* Re-running \`pdfLaTeX "$TEXFILE"' *"; \
        $RM $LOGFILE; \
        $PDFLATEX $TEXFILE; \
        done
fi
--8<---------------cut here---------------end--------------->8---


This works very well too.

Except that, as I removed the first dot in exported filenames, these are no
longer hidden and are thus displayed in the web interface (in Recent or
Directory view). Do you know how to avoid this?


>> 4) Is it possible to add a button in order to create a new file directly from
>>    the web interface?
>
> Yes, with the edit-able option set to true, you will just need to type
> the path to the new file as a url into your web browser.  If blorgit
> can't find a file there it will offer to let you create one.

Indeed, this works very well. Thanks for the tip.


I have a lot of other questions to raise about Blorgit, but I need some time
to better understand how it works and experiment a bit more. I will raise my
questions in separate threads.

Now, thanks to Blorgit, anyone in my office can edit org files and get the
associated PDF (with our own LaTeX style) without having to configure neither
Emacs or even LaTeX.

This is really great.

Thanks,
Francesco


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  parent reply	other threads:[~2009-11-19 10:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-13 15:47 Blorgit > SVN integration Francesco Pizzolante
2009-11-13 17:45 ` Eric Schulte
     [not found]   ` <m2r5s2gvyc.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-19 10:06     ` Francesco Pizzolante [this message]
2009-11-19 15:17       ` Eric Schulte
     [not found]         ` <m2skcazgr6.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-20 12:36           ` Francesco Pizzolante
2009-11-20 17:15             ` Eric Schulte
2009-11-23 12:58           ` Blorgit > Adding PDF export Francesco Pizzolante
2009-11-23 14:43             ` Eric Schulte
     [not found]               ` <m2ljhxi9oi.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-23 15:23                 ` Francesco Pizzolante
2009-11-23 15:38                   ` Eric Schulte
2009-12-03 15:59           ` Blorgit > SVN integration Francesco Pizzolante
2009-12-05  3:54             ` Eric Schulte
     [not found]               ` <m27ht23wj2.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-12-07 12:33                 ` Francesco Pizzolante

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87fx8asu9s.fsf@missioncriticalit.com \
    --to=fpz-djc/ipccudyqhejpep6iedvlejwurmry@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    --cc=schulte.eric-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).