Skip to content

Commit 9525f49

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

File tree

11 files changed

+71
-33
lines changed

11 files changed

+71
-33
lines changed

DEPENDS

Lines changed: 1 addition & 1 deletion
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
44
Depends: bash, tar, gzip, sed, grep, findutils, coreutils

README.md

Lines changed: 2 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,8 @@ 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
2020
OPTIONS:
21-
-i using exist index.html
2221
-h display help and exit
2322

2423

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: 5 additions & 4 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

war-create renamed to usr/bin/war-create

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/bin/bash
22

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
37
user="$(whoami)"
4-
tmpdir="/tmp/war_$user"
5-
tmpdirsed="\/tmp\/war_$user\/"
8+
tmpdir="${tmpdir}_${user}"
69

710
function usage()
811
{
912
echo "WAR file (KDE WEB archive) creator."
1013
echo
11-
echo "USAGE: $0 [options] /path/to/html file.war"
14+
echo "USAGE: $0 [options] /path/to/html/dir file.war"
1215
echo "options:"
13-
echo " -i using exist index.html."
1416
echo " -h help."
1517
echo
1618
exit 1
@@ -20,13 +22,9 @@ then
2022
usage
2123
fi
2224

23-
indexuse="false"
24-
25-
while getopts ":ih" opt
25+
while getopts ":h" opt
2626
do
2727
case $opt in
28-
i) indexuse="true"
29-
;;
3028
h) usage
3129
;;
3230
*) echo "Unknown option -$OPTARG"
@@ -46,12 +44,10 @@ then
4644
warfile="$htmldir.war"
4745
fi
4846

49-
if [ $indexuse = "true" ]
47+
indexuse="false"
48+
if [ -f "$htmldir/index.html" ]
5049
then
51-
if [ ! -f "$htmldir/index.html" ]
52-
then
53-
indexuse="false"
54-
fi
50+
indexuse="true"
5551
fi
5652

5753
rm -rf "$tmpdir"
@@ -62,7 +58,8 @@ if [ $indexuse = "true" ]
6258
then
6359
tar cz -C "$tmpdir/$htmldir" -f "$warfile" .
6460
else
65-
cat > "$tmpdir/index.html" <<EOF
61+
tmpdirsed="$(echo $tmpdir/$htmldir | sed 's%\/%\\/%g')\/"
62+
cat > "$tmpdir/$htmldir/index.html" <<EOF
6663
<!DOCTYPE html>
6764
<!-- Source is http://www.warmplace.ru/ -->
6865
<html>
@@ -74,14 +71,14 @@ else
7471
<h1>$htmldir</h1>
7572
<ol>
7673
EOF
77-
find "$tmpdir" -iname "*.html" | sed -e "s/$tmpdirsed//;s/.*/ <li><a href=\".\/&\">&<\/a><\/li>/;" >> "$tmpdir/index.html"
78-
find "$tmpdir" -iname "*.htm" | sed -e "s/$tmpdirsed//;s/.*/ <li><a href=\".\/&\">&<\/a><\/li>/;" >> "$tmpdir/index.html"
79-
cat >> "$tmpdir/index.html" <<EOF
74+
find "$tmpdir/$htmldir" -iname "*.html" | sed -e "s/$tmpdirsed//;s/.*/ <li><a href=\".\/&\">&<\/a><\/li>/;" >> "$tmpdir/$htmldir/index.html"
75+
find "$tmpdir/$htmldir" -iname "*.htm" | sed -e "s/$tmpdirsed//;s/.*/ <li><a href=\".\/&\">&<\/a><\/li>/;" >> "$tmpdir/$htmldir/index.html"
76+
cat >> "$tmpdir/$htmldir/index.html" <<EOF
8077
</ol>
8178
</body>
8279
</html>
8380
EOF
84-
sed -i -e '/<li><a href=".\/index.html">index.html<\/a><\/li>/d' "$tmpdir/index.html"
85-
tar cz -C "$tmpdir" -f "$warfile" .
81+
sed -i -e '/<li><a href=".\/index.html">index.html<\/a><\/li>/d' "$tmpdir/$htmldir/index.html"
82+
tar cz -C "$tmpdir/$htmldir" -f "$warfile" .
8683
fi
8784
rm -rf "$tmpdir"

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

usr/share/doc/war-bash/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# war-bash
2+
Version 0.20171223
3+
4+
WAR file (KDE WEB archive) create and browse in bash.
5+
6+
Utils:
7+
8+
war-browse
9+
WAR file (KDE WEB archive) viewer in browser.
10+
11+
USAGE: war-browse [options] file.war
12+
OPTIONS:
13+
-b use browser (default = 'x-www-browser');
14+
-h display help and exit
15+
16+
war-create
17+
WAR file (KDE WEB archive) creator.
18+
19+
USAGE: war-create [options] /path/to/html/dir file.war
20+
OPTIONS:
21+
-h display help and exit
22+
23+
24+
COPYRIGHT:
25+
Copyright (c) 2017 zvezdochiot
26+
27+
CONTACTS:
28+
Homepage: https://github.com/zvezdochiot/war-bash

usr/share/doc/war-bash/VERSION

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

sample/sys-bash.war renamed to usr/share/doc/war-bash/sample/sys-bash.war

File renamed without changes.

0 commit comments

Comments
 (0)