Compare commits

..

7 Commits

Author SHA1 Message Date
c5d2e44156 Main script for create index files 2024-12-16 20:49:16 +01:00
1286e0f1c8 Main index html for redirect for files 2024-12-16 20:48:59 +01:00
e2b16423f5 Template file 2024-12-16 20:48:23 +01:00
36c9b13daa Set language index script 2024-12-16 20:47:47 +01:00
36b818953c Clean index files 2024-12-16 20:47:27 +01:00
5a246ac75d Index scripts 2024-12-16 20:47:11 +01:00
e4896f1890 Resources 2024-12-16 20:46:48 +01:00
21 changed files with 8283 additions and 0 deletions

45
clean.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# Variables
find_list="/tmp/find_list"
files_list="/tmp/files_list"
path_gen=$(pwd)
make_file=${path_gen}/index.sh
# Show help and clean index files recursively
if [ -z "${1}" ] ; then
echo ""
echo "Usage: $0 <folder>"
echo ""
else
# Generate list recursive
if [ -d "${1}" ] ; then
list_find=$(find "${1}"/ -type d \( ! -iname ".*" \))
echo > ${find_list}
for list in $list_find ; do
check_list=$(echo $list | grep "/res")
if [ -z ${check_list} ] ; then
echo ${list} >> ${find_list}
else
echo > /dev/null
fi
done
count_find=$(wc -l ${find_list} | cut -d " " -f 1)
countf=1
while [ ${countf} -le ${count_find} ] ; do
find_read=$(cat ${find_list} | head -${countf} | tail -1)
rm -rf ${find_read}/.res 2> /dev/null
rm -rf ${find_read}/.index.html 2> /dev/null
rm -rf ${find_read}/.index.sh 2> /dev/null
if [ ! -z "${find_read}" ] ; then
echo "# Cleaning index files for ${find_read}"
fi
cd ${find_read}
cd ${path_gen}
countf=$(expr ${countf} + 1)
done
#rm -rf ${find_list}
else
echo "# Folder '${1}' not found"
fi
fi

0
files/template.txt Normal file
View File

54
index-recursive.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
# Variables
find_list="/tmp/find_list"
files_list="/tmp/files_list"
path_gen=$(pwd)
make_file=${path_gen}/index.sh
# Show help and init generate index files recursively
if [ -z "${1}" ] ; then
echo ""
echo "Usage: $0 <folder>"
echo ""
else
cp -rf ${path_gen}/index.sh ${path_gen}/.index.sh 2> /dev/null
chmod +x ${make_file}
bash ${path_gen}/index.sh "${1}"
# Generate index recursive
if [ -d "${1}" ] ; then
list_find=$(find "${1}"/ -type d \( ! -iname ".*" \))
echo > ${find_list}
for list in $list_find ; do
check_list=$(echo $list | grep "/res")
if [ -z ${check_list} ] ; then
echo ${list} >> ${find_list}
else
echo > /dev/null
fi
done
count_find=$(wc -l ${find_list} | cut -d " " -f 1)
countf=1
while [ ${countf} -le ${count_find} ] ; do
find_read=$(cat ${find_list} | head -${countf} | tail -1)
rm -rf ${find_read}/.res/res 2> /dev/null
cp -rf ${path_gen}/.res ${find_read}/ 2> /dev/null
cp -rf ${path_gen}/res ${find_read}/.res 2> /dev/null
cp -rf ${path_gen}/index.sh ${find_read}/.index.sh 2> /dev/null
cp -rf ${path_gen}/.index.sh ${find_read}/.index.sh 2> /dev/null
#cp -rf ${path_gen}/index-recursive.sh ${find_read}/.index-recursive.sh 2> /dev/null
#cp -rf ${path_gen}/.index-recursive.sh ${find_read}/.index-recursive.sh 2> /dev/null
if [ ! -z "${find_read}" ] ; then
echo "# Generating index files for ${find_read}"
fi
cd ${find_read}
chmod +x .index.sh 2> /dev/null
bash .index.sh . 2> /dev/null
cd ${path_gen}
countf=$(expr ${countf} + 1)
done
#rm -rf ${find_list}
else
echo "# Folder '${1}' not found"
fi
fi

3
index.html Executable file
View File

@ -0,0 +1,3 @@
<html>
<meta http-equiv="Refresh" content="0; url='files/.index.html'" />
</html>

72
index.sh Executable file
View File

@ -0,0 +1,72 @@
#!/bin/bash
# Variables
find_list="/tmp/find_list"
files_list="/tmp/files_list"
path_gen=$(pwd)
# Commands
ls_command="/bin/ls"
# Show help and init generate index files
if [ -z "${1}" ] ; then
echo ""
echo "Usage: $0 <folder>"
echo ""
else
# Generate main index folder
if [ -d "${1}" ] ; then
#echo "# Generating index files for ${1}"
${ls_command} -1 --group-directories-first "${1}"/ > ${files_list}
rm -rf ${1}/.res/res 2> /dev/null
cp -rf ${path_gen}/res ${1}/.res 2> /dev/null
cp -rf ${path_gen}/res/head.html ${1}/.index.html 2> /dev/null
cp -rf ${path_gen}/.res ${1}/ 2> /dev/null
cp -rf ${path_gen}/.res/head.html ${1}/.index.html 2> /dev/null
count_list=$(wc -l ${files_list} | cut -d " " -f 1)
count=1
while [ ${count} -le ${count_list} ] ; do
line_read=$(cat ${files_list} | head -${count} | tail -1)
if [ "${line_read}" == "index.sh" ] ; then
count=$(expr ${count} + 1)
elif [ "${line_read}" == "index-recursive.sh" ] ; then
count=$(expr ${count} + 1)
elif [ "${line_read}" == "index.html" ] ; then
count=$(expr ${count} + 1)
elif [ "${line_read}" == "res" ] ; then
count=$(expr ${count} + 1)
else
if [ -d "${line_read}" ] ; then
echo "# Generating entry for '${line_read}'"
echo -n '<li class="list-group-item"><center><img src=".res/folder.png" width="21" height="21"> <a href="' >> ${1}/.index.html
echo -n "${line_read}/.index.html" >> ${1}/.index.html
echo -n '">' >> ${1}/.index.html
echo -n "${line_read}" >> ${1}/.index.html
echo '</a></center></li>' >> ${1}/.index.html
count=$(expr ${count} + 1)
elif [ -f "${line_read}" ] ; then
echo "# Generating entry for '${line_read}'"
echo -n '<li class="list-group-item"><center><img src=".res/file.png" width="21" height="21"> <a href="' >> ${1}/.index.html
echo -n "${line_read}" >> ${1}/.index.html
echo -n '">' >> ${1}/.index.html
echo -n "${line_read}" >> ${1}/.index.html
echo '</a></center></li>' >> ${1}/.index.html
count=$(expr ${count} + 1)
else
echo "# Generating entry for '${line_read}'"
echo -n '<li class="list-group-item"><center><img src=".res/link.png" width="23" height="21"> <a href="' >> ${1}/.index.html
echo -n "${line_read}/.index.html" >> ${1}/.index.html
echo -n '">' >> ${1}/.index.html
echo -n "${line_read}" >> ${1}/.index.html
echo '</a></center></li>' >> ${1}/.index.html
count=$(expr ${count} + 1)
fi
fi
done
cat ${path_gen}/res/tail.html >> ${1}/.index.html 2> /dev/null
cat ${path_gen}/.res/tail.html >> ${1}/.index.html 2> /dev/null
rm -rf ${files_list}
else
echo "# Folder '${1}' not found"
fi
fi

14
lang/de.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - Über das HTTP(s)-Protokoll freigegebene Dateien</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - Über das HTTP(s)-Protokoll freigegebene Dateien</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Zurück <img src=".res/arrow.png" width="10" height="15"> Zum vorherigen Verzeichnis wechseln</a></center></li>

14
lang/en.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - Files shared via HTTP(s) protocol</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - Files shared via HTTP(s) protocol</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Back <img src=".res/arrow.png" width="10" height="15"> Go to previous directory</a></center></li>

14
lang/es.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - Archivos compartidos mediante el protocolo HTTP(s)</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - Archivos compartidos mediante el protocolo HTTP(s)</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Atrás <img src=".res/arrow.png" width="10" height="15"> Ir al directorio previo</a></center></li>

14
lang/fr.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - Fichiers partagés via le protocole HTTP(s)</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - Fichiers partagés via le protocole HTTP(s)</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Retour <img src=".res/arrow.png" width="10" height="15"> Aller au répertoire précédent</a></center></li>

14
lang/it.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - File condivisi tramite protocollo HTTP(s)</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - File condivisi tramite protocollo HTTP(s)</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Indietro <img src=".res/arrow.png" width="10" height="15"> Vai alla directory precedente</a></center></li>

14
lang/ru.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - Обмен файлами по протоколу HTTP(s)</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - Обмен файлами по протоколу HTTP(s)</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Назад <img src=".res/arrow.png" width="10" height="15"> Перейти в предыдущий каталог</a></center></li>

9
make-html-browser.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
dir=$(dirname $0)
dir_files="$(dirname $0)/files"
# Create index for HTML
cd ${dir}
bash clean.sh ${dir_files}
bash index-recursive.sh ${dir_files}

BIN
res/arrow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

7968
res/bootstrap-dark.min.css vendored Executable file

File diff suppressed because it is too large Load Diff

BIN
res/file.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
res/folder.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

14
res/head.html Executable file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="s" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href=".res/folder.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files - Files shared via HTTP(s) protocol</title>
<link rel="stylesheet" href=".res/bootstrap-dark.min.css">
</head>
<body class="bootstrap-dark">
<div class="container">
<h4><center><img src=".res/folder.png" width="25" height="25"> Files - Files shared via HTTP(s) protocol</center></h4>
<ul class="list-group">
<li class="list-group-item"><center><a href="../.index.html">Back <img src=".res/arrow.png" width="10" height="15"> Go to previous directory</a></center></li>

BIN
res/link.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

5
res/tail.html Executable file
View File

@ -0,0 +1,5 @@
</ul>
<br>
</div>
</body>
</html>

BIN
res/ubuntu.ttf Executable file

Binary file not shown.

29
set-lang.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
dir=$(dirname $0)
lang_dir="$(dirname $0)/lang"
# List available languages
lang_available=$(ls -1 ${lang_dir}/ 2> /dev/null | cut -d "." -f 1)
# Set language
if [ -z "${1}" ] ; then
echo ""
echo "* Set language for html indexer"
echo ""
echo "Sintax: $0 <lang>"
echo ""
echo "Available lang:" ${lang_available}
echo ""
else
if [ -f "${lang_dir}/${1}.html" ] ; then
cp -rf "${lang_dir}/${1}.html" "${dir}/res/head.html"
echo "Language '${1}' set correctly"
echo "Run 'make-html-browser.sh' for to generate the html files"
exit 0
else
echo "Language '${1}' not available"
exit 1
fi
fi