Initial commit

This commit is contained in:
Gordon Grant-Stuart 2023-06-12 22:35:52 +01:00
parent 4c59c9c56c
commit 9bd457dc40
51 changed files with 816 additions and 0 deletions

29
.Books/atmo.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
SCRIPT_DIR=$(dirname $(realpath $0))
BG_DIR="${SCRIPT_DIR/\/.Books/}/backgrounds"
while [[ $chosen != 'chosen' ]]; do
clear
echo -e "============================================\033[1;38;5;94m"
ls $BG_DIR
echo -e "\033[38;5;95m============================================"
cd $BG_DIR
read -e -p " Choose a background:$(echo -e "\033[1;38;5;94m") " bg
if [[ -e "$bg" && "$bg" =~ \.(jpg|jpeg)$ ]]; then
echo
$SCRIPT_DIR/viu "$bg" -w64
echo
read -sn1 -p "This one? [Y|n]" yn
if [[ ! ${yn^^} == 'N' ]]; then
rm -f $SCRIPT_DIR/backgrounds/atmo.jpg
ln -s "$(realpath "$bg")" $SCRIPT_DIR/backgrounds/atmo.jpg
chosen='chosen'
fi
echo
else
echo Not a .jpg
fi
done

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

1
.Books/backgrounds/atmo.jpg Symbolic link
View File

@ -0,0 +1 @@
/home/ggstuart/Nextcloud/Documents/writing/Books/.Books/backgrounds/kowloon3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 KiB

32
.Books/booksenv.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# This script should be sourced
BOOK_DIR=$1
lightbrown="\[\033[1;38;5;94m\]"
darkbrown="\[\033[38;5;95m\]"
# export PERIOD=30
export MANUSKRIPT_BIN="$HOME/.Books/manuskript/bin/manuskript"
# export MANUSKRIPT_BIN="manuskript"
alias upload="$HOME/.Books/upload.sh"
alias download="$HOME/.Books/download.sh"
alias write="$HOME/.Books/write.sh"
alias wryte="$HOME/.Books/write.sh"
alias manuskript="$HOME/.Books/write.sh"
alias atmo="$HOME/.Books/atmo.sh"
alias compile="$HOME/.Books/compile.sh"
# alias rollback="$HOME/.Books/rollback.sh"
# mkdir -p /tmp/manuskriptbackups
# find /tmp/manuskriptbackups/ -ctime +1 | xargs -I% rm % # remove backups older than a day
bookmoji=$(echo -e "\U1F4D6")
PS1=$(echo -e "$bookmoji $lightbrown-Books-\[\033[0m\] $darkbrown")
which guake &>/dev/null && guake -r $bookmoji
history -c
history -r "$HOME/.Books/history"
cd $BOOK_DIR
#$HOME/.Books/download.sh
clear

22
.Books/branchy.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}
# PERIOD=10
while [[ ! `pgrep -f "manuskript $1"` ]]; do
sleep 0.5
done
notify-send "Making backups of $1 every $PERIOD seconds."
tick=1
while [[ `pgrep -f "manuskript $1"` ]]; do
sleep 1
if [[ $tick -ge $PERIOD ]]; then
committy "$1"
tick=0
fi
tick=$(( $tick + 1 ))
done
notify-send "No longer making backups of $1."
rm -f $BOOK_DIR/nohup.out

101
.Books/compile.sh Executable file
View File

