Skip to content

Commit

Permalink
partial fix #391 (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
lagleki committed Nov 24, 2019
1 parent 0b3f7c2 commit 647cd6a
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION="geklojban-1.2.1"
TITLE=The Complete GekLojban Languag
VERSION="geklojban-1.3.0"
TITLE=The Complete GekLojban Language
PUBLISHER=An Illogical Language Group Publication
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.#*
scripts/chapter-list*
build/
node_modules/
fontconfig/
xml/docbook-xsl-1.78.1/
xml/docbook-xsl-1.78.1.zip
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN dnf -y install vim sudo tmux zsh moreutils make moreutils sudo \
initscripts openssh man-db ncurses-compat-libs wget curl \
libcurl-devel pcre-devel bzip2-devel rsync zlib-devel \
pkgconfig w3m openssl-devel gcc rubygem-rake fpaste \
zip unzip psmisc lsof python yum-plugin-ovl glibc-all-langpacks
zip unzip psmisc lsof python yum-plugin-ovl glibc-all-langpacks nodejs

# Specifically needed packages, with versions where the package is
# important.
Expand Down Expand Up @@ -40,6 +40,9 @@ RUN bundle install
RUN cd /usr/src ; wget https://www.princexml.com/download/prince-12.5-1.centos7.x86_64.rpm
RUN dnf -y install /usr/src/prince-12.5-1.centos7.x86_64.rpm

# Install Nodejs scripts
RUN cd /srv/cll ; npm i

# Stuff to do on "boot"
COPY container_init.sh /tmp/container_init.sh
RUN sudo dos2unix /tmp/container_init.sh
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "cll",
"version": "1.0.0",
"description": "Node.js scripts",
"main": "scripts/diff.js",
"dependencies": {
"htmldiff-js": "^1.0.5"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lojban/cll.git"
},
"bugs": {
"url": "https://github.com/lojban/cll/issues"
},
"homepage": "https://github.com/lojban/cll#readme"
}
57 changes: 57 additions & 0 deletions scripts/diff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const HtmlDiff = require("htmldiff-js").default;
const fs = require("fs"),
path = require("path");

const oldFileName = "../build/cll_diffs/diff_old_xhtml_no_chunks/index.html";
const newFileName = "../build/cll_diffs/diff_new_xhtml_no_chunks/index.html";
const diffFileName =
"../build/cll_diffs/diff_new_xhtml_no_chunks/difference.html";
const diffPrefixedFileName =
"../build/cll_diffs/diff_new_xhtml_no_chunks/difference_prefixed.html";

function getFileContent(pathTo) {
return fs.readFileSync(path.resolve(__dirname, pathTo), {
encoding: "utf8"
});
}
try {
let result = HtmlDiff.execute(
getFileContent(oldFileName),
getFileContent(newFileName)
).replace(
"<head>",
`<head>
<style>
ins {
background-color: #97f295;
}
del{
background-color: #ffb6ba;
}
.diff_pre{
font-size:50%;
}
</style>
`);
let result_with_prefixes = result.replace("</body>",`<script>
document.querySelectorAll('ins').forEach(function(ins) {
var span = document.createElement('span');
span.innerHTML = 'ins\`';
span.className = 'diff_pre';
ins.parentNode.insertBefore(span, ins);
});
document.querySelectorAll('del').forEach(function(del) {
var span = document.createElement('span');
span.innerHTML = 'del\`';
span.className = 'diff_pre';
del.parentNode.insertBefore(span, del);
});
</script></body>`);
fs.writeFileSync(path.resolve(__dirname, diffFileName), result, {
encoding: "utf8"
});
fs.writeFileSync(path.resolve(__dirname, diffPrefixedFileName), result_with_prefixes, {
encoding: "utf8"
});
} catch (error) {}
8 changes: 7 additions & 1 deletion scripts/diff_official
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

tempdir=/tmp/cll_diffs
tempdir=./build/cll_diffs

rm -rf $tempdir
mkdir -p $tempdir
Expand Down Expand Up @@ -123,6 +123,12 @@ do
echo "Diffs found; stopping to let you examine them. If you want to show all diffs instead, run with -c"
exit
fi
if [[ $type == 'xhtml?no?chunks' ]]
then
echo "Preparing a visual HTML diff file ..."
node $PWD/scripts/diff
echo "A visual HTML diff is placed in $tempdir/diff_new_xhtml_no_chunks/difference.html and $tempdir/diff_new_xhtml_no_chunks/difference_prefixed.html files."
fi
done

echo
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_jbovlaste_xml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ size="$(stat -c %s $builddir/jbovlaste.xml || echo 0)"
if [ ! -f "$builddir/jbovlaste.xml" -o ! "$size" -o "$size" -lt 100 ]
then
echo
echo "old jbovlaste build file is bad; replacing"
echo "old jbovlaste build file is bad or doesn't exist; replacing"
echo
mv "$builddir/jbovlaste.xml.new" "$builddir/jbovlaste.xml"
else
Expand Down

0 comments on commit 647cd6a

Please sign in to comment.