maj des templates
This commit is contained in:
parent
d4f5d6bf86
commit
cfdce28833
|
@ -3,6 +3,8 @@
|
|||
# Noms et extensions reconnus
|
||||
NAMES=(
|
||||
Properties:javaproperties
|
||||
overview.html:javadoc-overview
|
||||
package.html:javadoc-package
|
||||
)
|
||||
EXTS=(
|
||||
txt:text
|
||||
|
@ -14,7 +16,7 @@ EXTS=(
|
|||
iuml:iuml
|
||||
sh:shell
|
||||
py:pyfile pyw:pyfile
|
||||
html:html4 htm:html4
|
||||
html:html htm:html
|
||||
php:php phps:php
|
||||
ctp:cakephp-ctp
|
||||
css:css
|
||||
|
@ -30,7 +32,8 @@ TEMPLATES=(
|
|||
sh:shell
|
||||
python:pyfile pyf:pyfile py:pyfile
|
||||
pym:pymodule
|
||||
html:html4
|
||||
jdo:javadoc-overview
|
||||
jdp:javadoc-package
|
||||
ctp:cakephp-ctp
|
||||
js:javascript
|
||||
properties:javaproperties jprops:javaproperties props:javaproperties
|
||||
|
@ -43,6 +46,6 @@ TEMPLS=(
|
|||
puml:plantuml iuml:plantuml
|
||||
shell:shell
|
||||
pyfile:python pymodule:python
|
||||
html5:www html4:www php:www cakephp-ctp:www css:www javascript:www
|
||||
html:www javadoc-package:www javadoc-overview:www php:www cakephp-ctp:www css:www javascript:www
|
||||
javaproperties:java java:java woapi:java wosrc:java wosrccomp:java
|
||||
)
|
||||
|
|
|
@ -23,7 +23,7 @@ OPTIONS
|
|||
}
|
||||
|
||||
NAME=www
|
||||
TEMPLATES=(html5 html4 javadoc-package javadoc-overview php cakephp-ctp css javascript)
|
||||
TEMPLATES=(html javadoc-package javadoc-overview php cakephp-ctp css javascript)
|
||||
NAMES=(package.html overview.html)
|
||||
EXTS=(html htm php phps ctp css js)
|
||||
|
||||
|
@ -59,24 +59,117 @@ function check_overwrite() {
|
|||
return 0
|
||||
}
|
||||
|
||||
function generate_html5() {
|
||||
local file="$1"
|
||||
local mode=html
|
||||
function __update_title() {
|
||||
titlehl="${titlehl,,}"
|
||||
[ -n "$titlehl" ] || titlehl=h1
|
||||
[ "${titlehl:0:1}" == "h" ] || titlehl="h$titlehl"
|
||||
|
||||
[ -n "$title" ] || {
|
||||
title="$(basename "$file")"
|
||||
title="${title%.*}"
|
||||
}
|
||||
[ -n "$head_title" ] || head_title="$title"
|
||||
}
|
||||
function __generate_html() {
|
||||
# $file et $mode doivent être initialisés
|
||||
|
||||
local dir="$(dirname "$file")"
|
||||
local nobpsuppl nobplocal nobpmobile
|
||||
if [ "$blueprint" == auto ]; then
|
||||
if [ -d "$dir/blueprint" ]; then
|
||||
blueprint=1
|
||||
[ -f "$dir/bpsuppl.css" ] || nobpsuppl=1
|
||||
[ -f "$dir/bplocal.css" ] || nobplocal=1
|
||||
[ -f "$dir/bpmobile.css" ] || nobpmobile=1
|
||||
else
|
||||
blueprint=
|
||||
fi
|
||||
fi
|
||||
local jquerymin
|
||||
if [ "$jquery" == auto ]; then
|
||||
if [ -f "$dir/jquery.min.js" ]; then
|
||||
jquery=1
|
||||
jquerymin=1
|
||||
elif [ -d "$dir/jquery.js" ]; then
|
||||
jquery=1
|
||||
else
|
||||
jquery=
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$doctype" in
|
||||
html4)
|
||||
doctype='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
html='<html lang="fr" xmlns="http://www.w3.org/TR/REC-html40">'
|
||||
;;
|
||||
html5)
|
||||
doctype='<!DOCTYPE html>'
|
||||
html='<html lang="fr">'
|
||||
;;
|
||||
*)
|
||||
doctype=
|
||||
html='<html>'
|
||||
;;
|
||||
esac
|
||||
head='<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset='"$encoding"'" />
|
||||
<link rel="shortcut" href="'"$baseurl"'favicon.ico" />
|
||||
<link rel="icon" href="'"$baseurl"'icon.png" />
|
||||
<link rel="apple-touch-icon" href="'"$baseurl"'icon.png" />'
|
||||
[ -n "$blueprint" ] && blueprint='<link rel="stylesheet" href="'"$bpurl"'screen.css" type="text/css" media="screen, projection" />
|
||||
<link rel="stylesheet" href="'"$bpurl"'print.css" type="text/css" media="print" />
|
||||
<!--[if lt IE 8]>
|
||||
<link rel="stylesheet" href="'"$bpurl"'ie.css" type="text/css" media="screen, projection" />
|
||||
<![endif]-->
|
||||
<'"${nobpsuppl:+!--}"'link rel="stylesheet" href="bpsuppl.css" type="text/css" media="screen, projection" /'"${nobpsuppl:+--}"'>
|
||||
<'"${nobplocal:+!--}"'link rel="stylesheet" href="bplocal.css" type="text/css" media="screen, projection" /'"${nobplocal:+--}"'>
|
||||
<'"${nobpmobile:+!--}"'link rel="stylesheet" href="bpmobile.css" type="text/css" media="handheld, only screen and (max-device-width: 480px)" /'"${nobpmobile:+--}"'>'
|
||||
[ -n "$jquery" ] && jquery='<script src="'"${baseurl}jquery${jquerymin:+.min}.js"'"></script>'
|
||||
start='<title>'"$head_title"'</title>
|
||||
</head>
|
||||
<body>'
|
||||
startbp='<div class="container">'
|
||||
endbp='</div>'
|
||||
end='</body>
|
||||
</html>'
|
||||
}
|
||||
function __update_html() {
|
||||
html="<!-- -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding
|
||||
-->$html"
|
||||
}
|
||||
function __write_html() {
|
||||
# $file et $mode doivent être initialisés
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
echo >"$file" "${doctype:+$doctype
|
||||
}$html
|
||||
$head
|
||||
${blueprint:+$blueprint
|
||||
}${jquery:+$jquery
|
||||
}$start
|
||||
${blueprint:+$startbp
|
||||
}${title:+<$titlehl>$title</$titlehl>
|
||||
}${blueprint:+$endbp
|
||||
}$end"
|
||||
}
|
||||
|
||||
function generate_html4() {
|
||||
function generate_html() {
|
||||
local file="$1"
|
||||
local mode=html
|
||||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
local titlehl="${titlehl:-h1}"
|
||||
local title="$title"
|
||||
__update_title
|
||||
|
||||
local doctype="$doctype"
|
||||
local blueprint="$blueprint"
|
||||
local jquery="$jquery"
|
||||
local html head start startbp endbp end
|
||||
__generate_html
|
||||
__update_html
|
||||
|
||||
__write_html
|
||||
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -85,9 +178,23 @@ function generate_javadoc_package() {
|
|||
local file="$1"
|
||||
local mode=html
|
||||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
local titlehl="${titlehl:-h2}"
|
||||
local title="$title"
|
||||
__update_title
|
||||
# title doit se terminer par un point
|
||||
[ "${title:$((-1)):1}" == / ] || title="$title."
|
||||
# Mettre un préfixe au titre
|
||||
title="Package: $title"
|
||||
|
||||
local doctype="$doctype"
|
||||
local blueprint=
|
||||
local jquery=
|
||||
local html head start startbp endbp end
|
||||
__generate_html
|
||||
__update_html
|
||||
|
||||
__write_html
|
||||
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -96,9 +203,23 @@ function generate_javadoc_overview() {
|
|||
local file="$1"
|
||||
local mode=html
|
||||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
local titlehl="${titlehl:-h2}"
|
||||
local title="$title"
|
||||
__update_title
|
||||
# title doit se terminer par un point
|
||||
[ "${title:$((-1)):1}" == / ] || title="$title."
|
||||
# Mettre un préfixe au titre
|
||||
title="Projet: $title"
|
||||
|
||||
local doctype="$doctype"
|
||||
local blueprint=
|
||||
local jquery=
|
||||
local html head start startbp endbp end
|
||||
__generate_html
|
||||
__update_html
|
||||
|
||||
__write_html
|
||||
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -107,9 +228,20 @@ function generate_php() {
|
|||
local file="$1"
|
||||
local mode=php
|
||||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
local titlehl="${titlehl:-h1}"
|
||||
local title="$title"
|
||||
__update_title
|
||||
|
||||
local doctype="$doctype"
|
||||
local blueprint="$blueprint"
|
||||
local jquery="$jquery"
|
||||
local html head start startbp endbp end
|
||||
__generate_html
|
||||
html="<?php # -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=2:sts=2:et:ai:si:sta:fenc=$encoding
|
||||
?>$html"
|
||||
|
||||
__write_html
|
||||
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -120,7 +252,8 @@ function generate_cakephp_ctp() {
|
|||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
echo >"$file" "<?php # -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=2:sts=2:et:ai:si:sta:fenc=$encoding"
|
||||
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -131,7 +264,8 @@ function generate_css() {
|
|||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
echo >"$file" "/* -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding
|
||||
*/@CHARSET $encoding;"
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -142,7 +276,8 @@ function generate_javascript() {
|
|||
|
||||
check_overwrite "$1" || return
|
||||
estep "$(ppath "$file")"
|
||||
echo >"$file" "# -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding"
|
||||
echo >"$file" "/* -*- coding: $encoding ${mode:+mode: $mode }-*- vim:sw=4:sts=4:et:ai:si:sta:fenc=$encoding
|
||||
*/"
|
||||
[ -n "$2" ] && array_add "$2" "$file"
|
||||
return 0
|
||||
}
|
||||
|
@ -152,6 +287,14 @@ edit=1
|
|||
overwrite=
|
||||
encoding=
|
||||
#executable=
|
||||
baseurl=/
|
||||
doctype=html4
|
||||
blueprint=auto
|
||||
jquery=auto
|
||||
bpurl=
|
||||
titlehl=
|
||||
title=
|
||||
head_title=
|
||||
parse_opts "${PRETTYOPTS[@]}" \
|
||||
--help '$exit_with display_help' \
|
||||
-t:,--template: template= \
|
||||
|
@ -159,12 +302,27 @@ parse_opts "${PRETTYOPTS[@]}" \
|
|||
-g,--no-edit edit= \
|
||||
-f,--overwrite overwrite=1 \
|
||||
-E:,--encoding: encoding= \
|
||||
--doctype: doctype= \
|
||||
-4,--html4 doctype=html4 \
|
||||
-5,--html5 doctype=html5 \
|
||||
-U:,--baseurl: baseurl= \
|
||||
-b,--blueprint,--bp blueprint=1 \
|
||||
-n,--no-blueprint,--noblueprint,--nobp blueprint= \
|
||||
-j,--jquery jquery=1 \
|
||||
-k,--no-jquery,--nojquery jquery= \
|
||||
-B:,--bpurl: bpurl= \
|
||||
--titlehl:,--hl: titlehl= \
|
||||
-T:,--title: title= \
|
||||
--head-title: head_title= \
|
||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||
# à rajouter ci-dessus si les fichiers peuvent être exécutables:
|
||||
#-x,--executable executable=1 \
|
||||
#-n,--no-executable executable= \
|
||||
|
||||
[ -n "$encoding" ] || encoding=utf-8
|
||||
[ -z "$baseurl" -o "${baseurl:$((-1)):1}" == / ] || baseurl="$baseurl/"
|
||||
[ -n "$bpurl" ] || bpurl="${baseurl}blueprint/"
|
||||
[ "${bpurl:$((-1)):1}" == / ] || bpurl="$bpurl/"
|
||||
|
||||
files2edit=()
|
||||
r=0
|
||||
|
@ -175,12 +333,14 @@ for file in "$@"; do
|
|||
name="$(basename "$file")"
|
||||
# Si template n'est pas spécifié, le déterminer le cas échéant à partir
|
||||
# du nom de fichier. Rajouter ici le code approprié
|
||||
case "$name" in
|
||||
overview.html) t=javadoc-overview;;
|
||||
package.html) t=javadoc-package;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "$t" == html5 ]; then
|
||||
generate_html5 "$file" files2edit || r=$?
|
||||
elif [ "$t" == html4 ]; then
|
||||
generate_html4 "$file" files2edit || r=$?
|
||||
if [ "$t" == html ]; then
|
||||
generate_html "$file" files2edit || r=$?
|
||||
elif [ "$t" == javadoc-package ]; then
|
||||
generate_javadoc_package "$file" files2edit || r=$?
|
||||
elif [ "$t" == javadoc-overview ]; then
|
||||
|
|
Loading…
Reference in New Issue