@ -0,0 +1,101 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}
####### defaults #########
YAML=$SCRIPT_DIR/frontmatter.yml
OUTPUT_FORMAT=docx
TEMPLATE=md2long.sh
SCENE_BREAK="\n\n### #\n\n"
LINE_BREAK="\n"
####### options #########
while getopts "hy:edsf:" opt; do
case $opt in
y) YAML=$OPTARG ;;
e) OUTPUT_FORMAT=epub ;;
d) OUTPUT_FORMAT=docx ;;
s) TEMPLATE=md2short.sh ;;
f) OUTPUT_FORMAT=$OPTARG ;;
h) echo "USAGE: compile [-y frontmatter.yml ] [ -e | -d | -f format ] FILE.msk" ;;
esac
done
shift $((OPTIND-1))
msk=$1
echo -e "*********** compiling *******************\033[19D$msk "
chapter() {
dir=$1
if [[ $(egrep -c "^compile: *0$" $dir/folder.txt) -eq 0 ]]; then
chaptitle=$(cat $dir/folder.txt | egrep "^title:" | sed 's/^title: *//g')
chapsubtitle=$(cat $dir/folder.txt | egrep "^summarySentence:" | sed 's/^summarySentence: *//g')
echo "# $chaptitle - $chapsubtitle"
for md in $dir/*.md; do
if [[ $(egrep -c "^compile: *0$" $md) -eq 0 ]]; then
start=$(( $(egrep -n -m1 '^$' $md | cut -d: -f1) + 2 ))
echo >> $md
tail -n +$start $md | while read line; do echo "$line"; echo -ne $LINE_BREAK; done
echo -ne $SCENE_BREAK
fi
done
fi
}
dir2md() {
shortbooktitle=$(cat $1/infos.txt | egrep "^Title:" | sed 's/^Title: *//g')
booktitle=$(cat $1/infos.txt | egrep "^Subtitle:" | sed 's/^Subtitle: *//g')
compiled_md=$(mktemp /tmp/XXXXXXXX.md)
cat $YAML | sed "s/^title:\ .*$/title: \"$shortbooktitle\"/g; s/^short_title:\ .*$/short_title: \"$shortbooktitle\"/g" > $compiled_md
for dir in $1/outline/*; do
if [[ -d $dir ]]; then
chapter $dir >> $compiled_md
fi
done
echo "*********** markdown compiled ***********"
}
compile() {
if [[ -f $msk ]]; then
if [[ $(cat $msk | wc -c) -eq 1 ]]; then
dir2md ${msk%\.*}
else
#unzip the msk
unzipped_dir=$(mktemp -d /tmp/XXXXXXXX)
unzip -qou "$msk" -d $unzipped_dir
dir2md $unzipped_dir
rm -rf $unzipped_dir
fi
elif [[ -d $msk && -f $msk/infos.txt ]]; then
dir2md $msk
else
echo No book specified
exit
fi
}
###### main ###########
case $OUTPUT_FORMAT in
docx)
compile
echo -en "\033[1;38;5;94m"
$SCRIPT_DIR/pandoc-templates/bin/$TEMPLATE --output "$booktitle.$OUTPUT_FORMAT" --overwrite $compiled_md #&> /dev/null
;;
epub)
compile
echo -en "\033[1;38;5;94m"
pandoc --from=markdown --to=epub --css=$SCRIPT_DIR/epub.css --output="$booktitle.$OUTPUT_FORMAT" --toc $compiled_md #&> /dev/null
;;
*)
echo -e "What on Earth is a \033[1m$OUTPUT_FORMAT\033[0m?"
echo "******* exiting because of reasons ******"
exit 1
;;
esac
echo -en "\033[1;38;5;95m"
echo "*********** pandoc finished *************"
rm $compiled_md
# echo $compiled_md
# echo $unzipped_dir
echo -e "\n\033[1m$booktitle.$OUTPUT_FORMAT\033[0m\n"

View File

9
.Books/download.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}
[[ ! -e $SCRIPT_DIR/initted ]] && $BOOK_DIR/init.sh
[[ ! -e $BOOK_DIR/backgrounds ]] && ln -s "$SCRIPT_DIR/backgrounds" "$BOOK_DIR/backgrounds"
cd $BOOK_DIR && git pull

54
.Books/epub.css Normal file
View File

@ -0,0 +1,54 @@
/* kindle friendly css with indents*/
body {
line-height: 1.75;
}
body * {
line-height: inherit;
}
p {
margin: 0rem 0% 0rem 0rem;
text-indent: 1rem;
}
h1+p, h2+p {
text-indent: 0em;
}
h1, h2, .author {
text-align: center;
}
h4, h5 {
font-size: 100%;
}
blockquote {
font-size: 90%;
color: #666666;
margin: 0;
padding: 1em 0 1em 3em;
border-left: 0.25em #EEE solid;
}
blockquote>p {
text-indent: 0em;
}
hr {
height: 0;
margin-top: 1em;
margin-bottom: 1em;
border: 0;
border-top: 1px solid #eee;
}
/*suppress numbering in TOC to match the default pandoc styling*/
ol.toc li {
list-style-type: none;
margin: 0;
padding: 0;
}

11
.Books/frontmatter.yml Normal file
View File

@ -0,0 +1,11 @@
---
title: "MANAGED BY SCRIPT - 'Subtitle' field in Manuskript"
short_title: "MANAGED BY SCRIPT - 'Title' field in Manuskript"
author: "by Gordon Grant-Stuart"
author_lastname: "Grant-Stuart"
contact_name: "Gordon Grant-Stuart"
contact_address: "42 Parkway"
contact_city_state_zip: "Camberley, GU15 2PE, UK"
contact_phone: "(+44) 07462 129908"
contact_email: "gordon@grant-stuart.com"
---

5
.Books/history Normal file
View File

@ -0,0 +1,5 @@
download
upload
compile
atmo
wryte

14
.Books/load.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
[[ ! -e $SCRIPT_DIR/.Books/initted ]] && $SCRIPT_DIR/init.sh
[[ ! -e $SCRIPT_DIR/backgrounds ]] && ln -s "$SCRIPT_DIR/.Books/backgrounds" "$SCRIPT_DIR/backgrounds"
cd $SCRIPT_DIR && git pull
mv -f $SCRIPT_DIR/*.msk $SCRIPT_DIR/.Books/backup/
for dir in $SCRIPT_DIR/.Books/unpacked/*; do
TITLE=${dir##*/}
cd "$SCRIPT_DIR/.Books/unpacked/$TITLE" && zip -qu -9 -r "$SCRIPT_DIR/$TITLE.msk" *
done

