huehuehuehuehue

This commit is contained in:
Geoffrey Frogeye 2017-10-30 11:44:12 +01:00
parent 9874c9858c
commit 71e7cf6eaf
4 changed files with 124 additions and 13 deletions

23
scripts/archive Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
import os
import argparse
parser = argparse.ArgumentParser(description="Place a folder in ~/Documents in ~/Documents/Archive and symlink it")
parser.add_argument('dir', metavar='DIRECTORY', type=str, help="The directory to archive")
args = parser.parse_args()
source = os.path.realpath(args.dir)
assert(os.path.isdir(source)), source + " must be a directory"
# Finding directories
assert('HOME' in os.environ), "Home directory unknown"
docs = os.path.realpath(os.path.join(os.environ['HOME'], 'Documents'))
assert(os.path.isdir(docs)), "Documents folder not found"
arcs = os.path.join(docs, 'Archives')
assert(os.path.isdir(arcs)), "Archives folder not found"
assert(source.startswith(docs)), "Directory is not in the document folder"
assert(not source.startswith(arcs)), "Directory is already in the archive folder"

70
scripts/gitghost Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/bash
# Replace git folders with a placeholder containing the remote and the commit
function prompt { # text
while true; do
read -p "$1 [yn] " yn
case $yn in
[Yy]* ) return 1;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
if [[ "$#" == 0 || "$#" > 2 ]]
then
echo "Usage: $0 gitfolder [-y]"
exit 1
fi
folder="$(echo "$1" | sed 's/\/*$//')"
if [ "$2" == "-y" ]
then
donotask=true
fi
if [ ! -d "$folder/.git" ]
then
echo "$folder is not a git repository"
exit 1
fi
if [ -n "$(git -C "$folder" diff)" ]
then
echo "WARNING: There are unstaged change. Those will be discarded if you continue."
fi
echo "Be sure that every commit in the repository is backed up somewhere else, since those will be discarded."
TMPFILE=$(mktemp)
(echo "[gitplaceholder]"
echo "lastcommit=$(git log --format="%H" -n 1)"
echo
echo "[remote]"
git -C "$folder" remote -v
echo
echo "[branch]"
git -C "$folder" branch -v
echo
echo "[diff]"
git -C "$folder" diff -v) > $TMPFILE 2> /dev/null
if [ ! $donotask ]
then
less $TMPFILE
echo
echo "This will be written in place of $folder."
prompt "Do you want to continue ?"
if [ "$?" == 0 ]
then
echo "Canceled"
rm $TMPFILE
exit 0
fi
fi
echo "Dummying..."
rm -rf "$folder"
mv $TMPFILE $folder

View File

@ -316,6 +316,10 @@ if [ $EXTRA == 1 ]; then
if [ $ARCH == 1 ]; then
inst jq
altInst pdftk translate-shell git-lfs js-beautify insect visidata-git
else
# translate-shell
curl -L git.io/trans > ~/.bin/trans
chmod +x ~/.bin/trans
fi
# Extra GUI

View File

@ -37,11 +37,13 @@ if (argv.t) {
template = fs.readFileSync(argv.t, "utf8");
}
var latex = true;
// TODO Arg
// Settings
var extraLangages = {
avrpseudo: function (hljs) {
avrpseudo: function(hljs) {
lang = extend({}, highlight.getLanguage('avrasm'));
lang.keywords.keyword += ' Si Alors Sinon FinSi TantQue FinTantQue Pour FinPour allant de à ←';
lang.keywords.keyword += ' Lire Sortir sur Appeler Retourner';
@ -55,7 +57,7 @@ var extraLangages = {
});
return lang;
},
avrasmplus: function (hljs) {
avrasmplus: function(hljs) {
lang = extend({}, highlight.getLanguage('avrasm'));
lang.keywords.keyword += ' si saut alors et ou if then goto && || <-';
lang.contains.push({
@ -73,8 +75,10 @@ for (lang in extraLangages) {
var renderer = new marked.Renderer();
marked.setOptions({
highlight: function (code, lang) {
if (highlight.getLanguage(lang)) {
highlight: function(code, lang) {
if (lang == 'raw') {
return code;
} else if (highlight.getLanguage(lang)) {
return highlight.highlight(lang, code).value;
} else {
// if (extraLangages[lang]) {
@ -93,17 +97,27 @@ marked.setOptions({
markdownString = fs.readFileSync(argv.i, "utf8");
// TeX
markdownString = markdownString.replace(/\\\$/g, '&dollar;')
markdownString = markdownString.replace(/\$\$([\s\S]+)\$\$/gm, function(glob, formula) {
return katex.renderToString(formula, {displayMode: true});
});
markdownString = markdownString.replace(/\$([^$]+)\$/g, function(glob, formula) {
return katex.renderToString(formula, {displayMode: false});
});
if (latex) {
markdownString = markdownString.replace(/\\\$/g, '&dollar;')
markdownString = markdownString.replace(/\$\$([\s\S]+)\$\$/gm, function(glob, formula) {
return katex.renderToString(formula, {
displayMode: true
});
});
markdownString = markdownString.replace(/\$([^$]+)\$/g, function(glob, formula) {
return katex.renderToString(formula, {
displayMode: false
});
});
}
// Conversion
htmlString = marked(markdownString, {renderer: renderer});
fullHtmlString = template.replace('%BODY%', htmlString);
htmlString = marked(markdownString, {
renderer: renderer
});
// fullHtmlString = htmlString;
fullHtmlString = template.replace('%BODY%', () => { return htmlString });
// Saving
if (argv.o == '/dev/stdout') {