48
loading...
This website collects cookies to deliver better user experience
sudo apt install ufw
sudo ufw allow ssh
sudo ufw enable
sudo ufw allow 8080
npm install tiddlywiki nodemon -g
-g
flag installs the software globally, rather than in a particular folder.tiddlywiki wiki --init server
192.168.0.12
.tiddlywiki wiki --listen host=192.168.0.12
nodemon --delay 30 -e tid --ignore 'wiki/tiddlers/$*.tid' --watch wiki/tiddlers/ $NVM_BIN/tiddlywiki wiki --listen host=192.168.0.19
mod-Shift-q
keypress, but your distro will likely be different). This method of exit is required because closing the terminal via standard methods (e.g. ctrl-c
followed by exit
) will likely also kill nodemon.--delay 30
ensures that after a change nodemon waits 30 seconds before restarting. If this did not occur then the server would be constantly restarting.e tid
tells nodemon that it needs to look for changes in files ending in tid
, that is in tiddlers.--ignore 'wiki/tiddlers/$*.tid'
ignores tiddlers that are generated by the system (which by convention start with $
) and not the user.--watch wiki/tiddlers/
tells nodemon the folder to watch where changes will happen.$NVM_BIN/tiddlywiki wiki --listen host=192.168.0.19
lastly this is the previous command as at the start of the section, but as we aren't running the command via node we have to explicitly tell nodemon where to find the tiddlywiki executable (in $NVM_BIN).mkdir ~/wiki
pamac install sshfs
sudo apt install sshfs
.~/.bash_profile
(or whatever shell we use - I use zsh so it is ~/.zshenv
)2 to include:export TIDDLYWIKIPATH=$HOME/wiki/tiddlers/
git clone --depth 1 https://github.com/sukima/vim-tiddlywiki ~/.config/nvim/pack/sukima/start/vim-tiddlywiki
let g:tiddlywiki_dir=$TIDDLYWIKIPATH
tw The use of knowledge in society
and start editing a tiddler named TheUseOfKnowledgeInSociety.tid in neovim.#!/bin/bash
# Opens a new tiddlywiki tiddler named after arguments that follow commands
# Uses vim-tiddlywiki plugin to create metadata
# https://www.preciouschicken.com/blog/posts/tiddlywiki5-raspberry-pi-guide/
# Checks if pi is mounted, if not mounts in folder created earlier
if (( $(mount | grep -e 'pi@'| wc -l) == 0 ));
then
sshfs [email protected]:/home/pi/wiki "$(dirname $TIDDLYWIKIPATH)" -o reconnect
fi
# Replaces non-alphanumeric characters in arguments
arguments=$(echo $@ | sed "s/[’]//g")
arguments=$(echo $arguments | sed 's/[^a-zA-Z0-9]/ /g')
# CamelCase converts all arguments
tid_title=''
for word in $arguments
do
# Changes argument to lowercase
lowercasevar=${word,,}
# Capitalises first character of argument
sentencevar=${lowercasevar^}
tid_title+="$sentencevar"
done
# Opens neovim with correct tiddler name
if [[ -f $TIDDLYWIKIPATH$tid_title'.tid' ]]
then
# Updates metadata if tiddler exists
nvim -c TiddlyWikiUpdateMetadata $TIDDLYWIKIPATH$tid_title'.tid'
else
# Creates tiddler if not found
nvim -c TiddlyWikiInitializeTemplate $TIDDLYWIKIPATH$tid_title'.tid'
fi
chmod a+x ~/.local/bin/tw
tw The use of knowledge in society
should create a new tiddler ready for us to type. If the tiddler already exists then the shell script will recognise that and update the metadata instead.ps aux | grep -i nodemon, find out which process number nodemon is, then issue a kill -9 [process ID]
curl -X PUT -i 'http://192.168.0.12:8080/recipes/default/tiddlers/NewTiddlerTitle' --data '{
"tags": "firstTag anotherTag",
"creator": "gene",
"modifier": "gene",
"text": "The use of knowledge in society"
}' -H "X-Requested-With: TiddlyWiki"
For clarity I suspect the problem was something to do with how I had installed or configured Bob, rather than an error in the system itself. But a fresh install is never a bad idea anyway. ↩
You could also use your ~/.bashrc or ~/.zshrc, but I think the profile / env files are preferable. ↩
48