emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Manoj Srivastava <srivasta@ieee.org>
To: emacs-orgmode@gnu.org
Subject: Re: Is there a good way to use org as blog system?
Date: Wed, 30 Sep 2009 09:09:32 -0500	[thread overview]
Message-ID: <874oqkh6cj.fsf@anzu.internal.golden-gryphon.com> (raw)
In-Reply-To: 83eipo4wd0.fsf@ymail.com

On Wed, Sep 30 2009, Water Lin wrote:

> I want to mantain a local static html blog system on my local
> computer. I think org is good enough to organise the stuff.
>
> Is there any special function for me to use org as blog system?
>
> I need a reference to start......

        With the following Ikiwiki plugin, I have been using org as my
 Ikiwiki input mechanism (so I write all my blog posts as org-mode
 files, and Ikiwiki transforms tehm into html and rss.

        manoj

--8<---------------cut here---------------start------------->8---
#!/usr/bin/perl
# File: org.pm
# Time-stamp: <2009-02-06 12:10:28 srivasta>
#
# Copyright (C) 2008 by Manoj Srivastava
#
# Author: Manoj Srivastava
#
# Description:
# This allows people to write Ikiwiki content using Emacs and org-mode
# (requires Emacs 23), and uses the html export facility of org-mode to
# create the output. Some bits based on otl.pm.

package IkiWiki::Plugin::org;
use warnings;
use strict;
use Carp;
use IkiWiki 3.00;

use File::Temp qw/ tempfile tempdir /;

# ------------------------------------------------------------

sub import {
  hook(type => "getsetup", id => "org", call => \&getsetup);
  hook(type => "htmlize",  id => "org", call => \&htmlize);
} #

sub getsetup () {
  return
    plugin => {
               safe => 0,
               rebuild => undef,
               advanced => 1,
              },
    emacs_binary => {
                     type => "string",
                     example => "/usr/bin/emacs-snapshot",
                     description => "location of an emacs binary with org-mode",
                     advanced => 1,
                     safe => 0,
                     rebuild => undef,
                    },
}



sub htmlize (@) {
  my %params  = @_;
  my $dir     = File::Temp->newdir();



  my $ret = open(INPUT, ">$dir/contents.org");
  unless (defined $ret) {
    debug("failed to open $dir/contents.org: $@");
    return $params{content};
  }
  my $emacs = '/usr/bin/emacs-snapshot';
  if (exists $config{emacs_binary} && -x $config{emacs_binary}) {
    $emacs = $config{emacs_binary};
  }
  print INPUT $params{content};
  close INPUT;
  $ret = open(INPUT, ">/tmp/contents.org");
  print INPUT $params{content};
  close INPUT;
  my $args = "$emacs --batch -l org " .
              "--eval '(setq org-export-headline-levels 3 org-export-with-toc nil org-export-author-info nil )' " .
              "--visit=$dir/contents.org " .
              '--funcall org-export-as-html-batch >/dev/null 2>&1';
  if (system($args)) {
    debug("failed to convert $params{page}: $@");
    return $params{content};
  }
  $ret = open(OUTPUT, "$dir/contents.html");
  unless (defined $ret) {
    debug("failed find html output for $params{page}: $@");
    return $params{content};
  }
  local $/ = undef;
  $ret = <OUTPUT>;
  close OUTPUT;
  $ret=~s/(.*<h1 class="title">){1}?//s;
  $ret=~s/^(.*<\/h1>){1}?//s;
  $ret=~s/<div id="postamble">.*//s;
  $ret=~s/(<\/div>\s*$)//s;
  open(OUTPUT, ">/tmp/contents.html");
  print OUTPUT $ret;
  close OUTPUT;
  
  return $ret;
}

# ------------------------------------------------------------
1; # modules have to return a true value
--8<---------------cut here---------------end--------------->8---

-- 
"UNIX is basically a simple operating system, but you have to be a
genius to understand the simplicity." -Dennis Ritchie
Manoj Srivastava <srivasta@acm.org> <http://www.golden-gryphon.com/>  
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

  parent reply	other threads:[~2009-09-30 14:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-30  9:26 Is there a good way to use org as blog system? Water Lin
2009-09-30 13:35 ` Eric Schulte
2009-09-30 14:09 ` Manoj Srivastava [this message]
2009-10-01  1:17   ` Nagarjuna G.
2009-10-01  1:43     ` Eric Schulte
2009-10-02  5:16       ` Nagarjuna G.
2010-05-20 22:18         ` GNOWSYS emacs web services (was: Re: Is there a good way to use org as blog system?) Sandro Giessl
2010-05-21 17:45           ` Nagarjuna G
2009-11-10 15:05   ` Re: Is there a good way to use org as blog system? Ian Barton
2009-11-11  7:20     ` Manoj Srivastava
2009-09-30 15:19 ` Bob Erb
2009-09-30 17:46   ` Matt Lundin
2009-09-30 18:26     ` Bob Erb
2009-10-02  4:35 ` Miguel Fernando Cabrera
2009-11-11  0:05   ` Rick Moynihan
2009-11-11  1:07     ` Ben Finney
2009-11-11 14:07       ` Rick Moynihan
2009-11-11  9:49     ` Ian Barton
2009-11-11 14:10       ` Rick Moynihan
2009-11-11 14:18         ` Ian Barton
2009-11-11 14:27         ` Ian Barton
2009-11-11 15:04           ` Greg Newman
2009-11-11 15:51             ` Rick Moynihan
2009-11-11 19:41               ` Eric Schulte

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=874oqkh6cj.fsf@anzu.internal.golden-gryphon.com \
    --to=srivasta@ieee.org \
    --cc=emacs-orgmode@gnu.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).