Skip to content

Commit f5533d6

Browse files
zvezdochiotmykaralw
authored andcommitted
0.20171223
Etc version
1 parent 9cc6826 commit f5533d6

File tree

15 files changed

+327
-103
lines changed

15 files changed

+327
-103
lines changed

DEPENDS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
war-bash
2-
Version: 0.20171221
2+
Version: 0.20171223
33
Description: WAR (KDE web archive) create and browse in bash
4-
Depends: bash, tar, gzip, sed, grep, findutils, coreutils
4+
Depends: bash, tar, gzip, sed, grep, findutils, coreutils, wget

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# war-bash
2-
Version 0.20171221
2+
Version 0.20171223
33

44
WAR file (KDE WEB archive) create and browse in bash.
55

@@ -16,9 +16,22 @@ OPTIONS:
1616
war-create
1717
WAR file (KDE WEB archive) creator.
1818

19-
USAGE: war-create [options] /path/to/html file.war
19+
USAGE: war-create [options] /path/to/html/dir [file.war]
20+
OPTIONS:
21+
-h display help and exit
22+
23+
war-unpack
24+
WAR file (KDE WEB archive) unpack.
25+
26+
USAGE: war-unpack [options] file.war
27+
OPTIONS:
28+
-h display help and exit
29+
30+
war-wget
31+
WAR file (KDE WEB archive) wget page.
32+
33+
USAGE: war-wget [options] name url/to/html/page
2034
OPTIONS:
21-
-i using exist index.html
2235
-h display help and exit
2336

2437

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.20171223

etc/war-bash.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# tmp dir
2+
# WARNING! Do not use "%" in the path
3+
#tmpdir="/tmp/war"
4+
tmpdir="/tmp/war"
5+
# browser
6+
#browser="x-www-browser"
7+
browser="x-www-browser"

war-browse renamed to usr/bin/war-browse

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/bash
22

3-
user="$(whoami)"
4-
tmpdir="/tmp/war_$user"
3+
tmpdir="/tmp/war"
54
browser="x-www-browser"
5+
[ -f /etc/war-bash.conf ] && source /etc/war-bash.conf
6+
[ -f ~/config/war-bash.conf ] && source ~/config/war-bash.conf
7+
user="$(whoami)"
8+
tmpdir="${tmpdir}_${user}"
69

710
function usage()
811
{
@@ -20,8 +23,6 @@ then
2023
usage
2124
fi
2225

23-
browser="x-www-browser"
24-
2526
while getopts ":b:h" opt
2627
do
2728
case $opt in
@@ -42,9 +43,9 @@ then
4243
fi
4344

4445
rm -rf "$tmpdir"
45-
mkdir -p "$tmpdir"
46-
tar xz -C "$tmpdir" -f "$warfile"
46+
mkdir -p "$tmpdir/$warfile"
47+
tar xz -C "$tmpdir/$warfile" -f "$warfile"
4748

48-
$browser "$tmpdir/index.html"
49+
$browser "$tmpdir/$warfile/index.html"
4950

5051
rm -rf "$tmpdir"

usr/bin/war-create

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
tmpdir="/tmp/war"
4+
browser="x-www-browser"
5+
[ -f /etc/war-bash.conf ] && source /etc/war-bash.conf
6+
[ -f ~/config/war-bash.conf ] && source ~/config/war-bash.conf
7+
user="$(whoami)"
8+
tmpdir="${tmpdir}_${user}"
9+
10+
function usage()
11+
{
12+
echo "WAR file (KDE WEB archive) creator."
13+
echo
14+
echo "USAGE: $0 [options] /path/to/html/dir [file.war]"
15+
echo "options:"
16+
echo " -h help."
17+
echo
18+
exit 1
19+
}
20+
if [ $# = 0 ]
21+
then
22+
usage
23+
fi
24+
25+
while getopts ":h" opt
26+
do
27+
case $opt in
28+
h) usage
29+
;;
30+
*) echo "Unknown option -$OPTARG"
31+
exit 1
32+
;;
33+
esac
34+
done
35+
shift "$(($OPTIND - 1))"
36+
htmldir="$1"
37+
if [ ! -d "$htmldir" ]
38+
then
39+
usage
40+
fi
41+
warfile="$2"
42+
if [ -z "$warfile" ]
43+
then
44+
warfile="$(basename $htmldir).war"
45+
fi
46+
47+
rm -rf "$tmpdir"
48+
mkdir -p "$tmpdir"
49+
cp -frv "$htmldir" "$tmpdir"
50+
51+
function index_gen()
52+
{
53+
td="$1"
54+
if [ -d "$td" ]
55+
then
56+
cd "$td"
57+
cat > "index.html" <<EOF
58+
<!DOCTYPE html>
59+
<!-- Source is http://www.warmplace.ru/ -->
60+
<html>
61+
<head>
62+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
63+
<title>$htmldir</title>
64+
</head>
65+
<body>
66+
<h1>$htmldir</h1>
67+
<ol>
68+
EOF
69+
find . -iname "*.html" -o -iname "*.htm" | sort | sed -e "s/.*/ <li><a href=\"&\">&<\/a><\/li>/;" >> "index.html"
70+
cat >> "index.html" <<EOF
71+
</ol>
72+
</body>
73+
</html>
74+
EOF
75+
sed -i -e '/<li><a href=".\/index.html">.\/index.html<\/a><\/li>/d' "index.html"
76+
cd -
77+
fi
78+
}
79+
80+
if [ ! -f "$tmpdir/$htmldir/index.html" ]
81+
then
82+
index_gen "$tmpdir/$htmldir"
83+
fi
84+
85+
tar cz -C "$tmpdir/$htmldir" -f "$warfile" .
86+
rm -rf "$tmpdir"

