From fea13e42550965fb95e03bbea8d034ffd1e15004 Mon Sep 17 00:00:00 2001 From: Esteban Carnevale Date: Wed, 24 Dec 2014 16:01:51 -0300 Subject: paraboladocs: Add script --- paraboladocs | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 paraboladocs diff --git a/paraboladocs b/paraboladocs new file mode 100644 index 0000000..0ad95c0 --- /dev/null +++ b/paraboladocs @@ -0,0 +1,118 @@ +. libremessages + +die2() { + echo "Current branch is: $(git branch)" + #die "$1" + error "$1" + return 1 +} + +titlecase() { + python -c "from titlecase import titlecase; print(titlecase(\"$1\"));" +} + +load() { + eval title="$(sed 's/ /_/g' <<< \"$1\")" + if [[ $2 ]] ; then + eval title_arch="$(sed 's/ /_/g' <<< \"$2\")" + else + eval title_arch="$title" + fi +} + +load_arch() { + #title="$1" + if [[ $1 == -t ]] ; then + title_arch="$(titlecase "$2")" + eval title_arch="$(sed 's/ /_/g' <<< \"$title_arch\")" + else + eval title_arch="$(sed 's/ /_/g' <<< \"$1\")" + fi +} + +show() { + echo "Parabola title : $title" + echo "Arch title : $title_arch" +} + +unload() { + unset title + unset titlearch +} + +export title +export title_arch + +diff() { + if [[ $title_arch ]] ; then + git diff --word-diff arch:"$title_arch" master:"$title" + else + git diff --word-diff arch:"$title" master:"$title" + fi +} + +editdiff() { + echo "Checking out master" + git checkout master + gvimdiff <(git show arch:"$title_arch") "$title" +} + +clipboard_save() { + #git show master:"$title" | xsel + cat "$title" | xsel +} + +compare() { + pkill -f 'iceweasel -P bigscreenparalelo' + iceweasel -P bigscreenparalelo -new-instance 2> /dev/null & + i3-msg workspace 14 > /dev/null + sleep 0.7 + + export DESKTOP_STARTUP_ID='' + url="https://wiki.parabola.nu" + iceweasel -P bigscreenparalelo -remote "openURL($url/index.php?title=$title&action=render,new-tab)" 2> /dev/null & + + url="https://wiki.archlinux.org" + iceweasel -P bigscreenparalelo -remote "openURL($url/index.php?title=$title_arch&action=render,new-window)" 2> /dev/null & +} + +edit() { + iceweasel "https://wiki.parabola.nu/index.php?title=$title&action=edit" +} + +#. /usr/local/bin/paraboladocs-get + +_get() { + if [[ $1 == parabola ]] ; then + wiki="ParabolaWiki" + branch="master" + url="https://wiki.parabola.nu" + elif [[ $1 == arch ]] ; then + title="$title_arch" + wiki="ArchWiki" + branch="arch" + url="https://wiki.archlinux.org" + fi + + git checkout "$branch" || \ + die2 "git checkout \"$branch\" failed" || return 1 + curl -s "$url/index.php?title=$title&action=raw" > "$title" || \ + die2 "curl failed" || return 1 + [[ $(cat "$title") ]] || \ + die2 "$wiki page is empty" || return 1 + git add "$title" || \ + die2 "$wiki git add failed" || return 1 + git commit -m "$title: add" || \ + die2 "$wiki git commit failed" || return 1 +} + +get() { + if [[ $1 == parabola ]] ; then + _get parabola + elif [[ $1 == arch ]] ; then + _get arch + elif [[ ! $1 ]] ; then + _get parabola + _get arch + fi +} -- cgit v1.2.3