summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2013-09-06 10:07:10 (GMT)
committer Jaromil <jaromil@dyne.org>2013-09-06 10:07:10 (GMT)
commit18570425831f572acab050f16e966a349d500918 (patch)
treea15a2288eb3a647802fb307494e736b40006ab94
parent56462efa00bfad4d98844ed98a1aa72823ad0dde (diff)
new toolset for commandline usage
-rwxr-xr-xtools/autorg-new-article103
-rwxr-xr-xtools/autorg-tex2pdf58
2 files changed, 161 insertions, 0 deletions
diff --git a/tools/autorg-new-article b/tools/autorg-new-article
new file mode 100755
index 0000000..18e4d1b
--- /dev/null
+++ b/tools/autorg-new-article
@@ -0,0 +1,103 @@
+#!/bin/zsh
+
+
+# standard output message routines
+autoload colors; colors
+# it's always useful to wrap them, in case we change behaviour later
+notice() { print "$fg_bold[green][*]$fg_no_bold[default] $1" >&2 }
+error() { print "$fg[red][!]$fg[default] $1" >&2 }
+func() { if [[ $DEBUG == 1 ]]; then print "$fg[blue][D]$fg[default] $1" >&2; fi }
+act() {
+ if [ "$1" = "-n" ]; then
+ print -n "$fg_bold[white] . $fg_no_bold[default] $2" >&2;
+ else
+ print "$fg_bold[white] . $fg_no_bold[default] $1" >&2;
+ fi
+}
+
+{ test "$1" = "" } && {
+ error "usage: autorg-new-article filename.org"
+ return 1 }
+
+{ test -r "$1" } && {
+ error "file already exists: $1"
+ return 1 }
+
+notice "AutOrg wizard - initialize a new article"
+
+fullname=`rlwrap -S 'Author full > ' -H ~/.autorg-wizard -o cat`
+shortname=`rlwrap -S 'Author abbreviated > ' -H ~/.autorg-wizard -o cat`
+title=`rlwrap -S 'Title of article > ' -H ~/.autorg-wizard -o cat`
+editor=`rlwrap -S 'Name of editor > ' -H ~/.autorg-wizard -o cat`
+
+
+
+cat <<EOF > $1
+#+TITLE: $title
+#+AUTHOR: $fullname
+#+DATE: `date '+%e +%B +%Y`
+
+#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t f:t TeX:t
+
+#+LaTeX_CLASS: article
+#+LaTeX_CLASS_OPTIONS: [a4,onecolumn,portrait]
+#+LATEX_HEADER: \usepackage[greek, english]{babel}
+
+#+LATEX_HEADER: \usepackage{ucs}
+#+LATEX_HEADER: \usepackage{inputenc}
+#+LATEX_HEADER: \usepackage{fontenc}
+#+LATEX_HEADER: \usepackage{hyperref}
+#+LATEX_HEADER: \usepackage{graphicx}
+
+#+LATEX_HEADER: \usepackage{lmodern}
+#+LATEX_HEADER: \usepackage[hang,small]{caption}
+#+LATEX_HEADER: \usepackage{float}
+
+#+LATEX_HEADER: \usepackage[textheight=1.8\textwidth, lmargin=20mm, rmargin=20mm, driver=pdftex, heightrounded, headsep=7mm, footskip=11mm, vmarginratio=1:1]{geometry}
+
+#+LATEX_HEADER: \usepackage{fancyhdr}
+#+LATEX_HEADER: \setlength{\headheight}{18pt}
+#+LATEX_HEADER: \pagestyle{fancyplain}
+
+
+#+LATEX: \fancyhf{}
+#+LATEX: \fancyhead[L]{\rule[-2ex]{0pt}{2ex}\small $title}
+#+LATEX: \fancyhead[R]{\rule[-2ex]{0pt}{2ex}\small $shortname}
+#+LATEX: \fancyfoot[C]{-- \thepage\ --}
+#+LATEX: \fancyfoot[R]{\small `date '+%e +%b +%Y`}
+#+LATEX: \fancyfoot[L]{\small $editor}
+
+#+LATEX: \renewcommand{\headrulewidth}{0.4pt}
+#+LATEX: \renewcommand{\footrulewidth}{0.4pt}
+
+
+*Abstract*:
+
+#+KEYWORDS:
+*Keywords*:
+
+#+EXCLUDE_KEYWORD: noexport
+
+[TABLE-OF-CONTENTS]
+
+#+LATEX: \newpage
+
+* Acknowledgments
+#+LATEX: \begin{minipage}[t]{0.6\textwidth}
+#+BEGIN_EXAMPLE
+
+$title
+
+© `date '+%Y'` $editor
+
+Author: $fullname
+
+
+#+END_EXAMPLE
+#+LATEX: \end{minipage}
+
+
+#+LATEX: \newpage
+
+
+EOF \ No newline at end of file
diff --git a/tools/autorg-tex2pdf b/tools/autorg-tex2pdf
new file mode 100755
index 0000000..060db04
--- /dev/null
+++ b/tools/autorg-tex2pdf
@@ -0,0 +1,58 @@
+#!/usr/bin/env zsh
+
+# standard output message routines
+autoload colors; colors
+# it's always useful to wrap them, in case we change behaviour later
+notice() { print "$fg_bold[green][*]$fg_no_bold[default] $1" >&2 }
+error() { print "$fg[red][!]$fg[default] $1" >&2 }
+func() { if [[ $DEBUG == 1 ]]; then print "$fg[blue][D]$fg[default] $1" >&2; fi }
+act() {
+ if [ "$1" = "-n" ]; then
+ print -n "$fg_bold[white] . $fg_no_bold[default] $2" >&2;
+ else
+ print "$fg_bold[white] . $fg_no_bold[default] $1" >&2;
+ fi
+}
+
+
+{ test "$1" = "" } && {
+ error "usage: $0 filename.tex"
+ return 1 }
+
+notice "Rendering Tex file into PDF: $1"
+
+file="${1%%.tex}"
+
+{ test -r "${file}.pdf" } && {
+ error "file already exists: ${file}.pdf"
+ return 1 }
+
+touch ${file}.log
+
+act "First pass with LaTex"
+latex $1 >> ${file}.log
+
+act "Generating the Index"
+makeindex ${file}.idx >> ${file}.log
+
+act "Including the Index"
+cat $1 | awk '
+/\\printindex/ { system("cat '"$file.ind"'"); next }
+{ print $0 }' > ${file}.full.tex
+
+
+act "Rendering the PDF"
+texi2dvi --pdf --verbose --batch ${file}.full.tex >> ${file}.log
+
+act "cleaning up leftovers"
+
+{ test -r ${file}.full.pdf } && {
+ mv ${file}.full.pdf ${file}.pdf }
+
+for i in aux dvi out ilg idx idxs ind toc; do
+ rm -f ${file}.${i}
+ rm -f ${file}.full.${i}
+done
+
+notice "Rendering done:"
+act "`ls -lh ${file}.pdf`" \ No newline at end of file