usr/bin/war-unpack

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
tmpdir="/tmp/war"
4+
browser="x-www-browser"
5+
[ -f /etc/war-bash.conf ] && source /etc/war-bash.conf
6+
[ -f ~/config/war-bash.conf ] && source ~/config/war-bash.conf
7+
user="$(whoami)"
8+
tmpdir="${tmpdir}_${user}"
9+
10+
function usage()
11+
{
12+
echo "WAR file (KDE WEB archive) unpack."
13+
echo
14+
echo "USAGE: $0 [options] file.war"
15+
echo "options:"
16+
echo " -h help."
17+
echo
18+
exit 1
19+
}
20+
if [ $# = 0 ]
21+
then
22+
usage
23+
fi
24+
25+
while getopts ":h" opt
26+
do
27+
case $opt in
28+
h) usage
29+
;;
30+
*) echo "Unknown option -$OPTARG"
31+
exit 1
32+
;;
33+
esac
34+
done
35+
shift "$(($OPTIND - 1))"
36+
warfile="$1"
37+
if [ -z "$warfile" ]
38+
then
39+
usage
40+
fi
41+
42+
upkdir="${warfile%.*}"
43+
mkdir -p "$upkdir"
44+
tar xz -C "$upkdir" -f "$warfile"

usr/bin/war-wget

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
3+
tmpdir="/tmp/war"
4+
browser="x-www-browser"
5+
[ -f /etc/war-bash.conf ] && source /etc/war-bash.conf
6+
[ -f ~/config/war-bash.conf ] && source ~/config/war-bash.conf
7+
user="$(whoami)"
8+
tmpdir="${tmpdir}_${user}"
9+
10+
function usage()
11+
{
12+
echo "WAR file (KDE WEB archive) wget page."
13+
echo
14+
echo "USAGE: $0 [options] name url/to/html/page"
15+
echo "options:"
16+
echo " -h help."
17+
echo
18+
exit 1
19+
}
20+
if [ $# = 0 ]
21+
then
22+
usage
23+
fi
24+
25+
while getopts ":h" opt
26+
do
27+
case $opt in
28+
h) usage
29+
;;
30+
*) echo "Unknown option -$OPTARG"
31+
exit 1
32+
;;
33+
esac
34+
done
35+
shift "$(($OPTIND - 1))"
36+
htmldir="$1"
37+
if [ -z "$htmldir" ]
38+
then
39+
usage
40+
fi
41+
htmlurl="$2"
42+
if [ -z "$htmlurl" ]
43+
then
44+
usage
45+
fi
46+
if [ -z "$warfile" ]
47+
then
48+
warfile="$htmldir.war"
49+
fi
50+
51+
rm -rf "$tmpdir"
52+
mkdir -p "$tmpdir"
53+
wget -c -t0 -p -k -E -P "$tmpdir/$htmldir" "$htmlurl"
54+
55+
function index_gen()
56+
{
57+
td="$1"
58+
if [ -d "$td" ]
59+
then
60+
cd "$td"
61+
cat > "index.html" <<EOF
62+
<!DOCTYPE html>
63+
<!-- Source is http://www.warmplace.ru/ -->
64+
<html>
65+
<head>
66+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
67+
<title>$htmldir</title>
68+
</head>
69+
<body>
70+
<h1>$htmldir</h1>
71+
<ol>
72+
EOF
73+
find . -iname "*.html" -o -iname "*.htm" | sort | sed -e "s/.*/ <li><a href=\"&\">&<\/a><\/li>/;" >> "index.html"
74+
cat >> "index.html" <<EOF
75+
</ol>
76+
</body>
77+
</html>
78+
EOF
79+
sed -i -e '/<li><a href=".\/index.html">.\/index.html<\/a><\/li>/d' "index.html"
80+
cd -
81+
fi
82+
}
83+
84+
if [ ! -f "$tmpdir/$htmldir/index.html" ]
85+
then
86+
index_gen "$tmpdir/$htmldir"
87+
fi
88+
89+
tar cz -C "$tmpdir/$htmldir" -f "$warfile" .
90+
rm -rf "$tmpdir"

usr/share/doc/war-bash/AUTORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
zvezdochiot <[email protected]>
2+
https://github.com/zvezdochiot/war-bash

usr/share/doc/war-bash/DEPENDS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
war-bash
2+
Version: 0.20171223
3+
Description: WAR (KDE web archive) create and browse in bash
4+
Depends: bash, tar, gzip, sed, grep, findutils, coreutils, wget

0 commit comments

Comments
 (0)