stmcrblog.sh
changeset 831 2fb6f961702d
parent 830 52df3d263c55
child 832 6ee7dee9df3a
equal deleted inserted replaced
830:52df3d263c55 831:2fb6f961702d
     1 #!/bin/bash
       
     2 
       
     3 # Example of this script using:
       
     4 #   (defun my-stmcrblog-after-add-entry-hook ()
       
     5 #     (shell-command (concat "stmcrblog " stmcrblog-file " /srv/www/htdocs/jobdoneblog.html"))
       
     6 #     )
       
     7 #   (add-hook 'stmcrblog-after-add-entry-hook 'my-stmcrblog-after-add-entry-hook)
       
     8 #   (global-set-key (kbd "C-c y") 'stmcrblog-post-current-line)
       
     9 
       
    10 in=$1
       
    11 out=$2
       
    12 
       
    13 if [[ ! -f $in ]]; then
       
    14   echo Input file not found.
       
    15   exit 1
       
    16 fi
       
    17 if [[ -z $out ]]; then
       
    18   echo I don\'t know where is output file...
       
    19   exit 1
       
    20 fi
       
    21 
       
    22 {
       
    23   echo '<html>'
       
    24   echo '<head>'
       
    25   echo '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
       
    26   echo '  <title>Job done blog.</title>'
       
    27   echo '</head>'
       
    28   echo '<body>'
       
    29   echo '<h1>Job done blog.</h1>'
       
    30 
       
    31   echo '<ul>'
       
    32 
       
    33   sed \
       
    34     -e 's|^\([[:digit:]-]\+[02468]\) \([[:digit:]:]\+\) \(.*\)|  <li><span style="color: green;">\1 \2</span> \3</li>|' \
       
    35     -e 's|^\([[:digit:]-]\+[13579]\) \([[:digit:]:]\+\) \(.*\)|  <li><span style="color: blue;">\1 \2</span> \3</li>|'
       
    36 
       
    37   echo '</ul>'
       
    38 
       
    39   echo '<address>'
       
    40   echo '  <a href="mailto:gavenko@bifit.com.ua">Oleksandr Gavenko</a>'
       
    41   echo '  </address>'
       
    42   echo '</body>'
       
    43   echo '</html>'
       
    44 
       
    45 } <$in >$out
       
    46