Version 0.2.8
This commit is contained in:
parent
6bf0d9ed50
commit
ee6ea02e9d
24 changed files with 1583 additions and 317 deletions
47
CHANGELOG.md
47
CHANGELOG.md
|
@ -6,11 +6,58 @@ STL: Statique Littérateur
|
|||
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
|
||||
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
|
||||
|
||||
## [0.2.8]
|
||||
### check
|
||||
- fix: new display message if db exists
|
||||
- added option: all (update all checked articles' database. Show logs)
|
||||
|
||||
### domain
|
||||
- changes in getting domain process
|
||||
|
||||
### publish (! sync argument becomes publish)
|
||||
- Arguments: (ARTICLE), all. From wip/ to www/ folder
|
||||
- new files copy (used by (ARTICLE))
|
||||
|
||||
### wip, www
|
||||
- new option: remove (ARTICLE)
|
||||
|
||||
### wip
|
||||
- new files copy (used by (ARTICLE)) to wip/ (including .stl source)
|
||||
|
||||
### sidebar
|
||||
- type: stl sidebar load
|
||||
- - create static file stl.sidebar in articles/sidebar/ (if not exists)
|
||||
- - create HTML sidebar according to URI's articles in stl.sidebar
|
||||
- new code to take this new feature compatible with legacy command
|
||||
|
||||
### edit, read
|
||||
- added option: sidebar (to edit,read static file stl.sidebar)
|
||||
|
||||
### Logs
|
||||
- Better harmony
|
||||
- new publish, and remove display (also for files in article when needed)
|
||||
- new set hash status display
|
||||
- new per article logs
|
||||
- new option: clean all. Remove all logs
|
||||
|
||||
### Stats
|
||||
- file is now created in wip/ when publish, and copied to www/
|
||||
|
||||
### Autocompletion
|
||||
- most of all arguments and options can be autocompleted
|
||||
|
||||
### update
|
||||
- update domain configuration file + all checked articles' database
|
||||
|
||||
### /!\ IMPORTANT NOTE /!\
|
||||
- After installing this version, do: stl update
|
||||
|
||||
|
||||
## [0.2.7]
|
||||
### WIP
|
||||
- corrected a bug with nginx/apache refusing to access "../"
|
||||
|
||||
|
||||
## [0.2.6]
|
||||
### DB
|
||||
- set some variables ouside of cat
|
||||
|
|
2
control
2
control
|
@ -1,5 +1,5 @@
|
|||
Package: estl
|
||||
Version: 0.2.7
|
||||
Version: 0.2.8
|
||||
Section: custom
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
|
|
|
@ -2,10 +2,18 @@
|
|||
# Name: Statique Littérateur
|
||||
# Type: Configuration file
|
||||
# file: stl.conf
|
||||
# Folder: /etc/stl/stl.conf
|
||||
# Folder: /etc/stl/
|
||||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 61
|
||||
# functions: 0
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Register main app folders
|
||||
|
|
|
@ -6,6 +6,58 @@ STL: Statique Littérateur
|
|||
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
|
||||
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
|
||||
|
||||
## [0.2.8]
|
||||
### check
|
||||
- fix: new display message if db exists
|
||||
- added option: all (update all checked articles' database. Show logs)
|
||||
|
||||
### domain
|
||||
- changes in getting domain process
|
||||
|
||||
### publish (! sync argument becomes publish)
|
||||
- Arguments: (ARTICLE), all. From wip/ to www/ folder
|
||||
- new files copy (used by (ARTICLE))
|
||||
|
||||
### wip, www
|
||||
- new option: remove (ARTICLE)
|
||||
|
||||
### wip
|
||||
- new files copy (used by (ARTICLE)) to wip/ (including .stl source)
|
||||
|
||||
### sidebar
|
||||
- type: stl sidebar load
|
||||
- - create static file stl.sidebar in articles/sidebar/ (if not exists)
|
||||
- - create HTML sidebar according to URI's articles in stl.sidebar
|
||||
- new code to take this new feature compatible with legacy command
|
||||
|
||||
### edit, read
|
||||
- added option: sidebar (to edit,read static file stl.sidebar)
|
||||
|
||||
### Logs
|
||||
- Better harmony
|
||||
- new publish, and remove display (also for files in article when needed)
|
||||
- new set hash status display
|
||||
- new per article logs
|
||||
- new option: clean all. Remove all logs
|
||||
|
||||
### Stats
|
||||
- file is now created in wip/ when publish, and copied to www/
|
||||
|
||||
### Autocompletion
|
||||
- most of all arguments and options can be autocompleted
|
||||
|
||||
### update
|
||||
- update domain configuration file + all checked articles' database
|
||||
|
||||
### /!\ IMPORTANT NOTE /!\
|
||||
- After installing this version, do: stl update
|
||||
|
||||
|
||||
## [0.2.7]
|
||||
### WIP
|
||||
- corrected a bug with nginx/apache refusing to access "../"
|
||||
|
||||
|
||||
## [0.2.6]
|
||||
### DB
|
||||
- set some variables ouside of cat
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
## Métas
|
||||
Les métas utilisent le format suivant :
|
||||
Séparation des champs par ' : '
|
||||
|
||||
```
|
||||
valeur: Champ 1 : Champ 2 : Champ 3
|
||||
# Séparation des champs par ' : '
|
||||
```
|
||||
|
||||
### Métas Obligatoires (uniques)
|
||||
Les métas obligatoire à renseigner dans votre article :
|
||||
|
||||
Les métas obligatoires à renseigner dans votre article :
|
||||
Note: Ne pas mettre le signe `"` dans les metas
|
||||
|
||||
```
|
||||
|
@ -24,14 +25,6 @@ tags: tag,tag 2,tag 3
|
|||
Ces métas permettent de définir vos liens ainsi que leur description
|
||||
pour vos fichiers et vos textes.
|
||||
|
||||
- NAME peut être un numéro ou un nom à reprendre dans l'article
|
||||
- (URI)FILENAME est le nom du fichier
|
||||
- - Commençant par @ : le fichier est dans le dossier files ou images
|
||||
- - - /articles/images/ # Pour le marqueur `image:`
|
||||
- - - /articles/files/ # Pour tout autre marqueur
|
||||
- - - Sous-dossiers possibles (ex: /articles/images/logos/, à créer vous-même)
|
||||
- ALT-TEXT est utilisé pour la balise HTML `title="ALT-TEXT"`
|
||||
|
||||
```
|
||||
image: NAME : (URI)FILENAME : ALT-TEXT
|
||||
abbr: COURT : Long text : écriture (Champ 3 optionnel)
|
||||
|
@ -41,15 +34,22 @@ code: NAME : (URI)FILENAME : ALT-TEXT
|
|||
brut: NAME : (URI)FILENAME
|
||||
```
|
||||
|
||||
Note
|
||||
Ne pas commencer (URI) par `/`.
|
||||
- NAME peut être un numéro ou un nom à reprendre dans l'article
|
||||
- (URI)FILENAME est le nom du fichier
|
||||
- - Ne pas commencer (URI) par `/`
|
||||
- - Commençant par @ : le fichier est dans le dossier files ou images
|
||||
- - - /articles/images/ # Pour le marqueur `image:`
|
||||
- - - /articles/files/ # Pour tout autre marqueur
|
||||
- - - Sous-dossiers possibles (ex: /articles/images/logos/, à créer vous-même)
|
||||
- ALT-TEXT est utilisé pour la balise HTML `title="ALT-TEXT"`
|
||||
|
||||
|
||||
```
|
||||
# Exemple de (URI)
|
||||
image: 1 : @logos/gnu.png : Logo de GNU
|
||||
# L'imge gnu.png se trouve dans le dossier /articles/images/logos/
|
||||
# L'image gnu.png se trouve dans le dossier /articles/images/logos/
|
||||
|
||||
file : Doc : @xmpp/1.pdf : Documentation XMPP
|
||||
file: Doc : @xmpp/1.pdf : Documentation XMPP
|
||||
# le fichier 1.pdf se trouve à partir du dossier de l'article .stl dans
|
||||
# le sous-dossier xmpp. Exemple :
|
||||
# /articles/documentations/index.stl
|
||||
|
|
25
help/help
25
help/help
|
@ -6,7 +6,7 @@
|
|||
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
|
||||
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
|
||||
|
||||
# Arguments
|
||||
# Arguments (most of all can be reached with autocompletion)
|
||||
help, -h : This help
|
||||
readme : Show README.md
|
||||
|
||||
|
@ -17,14 +17,17 @@
|
|||
read
|
||||
(ARTICLE) : Read (ARTICLE) in terminal
|
||||
conf : Read current PWD DOMAIN configuration in terminal
|
||||
sidebar : Read current static sidebar file
|
||||
|
||||
edit
|
||||
(ARTICLE) : Edit (ARTICLE) in nano
|
||||
conf : Edit current PWD DOMAIN configuration in nano
|
||||
sidebar : Edit current static sidebar file
|
||||
|
||||
check : (Multi-arguments)
|
||||
(ARTICLE) : Check STL syntax
|
||||
-F : Force check again
|
||||
all : (independant). Update all checked articles' database
|
||||
|
||||
wip : (Multi-arguments)
|
||||
(ARTICLE) : Convert (ARTICLE) to HTML in wip folder
|
||||
|
@ -33,29 +36,39 @@
|
|||
sidebar=POS : POS is between 1 and max configured. After converted
|
||||
put article in sidebar at postition POS
|
||||
|
||||
publish : (ARTICLE), all. Create RSS feed, Stats and
|
||||
sync wip/ to www/
|
||||
all : Ask to perform rsync --delete
|
||||
(ARTICLE) : Mirrors needed folders, and files used by (ARTICLE)
|
||||
|
||||
remove : wip,www (ARTICLE). Remove (ARTICLE) from wip/, www/
|
||||
|
||||
rss : Create RSS feed in wip folder
|
||||
|
||||
sidebar : (ACTION) (POSITION) (ARTICLE)
|
||||
(ACTION) : No need (POSITION) nor (ARTICLE) for latest, oldest
|
||||
latest : Create sidebar with latest articles (ARTICLE date)
|
||||
oldest : Create sidebar with oldest articles (ARTICLE date)
|
||||
add : Create sidebar, add/replace (ARTICLE) at (POSITION)
|
||||
create : (alone argument), (re)Create whole sidebar
|
||||
load : Manage your static sidebar file (stl.sidebar)
|
||||
|
||||
stats : Manually generate stats (for statoolinfos)
|
||||
! useless with sync argument.
|
||||
! Works only for "server" install
|
||||
|
||||
sync : Create RSS feed, Stats and sync folders from wip to www
|
||||
rss : Create RSS feed in wip folder
|
||||
|
||||
log : (Multi-arguments)
|
||||
(ARTICLE) : Show logs for (ARTICLE) || default: all
|
||||
clean : Clean logs for (ARTICLE)
|
||||
all : Only with clean: remove all logs files
|
||||
|
||||
db
|
||||
list : list all databases in a table with some article datas
|
||||
(ARTICLE) : Read (ARTICLE) values in database
|
||||
|
||||
-v : Show installed version and its changes
|
||||
update : update domain conf file and databases
|
||||
version : Show installed version and its changes
|
||||
-u : Check for available version and show new last changes
|
||||
|
||||
-U : Like -u, but ask to perform manual STL upgrade
|
||||
! not for debian based systme
|
||||
! not for debian based system
|
||||
|
|
|
@ -1,5 +1,44 @@
|
|||
# DB
|
||||
- set some variables ouside of cat
|
||||
# check
|
||||
- fix: new display message if db exists
|
||||
- added option: all (update all checked articles' database. Show logs)
|
||||
|
||||
# domain
|
||||
- changes in getting domain process
|
||||
|
||||
# publish (! sync argument becomes publish)
|
||||
- Arguments: (ARTICLE), all. From wip/ to www/ folder
|
||||
- new files copy (used by (ARTICLE))
|
||||
|
||||
# wip, www
|
||||
- new option: remove (ARTICLE)
|
||||
|
||||
# wip
|
||||
- new files copy (used by (ARTICLE)) to wip/ (including .stl source)
|
||||
|
||||
# sidebar
|
||||
- type: stl sidebar load
|
||||
- - create static file stl.sidebar in articles/sidebar/ (if not exists)
|
||||
- - create HTML sidebar according to URI's articles in stl.sidebar
|
||||
- new code to take this new feature compatible with legacy command
|
||||
|
||||
# edit, read
|
||||
- added option: sidebar (to edit,read static file stl.sidebar)
|
||||
|
||||
# Logs
|
||||
- no more all article logs shown if check already done
|
||||
- Better harmony
|
||||
- new publish, and remove display (also for files in article when needed)
|
||||
- new set hash status display
|
||||
- new per article logs
|
||||
- new option: clean all. Remove all logs
|
||||
|
||||
# Stats
|
||||
- file is now created in wip/ when publish, and copied to www/
|
||||
|
||||
# Autocompletion
|
||||
- most of all arguments and options can be autocompleted
|
||||
|
||||
# update
|
||||
- update domain configuration file + all checked articles' database
|
||||
|
||||
# /!\ IMPORTANT NOTE /!\
|
||||
- After installing this version, do: stl update
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
#!/bin/bash
|
||||
# Version: 0.2.7
|
||||
# Version: 0.2.8
|
||||
# Name: Statique Littérateur
|
||||
# Type: Executable
|
||||
# Description: Static website generator
|
||||
# file: stl
|
||||
# Folder: /usr/local/bin
|
||||
# Folder: /usr/local/bin/
|
||||
# By echolib (XMPP: im@echolib.re)
|
||||
# Repo: https://git.a-lec.org/echolib/stl.git
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# scripts files: 14
|
||||
# app lines: 4644
|
||||
# app functions: 104
|
||||
# lines: 149
|
||||
# functions: 4
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Main Tools functions
|
||||
|
@ -33,8 +45,8 @@ if__file() {
|
|||
&& exit
|
||||
|
||||
case "$2" in
|
||||
source) source "$1" || exit ;;
|
||||
read) cat "$1" ;;
|
||||
source) source "$1" ;;
|
||||
read) cat "$1";exit ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -77,9 +89,10 @@ if__file "$stl_dir_scripts/manage__articles" source
|
|||
if__file "$stl_dir_scripts/manage__logs" source
|
||||
if__file "$stl_dir_scripts/manage__db" source
|
||||
if__file "$stl_dir_scripts/manage__HTML" source
|
||||
if__file "$stl_dir_scripts/manage__publish" source
|
||||
if__file "$stl_dir_scripts/manage__sidebar" source
|
||||
if__file "$stl_dir_scripts/manage__stats" source
|
||||
if__file "$stl_dir_scripts/manage__update" source
|
||||
if__file "$stl_dir_scripts/manage__update" source
|
||||
|
||||
if__file "$stl_dir_scripts/check__article" source
|
||||
if__file "$stl_dir_scripts/wip__article" source
|
||||
|
@ -99,20 +112,24 @@ case "$1" in
|
|||
"# GNU AFFERO GENERAL PUBLIC LICENSE" \
|
||||
"Version 3, 19 November 2007"
|
||||
exit ;;
|
||||
|
||||
check) check__OPTIONS "$@" ;; # check__article
|
||||
wip) wip__OPTIONS "$@" ;; # wip__article
|
||||
sidebar) sidebar__OPTIONS "$@" ;; # manage__sidebar
|
||||
publish) publish__OPTIONS "$@" ;; # manage__publish
|
||||
remove) remove__OPTIONS "$@" ;; # manage__article
|
||||
|
||||
read) read__OPTIONS "$@" ;; # manage__articles
|
||||
edit) edit__OPTIONS "$@" ;; # manage__articles
|
||||
log) log__OPTIONS "$@" ;; # manage__logs
|
||||
db) db__OPTIONS "$@" ;; # manage__db
|
||||
stats) stats__OPTIONS ;; # manage__stats
|
||||
rss) domain__get;create__RSS_feed ;; # mamage__HTML
|
||||
|
||||
check) check__OPTIONS "$@" ;; # check__article
|
||||
wip) wip__OPTIONS "$@" ;; # wip__article
|
||||
sidebar) sidebar__OPTIONS "$@" ;; # manage__sidebar
|
||||
rss) domain__get;create__RSS_feed ;; # mamage__HTML
|
||||
sync) sync_wip_to_www ;; # manage__HTML
|
||||
update) update__OPTIONS "$@" ;; # manage__update
|
||||
version|-u|-U) update__OPTIONS "$@" ;; # manage__update
|
||||
|
||||
read) read__OPTIONS "$@" ;; # manage__articles
|
||||
edit) edit__OPTIONS "$@" ;; # manage__articles
|
||||
log) log__OPTIONS "$@" ;; # manage__articles
|
||||
db) db__OPTIONS "$@" ;; # manage__db
|
||||
stats) stats__OPTIONS ;; # manage__stats
|
||||
-v|-u|-U) update__OPTIONS "$@" ;; # manage__update
|
||||
*) noarg "$1" "Use help|-h" ;;
|
||||
*) noarg "$1" "Use: help, -h" ;;
|
||||
esac
|
||||
|
||||
#======================================================================
|
||||
|
@ -122,13 +139,11 @@ logs__print "$stl_file_last_log" # exit if none
|
|||
|
||||
# Create whole logs
|
||||
cat "$stl_file_last_log" >> "$stl_file_log"
|
||||
echo -e "---\t" >> "$stl_file_log"
|
||||
echo -e "${NC}---│" >> "$stl_file_log"
|
||||
|
||||
# Create logs for specific article
|
||||
cat "$stl_file_last_log" >> "$stl_dir_log/$article_id.log"
|
||||
echo -e "---\t" >> "$stl_dir_log/$article_id.log"
|
||||
# Create session logs for specific article
|
||||
echo -e "${NC}---│" >> "$stl_dir_log/$article_id.log"
|
||||
|
||||
# Remove last log session
|
||||
rm -f "$stl_file_last_log"
|
||||
|
||||
exit
|
||||
|
|
|
@ -1,13 +1,265 @@
|
|||
_stl_completions()
|
||||
{
|
||||
local stlfiles cur
|
||||
stlfiles=$(find . -type f -name "*.stl" 2>/dev/null \
|
||||
| awk -F"./articles/" '{print $2}')
|
||||
|
||||
#!/bin/bash
|
||||
# Name: Statique Littérateur
|
||||
# Type: Aucocompletion for STL
|
||||
# file: stl
|
||||
# Folder: /usr/share/bash-completion/completions/
|
||||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 265
|
||||
# functions: 10
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
# when arguments are used, do not show again
|
||||
|
||||
|
||||
# Ensure good work dir, source conf, to get max sidebar items, and more
|
||||
if [[ -f ".stl.conf" ]];then
|
||||
source ".stl.conf"
|
||||
|
||||
else
|
||||
nodomain=true
|
||||
fi
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Arguments available
|
||||
#======================================================================
|
||||
#----------------------------------------------------------------------
|
||||
# First argument command
|
||||
#----------------------------------------------------------------------
|
||||
_stl_arg1() {
|
||||
if [[ $nodomain ]];then
|
||||
cat <<EOL
|
||||
domain
|
||||
help
|
||||
license
|
||||
log
|
||||
version
|
||||
EOL
|
||||
|
||||
else
|
||||
cat <<EOL
|
||||
check
|
||||
domain
|
||||
edit
|
||||
help
|
||||
license
|
||||
log
|
||||
read
|
||||
sidebar
|
||||
publish
|
||||
remove
|
||||
update
|
||||
version
|
||||
wip
|
||||
EOL
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Specifics for edit and read
|
||||
#----------------------------------------------------------------------
|
||||
_stl_arg_editread() {
|
||||
[[ $nodomain ]] && return 0
|
||||
cat << EOL
|
||||
conf
|
||||
sidebar
|
||||
$(_stl_articles)
|
||||
EOL
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Specifics for sidebar
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# Second argument for sidebar
|
||||
# ---------------------------
|
||||
_stl_arg_sidebar() {
|
||||
[[ $nodomain ]] && return 0
|
||||
[[ $arg_sidebar_opt ]] && return 0
|
||||
|
||||
cat <<EOL
|
||||
add
|
||||
load
|
||||
create
|
||||
latest
|
||||
oldest
|
||||
EOL
|
||||
arg_sidebar_opt=true
|
||||
}
|
||||
|
||||
# Third argument for sidebar
|
||||
#---------------------------
|
||||
_stl_arg_sidebar_nbr() {
|
||||
[[ $nodomain ]] && return 0
|
||||
[[ $arg_item_nbr ]] && return 0
|
||||
|
||||
for i in `seq 1 $domain_sidebar_items`
|
||||
do
|
||||
echo "$i"
|
||||
done
|
||||
arg_item_nbr=true
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Specifics for remove
|
||||
#----------------------------------------------------------------------
|
||||
_stl_arg_remove() {
|
||||
cat <<EOL
|
||||
wip
|
||||
www
|
||||
EOL
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Specifics for wip
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# Third argument wip
|
||||
#----------------------------------------------------------------------
|
||||
_stl_arg_wip_sidebar_nbr() {
|
||||
[[ $nodomain ]] && return 0
|
||||
[[ $arg_sidebar_nbr ]] && return 0
|
||||
|
||||
for i in `seq 1 $domain_sidebar_items`
|
||||
do
|
||||
echo "sidebar=$i"
|
||||
done
|
||||
arg_sidebar_nbr=true
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# All .stl articles (with URI)
|
||||
#----------------------------------------------------------------------
|
||||
_stl_articles() {
|
||||
[[ $nodomain ]] && return 0
|
||||
[[ $arg_articles ]] && return 0
|
||||
|
||||
find . -type f -name "*.stl" 2>/dev/null \
|
||||
| awk -F"./articles/" '{print $2}'
|
||||
arg_articles=true
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Specifics for domain
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# Second argument for domain
|
||||
# --------------------------
|
||||
_stl_arg_domain() {
|
||||
if [[ $nodomain ]];then
|
||||
echo 'new'
|
||||
new
|
||||
|
||||
else
|
||||
echo 'edit'
|
||||
fi
|
||||
}
|
||||
|
||||
# Third argument for convenience domain
|
||||
#--------------------------------------
|
||||
_stl_arg_domain_url() {
|
||||
echo 'https://www.example.com'
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Aucocompletion script according to position
|
||||
#======================================================================
|
||||
_stl_completions() {
|
||||
local cur
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
COMPREPLY=( $(compgen -W "$stlfiles" -- ${cur}) )
|
||||
case $COMP_CWORD in
|
||||
1)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg1)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
2)
|
||||
case "${COMP_WORDS[COMP_CWORD-1]}" in
|
||||
edit|read)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_editread)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
sidebar)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_sidebar)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
wip)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_articles)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
domain)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_domain)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
remove)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_remove)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_articles)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
3)
|
||||
case "${COMP_WORDS[COMP_CWORD-1]}" in
|
||||
add)
|
||||
# sidebar
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_sidebar_nbr)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
sidebar)
|
||||
# usually wip sidebar (shortcut for stl sidebar create)
|
||||
return 0
|
||||
;;
|
||||
|
||||
new)
|
||||
# domain
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_domain_url)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${COMP_WORDS[COMP_CWORD-2]}" in
|
||||
wip)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_arg_wip_sidebar_nbr)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
remove)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_articles)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "$(_stl_articles)" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _stl_completions 'stl'
|
||||
|
|
|
@ -6,6 +6,58 @@ STL: Statique Littérateur
|
|||
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
|
||||
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
|
||||
|
||||
## [0.2.8]
|
||||
### check
|
||||
- fix: new display message if db exists
|
||||
- added option: all (update all checked articles' database. Show logs)
|
||||
|
||||
### domain
|
||||
- changes in getting domain process
|
||||
|
||||
### publish (! sync argument becomes publish)
|
||||
- Arguments: (ARTICLE), all. From wip/ to www/ folder
|
||||
- new files copy (used by (ARTICLE))
|
||||
|
||||
### wip, www
|
||||
- new option: remove (ARTICLE)
|
||||
|
||||
### wip
|
||||
- new files copy (used by (ARTICLE)) to wip/ (including .stl source)
|
||||
|
||||
### sidebar
|
||||
- type: stl sidebar load
|
||||
- - create static file stl.sidebar in articles/sidebar/ (if not exists)
|
||||
- - create HTML sidebar according to URI's articles in stl.sidebar
|
||||
- new code to take this new feature compatible with legacy command
|
||||
|
||||
### edit, read
|
||||
- added option: sidebar (to edit,read static file stl.sidebar)
|
||||
|
||||
### Logs
|
||||
- Better harmony
|
||||
- new publish, and remove display (also for files in article when needed)
|
||||
- new set hash status display
|
||||
- new per article logs
|
||||
- new option: clean all. Remove all logs
|
||||
|
||||
### Stats
|
||||
- file is now created in wip/ when publish, and copied to www/
|
||||
|
||||
### Autocompletion
|
||||
- most of all arguments and options can be autocompleted
|
||||
|
||||
### update
|
||||
- update domain configuration file + all checked articles' database
|
||||
|
||||
### /!\ IMPORTANT NOTE /!\
|
||||
- After installing this version, do: stl update
|
||||
|
||||
|
||||
## [0.2.7]
|
||||
### WIP
|
||||
- corrected a bug with nginx/apache refusing to access "../"
|
||||
|
||||
|
||||
## [0.2.6]
|
||||
### DB
|
||||
- set some variables ouside of cat
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
## Métas
|
||||
Les métas utilisent le format suivant :
|
||||
Séparation des champs par ' : '
|
||||
|
||||
```
|
||||
valeur: Champ 1 : Champ 2 : Champ 3
|
||||
# Séparation des champs par ' : '
|
||||
```
|
||||
|
||||
### Métas Obligatoires (uniques)
|
||||
Les métas obligatoire à renseigner dans votre article :
|
||||
|
||||
Les métas obligatoires à renseigner dans votre article :
|
||||
Note: Ne pas mettre le signe `"` dans les metas
|
||||
|
||||
```
|
||||
|
@ -24,14 +25,6 @@ tags: tag,tag 2,tag 3
|
|||
Ces métas permettent de définir vos liens ainsi que leur description
|
||||
pour vos fichiers et vos textes.
|
||||
|
||||
- NAME peut être un numéro ou un nom à reprendre dans l'article
|
||||
- (URI)FILENAME est le nom du fichier
|
||||
- - Commençant par @ : le fichier est dans le dossier files ou images
|
||||
- - - /articles/images/ # Pour le marqueur `image:`
|
||||
- - - /articles/files/ # Pour tout autre marqueur
|
||||
- - - Sous-dossiers possibles (ex: /articles/images/logos/, à créer vous-même)
|
||||
- ALT-TEXT est utilisé pour la balise HTML `title="ALT-TEXT"`
|
||||
|
||||
```
|
||||
image: NAME : (URI)FILENAME : ALT-TEXT
|
||||
abbr: COURT : Long text : écriture (Champ 3 optionnel)
|
||||
|
@ -41,15 +34,22 @@ code: NAME : (URI)FILENAME : ALT-TEXT
|
|||
brut: NAME : (URI)FILENAME
|
||||
```
|
||||
|
||||
Note
|
||||
Ne pas commencer (URI) par `/`.
|
||||
- NAME peut être un numéro ou un nom à reprendre dans l'article
|
||||
- (URI)FILENAME est le nom du fichier
|
||||
- - Ne pas commencer (URI) par `/`
|
||||
- - Commençant par @ : le fichier est dans le dossier files ou images
|
||||
- - - /articles/images/ # Pour le marqueur `image:`
|
||||
- - - /articles/files/ # Pour tout autre marqueur
|
||||
- - - Sous-dossiers possibles (ex: /articles/images/logos/, à créer vous-même)
|
||||
- ALT-TEXT est utilisé pour la balise HTML `title="ALT-TEXT"`
|
||||
|
||||
|
||||
```
|
||||
# Exemple de (URI)
|
||||
image: 1 : @logos/gnu.png : Logo de GNU
|
||||
# L'imge gnu.png se trouve dans le dossier /articles/images/logos/
|
||||
# L'image gnu.png se trouve dans le dossier /articles/images/logos/
|
||||
|
||||
file : Doc : @xmpp/1.pdf : Documentation XMPP
|
||||
file: Doc : @xmpp/1.pdf : Documentation XMPP
|
||||
# le fichier 1.pdf se trouve à partir du dossier de l'article .stl dans
|
||||
# le sous-dossier xmpp. Exemple :
|
||||
# /articles/documentations/index.stl
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
|
||||
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
|
||||
|
||||
# Arguments
|
||||
# Arguments (most of all can be reached with autocompletion)
|
||||
help, -h : This help
|
||||
readme : Show README.md
|
||||
|
||||
|
@ -17,14 +17,17 @@
|
|||
read
|
||||
(ARTICLE) : Read (ARTICLE) in terminal
|
||||
conf : Read current PWD DOMAIN configuration in terminal
|
||||
sidebar : Read current static sidebar file
|
||||
|
||||
edit
|
||||
(ARTICLE) : Edit (ARTICLE) in nano
|
||||
conf : Edit current PWD DOMAIN configuration in nano
|
||||
sidebar : Edit current static sidebar file
|
||||
|
||||
check : (Multi-arguments)
|
||||
(ARTICLE) : Check STL syntax
|
||||
-F : Force check again
|
||||
all : (independant). Update all checked articles' database
|
||||
|
||||
wip : (Multi-arguments)
|
||||
(ARTICLE) : Convert (ARTICLE) to HTML in wip folder
|
||||
|
@ -33,29 +36,39 @@
|
|||
sidebar=POS : POS is between 1 and max configured. After converted
|
||||
put article in sidebar at postition POS
|
||||
|
||||
publish : (ARTICLE), all. Create RSS feed, Stats and
|
||||
sync wip/ to www/
|
||||
all : Ask to perform rsync --delete
|
||||
(ARTICLE) : Mirrors needed folders, and files used by (ARTICLE)
|
||||
|
||||
remove : wip,www (ARTICLE). Remove (ARTICLE) from wip/, www/
|
||||
|
||||
rss : Create RSS feed in wip folder
|
||||
|
||||
sidebar : (ACTION) (POSITION) (ARTICLE)
|
||||
(ACTION) : No need (POSITION) nor (ARTICLE) for latest, oldest
|
||||
latest : Create sidebar with latest articles (ARTICLE date)
|
||||
oldest : Create sidebar with oldest articles (ARTICLE date)
|
||||
add : Create sidebar, add/replace (ARTICLE) at (POSITION)
|
||||
create : (alone argument), (re)Create whole sidebar
|
||||
load : Manage your static sidebar file (stl.sidebar)
|
||||
|
||||
stats : Manually generate stats (for statoolinfos)
|
||||
! useless with sync argument.
|
||||
! Works only for "server" install
|
||||
|
||||
sync : Create RSS feed, Stats and sync folders from wip to www
|
||||
rss : Create RSS feed in wip folder
|
||||
|
||||
log : (Multi-arguments)
|
||||
(ARTICLE) : Show logs for (ARTICLE) || default: all
|
||||
clean : Clean logs for (ARTICLE)
|
||||
all : Only with clean: remove all logs files
|
||||
|
||||
db
|
||||
list : list all databases in a table with some article datas
|
||||
(ARTICLE) : Read (ARTICLE) values in database
|
||||
|
||||
-v : Show installed version and its changes
|
||||
update : update domain conf file and databases
|
||||
version : Show installed version and its changes
|
||||
-u : Check for available version and show new last changes
|
||||
|
||||
-U : Like -u, but ask to perform manual STL upgrade
|
||||
! not for debian based systme
|
||||
! not for debian based system
|
||||
|
|
|
@ -1,5 +1,44 @@
|
|||
# DB
|
||||
- set some variables ouside of cat
|
||||
# check
|
||||
- fix: new display message if db exists
|
||||
- added option: all (update all checked articles' database. Show logs)
|
||||
|
||||
# domain
|
||||
- changes in getting domain process
|
||||
|
||||
# publish (! sync argument becomes publish)
|
||||
- Arguments: (ARTICLE), all. From wip/ to www/ folder
|
||||
- new files copy (used by (ARTICLE))
|
||||
|
||||
# wip, www
|
||||
- new option: remove (ARTICLE)
|
||||
|
||||
# wip
|
||||
- new files copy (used by (ARTICLE)) to wip/ (including .stl source)
|
||||
|
||||
# sidebar
|
||||
- type: stl sidebar load
|
||||
- - create static file stl.sidebar in articles/sidebar/ (if not exists)
|
||||
- - create HTML sidebar according to URI's articles in stl.sidebar
|
||||
- new code to take this new feature compatible with legacy command
|
||||
|
||||
# edit, read
|
||||
- added option: sidebar (to edit,read static file stl.sidebar)
|
||||
|
||||
# Logs
|
||||
- no more all article logs shown if check already done
|
||||
- Better harmony
|
||||
- new publish, and remove display (also for files in article when needed)
|
||||
- new set hash status display
|
||||
- new per article logs
|
||||
- new option: clean all. Remove all logs
|
||||
|
||||
# Stats
|
||||
- file is now created in wip/ when publish, and copied to www/
|
||||
|
||||
# Autocompletion
|
||||
- most of all arguments and options can be autocompleted
|
||||
|
||||
# update
|
||||
- update domain configuration file + all checked articles' database
|
||||
|
||||
# /!\ IMPORTANT NOTE /!\
|
||||
- After installing this version, do: stl update
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 717
|
||||
# functions: 20
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Argument check
|
||||
# $1: check
|
||||
|
@ -17,16 +26,12 @@ check__OPTIONS() {
|
|||
|
||||
while test "$2"
|
||||
do
|
||||
#echo "$2"
|
||||
case "$2" in
|
||||
-F) check_force=true ;;
|
||||
|
||||
*".stl")
|
||||
article__hash "$2"
|
||||
;;
|
||||
|
||||
*)
|
||||
noarg "$2"
|
||||
;;
|
||||
all) domain__get;check_all=true;update__database ;;
|
||||
-F) check_force=true ;;
|
||||
*".stl") article__hash "$2" ;;
|
||||
*) noarg "$2" "add (ARTICLE)" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -42,18 +47,19 @@ done
|
|||
# $1: article
|
||||
#======================================================================
|
||||
checkers() {
|
||||
if__article_db "$article_db" # If DB exists
|
||||
|
||||
if ! [[ $check_force || $need_check ]];then
|
||||
printf '%s\n%s\n%s\n%s\n' \
|
||||
"# Article: $uri_article" \
|
||||
" Database: $db_file (type stl db $this_article) for content" \
|
||||
" Hash: $article_hash" \
|
||||
" Status: Already checked (Use -F to force check again)"
|
||||
exit
|
||||
# Check if article DB exists, compare hashes
|
||||
if__article_db "$article_db"
|
||||
if ! [[ $check_force ]];then # If DB exists
|
||||
if [[ $db_exists ]] && ! [[ $need_check ]];then
|
||||
printf '%s\n%s\n%s\n%s\n' \
|
||||
"# Article: $uri_article" \
|
||||
" Database: $db_file (type stl db $this_article) for content" \
|
||||
" Hash: $article_hash" \
|
||||
" Status: Already checked (Use -F to force check again)"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Set article uri
|
||||
article_name=`basename "$uri_article"`
|
||||
uri_folder=${uri_article/\/$article_name/} #No ending / for checkers
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 292
|
||||
# functions: 7
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# HTML code for <header>
|
||||
|
@ -100,7 +108,7 @@ if [[ `grep -i "fr" <<<"$domain_lang"` ]];then
|
|||
stl_by="par"
|
||||
stl_read="Lire l'article de"
|
||||
stl_rss_info="Tous les titres de"
|
||||
|
||||
|
||||
# Convert date from INT to shit FR format (Yes, i love it...)
|
||||
stl_date_y=`awk -F- '{print $1}' <<<"$article_date"`
|
||||
stl_date_m=`awk -F- '{print $2}' <<<"$article_date"`
|
||||
|
@ -127,16 +135,26 @@ fi
|
|||
create__HTML_page() {
|
||||
create__HTML_translation
|
||||
|
||||
# Create HTML footer and metas if not exist
|
||||
! [[ -f "$domain_dir_wip_tpl/metas.html" ]] \
|
||||
&& create__HTML_metas
|
||||
|
||||
! [[ -f "$domain_dir_wip_tpl/footer.html" ]] \
|
||||
&& create__HTML_footer
|
||||
|
||||
# Ceeate uri articl folders
|
||||
mkdir -p "$domain_dir_wip$article_dir_srv"
|
||||
rsync -a --exclude ".*" "articles$article_dir_srv/" "$domain_dir_wip$article_dir_srv/"
|
||||
# Sync basis images, files
|
||||
sync__files "$domain_dir_images/" \
|
||||
"$domain_dir_wip_images/" \
|
||||
"WIP"
|
||||
|
||||
sync__files "$domain_dir_files/" \
|
||||
"$domain_dir_wip_files/" \
|
||||
"WIP"
|
||||
|
||||
# Sync specific included files from article to wip/
|
||||
get__article_files_sync WIP # in manage__publish
|
||||
|
||||
# Create HTML Page
|
||||
cat <<EOPAGE > "$domain_dir_wip$article_uri_srv"
|
||||
<!DOCTYPE html>
|
||||
<html lang="${domain_lang: :2}">
|
||||
|
@ -246,31 +264,29 @@ log__add -i -M RSS "Created feed"
|
|||
|
||||
|
||||
#======================================================================
|
||||
# Sync WIp to WWW
|
||||
# Before sync, create RSS FEED in wip
|
||||
# Article Item for sidebar
|
||||
# Called from sidebar__create_HTML_item() in manage__sidebar
|
||||
# $1: file ($sidebar_HTML_item)
|
||||
#======================================================================
|
||||
sync_wip_to_www() {
|
||||
domain__get
|
||||
[[ $stl_install == "local" ]] \
|
||||
&& echo "! $stl_install Installation. Useless sync" \
|
||||
&& return
|
||||
create__HTML_sidebar_item() {
|
||||
create__HTML_translation
|
||||
|
||||
create__RSS_feed
|
||||
cat <<EOSIDEBARITEM > "$1"
|
||||
<li class="${domain_css}_list-post-item">
|
||||
<a href="$article_uri_srv"
|
||||
class="${domain_css}_list-post-link"
|
||||
title="$stl_read $article_author: $article_title">
|
||||
|
||||
# Create www hash status in DB
|
||||
db__get_wip_articles "set_www_hash" # manage__db
|
||||
<span class="${domain_css}_list-post-title">$article_title</span>
|
||||
|
||||
# Statistics
|
||||
if [[ $domain_stats == "yes" ]];then
|
||||
stats__init
|
||||
db__get_wip_articles "stats"
|
||||
stats__statoolinfos
|
||||
fi
|
||||
<div class="${domain_css}_list-post-metas">
|
||||
$stl_the $stl_date $stl_by $article_author
|
||||
</div>
|
||||
|
||||
# Sync wip to www
|
||||
rsync -a --exclude ".*" "$domain_dir_wip/" "$domain_dir_www/"
|
||||
|
||||
# Log
|
||||
this_article="$domain_dir_www"
|
||||
log__add -i -M WWW "Synced WIP server to WWW server"
|
||||
<div class="${domain_css}_list-post-info">
|
||||
$article_about
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
EOSIDEBARITEM
|
||||
}
|
||||
|
|
|
@ -6,6 +6,82 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 245
|
||||
# functions: 7
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Argument remove
|
||||
# Remove article in wip/, www/ if wip, publish
|
||||
# $1: remove
|
||||
# $2: argument
|
||||
#======================================================================
|
||||
remove__OPTIONS() {
|
||||
case "$2" in
|
||||
wip) wip_remove=true;srv="WIP" ;;
|
||||
www) www_remove=true;srv="WWW" ;;
|
||||
*) noarg "$2" "Use: wip,www (ARTICLE)" ;;
|
||||
esac
|
||||
|
||||
case "$3" in
|
||||
*".stl") article__hash "$3" ;;
|
||||
*) noarg "$3" "Use: (ARTICLE).stl" ;;
|
||||
esac
|
||||
|
||||
if__article_db "$article_db"
|
||||
if ! [[ $db_exists ]];then
|
||||
echo "! $this_article must be checked first"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Checking wip status
|
||||
if [[ $wip_remove ]];then
|
||||
! [[ $article_wip_hash ]] \
|
||||
&& echo "! $3 is not in wip/ server" \
|
||||
&& exit
|
||||
|
||||
dir_target="$domain_dir_wip"
|
||||
|
||||
# Checking www status
|
||||
elif [[ $www_remove ]];then
|
||||
[[ $stl_server == "server" ]] \
|
||||
&& echo "! STL install: $stl_install. Unuse www/" \
|
||||
&& exit
|
||||
|
||||
! [[ $article_www_hash ]] \
|
||||
&& echo "! Article '$3' is not in www/ server" \
|
||||
&& exit
|
||||
|
||||
dir_target="$domain_dir_www"
|
||||
fi
|
||||
|
||||
# Remove .html, .stl from server
|
||||
for rm_file in "$dir_target$article_uri_srv" \
|
||||
"$dir_target$article_uri_src"
|
||||
do
|
||||
if [[ -f "$rm_file" ]];then
|
||||
rm -f "$rm_file"
|
||||
log__add -w "$srv" -rm \
|
||||
"file from server"
|
||||
fi
|
||||
done
|
||||
|
||||
# in manage__publish: remove included files used by article
|
||||
get__article_files_inluded
|
||||
|
||||
# Remove empty directories
|
||||
find "$dir_target" -type d -empty -delete
|
||||
|
||||
# Remove www hash to DB
|
||||
db__srv_status_hash "$srv" Unset
|
||||
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Argument read
|
||||
|
@ -17,28 +93,18 @@ read__OPTIONS() {
|
|||
&& noarg "Cannot be empty"
|
||||
|
||||
case "$2" in
|
||||
*".stl")
|
||||
article__hash "$2"
|
||||
if__file "$uri_article"
|
||||
cat -n "$uri_article"
|
||||
exit
|
||||
;;
|
||||
|
||||
conf)
|
||||
domain__get
|
||||
if__file "$stl_file_pwd_conf" read
|
||||
exit
|
||||
;;
|
||||
|
||||
*)
|
||||
noarg "$2"
|
||||
;;
|
||||
*".stl") article__hash "$2" ;;
|
||||
conf) domain__get;uri_article="$stl_file_pwd_conf" ;;
|
||||
sidebar) domain__get;uri_article="$domain_file_sidebar_load" ;;
|
||||
*) noarg "$2" ;;
|
||||
esac
|
||||
|
||||
if__file "$uri_article" read
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Argument read
|
||||
# Argument edit
|
||||
# $1: edit
|
||||
# $2: argument
|
||||
#======================================================================
|
||||
|
@ -46,21 +112,16 @@ edit__OPTIONS() {
|
|||
! [[ "$2" ]] \
|
||||
&& noarg "Cannot be empty"
|
||||
|
||||
domain__get
|
||||
case "$2" in
|
||||
*".stl")
|
||||
article__hash "$2"
|
||||
nano --linenumbers "$uri_article"
|
||||
;;
|
||||
|
||||
conf)
|
||||
domain__get
|
||||
domain__OPTIONS "nc" "edit"
|
||||
;;
|
||||
|
||||
*)
|
||||
noarg "$2"
|
||||
;;
|
||||
*".stl") article__hash "$2" ;;
|
||||
conf) uri_article="$domain_conf" ;;
|
||||
sidebar) uri_article="$domain_file_sidebar_load" ;;
|
||||
*) noarg "$2" ;;
|
||||
esac
|
||||
|
||||
nano --linenumbers "$uri_article"
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,9 +175,11 @@ ln=$(( ln + article_begin - 1 ))
|
|||
article__hash() {
|
||||
domain__get
|
||||
this_article="$1"
|
||||
this_article_bkp="$1"
|
||||
uri_article="$domain_dir_articles/$1"
|
||||
if__file "$uri_article"
|
||||
|
||||
# Get Hash, Size, Uri
|
||||
while read -r "H" "S" "U"
|
||||
do
|
||||
article_hash="$H"
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 315
|
||||
# functions: 7
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# argument: db
|
||||
|
@ -47,6 +55,7 @@ db_file="$domain_db_articles/$1"
|
|||
if [[ -f "$db_file" ]];then
|
||||
source "$db_file"
|
||||
compare__db
|
||||
db_exists=true
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -55,8 +64,25 @@ fi
|
|||
# Compare article from DB to know if check is needed
|
||||
#======================================================================
|
||||
compare__db() {
|
||||
(( $article_hash != $article_chk_hash )) \
|
||||
[[ $article_hash != $article_chk_hash ]] \
|
||||
&& need_check=true
|
||||
|
||||
[[ $article_wip_hash ]] && \
|
||||
[[ $article_chk_hash != $article_wip_hash ]] \
|
||||
&& old_wip=true \
|
||||
&& sync_mess="! $this_article is newer (WIP is older)"
|
||||
|
||||
if [[ $stl_install == "server" && $article_wip_hash ]] && \
|
||||
[[ $article_wip_hash == $article_www_hash ]] && \
|
||||
[[ -f $domain_dir_www$article_uri_srv ]];then
|
||||
www_is_wip=true
|
||||
sync_mess="! $this_article is already up to date online"
|
||||
|
||||
# Need to also check each "external" article's files
|
||||
fi
|
||||
|
||||
[[ $article_error == 'yes' ]] \
|
||||
&& check_force=true
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,18 +92,15 @@ compare__db() {
|
|||
# $1: $db_file
|
||||
#======================================================================
|
||||
db__print() {
|
||||
if ! [[ -f "$db_file" ]];then
|
||||
log__add -i -db $article_id \
|
||||
"New, created"
|
||||
! [[ -f "$db_file" ]] \
|
||||
&& log_db_written="New Datas written" \
|
||||
|| log_db_written="Datas updated"
|
||||
|
||||
else
|
||||
log__add -i -db $article_id \
|
||||
"Datas written"
|
||||
fi
|
||||
|
||||
# Set some variables
|
||||
article_page_srv=${article_name/.stl/.html}
|
||||
article_uri_srv="$article_dir_srv/$article_page_srv"
|
||||
article_uri_src="$article_dir_srv/$article_name"
|
||||
[[ $stl_error ]] \
|
||||
&& article_error='yes' \
|
||||
|| article_error='no'
|
||||
|
@ -89,9 +112,13 @@ database_file='$article_id.db'
|
|||
database_uri='$db_file'
|
||||
|
||||
# File metas
|
||||
article_uri='$uri_article'
|
||||
article_name='$article_name'
|
||||
article_size=$article_size
|
||||
|
||||
# URI file
|
||||
article_uri='$uri_article'
|
||||
article_uri_src='$article_uri_src'
|
||||
|
||||
# URI Server
|
||||
article_dir_srv='$article_dir_srv'
|
||||
article_page_srv='$article_page_srv'
|
||||
|
@ -106,6 +133,8 @@ $(
|
|||
[[ "$stl_install" == "server" ]] \
|
||||
&& echo "article_www_hash=$article_www_hash"
|
||||
)
|
||||
|
||||
# Sidebar
|
||||
sidebar_position=$sidebar_position
|
||||
|
||||
# Article Metas
|
||||
|
@ -140,6 +169,10 @@ files_links=$stat_link_files
|
|||
files_codes=$stat_codes
|
||||
files_bruts=$stat_bruts
|
||||
EODBPRINT
|
||||
|
||||
this_article="$db_file"
|
||||
log__add -i -db -W \
|
||||
"'$article_Title'. $log_db_written"
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,28 +233,22 @@ exit
|
|||
#======================================================================
|
||||
# Get articles from database, with wip status
|
||||
# Generic function to :
|
||||
# - "set_www_hash" for stl sync
|
||||
# - "set_www_hash" for stl publish all
|
||||
# - "stats" create stats
|
||||
# $1: set_www_hash
|
||||
#======================================================================
|
||||
db__get_wip_articles() {
|
||||
while IFS=: read -r 'file' 'article_wip'
|
||||
while IFS=: read -r 'db_file' 'article_wip'
|
||||
do
|
||||
[[ `awk -F= '{print $2}' <<<"$article_wip"` -gt 0 ]] || continue
|
||||
|
||||
source "$file"
|
||||
source "$db_file"
|
||||
this_article="$article_uri_src"
|
||||
|
||||
case "$1" in
|
||||
# From sync_wip_to_www() ; manage__HTML
|
||||
set_www_hash)
|
||||
if ! [[ $article_www_hash == $article_wip_hash ]];then
|
||||
sed -i "s^article_www_hash=.*^article_www_hash=$article_wip_hash^" \
|
||||
"$file"
|
||||
|
||||
# Log
|
||||
this_article="$domain_dir_www$article_uri_srv"
|
||||
log__add -i -W -A "Added online: $article_title"
|
||||
fi
|
||||
db__srv_status_hash WWW Set
|
||||
;;
|
||||
|
||||
# Generate statistics
|
||||
|
@ -258,3 +285,31 @@ do
|
|||
|
||||
done < <(grep -H "article_wip_hash" "$domain_db_articles/"*.db)
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Set hash wip or www status
|
||||
# $1: wip,www
|
||||
# $2: Set, Unset
|
||||
#======================================================================
|
||||
db__srv_status_hash() {
|
||||
[[ "$2" == "Unset" ]] \
|
||||
&& unset article_hash article_wip_hash
|
||||
|
||||
case "$1" in
|
||||
WIP)
|
||||
log_hash=" $article_hash"
|
||||
sed -i "s^article_wip_hash=.*^article_wip_hash=$article_hash^" \
|
||||
"$db_file"
|
||||
;;
|
||||
|
||||
WWW)
|
||||
log_hash=" $article_wip_hash"
|
||||
sed -i "s^article_www_hash=.*^article_www_hash=$article_wip_hash^" \
|
||||
"$db_file"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Log
|
||||
log__add -i -db -A "$2 $1 status: $article_title.$log_hash"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 509
|
||||
# functions: 7
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# --------------
|
||||
|
@ -19,17 +27,35 @@
|
|||
# $2: change
|
||||
#----------------------------------------------------------------------
|
||||
domain__OPTIONS() {
|
||||
domain_check=true
|
||||
case "$2" in
|
||||
'') ;;
|
||||
new) domain_add=true; [[ "$3" ]] && domain_name="$3" ;;
|
||||
edit) domain_edit=true ;;
|
||||
*) noarg "$2" ;;
|
||||
'') domain_show=true ;;
|
||||
new) domain_show=true;domain_add=true;
|
||||
[[ "$3" ]] && domain_name="$3" ;;
|
||||
edit) edit__OPTIONS "" conf ;;
|
||||
*) noarg "$2" "Use: new, edit" ;;
|
||||
esac
|
||||
|
||||
domain__get
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Domain is check from argument
|
||||
#----------------------------------------------------------------------
|
||||
domain__pass() {
|
||||
case "$1" in
|
||||
missing)
|
||||
[[ $domain_add ]] \
|
||||
&& domain__set \
|
||||
|| exit 0
|
||||
;;
|
||||
|
||||
show)
|
||||
[[ $domain_show ]] \
|
||||
&& echo "# Domain '$domain_name' set for this directory: $PWD" \
|
||||
&& exit
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Check for PWD config file and source
|
||||
|
@ -38,20 +64,11 @@ domain__get
|
|||
domain__get() {
|
||||
if [[ -f "$stl_file_pwd_conf" ]];then
|
||||
source "$stl_file_pwd_conf" # Source config PWD file
|
||||
domain__pass show
|
||||
|
||||
else
|
||||
echo "# No domain set for this directory: $PWD"
|
||||
[[ $domain_add ]] && domain__set
|
||||
[[ $domain_check ]] || exit # exit if domain__get call
|
||||
fi
|
||||
|
||||
# From command line domain only (check)
|
||||
if [[ $domain_check ]] && [[ $domain_name ]];then
|
||||
[[ $domain_edit ]] \
|
||||
&& nano "$stl_file_pwd_conf"
|
||||
|
||||
echo "# Domain '$domain_name' set for this directory: $PWD"
|
||||
exit
|
||||
domain__pass missing
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -80,7 +97,7 @@ if__writeable "$PWD"
|
|||
is__protocol() {
|
||||
[[ "${domain_name: -1}" == "/" ]] \
|
||||
&& domain_name=${domain_name::-1}
|
||||
|
||||
|
||||
# Confirm, configuration not already exists
|
||||
if [[ -f "$stl_dir_db/$domain_name/$domain_name.conf" ]];then
|
||||
source "$stl_dir_db/$domain_name/$domain_name.conf"
|
||||
|
@ -306,6 +323,7 @@ Tags : $domain_tags
|
|||
Copyright : $domain_cr
|
||||
Sidebar Name : $domain_sidebar_title
|
||||
Sidebar Items : $domain_sidebar_items
|
||||
Sidebar load file : $PWD/articles/sidebar/stl.sidebar
|
||||
CSS prefix : $domain_css (configuree your own style.css)
|
||||
$(
|
||||
if ! [[ $domain_logo ]];then
|
||||
|
@ -323,7 +341,7 @@ EODOMAINCONF
|
|||
echo -e "! Use $domain_name only in $PWD"
|
||||
read -rp "- Write to $PWD/.stl.conf (Y|*) ? " set_conf
|
||||
case "$set_conf" in
|
||||
Y|y) true ;;
|
||||
Y|y) true ;;
|
||||
*) echo "# Maybe later...";exit ;;
|
||||
esac
|
||||
|
||||
|
@ -374,6 +392,10 @@ domain_dir_wip_tpl="$domain_srv/wip/template"
|
|||
domain_dir_wip_images="$domain_srv/wip/images"
|
||||
domain_dir_wip_files="$domain_srv/wip/files"
|
||||
|
||||
# Sidebar
|
||||
domain_dir_sidebar="$PWD/articles/sidebar"
|
||||
domain_file_sidebar_load="$PWD/articles/sidebar/stl.sidebar"
|
||||
|
||||
EODOMAINCONF
|
||||
|
||||
# Create a backup of the config in db
|
||||
|
@ -384,6 +406,9 @@ rsync -a "$PWD/$stl_file_pwd_conf" \
|
|||
mkdir -p "$PWD/articles"
|
||||
mkdir -p "$PWD/articles/images"
|
||||
mkdir -p "$PWD/articles/files"
|
||||
mkdir -p "$PWD/articles/sidebar"
|
||||
|
||||
# Create folders for WIP
|
||||
mkdir -p "$domain_srv/wip"
|
||||
mkdir -p "$domain_srv/wip/template"
|
||||
mkdir -p "$domain_srv/wip/files"
|
||||
|
@ -406,7 +431,79 @@ case "$stl_install" in
|
|||
;;
|
||||
esac
|
||||
|
||||
create__file_sidebar_load
|
||||
|
||||
printf '%s%s\n\n' \
|
||||
"! files template (logo, style.css...) must be put in " \
|
||||
"$domain_srv/wip/template/"
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Creating static stl.sidebar (empty but commented)
|
||||
# According to lang selected (en, fr)
|
||||
#======================================================================
|
||||
create__file_sidebar_load() {
|
||||
touch "$domain_file_sidebar_load"
|
||||
|
||||
case "$domain_lang" in
|
||||
fr|FR|Fr) file__sidebar_load_fr ;;
|
||||
*) file__sidebar_load_en ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# stl.sidebar in fr
|
||||
#======================================================================
|
||||
file__sidebar_load_fr() {
|
||||
cat <<EOsdbl > "$domain_file_sidebar_load"
|
||||
# Name: Statique Littérateur
|
||||
# Type: fichier brut
|
||||
# Description: Fichier statique appelé par : stl sidebar load
|
||||
# file: stl.sidebar
|
||||
# Folder: articles/sidebar/
|
||||
# (depuis le dossier de configuration du domaine)
|
||||
|
||||
# Les interlignes vides sont acceptés
|
||||
# 1 URI de l'article.stl par ligne, rien d'autre
|
||||
# l'URI NE DOIT PAS commencer par /
|
||||
# exemples :
|
||||
# index.stl
|
||||
# dir1/index.stl
|
||||
|
||||
# Position de l'article: dans l'ordre de haut en bas
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
EOsdbl
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# stl.sidebar in en
|
||||
#======================================================================
|
||||
file__sidebar_load_en() {
|
||||
cat <<EOsdbl > "$domain_file_sidebar_load"
|
||||
# Name: Statique Littérateur
|
||||
# Type: brut file
|
||||
# Description: Static file called by : stl sidebar load
|
||||
# file: stl.sidebar
|
||||
# Folder: articles/sidebar/
|
||||
# (from domain configured folder)
|
||||
|
||||
# Empty lines are accepted
|
||||
# ONLY 1 article's URI per line, nothing else
|
||||
# URI must NOT begin with /
|
||||
# examples :
|
||||
# index.stl
|
||||
# dir1/index.stl
|
||||
|
||||
# Article's Position: from top to bottom order
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
EOsdbl
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 156
|
||||
# functions: 3
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Manage Arguments
|
||||
|
@ -15,40 +23,48 @@ log__OPTIONS() {
|
|||
|
||||
while test "$2"
|
||||
do
|
||||
case "$2" in
|
||||
*.log)
|
||||
article_log=`basename "$2"`
|
||||
;;
|
||||
|
||||
*".stl")
|
||||
unset article_log
|
||||
article__hash "$2"
|
||||
;;
|
||||
|
||||
clean)
|
||||
log_clean=true
|
||||
[[ $from_stl || $from_id ]] || article_log="stl.log"
|
||||
;;
|
||||
|
||||
*)
|
||||
noarg "$2"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
case "$2" in
|
||||
*.log)
|
||||
article_log=`basename "$2"`
|
||||
;;
|
||||
|
||||
*".stl")
|
||||
unset article_log
|
||||
article__hash "$2"
|
||||
;;
|
||||
|
||||
clean)
|
||||
log_clean=true
|
||||
[[ $from_stl || $from_id ]] || article_log="stl.log"
|
||||
;;
|
||||
|
||||
all)
|
||||
[[ $log_clean ]] || continue
|
||||
unset articl_log
|
||||
rm -f /var/log/stl/*.log 2>/dev/null
|
||||
echo "# All logs cleaned"
|
||||
exit
|
||||
;;
|
||||
|
||||
*)
|
||||
noarg "$2" "Use: (ARTICLE) (+ clean)"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
! [[ -f "$stl_dir_log/$article_log" ]] \
|
||||
&& echo "# Logs not found: $stl_dir_log/$article_log" \
|
||||
&& echo "# No logs yet, for this article" \
|
||||
&& exit
|
||||
|
||||
if [[ $log_clean ]];then
|
||||
rm -f "$stl_dir_log/$article_log" && \
|
||||
echo "# logs cleaned: $stl_dir_log/$article_log"
|
||||
echo "# Logs cleaned: $stl_dir_log/$article_log"
|
||||
exit
|
||||
|
||||
else
|
||||
logs__print "$stl_dir_log/$article_log"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,20 +102,45 @@ case "$3" in
|
|||
-M) log_f3="Metas" ;;
|
||||
-A) log_f3="Article" ;;
|
||||
-S) log_f3="Stats" ;;
|
||||
-rs) log_f3="Publish" ;;
|
||||
-rm) log_f3="Remove" ;;
|
||||
-W) log_f3="Write" ;;
|
||||
*) log_f3="$3"
|
||||
esac
|
||||
|
||||
printf '%b%s %s %-10s\t%-10s\t%-30s\t%s\t%s%b\n' \
|
||||
log_f4="$4"
|
||||
|
||||
# Maube to consider later...
|
||||
#f4_l=${#log_f4}
|
||||
#log_sp=$(( 40 - f4_l ))
|
||||
#echo "> f4_l=$f4_l ; log_sp=$log_sp"
|
||||
|
||||
printf "%b%s%s%s%s%s%s%s%b\n" \
|
||||
"${CL}" \
|
||||
"`date +%F' '%T`" \
|
||||
"$log_f1" \
|
||||
"$log_f2" \
|
||||
"$log_f3" \
|
||||
"$4" \
|
||||
"$domain_name" \
|
||||
"$this_article" \
|
||||
"`date +%F' '%T`│" \
|
||||
"$domain_name│" \
|
||||
"$log_f1│" \
|
||||
"$log_f2│" \
|
||||
"$log_f3│" \
|
||||
"$log_f4│" \
|
||||
"$this_article│" \
|
||||
"${NC}" \
|
||||
>> "$stl_file_last_log"
|
||||
|
||||
printf "%b%s%s%s%s%s%s%s%b\n" \
|
||||
"${CL}" \
|
||||
"`date +%F' '%T`│" \
|
||||
"$domain_name│" \
|
||||
"$log_f1│" \
|
||||
"$log_f2│" \
|
||||
"$log_f3│" \
|
||||
"$log_f4│" \
|
||||
"$this_article│" \
|
||||
"${NC}" \
|
||||
>> "$stl_dir_log/$article_id.log"
|
||||
|
||||
# Restore var
|
||||
this_article="$this_article_bkp"
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
|
@ -107,7 +148,9 @@ printf '%b%s %s %-10s\t%-10s\t%-30s\t%s\t%s%b\n' \
|
|||
# $1: file
|
||||
#======================================================================
|
||||
logs__print() {
|
||||
[[ -f "$1" ]] \
|
||||
&& cat "$1" | column -t -s$'\t' -o' ' \
|
||||
|| exit
|
||||
[[ -f "$1" ]] || exit 0
|
||||
|
||||
cat "$1" | column -t -s'│' -o' '
|
||||
|
||||
#cat "$1" | column -t -s$'\t' -o' '
|
||||
}
|
||||
|
|
239
var/lib/stl/scripts/manage__publish
Normal file
239
var/lib/stl/scripts/manage__publish
Normal file
|
@ -0,0 +1,239 @@
|
|||
#!/bin/bash
|
||||
# Name: Statique Littérateur
|
||||
# Type: Manage sync from wip to www
|
||||
# file: manage__publish
|
||||
# Folder: /var/lib/stl/scripts/
|
||||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 239
|
||||
# functions: 5
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Manage argument sync
|
||||
# if article, sync only it,
|
||||
# else:
|
||||
# Get all wip status from all DB articles, and do sync
|
||||
#======================================================================
|
||||
publish__OPTIONS() {
|
||||
domain__get
|
||||
|
||||
if [[ "$stl_install" == "local" ]];then
|
||||
echo "! $stl_install Installation. Useless sync"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Sync basis images, files, template folders from wip to www
|
||||
sync__files "$domain_dir_wip_images/" \
|
||||
"$domain_dir_www_images/" \
|
||||
"WWW"
|
||||
|
||||
sync__files "$domain_dir_wip_files/" \
|
||||
"$domain_dir_www_files/" \
|
||||
"WWW"
|
||||
|
||||
sync__files "$domain_dir_wip_tpl/" \
|
||||
"$domain_dir_www_tpl/" \
|
||||
"WWW"
|
||||
|
||||
case "$2" in
|
||||
all)
|
||||
echo "! You are about to rsync --delete from wip/ to www/"
|
||||
read -rp "- Are you sure (Y|*) ? " ask_publish
|
||||
case "$ask_publish" in
|
||||
Y|y)
|
||||
echo
|
||||
rsync -a --delete "$domain_dir_wip/" "$domain_dir_www/"
|
||||
this_article="$domain_dir_wip/"
|
||||
log__add -w -W -rs "To: $domain_dir_www/"
|
||||
db__get_wip_articles "set_www_hash" # Create ALL www hash in DB
|
||||
return
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "# Maybe later..."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*".stl")
|
||||
article__hash "$2"
|
||||
if__article_db "$article_db"
|
||||
|
||||
if ! [[ $db_exists ]];then
|
||||
echo "! $this_article must be checked first"
|
||||
exit
|
||||
|
||||
elif ! [[ $article_wip_hash ]];then
|
||||
echo "! $this_article must be converted first"
|
||||
exit
|
||||
|
||||
elif [[ $old_wip ]] || [[ $www_is_wip ]];then
|
||||
echo "$sync_mess"
|
||||
read -rp "- Sync it online (Y|*) ? " sync_ask
|
||||
case "$sync_ask" in
|
||||
Y|y) true ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
noarg "$2" "(ARTICLE), all"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Start sync wip to www
|
||||
get__article_files_sync WWW
|
||||
|
||||
# Write wip hash to DB
|
||||
db__srv_status_hash WWW set
|
||||
|
||||
# RSS is created at publish command
|
||||
# If local install, One has to use stl rss
|
||||
create__RSS_feed && \
|
||||
sync__files "$domain_dir_wip/rss.xml" "$domain_dir_www/rss.xml" "WWW"
|
||||
|
||||
# Statistics
|
||||
if [[ $domain_stats == "yes" ]];then
|
||||
stats__init
|
||||
db__get_wip_articles "stats"
|
||||
stats__statoolinfos
|
||||
sync__files "$domain_dir_wip/stl-stats.properties" \
|
||||
"$domain_dir_www/stl-stats.properties" \
|
||||
"WWW"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Called from
|
||||
# - publish__OPTIONS()
|
||||
# - create__HTML_page()
|
||||
# Sync article files (.html, and included ones in article)
|
||||
# $1: WIP, WWW
|
||||
#======================================================================
|
||||
get__article_files_sync() {
|
||||
case "$1" in
|
||||
WIP)
|
||||
dir_source="$domain_dir_articles"
|
||||
dir_target="$domain_dir_wip"
|
||||
;;
|
||||
|
||||
WWW)
|
||||
dir_source="$domain_dir_wip"
|
||||
dir_target="$domain_dir_www"
|
||||
|
||||
# Copy html file from wip to www
|
||||
if ! [[ "$article_dir_srv" ]];then
|
||||
sync__files "$dir_source$article_uri_srv" \
|
||||
"$dir_target$article_uri_srv" \
|
||||
"$1"
|
||||
|
||||
else
|
||||
sync__files "$dir_source$article_uri_srv" \
|
||||
"$dir_target$article_uri_srv" \
|
||||
"$1" \
|
||||
"$dir_target$article_dir_srv"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
srv="$1"
|
||||
|
||||
# Add .stl source file to wip dir
|
||||
sync__files "$dir_source$article_uri_src" \
|
||||
"$dir_target$article_uri_src" \
|
||||
"$1" \
|
||||
"$dir_target$article_dir_srv/"
|
||||
|
||||
# Sync included files used by article
|
||||
get__article_files_inluded
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Search and get uri files used by article
|
||||
# Sync, or remove thme
|
||||
# Also called by remove__OPTIONS()
|
||||
#======================================================================
|
||||
get__article_files_inluded() {
|
||||
images_nbr=`grep "Image_" "$db_file" | tail -n 1 | cut -c7-7`
|
||||
if__article_file "Image_" "$images_nbr" "$srv"
|
||||
|
||||
files_nbr=`grep "File_" "$db_file" | tail -n 1 | cut -c6-6`
|
||||
if__article_file "File_" "$files_nbr" "$srv"
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Called from
|
||||
# - get__article_file()
|
||||
# - remove__OPTIONS()
|
||||
# For each found file in article (image, file, code...)
|
||||
# Rxecept for basis folders: sync or remove
|
||||
# $1: type of file (var name)
|
||||
# $2: number from type of file
|
||||
# $3: WIP,WWW ($log_type)
|
||||
#======================================================================
|
||||
if__article_file() {
|
||||
[[ "$2" ]] || return
|
||||
|
||||
for i in `seq 1 $2`
|
||||
do
|
||||
# Extract needed uri, removing root dir
|
||||
file_uri=`grep "$1$i" $db_file | awk -F"'" '{print $2}'`
|
||||
file_uri=`echo ${file_uri/$domain_dir_articles}`
|
||||
uri_bsn=`basename "$file_uri"`
|
||||
uri_dir=${file_uri/$uri_bsn}
|
||||
|
||||
# Useless sync if basis folders
|
||||
if [[ "$file_uri" =~ ^"/images/" ]] || \
|
||||
[[ "$file_uri" =~ ^"/files/" ]];then
|
||||
continue
|
||||
|
||||
else
|
||||
if [[ $wip_remove || $www_remove ]];then
|
||||
if [[ -f "$dir_target$file_uri" ]];then
|
||||
rm -f "$dir_target$file_uri"
|
||||
this_article="$dir_target$file_uri"
|
||||
log__add -w "$3" -rm \
|
||||
"file from server"
|
||||
fi
|
||||
|
||||
else
|
||||
sync__files "$dir_source$file_uri" \
|
||||
"$dir_target$file_uri" \
|
||||
"$3" \
|
||||
"$dir_target$uri_dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Sync Generic
|
||||
# rsync and log if sync is needed, by checking diff
|
||||
# $1: source
|
||||
# $2: target
|
||||
# $3: WIP,WWW ($log_type)
|
||||
# $4: dirs (to create/check with mkdir -p)
|
||||
#======================================================================
|
||||
sync__files() {
|
||||
[[ "$4" && ! -d "$4" ]] && mkdir -p "$4" # Create/check needed folders
|
||||
|
||||
diff -r -q $1 $2 &>/dev/null
|
||||
(( $? == 0 )) && return
|
||||
|
||||
rsync -a --exclude ".*" --delete "$1" "$2"
|
||||
this_article="$1"
|
||||
log__add -i "$3" -rs "To: $2"
|
||||
}
|
|
@ -6,57 +6,107 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 320
|
||||
# functions: 5
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Sidebar: Manage arguments
|
||||
# Check Article, WIP and Position
|
||||
#======================================================================
|
||||
sidebar__OPTIONS() {
|
||||
[[ $sdb_load ]] || domain__get
|
||||
|
||||
case "$2" in
|
||||
create)
|
||||
domain__get
|
||||
sidebar__create_HTML
|
||||
return
|
||||
;;
|
||||
|
||||
|
||||
load)
|
||||
sidebar__load
|
||||
return
|
||||
;;
|
||||
|
||||
add)
|
||||
# Argument article
|
||||
! [[ "$4" ]] \
|
||||
&& noarg "$4" "Use: sidebar add (POS) (ARTICLE)" \
|
||||
&& exit
|
||||
|
||||
# Position. Must be numeric: 1 to max_items
|
||||
[[ "$3" == *[!0-9]* ]] \
|
||||
&& noarg "$3" "Use numeric position: 1 to $domain_siddebar_items" \
|
||||
&& exit
|
||||
|
||||
# Position mismatches values
|
||||
(( "$3" == 0 || "$3" > $domain_sidebar_items )) \
|
||||
&& noarg "$3" "Use position 1 to $domain_siddebar_items" \
|
||||
&& exit
|
||||
|
||||
# Article
|
||||
article__hash "$4"
|
||||
if__article_db "$article_db"
|
||||
|
||||
# Database
|
||||
db_file="$domain_db_articles/$article_id.db"
|
||||
source "$db_file"
|
||||
# Article not yet checked
|
||||
if ! [[ $db_exists ]];then
|
||||
log__add -e -S -A \
|
||||
"'$article_title' is not yet checked"
|
||||
|
||||
# Already in sidebar at same position
|
||||
[[ "$3" == $sidebar_position ]] \
|
||||
&& echo "! Article is in sidebar at same position: $3" \
|
||||
&& return
|
||||
|
||||
# Already in sidebar, different position
|
||||
[[ $sidebar_position ]] \
|
||||
&& echo "! Article is in sidebar at position: $sidebar_position" \
|
||||
&& return
|
||||
# sidebar load
|
||||
[[ $sdb_load ]] && item=$(( item - 1 ))
|
||||
return
|
||||
fi
|
||||
|
||||
# article is checked and newer than WIP one
|
||||
if [[ $old_wip ]];then
|
||||
log__add -e -S -A \
|
||||
"$sync_mess"
|
||||
|
||||
# sidebar load
|
||||
[[ $sdb_load ]] && item=$(( item - 1 ))
|
||||
return
|
||||
fi
|
||||
|
||||
# WIP check
|
||||
! [[ $article_wip_hash -gt 0 ]] \
|
||||
&& echo "! Article not yet converted in HTML (wip)" \
|
||||
&& return
|
||||
|
||||
# Position. Must be 1 to max_items
|
||||
if [[ "$3" == *[!0-9]* ]];then
|
||||
[[ $sidebar ]] \
|
||||
&& echo "Use position 1 to $domain_siddebar_items" \
|
||||
|| noarg "$3" "Use position 1 to $domain_siddebar_items"
|
||||
if ! [[ $article_wip_hash ]];then
|
||||
log__add -e -S -A \
|
||||
"'$article_title' is not yet converted in HTML"
|
||||
|
||||
# sidebar load
|
||||
[[ $sdb_load ]] && item=$(( item - 1 ))
|
||||
return
|
||||
fi
|
||||
|
||||
if (( "$3" == 0 || "$3" > $domain_sidebar_items ));then
|
||||
[[ $sidebar ]] \
|
||||
&& echo "Use position 1 to $domain_siddebar_items" \
|
||||
|| noarg "$3" "Use position 1 to $domain_siddebar_items"
|
||||
# Already in sidebar at same position
|
||||
if [[ "$3" == $sidebar_position ]];then
|
||||
log__add -w -S -A \
|
||||
"'$article_title' is already at position: $3"
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
# Already in sidebar, different position
|
||||
if [[ $sidebar_position ]];then
|
||||
sed -i "s^sidebar_position=.*^sidebar_position=^" "$db_file"
|
||||
if [[ -f "$domain_dir_sidebar/.$sidebar_position.sidebar" ]];then
|
||||
rm -f "$domain_dir_sidebar/.$sidebar_position.sidebar"
|
||||
log__add -w -S -rm \
|
||||
"$article_title at position: $sidebar_position"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create HTML idem file
|
||||
mkdir -p "$domain_dir_sidebar" # ensure articles/sidebar is creeated
|
||||
position="$3"
|
||||
sidebar_HTML_item="$domain_dir_wip_tpl/.$3.sidebar"
|
||||
sidebar_HTML_item="$domain_dir_sidebar/.$3.sidebar"
|
||||
sidebar_add=true
|
||||
;;
|
||||
|
||||
latest|oldest)
|
||||
|
@ -64,7 +114,7 @@ case "$2" in
|
|||
;;
|
||||
|
||||
*)
|
||||
noarg "$2" "Use: add,latest,oldest"
|
||||
noarg "$2" "Use: load, add, latest, oldest, create"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -102,7 +152,7 @@ case "$1" in
|
|||
! [[ $article_wip_hash -gt 0 ]] \
|
||||
&& continue
|
||||
|
||||
sidebar_HTML_item="$domain_dir_wip_tpl/.$position.sidebar"
|
||||
sidebar_HTML_item="$domain_dir_sidebar/.$position.sidebar"
|
||||
sidebar__create_HTML_item "$sidebar_HTML_item"
|
||||
|
||||
done < <(grep -H "article_timestamp" "$domain_db_articles/"*.db \
|
||||
|
@ -114,7 +164,10 @@ case "$1" in
|
|||
;;
|
||||
esac
|
||||
|
||||
sidebar__create_HTML "$gsl_dir_domain_tpl/sidebar.html"
|
||||
# sidebar load: do not create the complete sidebar now
|
||||
[[ $sdb_load ]] && return
|
||||
|
||||
sidebar__create_HTML
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,25 +179,7 @@ sidebar__create_HTML "$gsl_dir_domain_tpl/sidebar.html"
|
|||
# $1: file ($sidebar_HTML_item)
|
||||
#======================================================================
|
||||
sidebar__create_HTML_item() {
|
||||
create__HTML_translation
|
||||
cat <<EOSIDEBARITEM > "$1"
|
||||
<li class="${domain_css}_list-post-item">
|
||||
<a href="$article_uri_srv"
|
||||
class="${domain_css}_list-post-link"
|
||||
title="$stl_read $article_author: $article_title">
|
||||
|
||||
<span class="${domain_css}_list-post-title">$article_title</span>
|
||||
|
||||
<div class="${domain_css}_list-post-metas">
|
||||
$stl_the $stl_date $stl_by $article_author
|
||||
</div>
|
||||
|
||||
<div class="${domain_css}_list-post-info">
|
||||
$article_about
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
EOSIDEBARITEM
|
||||
create__HTML_sidebar_item "$1"
|
||||
|
||||
# Log added
|
||||
log__add -i -S -A "$article_title added to position: $position"
|
||||
|
@ -155,32 +190,131 @@ grep -H "sidebar_position=$position" \
|
|||
"$domain_db_articles/"*.db \
|
||||
| awk -F: '{print $1}'`
|
||||
|
||||
# Add value to DB
|
||||
sed -i "s^sidebar_position=.*^sidebar_position=$position^" "$db_file"
|
||||
|
||||
# If position is used by another article
|
||||
if [[ $db_file_sidebar ]];then
|
||||
source "$db_file_sidebar"
|
||||
sed -i "s^sidebar_position=.*^sidebar_position=^" "$db_file_sidebar"
|
||||
log__add -w -S -A "$article_title removed from position: $position"
|
||||
|
||||
# Create log for this other article
|
||||
uri_src=${article_uri_src:1}
|
||||
article__hash "$uri_src"
|
||||
log__add -w -S -rm "$article_title at position: $position"
|
||||
fi
|
||||
|
||||
# Add value to DB
|
||||
sed -i "s^sidebar_position=.*^sidebar_position=$position^" "$db_file"
|
||||
}
|
||||
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Create sidebar.html from files .1-max.sidebar
|
||||
# Create sidebar.html from files .(1-MAX).sidebar
|
||||
#======================================================================
|
||||
sidebar__create_HTML() {
|
||||
[[ -f "$domain_dir_wip_tpl/sidebar.html" ]] \
|
||||
&& rm -f "$domain_dir_wip_tpl/sidebar.html"
|
||||
if [[ -f "$domain_dir_wip_tpl/sidebar.html" ]];then
|
||||
rm -f "$domain_dir_wip_tpl/sidebar.html"
|
||||
this_article="$domain_dir_wip_tpl/sidebar.html"
|
||||
log__add -w -S -rm \
|
||||
"Create new"
|
||||
fi
|
||||
|
||||
for i in `seq 1 $domain_sidebar_items`
|
||||
do
|
||||
[[ -f "$domain_dir_wip_tpl/.$i.sidebar" ]] \
|
||||
&& cat "$domain_dir_wip_tpl/.$i.sidebar" \
|
||||
[[ -f "$domain_dir_sidebar/.$i.sidebar" ]] \
|
||||
&& cat "$domain_dir_sidebar/.$i.sidebar" \
|
||||
>> "$domain_dir_wip_tpl/sidebar.html"
|
||||
done
|
||||
|
||||
this_article="$domain_dir_wip_tpl/sidebar.html"
|
||||
log__add -i -S WIP "Created items from 1 to $domain_sidebar_items"
|
||||
log__add -i -M -rs "Created items from 1 to $domain_sidebar_items"
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Specific. Loading static stl.sidebar and create sidebar
|
||||
#======================================================================
|
||||
sidebar__load() {
|
||||
sdb_load=true
|
||||
domain__get
|
||||
|
||||
mkdir -p "$domain_dir_sidebar" # ensure articles/sidebar is creeated
|
||||
|
||||
# Not yet configured (for older versions)
|
||||
! [[ "$domain_file_sidebar_load" ]] \
|
||||
&& echo "! Unused configuration for sidebar. Type: stl update" \
|
||||
&& exit
|
||||
|
||||
# Create, stl.sidebar file (if not exists)
|
||||
if ! [[ -f "$domain_file_sidebar_load" ]];then
|
||||
create__file_sidebar_load # manage__domain
|
||||
echo "# Static sidebar file created: $domain_file_sidebar_load"
|
||||
|
||||
# Get sidebar hash, create default id file
|
||||
sidebar_hash=`cksum "$domain_file_sidebar_load" | awk '{print $1}'`
|
||||
touch "$domain_dir_sidebar/.id.sidebar"
|
||||
echo "user_sidebar=$sidebar_hash" \
|
||||
> "$domain_dir_sidebar/.id.sidebar"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Get sidebar hash
|
||||
sidebar_hash=`cksum "$domain_file_sidebar_load" | awk '{print $1}'`
|
||||
|
||||
# Check .id.sidebar file
|
||||
if ! [[ -f "$domain_dir_sidebar/.id.sidebar" ]];then
|
||||
touch "$domain_dir_sidebar/.id.sidebar"
|
||||
echo "user_sidebar=$sidebar_hash" \
|
||||
> "$domain_dir_sidebar/.id.sidebar"
|
||||
|
||||
fi
|
||||
|
||||
source "$domain_dir_sidebar/.id.sidebar"
|
||||
case "$sidebar_hash" in
|
||||
# Default file
|
||||
"4269375654"|"2074433654")
|
||||
echo "! Sidebar not yet configured: $domain_file_sidebar_load"
|
||||
exit
|
||||
;;
|
||||
|
||||
"$user_sidebar")
|
||||
echo "! No changes in $domain_file_sidebar_load"
|
||||
exit
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "user_sidebar=$sidebar_hash" \
|
||||
> "$domain_dir_sidebar/.id.sidebar"
|
||||
;;
|
||||
esac
|
||||
|
||||
# loop stl.sidebar lines
|
||||
item=0
|
||||
while read -r "line"
|
||||
do
|
||||
# Ignore comments, empty lines
|
||||
[[ "$line" =~ ^'#' ]] || [[ -z "$line" ]] && continue
|
||||
|
||||
# Remove first / if found
|
||||
[[ ${line::1} == '/' ]] && line=${line:1}
|
||||
|
||||
# Get from DB if exists
|
||||
db_file=`
|
||||
grep -H "article_uri_src='/$line'" $domain_db_articles/*.db \
|
||||
| head -n 1 \
|
||||
| awk -F: '{print $1}'`
|
||||
|
||||
# Article not yet checked
|
||||
[[ "$db_file" ]] || continue
|
||||
|
||||
((item++))
|
||||
sidebar__OPTIONS " " add "$item" "$line"
|
||||
|
||||
# Count to max definded items
|
||||
#set -a item
|
||||
(( $item > $domain_sidebar_items )) && break
|
||||
|
||||
done <"$domain_dir_sidebar/stl.sidebar"
|
||||
|
||||
# Create HTML sidebar
|
||||
[[ $sidebar_add ]] && sidebar__create_HTML
|
||||
}
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 129
|
||||
# functions: 4
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Argument: stats
|
||||
|
@ -51,7 +59,7 @@ stats__statoolinfos() {
|
|||
case "$stl_install" in
|
||||
server)
|
||||
touch "$domain_dir_www/stl-stats.properties"
|
||||
cat <<EOSTATS > "$domain_dir_www/stl-stats.properties"
|
||||
cat <<EOSTATS > "$domain_dir_wip/stl-stats.properties"
|
||||
stl.articles = $stat_articles_www
|
||||
|
||||
stl.articles.titles = $article_titles_www
|
||||
|
@ -75,8 +83,8 @@ stl.articles.filebruts = $files_bruts_www
|
|||
EOSTATS
|
||||
|
||||
# log
|
||||
this_article="$domain_dir_www/stl-stats.properties"
|
||||
log__add -i -W -S "Statoolinfos file generated"
|
||||
this_article="$domain_dir_wip/stl-stats.properties"
|
||||
log__add -i -W -S "Created stats (Statoolinfos)"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 224
|
||||
# functions: 6
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# --------------------
|
||||
|
@ -17,14 +25,14 @@ update__OPTIONS() {
|
|||
cur_stl_version=`awk 'NR==2 {print $3}' "$stl_bin"`
|
||||
|
||||
case "$1" in
|
||||
-v) version__installed ;;
|
||||
-u) update__check ;;
|
||||
-U) stl_upg=true;update__check ;;
|
||||
version) version__installed ;;
|
||||
-u) update__check ;;
|
||||
-U) stl_upg=true;update__check ;;
|
||||
update) update__conf ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Show current version
|
||||
#======================================================================
|
||||
|
@ -158,3 +166,59 @@ echo "- Copy scripts: /var/lib/stl/scripts/"
|
|||
# Cleaning
|
||||
rm -rf "/tmp/STL/"
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
# Checking and updating conf after STL update
|
||||
#======================================================================
|
||||
update__conf() {
|
||||
domain__get
|
||||
echo "# Configuration:"
|
||||
|
||||
# Sidebar
|
||||
if [[ "$domain_dir_sidebar" && "$domain_file_sidebar_load" ]];then
|
||||
echo " - Sidebar Ok"
|
||||
|
||||
else
|
||||
cat << EOCONF >> "$stl_file_pwd_conf"
|
||||
|
||||
# Sidebar
|
||||
domain_dir_sidebar="$PWD/articles/sidebar"
|
||||
domain_file_sidebar_load="$PWD/articles/sidebar/stl.sidebar"
|
||||
EOCONF
|
||||
echo " - Sidebar configured"
|
||||
fi
|
||||
|
||||
# Logs
|
||||
echo
|
||||
stl log clean all
|
||||
|
||||
# Re check all checked article to wirte DB
|
||||
echo -e "\n# Database:"
|
||||
update__database
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Force check all checked articles
|
||||
#======================================================================
|
||||
update__database() {
|
||||
for db_check in $domain_db_articles/*.db
|
||||
do
|
||||
source "$db_check"
|
||||
uri_dba="$article_uri_srv"
|
||||
uri_dba=${uri_dba:1}
|
||||
uri_dba=${uri_dba/.html/.stl}
|
||||
|
||||
if [[ $check_all ]];then
|
||||
stl check -F "$uri_dba"
|
||||
echo
|
||||
|
||||
else
|
||||
stl check -F "$uri_dba" &>/dev/null
|
||||
echo " - $uri_dba updated"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ $check_all ]] && exit
|
||||
}
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
# By echolib (XMPP: im@echolib.re)
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#------------
|
||||
# funny stats
|
||||
#------------
|
||||
# lines: 1023
|
||||
# functions: 19
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#**********************************************************************
|
||||
|
||||
#======================================================================
|
||||
# Argument make
|
||||
# $1: mak
|
||||
|
@ -31,7 +40,7 @@ do
|
|||
-F) wip_force=true ;;
|
||||
*".stl") article__hash "$2" ;;
|
||||
"sidebar="*) sidebar="$2";position=${sidebar/sidebar=} ;;
|
||||
*) noarg "$2" "Use: -F, (ARTICLE).stl,sidebar" ;;
|
||||
*) noarg "$2" "Use: -F, (ARTICLE), sidebar" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -42,41 +51,45 @@ if [[ $need_check ]];then
|
|||
echo "! Article has changed. you must check it first"
|
||||
exit
|
||||
|
||||
elif [[ $article_error == 'yes' ]];then
|
||||
# Article has error
|
||||
elif [[ $check_force ]];then
|
||||
echo "! Article is not valid. Check for errors first"
|
||||
exit
|
||||
fi
|
||||
|
||||
# check wip hash and wip file exists
|
||||
do_wip=true
|
||||
if [[ $article_wip_hash ]];then
|
||||
if [[ -f "$domain_dir_wip$article_uri_srv" ]];then
|
||||
this_article="$domain_dir_wip$article_uri_srv"
|
||||
|
||||
if ! [[ $article_wip_hash ]];then
|
||||
log__add -i -M -A \
|
||||
"Create new HTML convertion"
|
||||
|
||||
else
|
||||
if ! [[ -f "$domain_dir_wip$article_uri_srv" ]];then
|
||||
log__add -w -M -A \
|
||||
"Was manually deleted ! Convert again"
|
||||
|
||||
else
|
||||
if [[ $article_wip_hash == $article_chk_hash ]];then
|
||||
if [[ $wip_force ]];then
|
||||
log__add -w -M -A \
|
||||
"Already Exists and up. Force connvert again"
|
||||
|
||||
else
|
||||
log__add -w -M -A \
|
||||
"Already Exists and up. Use -F to connvert again"
|
||||
unset do_wip
|
||||
fi
|
||||
log__add -w -M -A \
|
||||
"Already Exists and up. Force connvert again"
|
||||
|
||||
else
|
||||
log__add -w -M -A \
|
||||
"Already Exists and up. Use -F to connvert again"
|
||||
unset do_wip
|
||||
fi
|
||||
|
||||
else
|
||||
log__add -i -M -A \
|
||||
"Already Exists but old. Connvert"
|
||||
"Already Exists but old. New connversion"
|
||||
fi
|
||||
|
||||
else
|
||||
log__add -w -M -A \
|
||||
"Was manually deleted ! Convert again"
|
||||
fi
|
||||
|
||||
else
|
||||
log__add -i -M -A \
|
||||
"Create new HTML convertion"
|
||||
fi
|
||||
|
||||
# Convert to HTML if asked or needed
|
||||
if [[ $do_wip ]];then
|
||||
split_article "$uri_article" # Split metas & content
|
||||
makers "$article_tmp_post"
|
||||
|
@ -136,12 +149,10 @@ sed -i -e "s|^|$spc|" "$article_tmp_post"
|
|||
create__HTML_translation
|
||||
create__HTML_page
|
||||
|
||||
# Write wip hash to Db
|
||||
sed -i "s^article_wip_hash=.*^article_wip_hash=$article_hash^" \
|
||||
"$db_file" && \
|
||||
log__add -i -db $article_id \
|
||||
"Updated wip status"
|
||||
|
||||
# Write wip hash to DB
|
||||
db__srv_status_hash WIP set
|
||||
|
||||
# Remove tmp files
|
||||
rm -f "$article_tmp_post"
|
||||
rm -f "$article_tmp_head"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue