-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d497728
Showing
13 changed files
with
1,855 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bin/bookmarklet_*_*.js | ||
lib/composer | ||
lib/spotch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Non-exhaustive list of people who contributed to this project. | ||
|
||
Name (N), email (E), web-address (W), description (D). | ||
|
||
--- | ||
|
||
N: Michaël Lecerf | ||
E: michael@nurpa.be | ||
D: Contributed to the JS code | ||
|
||
N: André Loconte | ||
E: andre@nurpa.be | ||
D: Original dev | ||
|
||
N: Laurent Peuch | ||
E: laurent@nurpa.be | ||
D: Contributed to the Bash code | ||
|
||
N: Wim Vandenbussche | ||
E: wim@datapanik.org | ||
W: http://datapanik.org | ||
D: Dutch translation |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Better Lex bookmarklet | ||
|
||
Better Lex bookmarklet is a tool for improving readability of the online Belgian consolidated legislation. It requires a modern Web browser, such as Firefox. | ||
|
||
## Overview | ||
|
||
Here is the structure of this project. | ||
|
||
``` | ||
betterlex-bookmarklet | ||
├── bin | ||
│ ├── bookmarklet_fr.js | ||
│ └── bookmarklet_nl.js | ||
├── lib | ||
├── scripts | ||
│ ├── build | ||
│ └── install | ||
├── src | ||
│ ├── main.css | ||
│ ├── main.js | ||
│ ├── translations.json | ||
│ └── utility.js | ||
├── CREDITS | ||
├── LICENSE | ||
└── README.md | ||
``` | ||
|
||
## How to build the bookmarklet from scratch | ||
|
||
### Dependencies | ||
|
||
* PHP 5.4 or any newer version | ||
* [Composer](https://getcomposer.org/), a package manager for PHP | ||
* [spotch](https://github.com/miclf/spotch), a bookmarklet generator | ||
|
||
### Download and install dependencies | ||
|
||
You can use the following bash script to install the project’s dependencies. | ||
|
||
```bash | ||
./scripts/install | ||
``` | ||
|
||
### Build the bookmarklet | ||
|
||
Once the dependencies are installed, you just need to run this build script to generate both the French and Dutch versions of the bookmarklet. | ||
|
||
```bash | ||
./scripts/build | ||
``` | ||
|
||
## License | ||
|
||
This is free/libre software, made available under the terms of the [GNU General Public License (GPLv3)](LICENSE). |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
# Execute the script from the right location | ||
|
||
source="${BASH_SOURCE}" | ||
|
||
while [ -h "$source" ]; do | ||
source="$(readlink $source)" | ||
done | ||
|
||
cd "$(dirname $source)" | ||
|
||
|
||
# Resources | ||
|
||
bin="../bin/" | ||
src="../src/" | ||
|
||
css="${src}main.css" | ||
main="${src}main.js" | ||
trans="${src}translations.json" | ||
utils="${src}utility.js" | ||
|
||
|
||
# Where the magic happens | ||
|
||
for bookmarkletLang in "nl" "fr"; do | ||
|
||
tmpCSS=$(mktemp -t "blex_css.js.XXXXXXXXXX") | ||
tmpTrans=$(mktemp -t "blex_trans.js.XXXXXXXXXX") | ||
timestamp=$(date +"%Y-%m-%d_%Hh%M") | ||
|
||
## Generate temporary files containing JS vars | ||
|
||
### CSS (minified) | ||
|
||
if [ -f "$tmpCSS" ]; then | ||
echo "var css = '$(cat $css)';" > "$tmpCSS" | ||
else | ||
echo "betterlex: unable to create temporary file $tmpCSS" | ||
exit | ||
fi | ||
|
||
### Translations | ||
|
||
if [ -f "$tmpTrans" ]; then | ||
echo "var bookmarkletLang = '$bookmarkletLang'; window._translations = $(cat $trans);" > "$tmpTrans" | ||
else | ||
echo "betterlex: unable to create temporary file $tmpTrans" | ||
exit | ||
fi | ||
|
||
## Generate the bookmarklet | ||
|
||
../lib/spotch/bin/spotch make "$tmpTrans" "$tmpCSS" "$utils" "$main" --output "${bin}bookmarklet_${bookmarkletLang}_${timestamp}.js" --no-minify "$tmpTrans" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
# Execute the script from the right location | ||
|
||
source="${BASH_SOURCE}" | ||
|
||
while [ -h "$source" ]; do | ||
source="$(readlink $source)" | ||
done | ||
|
||
cd "$(dirname $source)" | ||
|
||
|
||
# Utility functions | ||
|
||
function is_installed() | ||
{ | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
function status() | ||
{ | ||
echo | ||
echo "betterlex: $1" | ||
echo | ||
} | ||
|
||
|
||
# Move to the "lib" directory | ||
|
||
cd ../lib | ||
|
||
|
||
# Create directories | ||
|
||
for dir in "composer" "spotch"; do | ||
if [ ! -d "$dir" ]; then | ||
mkdir "$dir" | ||
fi | ||
done | ||
|
||
|
||
# Install dependencies | ||
|
||
## Check if PHP is installed | ||
|
||
if ! is_installed php; then | ||
status "please install PHP before continuing." | ||
exit | ||
fi | ||
|
||
## Install Composer | ||
|
||
if [ ! -e "composer/composer.phar" ]; then | ||
status "installing Composer..." | ||
|
||
php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=composer | ||
fi | ||
|
||
## Install Spotch | ||
|
||
if [ ! -e "spotch/bin/spotch" ]; then | ||
status "installing Spotch..." | ||
|
||
git clone "https://github.com/miclf/spotch.git" "spotch" | ||
(cd spotch && ../composer/composer.phar update) | ||
chmod +x "spotch/bin/spotch" | ||
fi |
Oops, something went wrong.