1
.Books/local.d/readme Normal file
View File

@ -0,0 +1 @@
This folder is for storing local scripts that don't get synced

28
.Books/rollback.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# check args
SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}
if [[ $# -eq 2 && -e $1 && $2 =~ [0-9]+ ]]; then
# ls -1 /tmp/manuskriptbackups/ | wc -l
rollto=$(find /tmp/manuskriptbackups/ -name "*$1.*" -cmin +$2 | sort | tail -n1)
if [[ -n $rollto ]]; then
if [[ `pgrep -f "manuskript $1"` ]]; then
echo $1 is still open in Manuskript
else
mv $BOOK_DIR/$1 $BOOK_DIR/$1.$(date +"%Y-%m-%d_%H:%M:%S")
mv $rollto $BOOK_DIR/$1
echo $1 rolled back to $rollto
fi
else
echo There is no backup of $1 from more than $2 minutes ago.
fi
else
echo
echo "USAGE : rollback FILE N"
echo
echo " FILE : .msk file"
echo " N : minutes to roll back"
echo
fi

13
.Books/save.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
for msk in *.msk; do
TITLE="${msk%.msk}"
rm -rf "$SCRIPT_DIR/.Books/unpacked/$TITLE"
unzip -qou "$msk" -d "$SCRIPT_DIR/.Books/unpacked/$TITLE"
done
cd $SCRIPT_DIR && git add .
git commit -m "Saved at $(date)"
git push

40
.Books/themes/atmo.theme Normal file
View File

@ -0,0 +1,40 @@
[General]
Name=Atmosphere
[Background]
Color=#000000
ImageFile=atmo.jpg
Type=3
[Foreground]
Color=#ffffff
Margin=40
Opacity=85
Padding=20
Position=1
Rounding=8
RoundingDisabled=0
Width=650
[ForegroundBlur]
Enabled=true
Radius=32
[ForegroundShadow]
Color=#000000
Enabled=true
Offset=2
Radius=16
[Spacings]
Alignment=0
IndentFirstLine=true
LineSpacing=150
ParagraphAbove=0
ParagraphBelow=0
TabWidth=48
[Text]
Color=#2e3436
Font="DejaVu Serif,14,-1,5,50,0,0,0,0,0"
Misspelled=#ff0000

View File

@ -0,0 +1,40 @@
[General]
LoadColor=#a8bacc
Name="Gentle Blues"
[Background]
Color=#a8bacc
ImageFile=
Type=0
[Foreground]
Color=#a8bacc
Margin=65
Opacity=0
Padding=10
Position=1
Rounding=0
RoundingDisabled=10
Width=700
[ForegroundBlur]
Enabled=false
Radius=32
[ForegroundShadow]
Color=#000000
Enabled=false
Offset=2
Radius=8
[Spacings]
IndentFirstLine=false
LineSpacing=100
ParagraphAbove=0
ParagraphBelow=0
TabWidth=48
[Text]
Color=#2d3f56
Font="Times New Roman,12,-1,5,50,0,0,0,0,0"
Misspelled=#ff0000

View File

@ -0,0 +1,39 @@
[General]
LoadColor=#000000
[Background]
Color=#000000
ImageFile=
Type=0
[Foreground]
Color=#000000
Margin=65
Opacity=0
Padding=10
Position=1
Rounding=0
RoundingDisabled=10
Width=700
[ForegroundBlur]
Enabled=false
Radius=32
[ForegroundShadow]
Color=#000000
Enabled=false
Offset=2
Radius=8
[Spacings]
IndentFirstLine=false
LineSpacing=100
ParagraphAbove=0
ParagraphBelow=0
TabWidth=48
[Text]
Color=#0cf155
Font="Courier New,12,-1,5,50,0,0,0,0,0"
Misspelled=#0d5322

37
.Books/themes/preview.txt Normal file
View File

@ -0,0 +1,37 @@
The regular early morning yell of horror was the sound of Arthur Dent waking up and suddenly remembering where he was.
It wasn't just that the cave was cold, it wasn't just that it was damp and smelly. It was the fact that the cave was in the middle of Islington and there wasn't a bus due for two million years.
Time is the worst place, so to speak, to get lost in, as Arthur Dent could testify, having been lost in both time and space a good deal. At least being lost in space kept you busy.
He was stranded in prehistoric Earth as the result of a complex sequence of events which had involved him being alternately blown up and insulted in more bizarre regions of the Galaxy than he ever dreamt existed, and though his life had now turned very, very, very quiet, he was still feeling jumpy.
He hadn't been blown up now for five years.
Since he had hardly seen anyone since he and Ford Prefect had parted company four years previously, he hadn't been insulted in all that time either.
Except just once.
It had happened on a spring evening about two years previously.
He was returning to his cave just a little after dusk when he became aware of lights flashing eerily through the clouds. He turned and stared, with hope suddenly clambering through his heart. Rescue. Escape. The castaway's impossible dream --- a ship.
And as he watched, as he stared in wonder and excitement, a long silver ship descended through the warm evening air, quietly, without fuss, its long legs unlocking in a smooth ballet of technology.
It alighted gently on the ground, and what little hum it had generated died away, as if lulled by the evening calm.
A ramp extended itself.
Light streamed out.
A tall figure appeared silhouetted in the hatchway. It walked down the ramp and stood in front of Arthur.
"You're a jerk, Dent," it said simply.
It was alien, very alien. It had a peculiar alien tallness, a peculiar alien flattened head, peculiar slitty little alien eyes, extravagantly draped golden ropes with a peculiarly alien collar design, and pale grey-green alien skin which had about it that lustrous shine which most grey-green faces can only acquire with plenty of exercise and very expensive soap.
Arthur boggled at it.
It gazed levelly at him.
Arthur's first sensations of hope and trepidation had instantly been overwhelmed by astonishment, and all sorts of thoughts were battling for the use of his vocal chords at this moment.
"Whh ...?" he said.
"Bu ... hu ... uh ..." he added.
"Ru ... ra ... wah ... who?" he managed finally to say and lapsed into a frantic kind of silence. He was feeling the effects of having not said anything to anybody for as long as he could remember.
The alien creature frowned briefly and consulted what appeared to be some species of clipboard which he was holding in his thin and spindly alien hand.
"Arthur Dent?" it said.
Arthur nodded helplessly.
"Arthur Philip Dent?" pursued the alien in a kind of efficient yap.
"Er ... er ... yes ... er ... er," confirmed Arthur.
"You're a jerk," repeated the alien, "a complete asshole."
"Er ..."
The creature nodded to itself, made a peculiar alien tick on its clipboard and turned briskly back towards the ship.
"Er ..." said Arthur desperately, "er ..."
"Don't give me that!" snapped the alien. It marched up the ramp, through the hatchway and disappeared into the ship. The ship sealed itself. It started to make a low throbbing hum.
"Er, hey!" shouted Arthur, and started to run helplessly towards it.
"Wait a minute!" he called. "What is this? What? Wait a minute!"
The ship rose, as if shedding its weight like a cloak to the ground, and hovered briefly. It swept strangely up into the evening sky. It passed up through the clouds, illuminating them briefly, and then was gone, leaving Arthur alone in an immensity of land dancing a helplessly tiny little dance.
"What?" he screamed. "What? What? Hey, what? Come back here and say that!"
He jumped and danced until his legs trembled, and shouted till his lungs rasped. There was no answer from anyone. There was no one to hear him or speak to him.

View File

@ -0,0 +1,39 @@
[General]
LoadColor=#5d3e3d
[Background]
Color=#000000
ImageFile=spacedreams.jpg
Type=5
[Foreground]
Color=#beaf9b
Margin=65
Opacity=50
Padding=10
Position=1
Rounding=10
RoundingDisabled=0
Width=700
[ForegroundBlur]
Enabled=true
Radius=32
[ForegroundShadow]
Color=#000000
Enabled=true
Offset=2
Radius=16
[Spacings]
IndentFirstLine=false
LineSpacing=100
ParagraphAbove=0
ParagraphBelow=0
TabWidth=48
[Text]
Color=#000000
Font="Times New Roman,12,-1,5,50,0,0,0,0,0"
Misspelled=#ff0000

View File

@ -0,0 +1,29 @@
[General]
Name=Wei Long
[Background]
Color=#000000
ImageFile=kowloon3.jpg
Type=3
[Foreground]
Color=#ffffff
Margin=40
Opacity=75
Padding=10
Position=1
Rounding=5
Width=900
[Spacings]
Alignment=0
IndentFirstLine=true
LineSpacing=150
ParagraphAbove=0
ParagraphBelow=0
TabWidth=48
[Text]
Color=#2e3436
Font="DejaVu Serif,14,-1,5,50,0,0,0,0,0"
Misspelled=#ff0000

View File

@ -0,0 +1,39 @@
[General]
LoadColor=#985a20
[Background]
Color=#985a20
ImageFile=writingdesk.jpg
Type=5
[Foreground]
Color=#fffdf6
Margin=65
Opacity=100
Padding=10
Position=1
Rounding=0
RoundingDisabled=10
Width=700
[ForegroundBlur]
Enabled=false
Radius=32
[ForegroundShadow]
Color=#000000
Enabled=true
Offset=1
Radius=4
[Spacings]
IndentFirstLine=false
LineSpacing=100
ParagraphAbove=0
ParagraphBelow=0
TabWidth=48
[Text]
Color=#000000
Font="Times New Roman,12,-1,5,50,0,0,0,0,0"
Misspelled=#ff0000

12
.Books/upload.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}
cd $BOOK_DIR && git add .
git commit -m "Saved at $(date) from $(hostname)"
git push #&& find /tmp/manuskriptbackups/ -cmin +60 | xargs -I% rm -f %
if [[ -e "$SCRIPT_DIR/local.d/postupload.sh" ]]; then
$SCRIPT_DIR/local.d/postupload.sh
fi

36
.Books/watchy.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
BOOK_DIR=${SCRIPT_DIR/\/.Books/}
# PERIOD=10
mds() {
md5sum "$1" | awk '{print $1}'
}
savey() {
newhash=$(mds "$1")
if [[ ! $newhash == $hash ]]; then
cp "$1" "/tmp/manuskriptbackups/$1.$(date +"%Y-%m-%d_%H:%M:%S")"
hash=$newhash
fi
}
while [[ ! `pgrep -f "manuskript $1"` ]]; do
sleep 0.5
done
notify-send "Making backups of $1 every $PERIOD seconds."
tick=1
hash=$(mds "$1")
while [[ `pgrep -f "manuskript $1"` ]]; do
sleep 1
if [[ $tick -ge $PERIOD ]]; then
savey "$1"
tick=0
fi
tick=$(( $tick + 1 ))
done
notify-send "No longer making backups of $1."
rm -f $BOOK_DIR/nohup.out

30
.Books/write.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# SCRIPT_DIR=$(dirname $(realpath $0))
# BOOK_DIR=${SCRIPT_DIR/\/.Books/}
# PERIOD=10
# bronch() {
# screen -d -m nohup $MANUSKRIPT_BIN "$1" &
# screen -d -m nohup $SCRIPT_DIR/branchy.sh "$1" &
# }
# worch() {
# screen -d -m nohup $MANUSKRIPT_BIN "$1" &
# screen -d -m nohup $SCRIPT_DIR/watchy.sh "$1" &
# }
# if [[ -f "$1" && -d "${1/.msk/}" ]]; then
# bronch "$1"
# elif [[ -d "$1" && -f "$1.msk" ]]; then
# bronch "$1.msk"
# fi
# if [[ -e "$1" && $(cat $1 | wc -c) -gt 10 ]]; then
# bronch "$1"
# else
# screen -d -m nohup $MANUSKRIPT_BIN &
# fi
screen -d -m nohup $MANUSKRIPT_BIN &>/dev/null &

31
.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
# Manuskript files.
#*.msk
# Compiled Outputs
*.docx
*.epub
# Standard archive formats
*.7z
*.jar
*.rar
*.zip
*.gz
*.gzip
*.tgz
*.bzip
*.bzip2
*.bz2
*.xz
*.lzma
*.cab
*.xar
# Specific files and folders
/.Books/manuskript/
/.Books/pandoc-templates/
/.Books/initted
/.Books/local.d/*.sh
/backgrounds
/manuskript
nohup.out

11
Sandersons3Laws.md Normal file
View File

@ -0,0 +1,11 @@
##Sanderson's First Law:
An author's ability to solve conflict with magic is *directly proportional* to how well the reader understands said magic.
Mysterious magic systems can only *cause* problems
##Sanderson's Second Law: Limitations > Power
The limitations of a magic system are more interesting than its capabilities. What the magic can't do is more interesting than what it can.
##Sanderson's Third Law: Expand on what you have already, before you add something new.
A brilliant magic system for a book is less often one with a thousand different powers and abilities -- and is more often a magic system with relatively few powers that the author has considered in depth.
###Sanderson's Zeroth Law: Err on the side of ***awesome***.

113
init.sh Executable file
View File

@ -0,0 +1,113 @@
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $(realpath $0))
lightbrown="\033[1;38;5;94m"
darkbrown="\033[38;5;95m"
echo -e "$lightbrown 📚 running the Books! init script 📚 $darkbrown"
al="alias Books=\". $HOME/.Books/booksenv.sh $SCRIPT_DIR\""
if [[ $(grep -c "$al" ~/.bash_aliases) -eq 0 ]]; then
echo $al >> ~/.bash_aliases
fi
if [[ $(grep -c "msk=1;38;5;95" ~/.bash_aliases) -eq 0 ]]; then
echo 'export LS_COLORS="$LS_COLORS:*.msk=1;38;5;95"' >> ~/.bash_aliases
fi
mv "$SCRIPT_DIR/.Books" "$HOME/.Books"
rm -rf $SCRIPT_DIR/.git # Get rid of the Books git project, create a new one for YOUR writing
########## Install screen, git & pandoc #############
if type yum &>/dev/null; then
pac='yum'
elif type apt &>/dev/null; then
pac='apt'
else
echo -e "$darkbrown You're Linuxing wrong."
exit
fi
for i in git screen pandoc; do
type $i &>/dev/null || echo -e "$darkbrown Installing $i" && sudo $pac install -y $i
done
########## Install manuskript ###############
function reresource() {
rm -rf "$HOME/.Books/manuskript/resources/$1"
ln -s "$HOME/.Books/$1" "$HOME/.Books/manuskript/resources/$1"
}
cd $HOME/.Books && git clone https://github.com/olivierkes/manuskript.git
if [[ $? -ne 0 ]]; then
cd $HOME/.Books/manuskript && git pull
fi
rm -rf "$HOME/.Books/manuskript/sample-projects"
reresource themes
reresource backgrounds
reresource dictionaries
rm $SCRIPT_DIR/backgrounds
ln -s "$HOME/.Books/backgrounds" "$SCRIPT_DIR/backgrounds"
# ln -s "$HOME/.Books/manuskript/bin/manuskript" "$SCRIPT_DIR/manuskript"
################# Install Prosegrinder pandoc templates ############
echo -e "$darkbrown Installing Pandoc Templates"
cd $HOME/.Books && git clone https://github.com/prosegrinder/pandoc-templates.git
if [[ $? -ne 0 ]]; then
cd $HOME/.Books/pandoc-templates && git pull
fi
################# Install LanguageTool ############
# if type "languagetool" &>/dev/null; then
# fi
echo -e "$darkbrown Installing LanguageTool"
sudo snap install languagetool
# if pip show language_tool_python &>/dev/null; then
# fi
echo -e "$darkbrown Installing LanguageTool Python"
sudo pip install language_tool_python
################# Install viu ############
if [[ ! -e "$HOME/.Books/viu" ]]; then
curl -o "$HOME/.Books/viu" "https://github.com/atanunq/viu/releases/download/v1.4.0/viu" && chmod +x "$HOME/.Books/viu"
fi
# cd $HOME/.Books
##################### Add the password to the git config
cd $SCRIPT_DIR
if [[ ! -d "$SCRIPT_DIR/.git" ]]; then
git init
fi
rou=$(git config --get remote.origin.url | sed 's$https://$$g')
if [[ $(echo $rou | egrep -c [^:]*:[^@]*@ ) -eq 0 ]]; then
echo -e '\n*******************************************************\n'
echo -n 'Enter the git username: '
read username
echo -n "Enter the git password for $username: "
stty -echo
read password
stty echo
newurl="https://$username:$password@$rou"
git config --replace-all remote.origin.url "$newurl"
echo
#sed -i "s/https:\/\/git.grant-stuart.com/https:\/\/gordon:$answer@git.grant-stuart.com/g; s/https:\/\/git.grant-stuart.com/\&/g" $SCRIPT_DIR/.git/config
fi
# sed -i "s%WIBBLE%$SCRIPT_DIR%g" $HOME/.Books/booksenv.sh
touch $HOME/.Books/initted