diff options
author | Esteban Carnevale <alfplayer@mailoo.org> | 2014-12-24 16:01:51 -0300 |
---|---|---|
committer | Esteban Carnevale <alfplayer@mailoo.org> | 2014-12-24 16:01:51 -0300 |
commit | fea13e42550965fb95e03bbea8d034ffd1e15004 (patch) | |
tree | 32bc1e393a6f09351ae84085adb61b7b90e14a2c /paraboladocs | |
parent | 6eb8d75db6e18e67ce609be8cd2259abb8f09ae0 (diff) |
paraboladocs: Add script
Diffstat (limited to 'paraboladocs')
-rw-r--r-- | paraboladocs | 118 |
1 files changed, 118 insertions, 0 deletions
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 +} |