-
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.
Showing
14 changed files
with
463 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,4 @@ | ||
htmlz-bash | ||
Version: 0.20171227 | ||
Description: HTMLZ (ZIP web archive) create and browse in bash | ||
Depends: bash, 7z, sed, grep, findutils, coreutils, wget |
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 |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# htmlz-bash | ||
Version 0.20171227 | ||
|
||
HTMLZ file (ZIP WEB archive) create and browse in bash. | ||
|
||
Utils: | ||
|
||
htmlz-browse | ||
HTMLZ file (ZIP WEB archive) viewer in browser. | ||
|
||
USAGE: htmlz-browse [options] file.htmlz | ||
OPTIONS: | ||
-b use browser (default = 'x-www-browser'); | ||
-h display help and exit | ||
|
||
htmlz-create | ||
HTMLZ file (ZIP WEB archive) creator. | ||
|
||
USAGE: htmlz-create [options] /path/to/html/dir [file.htmlz] | ||
OPTIONS: | ||
-h display help and exit | ||
|
||
htmlz-unpack | ||
HTMLZ file (ZIP WEB archive) unpack. | ||
|
||
USAGE: htmlz-unpack [options] file.htmz | ||
OPTIONS: | ||
-h display help and exit | ||
|
||
htmlz-wget | ||
HTMLZ file (ZIP WEB archive) wget page. | ||
|
||
USAGE: htmlz-wget [options] name url/to/html/page | ||
OPTIONS: | ||
-c clean LIST (sample 'js,php,eot,wott,ttf', default = '') | ||
-r reject LIST (sample 'js,php,eot,wott,ttf', default = '') | ||
-h display help and exit | ||
|
||
COPYRIGHT: | ||
Copyright (c) 2017 zvezdochiot | ||
|
||
CONTACTS: | ||
Homepage: https://github.com/zvezdochiot/htmlz-bash |
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 @@ | ||
0.20171227 |
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,10 @@ | ||
# tmp dir | ||
# WARNING! Do not use "%" in the path | ||
#tmpdir="/tmp/htmlz" | ||
tmpdir="/tmp/htmlz" | ||
# browser | ||
#browser="x-www-browser" | ||
browser="x-www-browser" | ||
# clean and reject options | ||
#cleanlist='js,php,eot,wott,ttf' | ||
#rejectlist='js,php,eot,wott,ttf' |
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,51 @@ | ||
#!/bin/bash | ||
|
||
tmpdir="/tmp/htmlz" | ||
browser="x-www-browser" | ||
[ -f /etc/htmlz-bash.conf ] && source /etc/htmlz-bash.conf | ||
[ -f ~/config/htmlz-bash.conf ] && source ~/config/htmlz-bash.conf | ||
user="$(whoami)" | ||
tmpdir="${tmpdir}_${user}" | ||
|
||
function usage() | ||
{ | ||
echo "HTMLZ file (ZIP WEB archive) viewer in browser." | ||
echo | ||
echo "USAGE: $0 [options] file.htmlz" | ||
echo "options:" | ||
echo " -b 'str' use browser (default = 'x-www-browser');" | ||
echo " -h help." | ||
echo | ||
exit 1 | ||
} | ||
if [ $# = 0 ] | ||
then | ||
usage | ||
fi | ||
|
||
while getopts ":b:h" opt | ||
do | ||
case $opt in | ||
b) browser="$OPTARG" | ||
;; | ||
h) usage | ||
;; | ||
*) echo "Unknown option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift "$(($OPTIND - 1))" | ||
htmlzfile="$1" | ||
if [ -z "$htmlzfile" ] | ||
then | ||
usage | ||
fi | ||
|
||
rm -rf "$tmpdir" | ||
mkdir -p "$tmpdir/$htmlzfile" | ||
7z x "$htmlzfile" -o"$tmpdir/$htmlzfile" | ||
|
||
$browser "$tmpdir/$htmlzfile/index.html" | ||
|
||
rm -rf "$tmpdir" |
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,88 @@ | ||
#!/bin/bash | ||
|
||
tmpdir="/tmp/htmlz" | ||
browser="x-www-browser" | ||
[ -f /etc/htmlz-bash.conf ] && source /etc/htmlz-bash.conf | ||
[ -f ~/config/htmlz-bash.conf ] && source ~/config/htmlz-bash.conf | ||
user="$(whoami)" | ||
tmpdir="${tmpdir}_${user}" | ||
|
||
function usage() | ||
{ | ||
echo "HTMLZ file (ZIP WEB archive) creator." | ||
echo | ||
echo "USAGE: $0 [options] /path/to/html/dir [file.htmlz]" | ||
echo "options:" | ||
echo " -h help." | ||
echo | ||
exit 1 | ||
} | ||
if [ $# = 0 ] | ||
then | ||
usage | ||
fi | ||
|
||
while getopts ":h" opt | ||
do | ||
case $opt in | ||
h) usage | ||
;; | ||
*) echo "Unknown option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift "$(($OPTIND - 1))" | ||
htmldir="$1" | ||
if [ ! -d "$htmldir" ] | ||
then | ||
usage | ||
fi | ||
htmlzfile="$2" | ||
if [ -z "$htmlzfile" ] | ||
then | ||
htmlzfile="$(basename $htmldir).htmlz" | ||
fi | ||
|
||
rm -rf "$tmpdir" | ||
mkdir -p "$tmpdir" | ||
cp -frv "$htmldir" "$tmpdir" | ||
|
||
function index_gen() | ||
{ | ||
td="$1" | ||
if [ -d "$td" ] | ||
then | ||
cd "$td" | ||
cat > "index.html" <<EOF | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | ||
<title>$htmldir</title> | ||
</head> | ||
<body> | ||
<h1>$htmldir</h1> | ||
<ol> | ||
EOF | ||
find . -iname "*.html" -o -iname "*.htm" | sort | sed -e "s/.*/ <li><a href=\"&\">&<\/a><\/li>/;" >> "index.html" | ||
cat >> "index.html" <<EOF | ||
</ol> | ||
</body> | ||
</html> | ||
EOF | ||
sed -i -e '/<li><a href=".\/index.html">.\/index.html<\/a><\/li>/d' "index.html" | ||
cd - | ||
fi | ||
} | ||
|
||
if [ ! -f "$tmpdir/$htmldir/index.html" ] | ||
then | ||
index_gen "$tmpdir/$htmldir" | ||
fi | ||
|
||
cd "$tmpdir/$htmldir" | ||
7z a "$htmlzfile" -tzip . | ||
cd - | ||
mv "$tmpdir/$htmldir/$htmlzfile" "$htmlzfile" | ||
rm -rf "$tmpdir" |
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,48 @@ | ||
#!/bin/bash | ||
|
||
tmpdir="/tmp/htmlz" | ||
browser="x-www-browser" | ||
[ -f /etc/htmlz-bash.conf ] && source /etc/htmlz-bash.conf | ||
[ -f ~/config/htmlz-bash.conf ] && source ~/config/htmlz-bash.conf | ||
user="$(whoami)" | ||
tmpdir="${tmpdir}_${user}" | ||
|
||
function usage() | ||
{ | ||
echo "HTMLZ file (ZIP WEB archive) unpack." | ||
echo | ||
echo "USAGE: $0 [options] file.htmlz" | ||
echo "options:" | ||
echo " -h help." | ||
echo | ||
exit 1 | ||
} | ||
if [ $# = 0 ] | ||
then | ||
usage | ||
fi | ||
|
||
while getopts ":h" opt | ||
do | ||
case $opt in | ||
h) usage | ||
;; | ||
*) echo "Unknown option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift "$(($OPTIND - 1))" | ||
htmlzfile="$1" | ||
if [ -z "$htmlzfile" ] | ||
then | ||
usage | ||
fi | ||
|
||
upkdir="${htmlzfile%.*}" | ||
if [ "$upkdir" = "$htmlzfile" ] | ||
then | ||
upkdir="${htmlzfile}$$" | ||
fi | ||
mkdir -p "$upkdir" | ||
7z x "$htmlzfile" -o"$upkdir" |
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,111 @@ | ||
#!/bin/bash | ||
|
||
tmpdir="/tmp/htmlz" | ||
browser="x-www-browser" | ||
[ -f /etc/htmlz-bash.conf ] && source /etc/htmlz-bash.conf | ||
[ -f ~/config/htmlz-bash.conf ] && source ~/config/htmlz-bash.conf | ||
user="$(whoami)" | ||
tmpdir="${tmpdir}_${user}" | ||
|
||
function usage() | ||
{ | ||
echo "HTMLZ file (ZIP WEB archive) wget page." | ||
echo | ||
echo "USAGE: $0 [options] name url/to/html/page" | ||
echo "options:" | ||
echo " -c clean LIST (sample 'js,php,eot,wott,ttf', default = '')" | ||
echo " -r reject LIST (sample 'js,php,eot,wott,ttf', default = '')" | ||
echo " -h help." | ||
echo | ||
exit 1 | ||
} | ||
if [ $# = 0 ] | ||
then | ||
usage | ||
fi | ||
|
||
while getopts ":c:r:h" opt | ||
do | ||
case $opt in | ||
c) cleanlist="$OPTARG" | ||
;; | ||
r) rejectlist="$OPTARG" | ||
;; | ||
h) usage | ||
;; | ||
*) echo "Unknown option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift "$(($OPTIND - 1))" | ||
htmldir="$1" | ||
if [ -z "$htmldir" ] | ||
then | ||
usage | ||
fi | ||
htmlurl="$2" | ||
if [ -z "$htmlurl" ] | ||
then | ||
usage | ||
fi | ||
if [ -z "$htmlzfile" ] | ||
then | ||
htmlzfile="$htmldir.htmlz" | ||
fi | ||
|
||
rm -rf "$tmpdir" | ||
mkdir -p "$tmpdir/$htmldir" | ||
|
||
if [ -z "$rejectlist" ] | ||
then | ||
wget -c -t0 -p -k -E -P "$tmpdir/$htmldir" "$htmlurl" | ||
else | ||
wget -c -t0 -p -k -E -R "$rejectlist" -P "$tmpdir/$htmldir" "$htmlurl" | ||
fi | ||
|
||
function index_gen() | ||
{ | ||
td="$1" | ||
if [ -d "$td" ] | ||
then | ||
cd "$td" | ||
cat > "index.html" <<EOF | ||
<!DOCTYPE html> | ||
<!-- Source is http://www.warmplace.ru/ --> | ||
<html> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | ||
<title>$htmldir</title> | ||
</head> | ||
<body> | ||
<h1>$htmldir</h1> | ||
<ol> | ||
EOF | ||
find . -iname "*.html" -o -iname "*.htm" | sort | sed -e "s/.*/ <li><a href=\"&\">&<\/a><\/li>/;" >> "index.html" | ||
cat >> "index.html" <<EOF | ||
</ol> | ||
</body> | ||
</html> | ||
EOF | ||
sed -i -e '/<li><a href=".\/index.html">.\/index.html<\/a><\/li>/d' "index.html" | ||
cd - | ||
fi | ||
} | ||
|
||
if [ ! -f "$tmpdir/$htmldir/index.html" ] | ||
then | ||
index_gen "$tmpdir/$htmldir" | ||
fi | ||
|
||
cleanopt=$(echo "$cleanlist" | sed "s/\,/|/g") | ||
if [ ! -z "$cleanopt" ] | ||
then | ||
find "$tmpdir" -type f -regextype posix-egrep -regex '.*\.('$cleanopt')$' | xargs rm -v | ||
find "$tmpdir" -type f -regextype posix-egrep -regex '.*\.('$cleanopt')\?.*$' | xargs rm -v | ||
fi | ||
cd "$tmpdir/$htmldir" | ||
7z a "$htmlzfile" -tzip | ||
cd - | ||
mv "$tmpdir/$htmldir/$htmlzfile" "$htmlzfile" | ||
rm -rf "$tmpdir" |
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,2 @@ | ||
zvezdochiot <zvezdochiot@github.com> | ||
https://github.com/zvezdochiot/htmlz-bash |
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,4 @@ | ||
htmlz-bash | ||
Version: 0.20171227 | ||
Description: HTMLZ (ZIP web archive) create and browse in bash | ||
Depends: bash, 7z, sed, grep, findutils, coreutils, wget |
Oops, something went wrong.