diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b24f9d..62f502c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,147 @@ GSL changes from releases. You can send an issue : - repo: https://git.a-lec.org/echolib/gsl/-/issues - Contact xmpp: im@echolib.re -## [0.0.37] +## [0.0.9] +## Please, see help (and documentations in help folder) + +### Add +- New code about everywhere, more comments, cleaner +- nano dependence +- Check installed configuration at launch +- Dedicated functions for ARGUMENTS in specific files category +- - check: gsl__post_checkers +- - make,sidebar: gsl__post_makers +- - sync,www,wip gsl__srv_manager +- - log: gsl__log_manager +- - db: gsl__db_manager +- - author,new,setdir: gsl__domain_manager +- - edit: gsl__edit_file +- - stats: gsl__stats + +### Installation +- new files: +- - gsl__srv_manager: for all about server +- - gsl__version: for -v, -vv, --version options +- - gsl__domain_manager: for OPT author, new, setdir +- - gsl__edit_file: functions to edit some configuration files +- - gsl__do_commons: Common functions to filter article lines +- - gsl__HTML_template: functions to create HTML pages +- New empty folder in installation: +- - /var/lib/gsl/db: for all DBs (.gitkepp) +- - /var/lib/gsl/domains: for all domains (.gitkeep) +- - /var/log/gsl: for logs files (.gitkeep) +- New help folder in +- - /var/lib/gsl/help (removed "helps" one) + +### Logs +- Better logs harmony +- New fields in log for article filename and domain name +- Specific number of characters spaces in some log fields +- More verbose +- "automatic" level log set from called functions +- Colored levels: war (yellow), err (red) + +### Databases +- Dedicated per article +- Folder: /var/lib/gsl/db/ +- New file format: domains.db +- More datas with new stats. Quicker sourced datas +- Dedicated articles in sub-directory "DOMAIN" +- Check if corrupted DB +- Database and wip files won't be removed if errors in article +- If corrupted Database, try restoring www & wip statuses at new check + +### Changes +- Changes in mapping process: +- - Processes get needed headers FIRST, then split article in 2 sections +- DOMAIN Profile is only in /var/lib/gsl/domains/DOMAIN/ +- Variables in DOMAIN.conf file has no more "gsl_" +- Some translated words in HTML page from lang set DOMAIN (fr || en) +- Between markers (code): put "everything" you want +- New CSS classes: see gsl help css or documentation +- Mark image (i.e. "_image:1:mycss:50%:25%:+)" +- - define your own css class 'mycss' +- - define unity ("%","px"... with height and witdth) +- New lists. Mix "+" (ol) and "=" (ul) and write an item on several lines +- Between hX titles: new div css (none if empty content) +- Changing article Type will remove old wip file (not www file !) +- sync: Logs not shown but added +- stats properties file is now in /www (online) + +### Process check [argument] +- slug: log err if already exists (log war if not well formated) + +### new ARGUMENTS +- new (page|post) (name): Create article, show its content + check it +- new domain: New domain configuration creator +- edit domains: Set/Edit registred domains database +- edit author: Same as author edit +- author edit: Opens nano to Add/Remove authors (one per line) by DOMAIN +- setdir: Set current folder for your DOMAIN (show if one) +- check -N: Only check newer articles not in DB +- clean all: Remove all backups (only) files +- sidebar: add|replace|latest|oldest (See gsl help) +- www sync: Same as sync www +- wip ...: Same as www but for wip + +### Markers +- css: MYCLASS Customize each article with your CSS (optional) +- brut: Insert brut code from file +- - In article header: "NBR : FILENAME"`` +- - In article content: "_brut: NBR" +- "_image:VALUE:MYCSS:WIDTH:HEIGHT:TARGET" (no target=no HTML link) +- Strong mark: '•...•' (alt+gr + ;) on french azerty keyboard) +- Bold mark: '·...·' (alt+gr + :) on french azerty keyboard) +- Emphasis mark: '”...”' (alt+gr + n) on french azerty keyboard) +- Strike mark: '×...×' (alt+gr + shift + ;) on french azerty keyboard +- ```<<``` and ```>>``` as "start" and "close" marker for lists + +### Template +- included basic header, metas and footer +- All about template is in /var/lib/gsl/scripts/gsl__HTML_template +- - No more header.html in templates folder +- - - Edit your own in create__HTML_header() function +- In /var/lib/gsl/domains/DOMAIN/templates/ +- - Auto created metas.html and footer.html if not exist +- - Edit your own footer.html +- - Edit your own metas per DOMAIN for HTML `````` in metas.html +- - - included basic pre-registred meta from datas article +- - No CSS styles included: create your own (see classes and IDs used in doc) +- For all changes here, after gsl make, use gsl sync... + +### Sidebar +- No more /var/lib/gsl/domains/DOMAIN/templates/last-posts-list.html +- - Remove it with files xxx.X in /var/lib/gsl/domains/DOMAIN/X-tra/ +- New HTML file: /var/lib/gsl/domains/DOMAIN/templates/sidebar.html +- - Created with files /var/lib/gsl/domains/DOMAIN/X-tra/sidebar/(POS).html +- articles are sorted from epoch date (in DB) with false time at check + +### Statoolinfos (added properties for www status) +- gsl.articles +- gsl.articles.pages +- gsl.articles.posts +- gsl.authors +- gsl.articles.tags +- gsl.articles.words +- gsl.articles.quotes +- gsl.articles.paragraphs +- gsl.articles.links +- gsl.articles.links.online +- gsl.articles.lists +- gsl.articles.lists.items +- gsl_articles.images + +### CRITIK +- Remove all files in /var/lib/gsl/db/ +- Use: ```gsl new domain```, give your registred DOMAIN name +- - Answer Y to autofix old configurations files and folders +- - Do it for each DOMAIN you registred +- - will add site_max_list=5 (default) in domain configuration file +- Use ```gsl check``` in your articles folder + + +## [0.0.37] ### Add - changelog - Make stats at each www call diff --git a/README.md b/README.md index c99027a..34cb566 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ ------------------------------------------------------------------------ GSL est un générateur de blogs/sites-web basé sur leur nom de domaine, -écrit en bash, afin de ne réduire ses dépendances au minimum. Les pages +écrit en bash, afin de réduire ses dépendances au minimum. Les pages générées sont presque entièrement statiques, à l'exception du module de -liste des derniers articles. Nginx peut être facilement configuré pour -interprêter ce module. +liste des derniers articles (sidebar) placé en include. Nginx peut être +facilement configuré pour interprêter ce module. + # Dépendances ------------------------------------------------------------------------ @@ -13,206 +14,179 @@ interprêter ce module. - bash - coreutils - curl (to check Posts links response) -- rsync +- rsync, nano # GSL: Installation ------------------------------------------------------------------------ -Une procédure d'installation via un setup est en cours de test. Il est +Une procédure d'installation via un setup est en préparation. Il est aussi possible et recommandé sous debian de l'installer grâce à son -paquet deb. +paquet deb (construit par make). Pour une installation manuelle, clonez ce dépôt, et copiez les dossiers -déjà pré-établis dans le système. GSL n'utilise pas sudo, il vous faut -donc donner les droits aux dossiers (chown -R) à l'utilisateur -(sauf au dossier /usr/local/bin). Pour ce dossier, vous donnerez les droits -via chown USER:USER /usr/local/bin/gsl +déjà pré-établis dans le système (avec sudo). GSL n'utilise pas sudo, +il vous faut donc donner les droits des dossiers (chown -R) à l'utilisateur +(sauf au dossier /usr/local/bin). Pour ce dossier, vous donnerez les +droits au fichier gsl seulement -## Configuration du DOMAIN (selon le choix de l'utilistaeur via $ gsl new) : -- HOME: ~/.config/gsl -- GLOBAL: /var/lib/gsl -- Dossier: --Prefix/domains/ (créé par GSL via $ gsl new) +Reportez-vous à la documentation dans le dossier help -### Données du DOMAIN : -- Dossier: --Prefix/DOMAIN/ (créé par GSL) -- - Fichiers: DOMAIN.conf, authors.db (créé par GSL) -- - Dossier: --Prefix/DOMAIN/templates/ (créé par GSL - pour vos css, logos...) - -## Dossier de configuration de GSL : /etc/gsl/ -- Fichier: gsl.conf - -## Dossier principal : /var/lib/gsl/ -- Folder: db (créé par GSL) -- Dossier: helps -- Dossier: scripts -- Fichier: README.md, README-english.md - -## Dossier des logs: /var/log/gsl/ -- Fichier: gsl.log (créé et géré par GSL via $ gsl log [OPT]...) - -## Dossier de l'éxécutable : /usr/local/bin/ -- Fichier: gsl - -## Dossier d'autocomplétion : /usr/share/bash-completion/completions/gsl/ -- Fichier: gsl # Comment configurer un domaine ------------------------------------------------------------------------ +Préparer un fichier de logo. L'important sera de renseigner le nom du +fichier lors du questionnaire. + +Attention: GSL aura besoin de créer des sous-dossier dans le serveur, +renseigné dans le questionnaire. (i.e. /var/www/). Il faut donc lui +donner les droits + +`` +$ gsl new) domain +``` Des questions vous seront posées lorsque vous voudrez ajouter un domaine -(exemple.com). Les données renseignées seront utilisées pour créer le -fichier DOMAIN.conf. Une question spécifique pour les fichier des articles -vous sera posée afin d'établir un dossier de stockage de vos articles. -Vous pourrez en créer à loisir autant que vous voulez plus tard. +(exemple.com). Les données renseignées seront utilisées pour créer la +configuration (voir la documentation d'installation) -``` -# helps -gsl help -gsl help new -gsl help install -# Ajouter un domaine -gsl new -``` - -## Définir un dossier pour les articles du DOMAIN +## Définir un dossier pour les articles du DOMAIN +------------------------------------------------------------------------ Si ce n'est pas déjà fait par GSL, ou que vous voulez ajouter un dossier -pour y stocker et convertir en HTML vos articles pour un DOMAIN précis : +pour y stocker vos articles bruts pour un DOMAIN précis : -- Ajouter/créer un dossier de votre choix +``` +gsl help -d +cd MYFOLDER +gsl setdir +``` + +ou: +- Aller dans/créer un dossier de votre choix - Créer dedans, un fichier vide nommé gsl.DOMAIAN (gsl.exemple.com) -## Ajouter un auteur + +## Ajouter / retirer un auteur +------------------------------------------------------------------------ +Après avoir enregistré un domain et configuré un dossier pour les +articles. **Un auteur par ligne !** + ``` cd MON-DOSSER-ARTICLES -gsl author add +gsl author edit ``` + ## Créer un article -Le moteur de convertion est nouveau, et est un mélange entre markdown et +------------------------------------------------------------------------ +Le moteur de convertion est nouveau. C'est un mélange entre markdown et reSTructuredText. Il est simple à apprendre et à utiliser. -- Créer un fichier (monarticle).gsl (extension .gsl) -- Suivez le guide plus bas pour comprendre les notions - -Vous devrez le faire valider par GSL : +Reportez-vous à la documentation dans le dossier help, ou: ``` -gsl check -gsl check monarticle.gsl # Vérfier que monarticle.gsl -gsl check -F Forcer la vérification -gsl check -F monarticle.gsl # Forcer la vérification de monarticle.gsl +gsl help -w ``` -## Convertir un ou tous les articles -Si votre article n'a pas d'erreurs, vous pouvez le convertir en HTML. -``` -gsl make -gsl make -F # Forcer la reconstruction) -gsl make -F monarticle.gsl # Forcer la reconstruction de monarticle.gsl -``` - -Votre article sera prêt dans le dossier webserver (ex: /var/www/DOMAIN/wip) -Vous pourrez donc vérifier son rendu. - -Si vous êtes satisfait, vous pouvez le déployer "officiellement" dans www - -``` -# Vous pouvez utiliser l'autocompletion pour les articles -gsl www add monarticle.gsl -``` +## Procédures de prévisualisation et mise en ligne +------------------------------------------------------------------------ +- gsl check monarticle.gsl (vérifie l'écriture en gsl) +- gsl make monarticle.gsl (Connvertit en HTML - dossier wip) +- gsl www add monarticle.gsl (copiel la page dans le dossier www) # Comment gérer la sidebar ------------------------------------------------------------------------ La gestion de la sidebar est manuelle. Un article doit être convertit avec make avant de pouvoir l'ajouter à la position ddsirée. Le nombre -d'articles maximum dans la sidebar est configurable dans /etc/gsl/gsl.conf - -Quelques exemples d'utilisations +d'articles maximum dans la sidebar est configurable dans le fichier de +configuration du domaine (DOMAIN.conf) ``` -# Liste les articles de la sidebar dans l'ordre -gsl sidebar - -# Ajoute monarticle en position 1 -gsl -S add 1 monarticle - -# Enlève monarticle2 de la sidebar -gsl -S remove monarticle2 - -# monarticle5 est en position 3. Le replacer par monarticle4 -gsl -S -A 3 monarticle4 +gsl sidebar replace 2 monarticle.gsl ``` -# Besoin d'aide ! +## Astuces +- Vous pouvez utiliser l'autocompletion pour les articles +- Reportez-vous à la documentation dans le dossier Help + +``` +gsl www add mona +``` + + +# Help ------------------------------------------------------------------------ -Reportez vous aux explications dans le dossier *help* - - -# HELP COMMAND ------------------------------------------------------------------------- -``` -$ gsl [ARG] +$ gsl (ARG) readme : Show README.md instructions - help | -h [OPT] : This Help - install : Show process installation - new : Adding a DOMAIN - write | -w : How to write a Post - template | -t : Tips to create your template + help | -h (OPT) : This Help and how to + install | -i : Show process installation + authors | -a : Add/Remove authors for this DOMAIN + setdir | -d : Set a directory for article's DOMAIN + write | -w : Write a Post + tpl | -T : Create your template + param | -p : Configure some parameters + css : Show used CSS classes + tips | -t : Show tips and advises you should know - new | -N : Add and configure a new DOMAIN - - log | -L [OPTS] : Show logs from all sessions + new | -N : Generic OPT to add/create + domain : Configure your DOMAIN + author : Same as gsl author edit + (TYPE) (NAME) : Create an article with (TYPE) named (NAME).gsl + + setdir | -D : Show current directory DOMAIN or set it + + log | -L (OPTS) : Show logs from all sessions clean | -C : Logs saved to {DATE}.gsl.log and cleaned + all : clean all saved logs, keep current -i | -w | -e : from levels (infos, warnings, errors) -s : from last session only - [TERM] : [TERM] : case insensitive, regex 'T1.*T2' + (TERM) : (TERM) : case insensitive, regex 'T1.*T2' (i.e. $ gsl log -e -s code) - author | -A [OPT] : List authors from DOMAIN set in PWD folder - add : Add author(s) for DOMAIN - remove : Remove author(s) for DOMAIN + author | -A : List authors from DOMAIN in PWD folder + edit : Add/Remove ! ONE author per line - create [TYPE] [NAME] : Create an article with [TYPE] named [NAME].gsl - - edit | -E : Open in default EDITOR [FILE] or with nano + edit | -E : Open in default EDITOR (FILE) or with nano conf : Domain configuration file - [FILE] : [FILE] (.gsl) + author : Same as gsl author edit + domain : Domains registred database + (FILE) : (FILE) ; .gsl - db [FILE] : Show DB statuses from [FILE] + db (FILE) : Show DB statuses from (FILE) - sync [OPT] : Sync Templates to www and wip + sync (OPT) : Sync Templates to www and wip wip : Only to wip server (also done with make) www : Only to www server (also done with www) - check | -C [OPT] [FILE] : Check Posts errors from PWD folder or [FILE] - -F : Force check again + check | -C (OPTIONS) : Check Post(s) errors from PWD folder + -N : Check only articles not in DB + -F : Force Check again ; Recreate in Database + (FILE) : Only this (FILE) - make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE] - to HTML file in server + make | -M (OPTIONS) : Make all HTML articles or only (FILE) -F : Force Make again + (FILE) : Only this (FILE) - www [OPT1] [OPT2] : Add/Remove Post from www server - [OPT1]: - add : Add all/[FILE] to www server - rmove : remove all/[FILE] from www server - [OPT2]: + www (OPT1) (OPT2) : Add/Remove Post(s) in www server + (OPT1): + sync : Same as "sync www" + add : Add all/(FILE) to www server + rmove : remove all/(FILE) from www server + (OPT2): all : Select all post with wip statuses - [FILE] : Select specific post (if wip status) + (FILE) : Select specific post (if wip status) + wip : Same as www for wip - sidebar | -S [ARG] [FILE]: Show Posts in list - [ARG]: - add | -A : Must set a Position number before [FILE] - Max posts in list is set in gsl.conf - Replace post position if post not exists in list - remove | -R : No Position to set, just [FILE]. - add/remove will build last-posts-list.html - create | -C : rebuild last-posts-list.html + sidebar | -S : Show Posts in list (ARG) (POS) (FILE) + (ARG): + add | -a : Put article at (POS). Remove last, roll from (POS) + replace | -r : Replace (POS) with article + latest | -l : Create sidebar with latest (remove all existing) -v : Show local versionn --version : Like -v + changes -vv : Shown local and repo Versions -``` + diff --git a/control b/control index 373af2e..c854da8 100644 --- a/control +++ b/control @@ -1,10 +1,10 @@ Package: egsl -Version: 0.0.37 +Version: 0.0.9 Section: custom Priority: optional Architecture: all Essential: no -Depends: curl,rsync +Depends: curl,rsync,nano Installed-Size: `du -ks usr|cut -f 1` Maintainer: echolib Description: Echolib's GSL is a multiple blogs/websites generator based on their domain, written in bash, for minimal dependancies. The websites are nearly all static, except for some includes pages, like listing posts, that nginx can easily get, in your webserver. diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index 4594716..24e435a 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -3,105 +3,121 @@ # By echolib # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 +#======================================================================= +# Set GSL Internal Configuration +#======================================================================= +# minimum size to check a post (default: 180) +gsl_article_min_Size=180 -#======================================================================= -# Folders -#======================================================================= +# Show log by time|level (default: 'time'); not set = level +gsl_log_order=time + +#---------------------------------------------------------------------- +# # Directories Structure +#---------------------------------------------------------------------- +# Main app_name="gsl" - -# Librairies gsl_dir_lib="/var/lib/gsl" gsl_dir_scripts="$gsl_dir_lib/scripts" -gsl_dir_helps="$gsl_dir_lib/helps" - -# Management -gsl_dir_db="$gsl_dir_lib/db" -gsl_dir_global_domains="/var/lib/gsl/domains" - -# Logs +gsl_dir_help="$gsl_dir_lib/help" gsl_dir_logs="/var/log/gsl" -# User -gsl_dir_user_domains="/home/$USER/.config/gsl/domains" +gsl_dir_domains="$gsl_dir_lib/domains" +gsl_dir_db="$gsl_dir_lib/db" + +#====================================================================== +# iNSTALLATION DEPENDANCIES +#====================================================================== +gsl_dirs=( +$gsl_dir_lib +$gsl_dir_scripts +$gsl_dir_domains +$gsl_dir_db +$gsl_dir_logs +$gsl_dir_help +) + +gsl_files_scripts=( +$gsl_dir_scripts/gsl__db_manager +$gsl_dir_scripts/gsl__do_commons +$gsl_dir_scripts/gsl__domain_manager +$gsl_dir_scripts/gsl__edit_file +$gsl_dir_scripts/gsl__HTML_template +$gsl_dir_scripts/gsl__log_manager +$gsl_dir_scripts/gsl__post_checkers +$gsl_dir_scripts/gsl__post_makers +$gsl_dir_scripts/gsl__post_manager +$gsl_dir_scripts/gsl__srv_manager +$gsl_dir_scripts/gsl__stats +$gsl_dir_scripts/gsl__version +) + +gsl_files_help=( +$gsl_dir_help/comment_ecrire-article.md +$gsl_dir_help/gsl_help.md +$gsl_dir_help/comment_installer-GSL.md +$gsl_dir_help/template-comment-creer.md +$gsl_dir_help/how_to-set_directory_for_articles.md +$gsl_dir_help/how_to-add_remove_authors.md +$gsl_dir_help/how_to-parameters_conf.md +$gsl_dir_help/how_to-CSS_classes.md +$gsl_dir_help/how_to-Tips_Advises.md +) + +gsl_dirs_w=( +$gsl_dir_domains +$gsl_dir_db +$gsl_dir_logs +) #======================================================================= # Files #======================================================================= -# Logs +gsl_file_db_domains="$gsl_dir_db/domains.db" gsl_file_logs="$gsl_dir_logs/gsl.log" -# Management -gsl_file_db_domains="$gsl_dir_db/domains.db" -gsl_file_db_posts="$gsl_dir_db/posts.db" -gsl_file_db_files="$gsl_dir_db/files.db" +# colors +NC="\e[0m" +CY="\e[33m" +CR="\e[0;91m" -# Registred Authors filename -gsl_filename_auth="authors.db" - -#======================================================================= -# GSL Internal Configuration -#======================================================================= -# minimum size to check a post -gsl_post_min_size=150 - -# Max Posts list in sidebar -gsl_list_max_posts=5 - -# Init log datas -gsl_log_e='Err' -gsl_log_w='War' +#---------------------------------------------------------------------- +# LOGS settings +#---------------------------------------------------------------------- +gsl_log_e="Err" +gsl_log_w="War" gsl_log_i='Inf' - -#----------------------------------------------------------------------- -# Set LOG help Activity for NEEDED HEADERS -#----------------------------------------------------------------------- -gsl_log_act_title='POST TITLE' +gsl_log_act_type="'page' or 'post'" +gsl_log_act_title='ARTICLE TITLE' gsl_log_act_author='REGISTRED NAME' -gsl_log_act_info='POST is ABOUT...' -gsl_log_act_slug='POST-TITLE' -gsl_log_act_code='NBR : FILENAME : Alt Text' -gsl_log_act_image='NBR : NAME : ALT TEXT' +gsl_log_act_info='it is about...' +gsl_log_act_slug='THIS-SLUG' +gsl_log_act_fcode='NBR : FILENAME : Alt Text' +gsl_log_act_fbrut='NBR : FILENAME' +gsl_log_act_flink='NAME : FILENAME : Alt Text' +gsl_log_act_image='NBR : FILENAME : ALT TEXT' gsl_log_act_abbr='SHORT : LONG' -gsl_log_act_h1='#1 POST CONTENT TITLE' -gsl_log_act_link='NAME : URL : Alt Text' -gsl_log_act_file='NAME : FILENAME : Alt Text' +gsl_log_act_link='NAME : URL : Alt-Text' -#----------------------------------------------------------------------- -# Set LOG for Process Type -#----------------------------------------------------------------------- -gsl_log_h_link="Header Link" -gsl_log_h_abbr="Header ABBR" -gsl_log_h_code="Header Code" -gsl_log_h_image="Header Image" -gsl_log_h_file="Header File" -gsl_log_h_image="Header Image" - -gsl_log_c_h1="Content Begins" -gsl_log_c_p="Content Paragraphs" -gsl_log_c_cite="Content Citations" -gsl_log_c_link="Content Link" -gsl_log_c_abbr="Content ABBR" -gsl_log_c_code="Content Code" -gsl_log_c_image="Content Image" -gsl_log_c_file="Content File" - -#----------------------------------------------------------------------- -# Set CONTENT POST markers -#----------------------------------------------------------------------- -gsl_mo_p='(' -gsl_mc_p=')' -gsl_mark_file='__' +#---------------------------------------------------------------------- +# CONTENT Article markers +#---------------------------------------------------------------------- +gsl_mark_p_start='(' +gsl_mark_p_close=')' +gsl_mark_flink='__' gsl_mark_image='_image' gsl_mark_fcode='_code' +gsl_mark_fbrut='_brut' gsl_mark_title='#' -gsl_mark_bold='\*' -gsl_mark_strong='\*\*' -gsl_mark_italic='\/' -gsl_mark_code="¤" +gsl_mark_bold='·' +gsl_mark_strong='•' +gsl_mark_em='”' +gsl_mark_icode="¤" gsl_mark_list='=' gsl_mark_listo="+" - - +gsl_mark_newline="|" +gsl_mark_strike="×" +gsl_mark_link='_' gsl_mark_blockquote='---' gsl_mark_blockquote_cite='_cite :' gsl_mark_blockquote_year='_year :' @@ -109,27 +125,35 @@ gsl_mark_blockquote_link='_link :' gsl_mark_blockquote_book='_book :' gsl_mark_blockquote_lang='_lang :' -#----------------------------------------------------------------------- -# Set HEADERS markers -#----------------------------------------------------------------------- -# type: page / post -gsl_marker_type='type: ' -gsl_marker_title='title: ' -gsl_marker_slug='slug: ' -gsl_marker_info='info: ' -gsl_marker_author='author: ' -gsl_marker_date='date: ' -gsl_marker_tags='tags: ' +#---------------------------------------------------------------------- +# HEADERS markers +#---------------------------------------------------------------------- +# Needed HEADER markers +gsl_marker_type='type:' +gsl_marker_title='title:' +gsl_marker_slug='slug:' +gsl_marker_info='info:' +gsl_marker_author='author:' +gsl_marker_date='date:' +gsl_marker_tags='tags:' -#Optional (include brut text) -gsl_marker_code='code: ' -gsl_marker_image='image: ' -gsl_marker_abbr='abbr: ' -gsl_marker_link='link: ' -gsl_marker_file='file: ' +# Optional HEADER markers +gsl_marker_css='css:' +gsl_marker_fcode='code:' +gsl_marker_fbrut='brut:' +gsl_marker_image='image:' +gsl_marker_abbr='abbr:' +gsl_marker_link='link:' +gsl_marker_flink='file:' -# Delimiters to seet for sed in case exists in inline-code -gsl_d=(\, \. \? \% \# \- \: \^ \/ \_ \| ) +# Closed HTML static code +HTML_strike_close='' +HTML_icode_close='' +HTML_em_close='"' +HTML_strong_close='' +HTML_bold_close='' +HTML_br='
' +HTML_p_close='

' # Onlinde Repo repo="https://git.a-lec.org/echolib/gsl/-/raw/main/usr/local/bin/gsl" diff --git a/help/article-comment-ecrire.md b/help/article-comment-ecrire.md deleted file mode 100644 index adf7c5e..0000000 --- a/help/article-comment-ecrire.md +++ /dev/null @@ -1,310 +0,0 @@ -# Créer un fichier depuis la ligne de commande ------------------------------------------------------------------------- - -Vous pouvez créer un fichier daté du jour avec les METAS obligatoires -intégrés (à renseigner après). Vous devez spécifier si votre article -sera une page ou un post (Voir section plus bas) et lui donner un nom. - -Rendez vous dans le dossier de vos articles, enregistrés lors de l'ajout -de votre domaine (ou celui que vous avez configuré). - -Évitez les espaces dans le nom du fichier ou utilisez des guillemets. - -``` -# Crréer une page nommée index -gsl create page index - -# Créer un article nommé mes-vacances -gsl create post mes-vacances -``` - -Vous pouvez l'éditer dans le terminal ou avec votre éditeur de texte. - -``` -gsl edit mes-vacances.gsl -``` - -# Comment écrire un article ------------------------------------------------------------------------- - -Votre article doit contenir 2 sections. Les METAS avant ```#1``` et -l'article à partir de ce repère (servant de titre h1). - -- METAS : configurer votre article (titre, date, liens...) -- ARTICLE : contenue rédactionnel avec quelques marqueurs (gras...) - -## METAS obligatoires (avant #1) - -``` -title: POST TITLE -slug: POST-TITLE (si espaces, GSL les convertira en -) -info: DESCRIPTION (À propos de cet article) -author: NAME (doit être enregistré via ($ gsl author add) -date: YYYY-MM-DD -tags: TAG1,Mon TAG2,TAG3 (séparé par une virgule) -``` - -### Page ou Article ? - -Vous pouvez spécifier pour chaque article si c'est une page ou un article -Si non renseigné, GSL ajoutera le type: post (article) par défaut à la -première ligne de votre article - -``` -# Page (index, 404, about...) -# Création HTML selon le slug: /POST-TITLE.html -type: page - -# Article (monarticle) -# Création HTML selon le slug: /POST-TITLE/index.html -type: post -``` - -## METAS optionnelles (avant ```#1```) - -Définir les marqueurs (abbr:, link:...) et utiliser ``` : ``` comme séparateur - -``` -abbr: COURT : LONG -file: NOM : NOM-DU-FICHIER : Text alternatif -link: NOM : URL : Text alternatif -code: NUMERO : NOM-DU-FICHIER : Text alternatif -image: NUMERO : NOM-DU-FICHIER : TEXT-ALTERNATIF -``` - -## Contenu de l'article: - -Les marqueurs *et leur contenu* (ex: ```= list 1...```, ```*__monfichier...```) -**doivent commencer et finir sur la même ligne**. - -### Abréviations -Définir en METAS... - -``` -abbr: CSS : Cascading Style Sheets -``` - -Dans l'article: - -``` -Les propriétés CSS ne sont pas définies -``` - -### Paragraphes - -Au début d'une nouvelle ligne, ouvrez avec ( et fermez avec ). -Vous pouvez utiliser 4 classes de paragraphes différentes : ( 1 ( 2 ( 3 - -Dans l'article... -``` -( 2 -Paragraphe avec une classe 2 (css) -) - -( -Paragraphe sans numéro de classe -) -``` - -### Liens - -Définir en METAS - -``` -link: Mon lien : URL : Alt text -link: https://a-lec.org/ : URL : Alt text -``` - -Dans l'article.. -- Écrivez ```_``` devant le nom du lien -- Ajoutez ```+``` pour ouvrir le lien dans un nouvel onglet - -``` -Visitez _Mon lien+ et charger ici la page _https://a-lec.org/ -``` - -### Fichiers - -Définir en METAS - -``` -file: Mon fichier : FILENAME : ALT-TEXT -``` - -Dans l'article... -``` -__Mon fichier -``` - -### Images - -Définir en METAS - -``` -image: 1 : FILENAME : ALT-TEXT -image: 2 : FILENAME : ALT-TEXT -``` - -Dans l'article... -Définir le marqueur ```_image``` sur une seule ligne et spécifiez les -valeurs séparées par ":" - -- Numero d'image -- Alignement: l,r, ou c (g,d également) pour gauche, droite, centre) -- Longueur width: juste le nombre -- Largeur height: juste le nombre -- Champ non vide: Lien de l'image dans un nouvel onglet - -Exemple d'images affichées l'une à côté de l'autre - -``` -( -_image:1 -_image:2:c:640:480 -_image:3:c:320:240:+ -) -``` - -Exemple d'images affichées l'une en dessous de l'autre, dont la première -peut s'ouvrir dans un nouvel onglet - -``` -( -_image:1:c:640:480:+ -) -( -_image:2:c:1920:1080 -) -``` - -### Block-Code depuis un fichier - -Définir en METAS - -``` -code: 1 : FILENAME : Alt Text -``` - -Dans l'article... -``` -_code:1 -``` - -### Écrire en très gras - -Dans l'article... - -``` -**c'est du surgras** -c'est in**défini**ssable -il ad**juge** : pas de pub ! -``` - -### Gras - -Dans l'article... - -``` -*c'est en gras* -``` - -### Italique -Dans l'article... - -``` -C'est /en italique/ -``` - -### Code en ligne - -Info: ¤ = alt-gr + $ sur un clavier FR azerty) -Dans l'article... - -``` -¤gsl help -w¤ -``` - -### Citation simple - -(au début de la ligne, mettez 3x -) -Dans l'article... - -``` ---- -( -Une citation simple dans un paragraphe -) ---- -``` - -### Citation avancée - -Dans l'article... -``` ---- -_cite : Richard Matthew Stallman -_link : https://stallman.org/ -_lang : en -( -In the free/libre software movement, we develop software that respects -users' freedom, so we and you can escape from software that doesn't. I -could have made money this way, and perhaps amused myself writing code. -But I knew that at the end of my career, I would look back on years of -building walls to divide people, and feel I had spent my life making the -world a worse place -) ---- -``` - -### Citation avancée : optionnel - -Ajoutez ces marqueurs, si connus dans la citation, par ex sous ```_cite``` - -``` -_year: 2021 -_book: Esperanza 64 -``` - - -### Créer des listes -L'arborescence est "infinie". -- Chaque contenu de la liste **doit être sur la même ligne** - -Dans l'article... -- utilisez ```=``` pour définir l'arborescence d'une liste simple (ul) -- utilisez ```+``` pour définir une liste ordonnée (ol) - -``` -( -Voici une liste simple -= Fruits : *mangez-en* -== Kiwis -== Fraises -=== pas mûres -== Bananes -=== Plantins -= Légumes -== Haricots -=== Rouges -=== Verts -Fin de la liste -) -``` - -### Ajouter des lignes vides - -Vous pouvez ajouter des ```
``` dans votre rédaction, mais pour une -lecture plus propre de votre article, vous pouvez utiliser le caractère -```|``` *au tout début d'une nouvelle ligne* - -Dans l'article... - -``` -#1 Mon titre -( -Ceci est un long paragraphe (Un peu d'imagination...) -| -Retour "forcé" à la ligne -) - -``` diff --git a/help/comment-parametrer-GSL.md b/help/comment-parametrer-GSL.md new file mode 100644 index 0000000..8a43cb8 --- /dev/null +++ b/help/comment-parametrer-GSL.md @@ -0,0 +1,16 @@ +# Configurations optionnelles de GSL + +Vous pouvez configurer quelques paramètres dans le fichier +**/etc/gsl/gsl.conf** + +## Afficher les logs par chronologie +``` +# Show log by time|level (default: 'time'); not set = level +gsl_log_order=time +``` + +## Définir la taille en octets minimum d'un fichier +``` +# Par défaut: 180 +gsl_article_min_Size=250 +``` diff --git a/help/comment_ecrire-article.md b/help/comment_ecrire-article.md new file mode 100644 index 0000000..b3aed6a --- /dev/null +++ b/help/comment_ecrire-article.md @@ -0,0 +1,363 @@ +# Créer un article depuis la ligne de commande +------------------------------------------------------------------------ +Vous pouvez créer un article daté du jour avec les METAS obligatoires +intégrées (à renseigner après) depuis la ligne de commande. Vous devez +spécifier si votre article sera une page ou un post (Voir section plus +bas), et lui donner un nom. Les metas optionnelles sont ajoutées enn +commentaires. + +Rendez vous dans le dossier de vos articles, enregistrés lors de l'ajout +de votre domaine (ou celui que vous avez configuré). + +Mettez des guillemets pour les nom du fichier avec espaces. + +``` +# Crréer une page nommée index (deviendra /index.html) +gsl new page index + +# Créer un article nommé "mes vacances" +gsl ew post "mes vacances" +``` + +Vous pouvez l'éditer dans le terminal ou avec votre éditeur de texte, en +utilisant l'autocompletion () + +``` +gsl edit "mes vacances.gsl" +``` + + +# Comment écrire un article +------------------------------------------------------------------------ +Votre article doit contenir 2 sections. Les METAS avant ```#1``` et +l'article à partir de ce repère (servant de titre h1). + +- METAS : configurer votre article (titre, date, liens...) +- ARTICLE : contenue rédactionnel avec quelques marqueurs (gras...) + +## METAS obligatoires (avant ```#1```) +**Écrire sur une seule ligne** chaque META + +``` +type: page +title: POST TITLE +slug: MY-SLUG (si espaces, GSL les convertira en -) +info: DESCRIPTION (À propos de cet article) +author: NAME (doit être enregistré via la commande: gsl author edit +date: YYYY-MM-DD +tags: TAG1,Mon TAG2,TAG3 (séparé par une virgule) +``` + +### Page ou Article ? +Vous devez spécifier pour chaque article si c'est une **page** ou un +**post** + +#### Page (index, 404, about...) +Création HTML à la racine selon le slug: /MY-SLUG.html + +``` +type: page +slug: 404 +``` + +#### Post (monarticle) +Création HTML dans un dossier selon le slug: /MY-SLUG/index.html +**! Le slug ne doit pas commencer par un /** + +``` +type: post +slug: service/xmpp/configurer-gajim +``` + +## METAS optionnelles (avant ```#1```) +Définir UN seul marqueur CSS par article pour personnaliser chaque +article avec sa propre CSS. + +``` +css: myID +``` + +Définir un ou plusieurs de ces marqueurs et utiliser ``` : ``` comme +séparateur + +``` +abbr: COURT : LONG +file: NOM : NOM-DU-FICHIER : Text alternatif +link: NOM : URL : Text alternatif +code: NUMERO : NOM-DU-FICHIER : Text alternatif +brut: NUMERO : NOM-DU-FICHIER +image: NUMERO : NOM-DU-FICHIER : TEXT-ALTERNATIF +``` + +## Contenu de l'article: +Les marqueurs (hors listes) *et leur contenu* (ex: ```__monfichier...```) +**doivent être sur la même ligne**. + +Les marqueurs à retenir et leur Combinaison de touches sur un clavier +azerty français + +- Très gras: '•...•' (alt+gr + ;) +- Gras: '·...·' (alt+gr + :) +- Italique: '”...”' (alt+gr + n) +- Barré: '×...×' (alt+gr + shift + ;) +- Code: '¤...¤' (alt+gr + $) + +### Écrire en très gras +Dans l'article... + +``` +•c'est en super gras (strong)• +c'est in•défini•ssable +il ad•juge• : pas de pub ! +``` + +### Écrire en gras +Dans l'article... + +``` +·Tout est en gras· +``` + +### Écrire en Italique +Dans l'article... + +``` +C'est ”en italique” +``` + +### Créer un texte "barré" +Dans l'article... + +``` +La réunion aura lieu ×demain× dans une semaine +``` + +### Écrire un Code en ligne +Dans l'article... + +``` +¤gsl help -w && echo "Be Happy"¤ +``` + +### Abréviations +Définir en METAS... (SHORT doit être en **lettres CAPITALES**) + +``` +abbr: CSS : Cascading Style Sheets +``` + +Dans l'article: + +``` +Les propriétés CSS ne sont pas définies +``` + +### Paragraphes +Au début d'une nouvelle ligne, ouvrez avec ( et fermez avec ). +Vous pouvez définir le nom de la classe du paragraphe en ajoutant la +valeur désirée ; par exemple : p3 + +Dans l'article... +``` +( p3 +Paragraphe avec une classe p3 en css +) + +( +Paragraphe sans classe +) +``` + +### Liens +Définir en METAS + +``` +link: Mon lien : URL : Alt text +link: https://a-lec.org/ : URL : Alt text +``` + +Dans l'article.. +- Écrivez ```_``` devant le nom du lien +- Ajoutez ```+``` pour ouvrir le lien dans un nouvel onglet + +``` +Visitez _Mon lien+ et charger ici la page _https://a-lec.org/ +``` + +### Fichiers +Définir en METAS + +``` +file: Mon fichier : FILENAME : ALT-TEXT +``` + +Dans l'article... +``` +__Mon fichier +``` + +### Images +Définir en METAS + +``` +image: 1 : FILENAME : ALT-TEXT +image: 2 : FILENAME : ALT-TEXT +``` + +Dans l'article... +Définir le marqueur ```_image``` sur une seule ligne et spécifiez les +valeurs séparées par ```:```. ```+``` indique l'ouverture dans une +nouvelle fenêtre. Seuls le "numéro d'image" est obligatoire + +- Numero d'image +- Alignement: l,r,(g,d également),c pour gauche, droite, centre) +- - maclasse au lieu de l,r,c pour utiliser la classe css "maclasse" +- - + (class="center") +- Longueur width: (avec unité) +- - + (taille originale) +- Largeur height: (avec unité) +- - + (longueur définie, largeur originale) +- Champ non vide: Lien de l'image dans un nouvel onglet + +Exemple d'images affichées l'une à côté de l'autre + +``` +( +_image:1 +_image:2:c:640px:25% +_image:3:maclass:320px:240px:+ +) +``` + +Exemple d'images affichées l'une en dessous de l'autre, dont la première +s'ouvrir dans un nouvel onglet avec sa taille originale et la classe css +center + +``` +( +_image:1:+ +) +( +_image:2:c:1920px:25% +) +``` + +### Block-Code depuis un fichier +Définir en METAS + +``` +code: python : FILENAME : Alt Text +``` + +Dans l'article... +``` +_code:python +``` + +### IMPORT de code brut (sera exécuté par le navigateur) +Définir en METAS + +``` +brut : 1 : FILENAME +``` + +Dans l'article... +``` +_brut:1 +``` + +### Citation simple +Définissez un bloc pour la citation. Utilisez ```---``` +Vous pouvez définir une classe CSS spécifique ```--- ma-classe-css``` + +Dans l'article... + +``` +--- +( +Une citation simple dans un paragraphe +) +--- +``` + +### Citation avancée +Dans l'article... Stallman est une classe CSS +``` +--- Stallman +_cite : Richard Matthew Stallman +_link : https://stallman.org/ +_lang : en +( +In the free/libre software movement, we develop software that respects +users' freedom, so we and you can escape from software that doesn't. I +could have made money this way, and perhaps amused myself writing code. +But I knew that at the end of my career, I would look back on years of +building walls to divide people, and feel I had spent my life making the +world a worse place +) +--- +``` + +### Citation avancée : données optionnelles +Ajoutez ces marqueurs, si connus dans la citation + +``` +_year: 2021 +_book: Esperanza 64 +``` + + +### Créer des listes +L'arborescence est "infinie". +- Définir le début d'une liste par ```<<``` et sa fin par ```>>``` +- Définir une classe CSS après ```<< ``` + +Dans l'article... +- utilisez ```=``` pour définir une liste simple (ul) +- utilisez ```+``` pour définir une liste ordonnée (ol) +- Mixez les 2 (dans la limite de ma patience :D) + +``` +( +Voici une liste simple +<< += Fruits : *mangez-en* +== Kiwis +== Fraises +=== pas mûres +== Bananes +=== Plantins += Légumes +== Haricots +=== Rouges +=== Verts +>> +) + +Voici une liste mixe avec sa classe "couverture" +<< couverture += Livre 1 ++ Chapitre 1 ++ Chaptire 2 +++ Résumé du Ch 2 += Livre 2 ++ Chapitre 1 +>> +``` + +### Ajouter des lignes vides +Vous pouvez ajouter des ```
``` dans votre rédaction, mais pour une +lecture plus propre de votre article, vous pouvez utiliser le caractère +```|``` **au tout début d'une nouvelle ligne**. Pratique dans les +paragraphes. + +Dans l'article... + +``` +#1 Mon titre +( +Ceci est un long paragraphe (Un peu d'imagination...) +| +Retour "forcé" à la ligne +) +``` diff --git a/help/comment_installer-GSL.md b/help/comment_installer-GSL.md new file mode 100644 index 0000000..ff0a0f5 --- /dev/null +++ b/help/comment_installer-GSL.md @@ -0,0 +1,84 @@ +# Comment installer GSL: Statique Littératueur +------------------------------------------------------------------------ + +- Un script d'installation install.sh est prévu, mais pas encore proposé. +- Un .deb peut être créé (merci neox) depuis le make de l'archive + +## Installation manuelle +- git clone https://git.a-lec.org/echolib/gsl && cd gsl +- Commencez par créer les dossiers de base (voir ci-dessous) +- Donnez leur les droits nécessaires + +GSL n'utilise pas de droits sudo, et a besoin pour écrire certains +fichiers et créer certains dossiers d'être propriétaire ou d'avoir les +droits en écriture des dossiers + +``` +# Pour le dossier du binaire +sudo rsync -a usr/local/bin/gsl /usr/local/bin/gsl +sudo chown USER:GROUP/usr/local/bin/gsl + +# Pour les dossiers de scripts +sudo mkdir -p "/var/lib/gsl" +sudo chown -R USER:GROUP "/var/lib/gsl" +rsync -a var/lib/gsl/ /var/lib/gsl/ + +# Pour le dossier de logs +sudo mkdir -p "/var/log/gsl" +sudo chown -R USER:GROUP "/var/log/gsl" + +# Pour le dossier de configuration +sudo mkdir -p /etc/gsl +sudo chown -R USER:GROUP "/etc/gsl" + +# Pour l'autocompletion des articles dans la commande +sudo rsync -a usr/share/bash-completion/completions/gsl /usr/share/bash-completion/completions/gsl +sudo chown USER:GROUP "/usr/share/bash-completion/completions/gsl" +``` + +Attention: GSL aura besoin de créer des sous-dossier dans le serveur, +renseigné dans le questionnaire. (i.e. /var/www/). Il faut donc lui +donner les droits + +# Arborescence des dossiers utilisés par GSL +------------------------------------------------------------------------ +Note: ```+``` indique que GSL créera ces dossiers + +- /etc/gsl +- /var/log/gsl +- /var/lib/gsl +- - /help/ +- - /scripts/ +- - /domains +- - - /DOMAIN +- - - - /templates/ + +- - - - /files/ + +- - - - /images/ + +- - - - /X-tra + +- - - - - /sidebar + +- - /db +- - - /DOMAIN + + +- /SRV (i.e. /var/www) +- - /DOMAIN +- - - /wip +- - - - /TEMPLATE (sync wip (command) from /var/lib/gsl/domains/DOMAIN/) +- - - /www +- - - - /TEMPLATE (sync www (command) from /var/lib/gsl/domains/DOMAIN/) + + +# Fichiers créés par GSL +------------------------------------------------------------------------ + +- /var/log/gsl +- - gsl.log +- - Y-M-D-H-M-S.gsl.log (backup when clean ; removed with clean all) +- /var/lib/gsl +- - /domains +- - - DOMAIN +- - - - authors.db +- - - - DOMAIN.conf +- - /db/ +- - - domains.db (registred domains) +- - - DOMAIN/ +- - - - (file).gsl.db (Un par article) diff --git a/help/gsl_help.md b/help/gsl_help.md new file mode 100644 index 0000000..73aef23 --- /dev/null +++ b/help/gsl_help.md @@ -0,0 +1,74 @@ +# GSL: Statique Littérateur + +$ gsl (ARG) + readme : Show README.md instructions + help | -h (OPT) : This Help and how to + install | -i : Show process installation + authors | -a : Add/Remove authors for this DOMAIN + setdir | -d : Set a directory for article's DOMAIN + write | -w : Write a Post + tpl | -T : Create your template + param | -p : Configure some parameters + css : Show used CSS classes + tips | -t : Show tips and advises you should know + + new | -N : Generic OPT to add/create + domain : Configure your DOMAIN + author : Same as gsl author edit + (TYPE) (NAME) : Create an article with (TYPE) named (NAME).gsl + + setdir | -D : Show current directory DOMAIN or set it + + log | -L (OPTS) : Show logs from all sessions + clean | -C : Logs saved to {DATE}.gsl.log and cleaned + all : clean all saved logs, keep current + -i | -w | -e : from levels (infos, warnings, errors) + -s : from last session only + (TERM) : (TERM) : case insensitive, regex 'T1.*T2' + (i.e. $ gsl log -e -s code) + + author | -A : List authors from DOMAIN in PWD folder + edit : Add/Remove ! ONE author per line + + edit | -E : Open in default EDITOR (FILE) or with nano + conf : Domain configuration file + author : Same as gsl author edit + domain : Domains registred database + (FILE) : (FILE) ; .gsl + + db (FILE) : Show DB statuses from (FILE) + + sync (OPT) : Sync Templates to www and wip + wip : Only to wip server (also done with make) + www : Only to www server (also done with www) + + + check | -C (OPTIONS) : Check Post(s) errors from PWD folder + -N : Check only articles not in DB + -F : Force Check again ; Recreate in Database + (FILE) : Only this (FILE) + + make | -M (OPTIONS) : Make all HTML articles or only (FILE) + -F : Force Make again + (FILE) : Only this (FILE) + + www (OPT1) (OPT2) : Add/Remove Post(s) in www server + (OPT1): + sync : Same as "sync www" + add : Add all/(FILE) to www server + rmove : remove all/(FILE) from www server + (OPT2): + all : Select all post with wip statuses + (FILE) : Select specific post (if wip status) + + wip : Same as www for wip + + sidebar | -S : Show Posts in list (ARG) (POS) (FILE) + (ARG): + add | -a : Put article at (POS). Remove last, roll from (POS) + replace | -r : Replace (POS) with article + latest | -l : Create sidebar with latest (remove all existing) + + -v : Show local versionn + --version : Like -v + changes + -vv : Shown local and repo Versions diff --git a/help/how_to-CSS_classes.md b/help/how_to-CSS_classes.md new file mode 100644 index 0000000..c7048ca --- /dev/null +++ b/help/how_to-CSS_classes.md @@ -0,0 +1,95 @@ +# CSS Classes and IDs +```xxx``` is your choosen CSS acronym for your DOMAIN +Note: if "myclass" or "myID" is not defined, class or ID is not used + +## Legacy HTML +### body +myID is set in article with css: myID +TYPE is set in article with type: page|post +- body: xxx_TYPE myID + +## Article Content +### Metas (author, date...) + +### Titles h1-h6 +X is 1 to 6 +- xxx_title xxx_title-X + +### div between titles +X is 1 to 6 from current title +- xxx_content_hX + +### Between markers (code, emphasis, strong...) +- bold: xxx_bold +- strong: xxx_strong +- emphasis: xxx_em +- strike: xxx_strike +- inline code: xxx_icode + +### Paragraphs +myclass is the content value used (i.e.```( myclass```) +- xxx_p myclass + +### Links +- xxx_link +- xxx_link xxx_link-window (if "+" for target) + +### Links from file +- xxx_link-file +- xxx_link-file xxx_link-file-window (if "+" for target) + +### Image and image link +myclass is from content marker (i.e. _image:1:myclass:90:90:+) +- link: xxx_image-link myclass +- img: xxx_image xxx_image-(left,right,cente) +- - If myclass replace xxx_image-(left...) by myclass + +### pre-codes from source file +X is the NAME/NBR registred in header +- pre: xxx_code-block xxx_code-block-X +- span line: xxx_code-line +- span content: xxx_code-content +- p after pre: xxx_code-p +- link source: xxx_code-link + +### Liste (ol | ul | li) +X is the item mark nbr (i.e. "+++" = 3, "=" = 1) +myclass is the registred value after << (i.e. << myclass). Only used at +the begining bloc. +- ol: xxx_list xxx_list-ol xxx_myclass xxx_myclass-ol +- ul: xxx_list xxx_list-ul xxx_myclass xxx_myclass-ul +- li: a-lec_li a-lec_li-X + +### Quotes +myclass is the registred value after "---" (i.e. --- myclass) +myclass is used on +- ```
``` (if no "_cite") +- - blockquote: xxx_quote myclass +- ```
``` if "_cite" +- - figure: xxx_quote-fig myclass + +## Sidebar Content +- aside: xxx_sidebar +- - div: xxx__wrapper +- - - nav: xxx_latest-posts +- - - - h1: xxx_latest-posts +- - - - ul: xxx_latest-posts +- - - - - li: xxx_list-post-item +- - - - - a: xxx_list-post-link +- - - - - - span: xxx_list-post-title +- - - - - - div: xxx__list-post-metas +- - - - - - div: xxx__list-post-info + +## Header content +- header: xxx_banner +- - div: xxx_site-logo +- - div: xxx_site-title +- - - h1: xxx_site-name +- - - h2: xxx_site-description + +## Footer content +- footer: xxx_footer (ID) +- - div: xxx_footer-infos (ID) +- - div: xxx_footer-about (ID) + + diff --git a/help/how_to-Tips_Advises.md b/help/how_to-Tips_Advises.md new file mode 100644 index 0000000..20fe0fe --- /dev/null +++ b/help/how_to-Tips_Advises.md @@ -0,0 +1,34 @@ +# Tips and Advises +## Configuration +- CSS acronym will always be in lower case + +## ABBR +- short name (HEADER): must be in CAPS LOCK (abbr: LEC : Libre en communs) +- short name (CONTENT): must contain a space (" LEC", " LEC ", "LEC ") + +## Files (Images, codes, scripts...) +You can create sub-directories in DOMAIN/files or DOMAIN/images +If you do so, in your article HEADER, set FILENAME with sub-dirs, but +do NOT begin with / +``` +# File put in /var/lib/gsl/domains/DOMAIN/images/dir/dir1/pic.png +image: 1 : dir/dir1/pic.png +``` + +## Images: set style and target +``` +# Open in new tab pic, keep origin sizes +_image:1:+ + +# Open pic in new tab, using your css class and with width in pixel +# (height is kept) +_image:1:c:640px:+ +``` + +## Make (changes in source file) +If you change the content of a file (script code, image...), you will +have to make -F your article, and do www add after + +## Sidebar +If your remove a www or wip page, and you put it in sidebar, +do not forget to replace it with another article diff --git a/help/how_to-add_remove_authors.md b/help/how_to-add_remove_authors.md new file mode 100644 index 0000000..20f038d --- /dev/null +++ b/help/how_to-add_remove_authors.md @@ -0,0 +1,4 @@ +# To add/remove authors: +- cd to your article folder +- gsl author edit +- Set one author per line ! diff --git a/help/how_to-parameters_conf.md b/help/how_to-parameters_conf.md new file mode 100644 index 0000000..ba38ab3 --- /dev/null +++ b/help/how_to-parameters_conf.md @@ -0,0 +1,7 @@ +# Edit the file: /etc/gsl.conf + +## Show logs by time or level (level ="") +- gsl_logs_order=time + +## Minimum Size of a post (default ="180") +- gsl_article_min_Size=250 diff --git a/help/how_to-set_directory_for_articles.md b/help/how_to-set_directory_for_articles.md new file mode 100644 index 0000000..69cac93 --- /dev/null +++ b/help/how_to-set_directory_for_articles.md @@ -0,0 +1,7 @@ +# To set a dedicated folder for your articles +- cd myfolder ; to go into your folder of choice +- gsl setdir ; to choose your domain ; + +If your directory is configured, it will be mentionned, else: +- You'll be asked to choose a reegistred one +- You can now create articles. filename must be a .gsl diff --git a/help/template-comment-creer.md b/help/template-comment-creer.md index f62eeb4..7dd7de8 100644 --- a/help/template-comment-creer.md +++ b/help/template-comment-creer.md @@ -34,6 +34,7 @@ gsl make -F ``` ## Listes de classes utilisées. + Rappel: les classes et IDs commencent par votre ACRONYM configuré, lors de la création d'un domaine avec ```gsl new```, suivi par ```_```. Pour une meilleure lisibilité, votre ACRONYM est marqué xxx. @@ -44,10 +45,10 @@ Pour une meilleure lisibilité, votre ACRONYM est marqué xxx. - - body: xxx_page - - header: xxx_banner - - logo dans header: xxx_site-logo -- - title dans header: xxxsite-title +- - title dans header: xxx_site-title - - name dans header: xxx_site-name - - Description dans header: xxx_site-description -- - ```
``` avant ```
```: xxxspage-wrapper +- - ```
``` avant ```
```: xxx_page-wrapper - - article: xxx_SLUG (SLUG est le "slug: SLUG" de l'article) - - div metas (auteur, date...): xxx_metas - - p dans div metas: xxx_auteur @@ -55,10 +56,12 @@ Pour une meilleure lisibilité, votre ACRONYM est marqué xxx. ### Dans ```
``` - CLASS= +- hX: xxx_title-X - - div après chaque titre ``````: xxx_content-p xxx_content-pX - - p dans div content-p: xxx_paragraph -- - - si contenu ```( 2```: xxx_paragraph-2 +- - - si contenu ```( 1z```: xxx_paragraph-1z - - code pour les inline-code avec ```¤...¤```: xxx_icode +- strikee: xxx_strike - - li (liste) en fonction du nombre N de ```= | +```: xxx__list-li x_list-N - - ul (liste) simple: xxx_list-ul - - ol (liste) ordonnée: xxx_list-ol diff --git a/new-version.md b/new-version.md index be2066d..74e97ab 100644 --- a/new-version.md +++ b/new-version.md @@ -1,15 +1,138 @@ -## [0.0.37] +## [0.0.9] + +## Please, see help (and documentations in help folder) ### Add -- changelog -- Make stats at each www call -- Set yourself a class ID for paragraphs: i.e. "( 1a" -- Better Logs harmony -- date: Set to DD-MM-YYYY if site lang=fr || YYYY-MM-DD -- date: Check for month value > 12 -- some changed syntax in make process +- New code about everywhere, more comments, cleaner +- nano dependence +- Check installed configuration at launch +- Dedicated functions for ARGUMENTS in specific files category +- - check: gsl__post_checkers +- - make,sidebar: gsl__post_makers +- - sync,www,wip gsl__srv_manager +- - log: gsl__log_manager +- - db: gsl__db_manager +- - author,new,setdir: gsl__domain_manager +- - edit: gsl__edit_file +- - stats: gsl__stats -### Fix -- link: check only online url from http... -- if 'error' log : do not exit 1 anymore -- Variable name propertie for stats (statoolinfos) +### Installation +- new files: +- - gsl__srv_manager: for all about server +- - gsl__version: for -v, -vv, --version options +- - gsl__domain_manager: for OPT author, new, setdir +- - gsl__edit_file: functions to edit some configuration files +- - gsl__do_commons: Common functions to filter article lines +- - gsl__HTML_template: functions to create HTML pages +- New empty folder in installation: +- - /var/lib/gsl/db: for all DBs (.gitkepp) +- - /var/lib/gsl/domains: for all domains (.gitkeep) +- - /var/log/gsl: for logs files (.gitkeep) +- New help folder in +- - /var/lib/gsl/help (removed "helps" one) + +### Logs +- Better logs harmony +- New fields in log for article filename and domain name +- Specific number of characters spaces in some log fields +- More verbose +- "automatic" level log set from called functions +- Colored levels: war (yellow), err (red) + +### Databases +- Dedicated per article +- Folder: /var/lib/gsl/db/ +- New file format: domains.db +- More datas with new stats. Quicker sourced datas +- Dedicated articles in sub-directory "DOMAIN" +- Check if corrupted DB +- Database and wip files won't be removed if errors in article +- If corrupted Database, try restoring www & wip statuses at new check + +### Changes +- Changes in mapping process: +- - Processes get needed headers FIRST, then split article in 2 sections +- DOMAIN Profile is only in /var/lib/gsl/domains/DOMAIN/ +- Variables in DOMAIN.conf file has no more "gsl_" +- Some translated words in HTML page from lang set DOMAIN (fr || en) +- Between markers (code): put "everything" you want +- New CSS classes: see gsl help css or documentation +- Mark image (i.e. "_image:1:mycss:50%:25%:+)" +- - define your own css class 'mycss' +- - define unity ("%","px"... with height and witdth) +- New lists. Mix "+" (ol) and "=" (ul) and write an item on several lines +- Between hX titles: new div css (none if empty content) +- Changing article Type will remove old wip file (not www file !) +- sync: Logs not shown but added +- stats properties file is now in /www (online) + +### Process check [argument] +- slug: log err if already exists (log war if not well formated) + +### new ARGUMENTS +- new (page|post) (name): Create article, show its content + check it +- new domain: New domain configuration creator +- edit domains: Set/Edit registred domains database +- edit author: Same as author edit +- author edit: Opens nano to Add/Remove authors (one per line) by DOMAIN +- setdir: Set current folder for your DOMAIN (show if one) +- check -N: Only check newer articles not in DB +- clean all: Remove all backups (only) files +- sidebar: add|replace|latest|oldest (See gsl help) +- www sync: Same as sync www +- wip ...: Same as www but for wip + +### Markers +- css: MYCLASS Customize each article with your CSS (optional) +- brut: Insert brut code from file +- - In article header: "NBR : FILENAME"`` +- - In article content: "_brut: NBR" +- "_image:VALUE:MYCSS:WIDTH:HEIGHT:TARGET" (no target=no HTML link) +- Strong mark: '•...•' (alt+gr + ;) on french azerty keyboard) +- Bold mark: '·...·' (alt+gr + :) on french azerty keyboard) +- Emphasis mark: '”...”' (alt+gr + n) on french azerty keyboard) +- Strike mark: '×...×' (alt+gr + shift + ;) on french azerty keyboard +- ```<<``` and ```>>``` as "start" and "close" marker for lists + +### Template +- included basic header, metas and footer +- All about template is in /var/lib/gsl/scripts/gsl__HTML_template +- - No more header.html in templates folder +- - - Edit your own in create__HTML_header() function +- In /var/lib/gsl/domains/DOMAIN/templates/ +- - Auto created metas.html and footer.html if not exist +- - Edit your own footer.html +- - Edit your own metas per DOMAIN for HTML `````` in metas.html +- - - included basic pre-registred meta from datas article +- - No CSS styles included: create your own (see classes and IDs used in doc) +- For all changes here, after gsl make, use gsl sync... + +### Sidebar +- No more /var/lib/gsl/domains/DOMAIN/templates/last-posts-list.html +- - Remove it with files xxx.X in /var/lib/gsl/domains/DOMAIN/X-tra/ +- New HTML file: /var/lib/gsl/domains/DOMAIN/templates/sidebar.html +- - Created with files /var/lib/gsl/domains/DOMAIN/X-tra/sidebar/(POS).html +- articles are sorted from epoch date (in DB) with false time at check + +### Statoolinfos (added properties for www status) +- gsl.articles +- gsl.articles.pages +- gsl.articles.posts +- gsl.authors +- gsl.articles.tags +- gsl.articles.words +- gsl.articles.quotes +- gsl.articles.paragraphs +- gsl.articles.links +- gsl.articles.links.online +- gsl.articles.lists +- gsl.articles.lists.items +- gsl_articles.images + +### CRITIK +- Remove all files in /var/lib/gsl/db/ +- Use: ```gsl new domain```, give your registred DOMAIN name +- - Answer Y to autofix old configurations files and folders +- - Do it for each DOMAIN you registred +- - will add site_max_list=5 (default) in domain configuration file +- Use ```gsl check``` in your articles folder diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index d363c4f..e5a5c80 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -1,10 +1,11 @@ #!/bin/bash -# Version: 0.0.37 +# Version: 0.0.9 # file: gsl # Folder: /usr/local/bin -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + #======================================================================= # Tools #======================================================================= @@ -14,531 +15,151 @@ if__command() { && exit } -gsl__if_file() { +if__file() { if ! [[ -f "$1" ]];then echo "! Missing file: $1" exit fi case "$2" in - source) - source "$1" || exit - ;; - read) - cat "$1" - ;; - post) - gsl_this_post="$1" - ;; + source) source "$1" || exit ;; + read) clear;cat "$1";exit ;; + post) gsl_this_post="$1" ;; esac } +if__folder() { +if ! [[ -d "$1" ]];then + echo "! Missing directory: $1" + exit +fi +} + gsl__invalid_option() { echo "! Invalid argument '$1': $2" exit } -# Get conf -gsl__if_file "/etc/gsl/gsl.conf" source -gsl__if_file "$gsl_dir_scripts/gsl__log_manager" source -gsl__if_file "/var/lib/gsl/scripts/gsl__tools" source -case "$1" in - help|--help|-h) - clear - case "$2" in - "") - gsl__if_file "$gsl_dir_helps/gsl_help" read - ;; - new) - gsl__if_file "$gsl_dir_helps/gsl_infos_new_website" read - ;; - install) - gsl__if_file "$gsl_dir_helps/gsl_help_install" read - ;; - write|-w) - gsl__if_file "$gsl_dir_lib/help/article-comment-ecrire.md" read - ;; - template|-t) - gsl__if_file "$gsl_dir_lib/help/template-comment-creer.md" read - ;; - esac - exit - ;; - - new|-N) - gsl__if_file "$gsl_dir_scripts/gsl__new_website" source - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "New Website" \ - "$gsl_dir_scripts/gsl__new_website" - - gsl__new_website - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "New Website" \ - "$gsl_dir_scripts/gsl__new_website" - - [[ -f "$gsl_file_db_domains" ]] && \ - [[ -d "$gsl_dir_user_posts" ]] \ - && cd "$gsl_dir_user_posts" \ - && gsl author add - - echo - gsl log -s -w - exit - ;; - - author|-A) - gsl__find_domain - gsl__if_file "$gsl_dir_scripts/gsl__auth_manager" source - case "$2" in - "") - gsl__authors_list - ;; - add) - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "author $2 for domain $gsl_find_domain" \ - "$gsl_file_auth_ndd" - - gsl__authors_add - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "author $2 for domain $gsl_find_domain" \ - "$gsl_file_auth_ndd" - ;; - remove) - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "author $2 for domain $gsl_find_domain" \ - "$gsl_file_auth_ndd" - - gsl__authors_remove - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "author $2 for domain $gsl_find_domain" \ - "$gsl_file_auth_ndd" - ;; - esac - exit - ;; - - readme) - clear - gsl__if_file "/var/lib/gsl/README.md" read - exit - ;; - - log|-L) - [[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \ - && echo "# No logs to show. File is empty." \ - && exit - - while test "$2" - do - case "$2" in - clean|-C) - gsl_date_logs=`date +%F-%H-%M-%S` - mv "$gsl_file_logs" "$gsl_dir_logs/$gsl_date_logs.gsl.log" - rm -f "$gsl_file_logs" - printf '%s %s %s\n' \ - "# Logs saved to" \ - "$gsl_dir_logs/$gsl_date_logs.gsl.log" \ - "and cleaned" - exit - ;; +#====================================================================== +# Source files for help +#====================================================================== +source__help() { +for file_help in ${gsl_files_help[@]} +do + if [[ -f "$file_help" ]];then + [[ "$file_help" == "$gsl_dir_help/gsl__help" ]] \ + && source "$file_help" - -s) gsl_logs_last_session=true ;; - -e) gsl_logs_err=true ;; - -i) gsl_logs_inf=true ;; - -w) gsl_logs_war=true ;; - *) gsl_logs_search="$2" ;; - esac - shift - done + else + echo "! Installation Failure. Missing file: $file_help" + exit + fi +done +} - gsl__logs_show - exit 0 - ;; - - -v) - awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/$app_name" - exit - ;; - - -vv) - v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"` - echo -n "# $app_name Current: $v_cur | " - if__command curl - v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'` - echo -ne "Online: $v_onl\n" - exit - ;; - - --version) - awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/$app_name" - gsl__if_file "$gsl_dir_lib/new-version.md" read - exit - ;; + +#====================================================================== +# Helper +# $2: arguments list +#====================================================================== +help__OPTIONS() { +clear +case "$1" in + write|-w) cat "$gsl_dir_help/comment_ecrire-article.md" ;; + tpl|-T) cat "$gsl_dir_help/template-comment-creer.md" ;; + install|-i) cat "$gsl_dir_help/comment_installer-GSL.md" ;; + authors|-a) cat "$gsl_dir_help/how_to-add_remove_authors.md" ;; + setdir|-d) cat "$gsl_dir_help/how_to-set_directory_for_articles.md" ;; + param|-p) cat "$gsl_dir_help/how_to-parameters_conf.md" ;; + css) cat "$gsl_dir_help/how_to-CSS_classes.md" ;; + tips|-t) cat "$gsl_dir_help/how_to-Tips_Advises.md" ;; + ""|*) cat "$gsl_dir_help/gsl_help.md" ;; esac +exit +} + + +#====================================================================== +# Get CONF and source variables +#====================================================================== +if__file "/etc/gsl/gsl.conf" source + + +#====================================================================== +# Check installation and source files +#====================================================================== +for dir in ${gsl_dirs[@]} +do + ! [[ -d "$dir" ]] \ + && echo "! Installation Failure. Missing directory: $dir" \ + && exit +done + +for file_script in ${gsl_files_scripts[@]} +do + if [[ -f "$file_script" ]];then + source "$file_script" + + else + echo "! Installation Failure. Missing file: $file_help" + exit + fi +done + +for dir_w in ${gsl_dirs_w[@]} +do + if ! [[ -w "$dir_w" ]];then + echo "! Installation Failure. Directory not writeable: $dir_w" + exit + fi +done + #======================================================================= -# Checking Dependancies -#======================================================================= -# Check/Create Files and Folders -gsl__create_ff - -gsl__find_domain -gsl__if_file "$gsl_dir_scripts/gsl__auth_manager" source -gsl__authors_list check || exit -gsl__if_file "$gsl_dir_scripts/gsl__post_checkers" source -gsl__if_file "$gsl_dir_scripts/gsl__post_manager" source -gsl__if_file "$gsl_dir_scripts/gsl__db_manager" source -gsl__if_file "$gsl_dir_scripts/gsl__post_makers" source -gsl__if_file "$gsl_dir_scripts/gsl__page_creator" source -gsl__if_file "$gsl_dir_scripts/gsl__do_commons" source - -#======================================================================= -# Main +# Check ARGUMENTS #======================================================================= case "$1" in - create) - case "$2" in - page|post) - true - ;; - *) - gsl__invalid_option "$2" "page|post" - ;; - esac - - case "$3" in - "") - gsl__invalid_option "$3" "Please set a name for your $2" - ;; - esac - - gsl_postname="$3" - [[ "$gsl_postname" =~ ".gsl" ]] \ - && gsl_postname=${gsl_postname/.gsl/} - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Create" \ - "$2" \ - "$PWD/$3.gsl" - - if [[ -f "$gsl_postname.gsl" ]];then - gsl__logs_print \ - "$gsl_log_w" \ - "Create" \ - "File" \ - "$3.gsl already exists !" \ - "$PWD/$3.gsl" - gsl_checker_war=true - else - [[ `grep -i "fr" <<<"$gsl_site_lang"` ]] \ - && gsl_today=`printf '%(%d-%m-%Y)T'` \ - || gsl_today=`date +%F` - - gsl__create_article "$2" "$gsl_today" "$gsl_postname" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Create" \ - "$2" \ - "You can edit it with 'gsl edit $3.gsl'" \ - "$PWD/$3.gsl" - fi - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Create" \ - "$2" \ - "$PWD/$3.gsl" - ;; - - edit|-E) - ! [[ "$2" ]] \ - && gsl__invalid_option "$2" "[File]" - - case "$2" in - conf) - echo "> $gsl_this_conf_domain/$gsl_find_domain.conf" - gsl_this_post="$gsl_this_conf_domain/$gsl_find_domain.conf" - gsl__if_file "$gsl_this_post" - ;; - *) - gsl__if_file "$PWD/$2" post - ;; - esac - - if ! [[ "$EDITOR" ]];then - if__command nano - EDITOR=`which nano` - fi - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "edit with $EDITOR" \ - "$gsl_this_post" - - gsl__get_sum "$gsl_this_post" - gsl__logs_print \ - "$gsl_log_i" \ - "Edit" \ - "File" \ - "Hash: $gsl_post_hash | Size: $gsl_post_size" \ - "$gsl_this_post" - - gsl_post_hash_old=$gsl_post_hash - $EDITOR "$gsl_this_post" - - gsl__get_sum "$gsl_this_post" - if (( $gsl_post_hash != $gsl_post_hash_old ));then - gsl_log_infos="NEW > Hash. Size: $gsl_post_size" - gsl_log_level="$gsl_log_w" - else - gsl_log_infos="Unchanged" - gsl_log_level="$gsl_log_i" - fi - - gsl__logs_print \ - "$gsl_log_level" \ - "Edit" \ - "File" \ - "$gsl_log_infos" \ - "$gsl_this_post" - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "edit with $EDITOR" \ - "$gsl_this_post" - ;; - - db) - ! [[ "$2" ]] \ - && gsl__invalid_option "$2" "[File]" - - gsl__if_file "$2" post - [[ -f "$gsl_dir_db/$gsl_this_post.db" ]] \ - && cat -n "$gsl_dir_db/$gsl_this_post.db" \ - || echo "! No DB yet for $gsl_this_post. Check it first." - exit - ;; - - check|-C) - case "$2" in - -F) - gsl_force_check=true - [[ "$3" ]] && gsl__if_file "$3" post - ;; - *) - [[ "$2" ]] && gsl__if_file "$2" post - ;; - esac - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "check Post for domain $gsl_find_domain" \ - "$PWD" - - gsl__loop_posts check - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "check Post for domain $gsl_find_domain" \ - "$PWD" - ;; - - sync|-s) - gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" - gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www" - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "Sync Templates for domain $gsl_find_domain" \ - "$PWD" - - case "$2" in - "") - gsl__srv_sync "$gsl_srv_wip" - gsl__srv_sync "$gsl_srv_www" - ;; - www) - gsl__srv_sync "$gsl_srv_www" - ;; - wip) - gsl__srv_sync "$gsl_srv_wip" - ;; - *) - gsl__invalid_option "$2" "www|wip" - gsl__logs_print \ - "$gsl_log_i" \ - "Sync" \ - "Argument" \ - "Invalid $2" \ - "$PWD" - ;; - esac - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "Sync Templates for domain $gsl_find_domain" \ - "$PWD" - ;; - - make|-M) - gsl_process="wip" - gsl_post_list="Add" - case "$2" in - -F) - gsl_force_make=true - [[ "$3" ]] && gsl__if_file "$3" post - ;; - *) - [[ "$2" ]] && gsl__if_file "$2" post - ;; - esac - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "make Post for domain $gsl_find_domain" \ - "$PWD" - - gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" - gsl__loop_posts make - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "make Post for domain $gsl_find_domain" \ - "$PWD" - ;; - - www) - ! [[ "$2" ]] \ - && gsl__invalid_option "$2" "add|remove" - - if__command rsync - gsl_www_act="$2" - case "$2" in - add) - gsl_ask="! Put online ALL wip posts (yes|N)? " - ;; - remove) - gsl_ask="! REMOVE ALL www posts (yes|N)? " - ;; - *) - gsl__invalid_option "$2" "add|remove" - ;; - esac - - ! [[ "$3" ]] \ - && gsl__invalid_option "$3" "[FILE]|all" - - case "$3" in - all) - read -rp "$gsl_ask" gsl_ask_www - case "$gsl_ask_www" in - YES|yes|Yes) - true - ;; - *) - echo "# Abandon" - exit - ;; - esac - ;; - *) - gsl__if_file "$3" post - ;; - esac - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "$1 ; $2 from domain $gsl_find_domain" \ - "$gsl_site_server" - - gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www" - gsl__loop_posts www "$2" - - # Stats - gsl__if_file "$gsl_dir_scripts/gsl__stats" source - gsl_file_sti="$gsl_site_server/$gsl_find_domain/gsl-sti.properties" - gsl__get_stats &>/dev/null && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Stats" \ - "File" \ - "Generated" \ - "$gsl_file_sti" - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "$1 ; $2 from domain $gsl_find_domain" \ - "$gsl_site_server" - ;; - - sidebar|-S) - gsl__if_file "$gsl_dir_scripts/gsl__sidebar" source - gsl__sidebar $1 $2 $3 $4 - ;; - - stats) - echo "! Working on it..." - gsl__if_file "$gsl_dir_scripts/gsl__stats" source - gsl_file_sti="$gsl_site_server/$gsl_find_domain/gsl-sti.properties" - - gsl__get_stats - exit - ;; - - *) - gsl help - exit - ;; + new|-N) new__OPTIONS "$2" "$3" ;; + author|-A) author__OPTIONS "$2" ;; + log|-L) log__OPTIONS "$@" ;; + -v|-vv|--version) version__OPTIONS "$1" ;; + readme) if__file "$gsl_dir_lib/README.md" read ;; + setdir|-D) setdir__OPTIONS ;; + help|--help|-h) source__help;help__OPTIONS "$2" ;; esac -#---------------------------------------------------------------------- -# Check for process errors or warnings -#---------------------------------------------------------------------- +# Check if registred DOMAIn and authors from PWD +domain__check +author__check || exit 0 # Check if authors registresd + +case "$1" in + db) db__OPTIONS "$2" ;; + sync|-s) sync__OPTIONS "$2" ;; + edit|-E) edit__file_OPTIONS "$2" "$3" ;; +esac + +if__gsl_post # from gsl__post_manager: check if .gsl +case "$1" in + check|-C) check__OPTIONS "$@" ;; + make|-M) make__OPTIONS "$@" ;; + sidebar|-S) sidebar__OPTIONS "$2" "$3" "$4" ;; + www) srv__OPTIONS "$1" "$2" "$3" ;; + wip) srv__OPTIONS "$1" "$2" "$3" ;; + stats) stats__datas ;; + *) gsl help; exit ;; +esac + +#====================================================================== +# After process, show logs +#====================================================================== gsl_logs_last_session=true + +[[ $gsl_log_order ]] \ + && gsl__logs_show \ + && exit + +gsl_logs_inf=true gsl__logs_show if [[ "$gsl_checker_war" ]];then @@ -551,5 +172,4 @@ if [[ "$gsl_checker_err" ]];then echo gsl_logs_err=true gsl__logs_show - exit fi diff --git a/var/lib/gsl/CHANGELOG.md b/var/lib/gsl/CHANGELOG.md new file mode 100644 index 0000000..62f502c --- /dev/null +++ b/var/lib/gsl/CHANGELOG.md @@ -0,0 +1,174 @@ +# Changelog + +GSL changes from releases. You can send an issue : +- repo: https://git.a-lec.org/echolib/gsl/-/issues +- Contact xmpp: im@echolib.re + +## [0.0.9] + +## Please, see help (and documentations in help folder) + +### Add +- New code about everywhere, more comments, cleaner +- nano dependence +- Check installed configuration at launch +- Dedicated functions for ARGUMENTS in specific files category +- - check: gsl__post_checkers +- - make,sidebar: gsl__post_makers +- - sync,www,wip gsl__srv_manager +- - log: gsl__log_manager +- - db: gsl__db_manager +- - author,new,setdir: gsl__domain_manager +- - edit: gsl__edit_file +- - stats: gsl__stats + +### Installation +- new files: +- - gsl__srv_manager: for all about server +- - gsl__version: for -v, -vv, --version options +- - gsl__domain_manager: for OPT author, new, setdir +- - gsl__edit_file: functions to edit some configuration files +- - gsl__do_commons: Common functions to filter article lines +- - gsl__HTML_template: functions to create HTML pages +- New empty folder in installation: +- - /var/lib/gsl/db: for all DBs (.gitkepp) +- - /var/lib/gsl/domains: for all domains (.gitkeep) +- - /var/log/gsl: for logs files (.gitkeep) +- New help folder in +- - /var/lib/gsl/help (removed "helps" one) + +### Logs +- Better logs harmony +- New fields in log for article filename and domain name +- Specific number of characters spaces in some log fields +- More verbose +- "automatic" level log set from called functions +- Colored levels: war (yellow), err (red) + +### Databases +- Dedicated per article +- Folder: /var/lib/gsl/db/ +- New file format: domains.db +- More datas with new stats. Quicker sourced datas +- Dedicated articles in sub-directory "DOMAIN" +- Check if corrupted DB +- Database and wip files won't be removed if errors in article +- If corrupted Database, try restoring www & wip statuses at new check + +### Changes +- Changes in mapping process: +- - Processes get needed headers FIRST, then split article in 2 sections +- DOMAIN Profile is only in /var/lib/gsl/domains/DOMAIN/ +- Variables in DOMAIN.conf file has no more "gsl_" +- Some translated words in HTML page from lang set DOMAIN (fr || en) +- Between markers (code): put "everything" you want +- New CSS classes: see gsl help css or documentation +- Mark image (i.e. "_image:1:mycss:50%:25%:+)" +- - define your own css class 'mycss' +- - define unity ("%","px"... with height and witdth) +- New lists. Mix "+" (ol) and "=" (ul) and write an item on several lines +- Between hX titles: new div css (none if empty content) +- Changing article Type will remove old wip file (not www file !) +- sync: Logs not shown but added +- stats properties file is now in /www (online) + +### Process check [argument] +- slug: log err if already exists (log war if not well formated) + +### new ARGUMENTS +- new (page|post) (name): Create article, show its content + check it +- new domain: New domain configuration creator +- edit domains: Set/Edit registred domains database +- edit author: Same as author edit +- author edit: Opens nano to Add/Remove authors (one per line) by DOMAIN +- setdir: Set current folder for your DOMAIN (show if one) +- check -N: Only check newer articles not in DB +- clean all: Remove all backups (only) files +- sidebar: add|replace|latest|oldest (See gsl help) +- www sync: Same as sync www +- wip ...: Same as www but for wip + +### Markers +- css: MYCLASS Customize each article with your CSS (optional) +- brut: Insert brut code from file +- - In article header: "NBR : FILENAME"`` +- - In article content: "_brut: NBR" +- "_image:VALUE:MYCSS:WIDTH:HEIGHT:TARGET" (no target=no HTML link) +- Strong mark: '•...•' (alt+gr + ;) on french azerty keyboard) +- Bold mark: '·...·' (alt+gr + :) on french azerty keyboard) +- Emphasis mark: '”...”' (alt+gr + n) on french azerty keyboard) +- Strike mark: '×...×' (alt+gr + shift + ;) on french azerty keyboard +- ```<<``` and ```>>``` as "start" and "close" marker for lists + +### Template +- included basic header, metas and footer +- All about template is in /var/lib/gsl/scripts/gsl__HTML_template +- - No more header.html in templates folder +- - - Edit your own in create__HTML_header() function +- In /var/lib/gsl/domains/DOMAIN/templates/ +- - Auto created metas.html and footer.html if not exist +- - Edit your own footer.html +- - Edit your own metas per DOMAIN for HTML `````` in metas.html +- - - included basic pre-registred meta from datas article +- - No CSS styles included: create your own (see classes and IDs used in doc) +- For all changes here, after gsl make, use gsl sync... + +### Sidebar +- No more /var/lib/gsl/domains/DOMAIN/templates/last-posts-list.html +- - Remove it with files xxx.X in /var/lib/gsl/domains/DOMAIN/X-tra/ +- New HTML file: /var/lib/gsl/domains/DOMAIN/templates/sidebar.html +- - Created with files /var/lib/gsl/domains/DOMAIN/X-tra/sidebar/(POS).html +- articles are sorted from epoch date (in DB) with false time at check + +### Statoolinfos (added properties for www status) +- gsl.articles +- gsl.articles.pages +- gsl.articles.posts +- gsl.authors +- gsl.articles.tags +- gsl.articles.words +- gsl.articles.quotes +- gsl.articles.paragraphs +- gsl.articles.links +- gsl.articles.links.online +- gsl.articles.lists +- gsl.articles.lists.items +- gsl_articles.images + +### CRITIK +- Remove all files in /var/lib/gsl/db/ +- Use: ```gsl new domain```, give your registred DOMAIN name +- - Answer Y to autofix old configurations files and folders +- - Do it for each DOMAIN you registred +- - will add site_max_list=5 (default) in domain configuration file +- Use ```gsl check``` in your articles folder + + +## [0.0.37] +### Add +- changelog +- Make stats at each www call +- Set yourself a class ID for paragraphs: i.e. "( 1a" +- Better Logs harmony +- date: Set to DD-MM-YYYY if site lang=fr || YYYY-MM-DD +- date: Check for month value > 12 +- some changed syntax in make process + +### Fix +- link: check only online url from http... +- if 'error' log : do not exit 1 anymore +- variable name propertie for stats (statoolinfos) + +## [0.0.36] + +### Add +- New list converter (Use + for ol, not ø) +- New block titles converter with div +- New option: create +- New option with edit: conf (to edit domain configuration) +- New option: --version (to show last changes) +- New generic function if invalid option +- New min size for post: 150 + +### Fix +- No ```
``` if block title empty diff --git a/var/lib/gsl/LICENSE b/var/lib/gsl/LICENSE new file mode 100644 index 0000000..2a1caa8 --- /dev/null +++ b/var/lib/gsl/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + GSL Statique Littérateur + Copyright (C) 2022 Libre en Communs / Commissions / Infrastructure + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/var/lib/gsl/README.md b/var/lib/gsl/README.md index c99027a..34cb566 100644 --- a/var/lib/gsl/README.md +++ b/var/lib/gsl/README.md @@ -2,10 +2,11 @@ ------------------------------------------------------------------------ GSL est un générateur de blogs/sites-web basé sur leur nom de domaine, -écrit en bash, afin de ne réduire ses dépendances au minimum. Les pages +écrit en bash, afin de réduire ses dépendances au minimum. Les pages générées sont presque entièrement statiques, à l'exception du module de -liste des derniers articles. Nginx peut être facilement configuré pour -interprêter ce module. +liste des derniers articles (sidebar) placé en include. Nginx peut être +facilement configuré pour interprêter ce module. + # Dépendances ------------------------------------------------------------------------ @@ -13,206 +14,179 @@ interprêter ce module. - bash - coreutils - curl (to check Posts links response) -- rsync +- rsync, nano # GSL: Installation ------------------------------------------------------------------------ -Une procédure d'installation via un setup est en cours de test. Il est +Une procédure d'installation via un setup est en préparation. Il est aussi possible et recommandé sous debian de l'installer grâce à son -paquet deb. +paquet deb (construit par make). Pour une installation manuelle, clonez ce dépôt, et copiez les dossiers -déjà pré-établis dans le système. GSL n'utilise pas sudo, il vous faut -donc donner les droits aux dossiers (chown -R) à l'utilisateur -(sauf au dossier /usr/local/bin). Pour ce dossier, vous donnerez les droits -via chown USER:USER /usr/local/bin/gsl +déjà pré-établis dans le système (avec sudo). GSL n'utilise pas sudo, +il vous faut donc donner les droits des dossiers (chown -R) à l'utilisateur +(sauf au dossier /usr/local/bin). Pour ce dossier, vous donnerez les +droits au fichier gsl seulement -## Configuration du DOMAIN (selon le choix de l'utilistaeur via $ gsl new) : -- HOME: ~/.config/gsl -- GLOBAL: /var/lib/gsl -- Dossier: --Prefix/domains/ (créé par GSL via $ gsl new) +Reportez-vous à la documentation dans le dossier help -### Données du DOMAIN : -- Dossier: --Prefix/DOMAIN/ (créé par GSL) -- - Fichiers: DOMAIN.conf, authors.db (créé par GSL) -- - Dossier: --Prefix/DOMAIN/templates/ (créé par GSL - pour vos css, logos...) - -## Dossier de configuration de GSL : /etc/gsl/ -- Fichier: gsl.conf - -## Dossier principal : /var/lib/gsl/ -- Folder: db (créé par GSL) -- Dossier: helps -- Dossier: scripts -- Fichier: README.md, README-english.md - -## Dossier des logs: /var/log/gsl/ -- Fichier: gsl.log (créé et géré par GSL via $ gsl log [OPT]...) - -## Dossier de l'éxécutable : /usr/local/bin/ -- Fichier: gsl - -## Dossier d'autocomplétion : /usr/share/bash-completion/completions/gsl/ -- Fichier: gsl # Comment configurer un domaine ------------------------------------------------------------------------ +Préparer un fichier de logo. L'important sera de renseigner le nom du +fichier lors du questionnaire. + +Attention: GSL aura besoin de créer des sous-dossier dans le serveur, +renseigné dans le questionnaire. (i.e. /var/www/). Il faut donc lui +donner les droits + +`` +$ gsl new) domain +``` Des questions vous seront posées lorsque vous voudrez ajouter un domaine -(exemple.com). Les données renseignées seront utilisées pour créer le -fichier DOMAIN.conf. Une question spécifique pour les fichier des articles -vous sera posée afin d'établir un dossier de stockage de vos articles. -Vous pourrez en créer à loisir autant que vous voulez plus tard. +(exemple.com). Les données renseignées seront utilisées pour créer la +configuration (voir la documentation d'installation) -``` -# helps -gsl help -gsl help new -gsl help install -# Ajouter un domaine -gsl new -``` - -## Définir un dossier pour les articles du DOMAIN +## Définir un dossier pour les articles du DOMAIN +------------------------------------------------------------------------ Si ce n'est pas déjà fait par GSL, ou que vous voulez ajouter un dossier -pour y stocker et convertir en HTML vos articles pour un DOMAIN précis : +pour y stocker vos articles bruts pour un DOMAIN précis : -- Ajouter/créer un dossier de votre choix +``` +gsl help -d +cd MYFOLDER +gsl setdir +``` + +ou: +- Aller dans/créer un dossier de votre choix - Créer dedans, un fichier vide nommé gsl.DOMAIAN (gsl.exemple.com) -## Ajouter un auteur + +## Ajouter / retirer un auteur +------------------------------------------------------------------------ +Après avoir enregistré un domain et configuré un dossier pour les +articles. **Un auteur par ligne !** + ``` cd MON-DOSSER-ARTICLES -gsl author add +gsl author edit ``` + ## Créer un article -Le moteur de convertion est nouveau, et est un mélange entre markdown et +------------------------------------------------------------------------ +Le moteur de convertion est nouveau. C'est un mélange entre markdown et reSTructuredText. Il est simple à apprendre et à utiliser. -- Créer un fichier (monarticle).gsl (extension .gsl) -- Suivez le guide plus bas pour comprendre les notions - -Vous devrez le faire valider par GSL : +Reportez-vous à la documentation dans le dossier help, ou: ``` -gsl check -gsl check monarticle.gsl # Vérfier que monarticle.gsl -gsl check -F Forcer la vérification -gsl check -F monarticle.gsl # Forcer la vérification de monarticle.gsl +gsl help -w ``` -## Convertir un ou tous les articles -Si votre article n'a pas d'erreurs, vous pouvez le convertir en HTML. -``` -gsl make -gsl make -F # Forcer la reconstruction) -gsl make -F monarticle.gsl # Forcer la reconstruction de monarticle.gsl -``` - -Votre article sera prêt dans le dossier webserver (ex: /var/www/DOMAIN/wip) -Vous pourrez donc vérifier son rendu. - -Si vous êtes satisfait, vous pouvez le déployer "officiellement" dans www - -``` -# Vous pouvez utiliser l'autocompletion pour les articles -gsl www add monarticle.gsl -``` +## Procédures de prévisualisation et mise en ligne +------------------------------------------------------------------------ +- gsl check monarticle.gsl (vérifie l'écriture en gsl) +- gsl make monarticle.gsl (Connvertit en HTML - dossier wip) +- gsl www add monarticle.gsl (copiel la page dans le dossier www) # Comment gérer la sidebar ------------------------------------------------------------------------ La gestion de la sidebar est manuelle. Un article doit être convertit avec make avant de pouvoir l'ajouter à la position ddsirée. Le nombre -d'articles maximum dans la sidebar est configurable dans /etc/gsl/gsl.conf - -Quelques exemples d'utilisations +d'articles maximum dans la sidebar est configurable dans le fichier de +configuration du domaine (DOMAIN.conf) ``` -# Liste les articles de la sidebar dans l'ordre -gsl sidebar - -# Ajoute monarticle en position 1 -gsl -S add 1 monarticle - -# Enlève monarticle2 de la sidebar -gsl -S remove monarticle2 - -# monarticle5 est en position 3. Le replacer par monarticle4 -gsl -S -A 3 monarticle4 +gsl sidebar replace 2 monarticle.gsl ``` -# Besoin d'aide ! +## Astuces +- Vous pouvez utiliser l'autocompletion pour les articles +- Reportez-vous à la documentation dans le dossier Help + +``` +gsl www add mona +``` + + +# Help ------------------------------------------------------------------------ -Reportez vous aux explications dans le dossier *help* - - -# HELP COMMAND ------------------------------------------------------------------------- -``` -$ gsl [ARG] +$ gsl (ARG) readme : Show README.md instructions - help | -h [OPT] : This Help - install : Show process installation - new : Adding a DOMAIN - write | -w : How to write a Post - template | -t : Tips to create your template + help | -h (OPT) : This Help and how to + install | -i : Show process installation + authors | -a : Add/Remove authors for this DOMAIN + setdir | -d : Set a directory for article's DOMAIN + write | -w : Write a Post + tpl | -T : Create your template + param | -p : Configure some parameters + css : Show used CSS classes + tips | -t : Show tips and advises you should know - new | -N : Add and configure a new DOMAIN - - log | -L [OPTS] : Show logs from all sessions + new | -N : Generic OPT to add/create + domain : Configure your DOMAIN + author : Same as gsl author edit + (TYPE) (NAME) : Create an article with (TYPE) named (NAME).gsl + + setdir | -D : Show current directory DOMAIN or set it + + log | -L (OPTS) : Show logs from all sessions clean | -C : Logs saved to {DATE}.gsl.log and cleaned + all : clean all saved logs, keep current -i | -w | -e : from levels (infos, warnings, errors) -s : from last session only - [TERM] : [TERM] : case insensitive, regex 'T1.*T2' + (TERM) : (TERM) : case insensitive, regex 'T1.*T2' (i.e. $ gsl log -e -s code) - author | -A [OPT] : List authors from DOMAIN set in PWD folder - add : Add author(s) for DOMAIN - remove : Remove author(s) for DOMAIN + author | -A : List authors from DOMAIN in PWD folder + edit : Add/Remove ! ONE author per line - create [TYPE] [NAME] : Create an article with [TYPE] named [NAME].gsl - - edit | -E : Open in default EDITOR [FILE] or with nano + edit | -E : Open in default EDITOR (FILE) or with nano conf : Domain configuration file - [FILE] : [FILE] (.gsl) + author : Same as gsl author edit + domain : Domains registred database + (FILE) : (FILE) ; .gsl - db [FILE] : Show DB statuses from [FILE] + db (FILE) : Show DB statuses from (FILE) - sync [OPT] : Sync Templates to www and wip + sync (OPT) : Sync Templates to www and wip wip : Only to wip server (also done with make) www : Only to www server (also done with www) - check | -C [OPT] [FILE] : Check Posts errors from PWD folder or [FILE] - -F : Force check again + check | -C (OPTIONS) : Check Post(s) errors from PWD folder + -N : Check only articles not in DB + -F : Force Check again ; Recreate in Database + (FILE) : Only this (FILE) - make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE] - to HTML file in server + make | -M (OPTIONS) : Make all HTML articles or only (FILE) -F : Force Make again + (FILE) : Only this (FILE) - www [OPT1] [OPT2] : Add/Remove Post from www server - [OPT1]: - add : Add all/[FILE] to www server - rmove : remove all/[FILE] from www server - [OPT2]: + www (OPT1) (OPT2) : Add/Remove Post(s) in www server + (OPT1): + sync : Same as "sync www" + add : Add all/(FILE) to www server + rmove : remove all/(FILE) from www server + (OPT2): all : Select all post with wip statuses - [FILE] : Select specific post (if wip status) + (FILE) : Select specific post (if wip status) + wip : Same as www for wip - sidebar | -S [ARG] [FILE]: Show Posts in list - [ARG]: - add | -A : Must set a Position number before [FILE] - Max posts in list is set in gsl.conf - Replace post position if post not exists in list - remove | -R : No Position to set, just [FILE]. - add/remove will build last-posts-list.html - create | -C : rebuild last-posts-list.html + sidebar | -S : Show Posts in list (ARG) (POS) (FILE) + (ARG): + add | -a : Put article at (POS). Remove last, roll from (POS) + replace | -r : Replace (POS) with article + latest | -l : Create sidebar with latest (remove all existing) -v : Show local versionn --version : Like -v + changes -vv : Shown local and repo Versions -``` + diff --git a/var/lib/gsl/db/.gitkeep b/var/lib/gsl/db/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/var/lib/gsl/domains/.gitkeep b/var/lib/gsl/domains/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/var/lib/gsl/help/article-comment-ecrire.md b/var/lib/gsl/help/article-comment-ecrire.md deleted file mode 100644 index adf7c5e..0000000 --- a/var/lib/gsl/help/article-comment-ecrire.md +++ /dev/null @@ -1,310 +0,0 @@ -# Créer un fichier depuis la ligne de commande ------------------------------------------------------------------------- - -Vous pouvez créer un fichier daté du jour avec les METAS obligatoires -intégrés (à renseigner après). Vous devez spécifier si votre article -sera une page ou un post (Voir section plus bas) et lui donner un nom. - -Rendez vous dans le dossier de vos articles, enregistrés lors de l'ajout -de votre domaine (ou celui que vous avez configuré). - -Évitez les espaces dans le nom du fichier ou utilisez des guillemets. - -``` -# Crréer une page nommée index -gsl create page index - -# Créer un article nommé mes-vacances -gsl create post mes-vacances -``` - -Vous pouvez l'éditer dans le terminal ou avec votre éditeur de texte. - -``` -gsl edit mes-vacances.gsl -``` - -# Comment écrire un article ------------------------------------------------------------------------- - -Votre article doit contenir 2 sections. Les METAS avant ```#1``` et -l'article à partir de ce repère (servant de titre h1). - -- METAS : configurer votre article (titre, date, liens...) -- ARTICLE : contenue rédactionnel avec quelques marqueurs (gras...) - -## METAS obligatoires (avant #1) - -``` -title: POST TITLE -slug: POST-TITLE (si espaces, GSL les convertira en -) -info: DESCRIPTION (À propos de cet article) -author: NAME (doit être enregistré via ($ gsl author add) -date: YYYY-MM-DD -tags: TAG1,Mon TAG2,TAG3 (séparé par une virgule) -``` - -### Page ou Article ? - -Vous pouvez spécifier pour chaque article si c'est une page ou un article -Si non renseigné, GSL ajoutera le type: post (article) par défaut à la -première ligne de votre article - -``` -# Page (index, 404, about...) -# Création HTML selon le slug: /POST-TITLE.html -type: page - -# Article (monarticle) -# Création HTML selon le slug: /POST-TITLE/index.html -type: post -``` - -## METAS optionnelles (avant ```#1```) - -Définir les marqueurs (abbr:, link:...) et utiliser ``` : ``` comme séparateur - -``` -abbr: COURT : LONG -file: NOM : NOM-DU-FICHIER : Text alternatif -link: NOM : URL : Text alternatif -code: NUMERO : NOM-DU-FICHIER : Text alternatif -image: NUMERO : NOM-DU-FICHIER : TEXT-ALTERNATIF -``` - -## Contenu de l'article: - -Les marqueurs *et leur contenu* (ex: ```= list 1...```, ```*__monfichier...```) -**doivent commencer et finir sur la même ligne**. - -### Abréviations -Définir en METAS... - -``` -abbr: CSS : Cascading Style Sheets -``` - -Dans l'article: - -``` -Les propriétés CSS ne sont pas définies -``` - -### Paragraphes - -Au début d'une nouvelle ligne, ouvrez avec ( et fermez avec ). -Vous pouvez utiliser 4 classes de paragraphes différentes : ( 1 ( 2 ( 3 - -Dans l'article... -``` -( 2 -Paragraphe avec une classe 2 (css) -) - -( -Paragraphe sans numéro de classe -) -``` - -### Liens - -Définir en METAS - -``` -link: Mon lien : URL : Alt text -link: https://a-lec.org/ : URL : Alt text -``` - -Dans l'article.. -- Écrivez ```_``` devant le nom du lien -- Ajoutez ```+``` pour ouvrir le lien dans un nouvel onglet - -``` -Visitez _Mon lien+ et charger ici la page _https://a-lec.org/ -``` - -### Fichiers - -Définir en METAS - -``` -file: Mon fichier : FILENAME : ALT-TEXT -``` - -Dans l'article... -``` -__Mon fichier -``` - -### Images - -Définir en METAS - -``` -image: 1 : FILENAME : ALT-TEXT -image: 2 : FILENAME : ALT-TEXT -``` - -Dans l'article... -Définir le marqueur ```_image``` sur une seule ligne et spécifiez les -valeurs séparées par ":" - -- Numero d'image -- Alignement: l,r, ou c (g,d également) pour gauche, droite, centre) -- Longueur width: juste le nombre -- Largeur height: juste le nombre -- Champ non vide: Lien de l'image dans un nouvel onglet - -Exemple d'images affichées l'une à côté de l'autre - -``` -( -_image:1 -_image:2:c:640:480 -_image:3:c:320:240:+ -) -``` - -Exemple d'images affichées l'une en dessous de l'autre, dont la première -peut s'ouvrir dans un nouvel onglet - -``` -( -_image:1:c:640:480:+ -) -( -_image:2:c:1920:1080 -) -``` - -### Block-Code depuis un fichier - -Définir en METAS - -``` -code: 1 : FILENAME : Alt Text -``` - -Dans l'article... -``` -_code:1 -``` - -### Écrire en très gras - -Dans l'article... - -``` -**c'est du surgras** -c'est in**défini**ssable -il ad**juge** : pas de pub ! -``` - -### Gras - -Dans l'article... - -``` -*c'est en gras* -``` - -### Italique -Dans l'article... - -``` -C'est /en italique/ -``` - -### Code en ligne - -Info: ¤ = alt-gr + $ sur un clavier FR azerty) -Dans l'article... - -``` -¤gsl help -w¤ -``` - -### Citation simple - -(au début de la ligne, mettez 3x -) -Dans l'article... - -``` ---- -( -Une citation simple dans un paragraphe -) ---- -``` - -### Citation avancée - -Dans l'article... -``` ---- -_cite : Richard Matthew Stallman -_link : https://stallman.org/ -_lang : en -( -In the free/libre software movement, we develop software that respects -users' freedom, so we and you can escape from software that doesn't. I -could have made money this way, and perhaps amused myself writing code. -But I knew that at the end of my career, I would look back on years of -building walls to divide people, and feel I had spent my life making the -world a worse place -) ---- -``` - -### Citation avancée : optionnel - -Ajoutez ces marqueurs, si connus dans la citation, par ex sous ```_cite``` - -``` -_year: 2021 -_book: Esperanza 64 -``` - - -### Créer des listes -L'arborescence est "infinie". -- Chaque contenu de la liste **doit être sur la même ligne** - -Dans l'article... -- utilisez ```=``` pour définir l'arborescence d'une liste simple (ul) -- utilisez ```+``` pour définir une liste ordonnée (ol) - -``` -( -Voici une liste simple -= Fruits : *mangez-en* -== Kiwis -== Fraises -=== pas mûres -== Bananes -=== Plantins -= Légumes -== Haricots -=== Rouges -=== Verts -Fin de la liste -) -``` - -### Ajouter des lignes vides - -Vous pouvez ajouter des ```
``` dans votre rédaction, mais pour une -lecture plus propre de votre article, vous pouvez utiliser le caractère -```|``` *au tout début d'une nouvelle ligne* - -Dans l'article... - -``` -#1 Mon titre -( -Ceci est un long paragraphe (Un peu d'imagination...) -| -Retour "forcé" à la ligne -) - -``` diff --git a/var/lib/gsl/help/comment-parametrer-GSL.md b/var/lib/gsl/help/comment-parametrer-GSL.md new file mode 100644 index 0000000..8a43cb8 --- /dev/null +++ b/var/lib/gsl/help/comment-parametrer-GSL.md @@ -0,0 +1,16 @@ +# Configurations optionnelles de GSL + +Vous pouvez configurer quelques paramètres dans le fichier +**/etc/gsl/gsl.conf** + +## Afficher les logs par chronologie +``` +# Show log by time|level (default: 'time'); not set = level +gsl_log_order=time +``` + +## Définir la taille en octets minimum d'un fichier +``` +# Par défaut: 180 +gsl_article_min_Size=250 +``` diff --git a/var/lib/gsl/help/comment_ecrire-article.md b/var/lib/gsl/help/comment_ecrire-article.md new file mode 100644 index 0000000..b3aed6a --- /dev/null +++ b/var/lib/gsl/help/comment_ecrire-article.md @@ -0,0 +1,363 @@ +# Créer un article depuis la ligne de commande +------------------------------------------------------------------------ +Vous pouvez créer un article daté du jour avec les METAS obligatoires +intégrées (à renseigner après) depuis la ligne de commande. Vous devez +spécifier si votre article sera une page ou un post (Voir section plus +bas), et lui donner un nom. Les metas optionnelles sont ajoutées enn +commentaires. + +Rendez vous dans le dossier de vos articles, enregistrés lors de l'ajout +de votre domaine (ou celui que vous avez configuré). + +Mettez des guillemets pour les nom du fichier avec espaces. + +``` +# Crréer une page nommée index (deviendra /index.html) +gsl new page index + +# Créer un article nommé "mes vacances" +gsl ew post "mes vacances" +``` + +Vous pouvez l'éditer dans le terminal ou avec votre éditeur de texte, en +utilisant l'autocompletion () + +``` +gsl edit "mes vacances.gsl" +``` + + +# Comment écrire un article +------------------------------------------------------------------------ +Votre article doit contenir 2 sections. Les METAS avant ```#1``` et +l'article à partir de ce repère (servant de titre h1). + +- METAS : configurer votre article (titre, date, liens...) +- ARTICLE : contenue rédactionnel avec quelques marqueurs (gras...) + +## METAS obligatoires (avant ```#1```) +**Écrire sur une seule ligne** chaque META + +``` +type: page +title: POST TITLE +slug: MY-SLUG (si espaces, GSL les convertira en -) +info: DESCRIPTION (À propos de cet article) +author: NAME (doit être enregistré via la commande: gsl author edit +date: YYYY-MM-DD +tags: TAG1,Mon TAG2,TAG3 (séparé par une virgule) +``` + +### Page ou Article ? +Vous devez spécifier pour chaque article si c'est une **page** ou un +**post** + +#### Page (index, 404, about...) +Création HTML à la racine selon le slug: /MY-SLUG.html + +``` +type: page +slug: 404 +``` + +#### Post (monarticle) +Création HTML dans un dossier selon le slug: /MY-SLUG/index.html +**! Le slug ne doit pas commencer par un /** + +``` +type: post +slug: service/xmpp/configurer-gajim +``` + +## METAS optionnelles (avant ```#1```) +Définir UN seul marqueur CSS par article pour personnaliser chaque +article avec sa propre CSS. + +``` +css: myID +``` + +Définir un ou plusieurs de ces marqueurs et utiliser ``` : ``` comme +séparateur + +``` +abbr: COURT : LONG +file: NOM : NOM-DU-FICHIER : Text alternatif +link: NOM : URL : Text alternatif +code: NUMERO : NOM-DU-FICHIER : Text alternatif +brut: NUMERO : NOM-DU-FICHIER +image: NUMERO : NOM-DU-FICHIER : TEXT-ALTERNATIF +``` + +## Contenu de l'article: +Les marqueurs (hors listes) *et leur contenu* (ex: ```__monfichier...```) +**doivent être sur la même ligne**. + +Les marqueurs à retenir et leur Combinaison de touches sur un clavier +azerty français + +- Très gras: '•...•' (alt+gr + ;) +- Gras: '·...·' (alt+gr + :) +- Italique: '”...”' (alt+gr + n) +- Barré: '×...×' (alt+gr + shift + ;) +- Code: '¤...¤' (alt+gr + $) + +### Écrire en très gras +Dans l'article... + +``` +•c'est en super gras (strong)• +c'est in•défini•ssable +il ad•juge• : pas de pub ! +``` + +### Écrire en gras +Dans l'article... + +``` +·Tout est en gras· +``` + +### Écrire en Italique +Dans l'article... + +``` +C'est ”en italique” +``` + +### Créer un texte "barré" +Dans l'article... + +``` +La réunion aura lieu ×demain× dans une semaine +``` + +### Écrire un Code en ligne +Dans l'article... + +``` +¤gsl help -w && echo "Be Happy"¤ +``` + +### Abréviations +Définir en METAS... (SHORT doit être en **lettres CAPITALES**) + +``` +abbr: CSS : Cascading Style Sheets +``` + +Dans l'article: + +``` +Les propriétés CSS ne sont pas définies +``` + +### Paragraphes +Au début d'une nouvelle ligne, ouvrez avec ( et fermez avec ). +Vous pouvez définir le nom de la classe du paragraphe en ajoutant la +valeur désirée ; par exemple : p3 + +Dans l'article... +``` +( p3 +Paragraphe avec une classe p3 en css +) + +( +Paragraphe sans classe +) +``` + +### Liens +Définir en METAS + +``` +link: Mon lien : URL : Alt text +link: https://a-lec.org/ : URL : Alt text +``` + +Dans l'article.. +- Écrivez ```_``` devant le nom du lien +- Ajoutez ```+``` pour ouvrir le lien dans un nouvel onglet + +``` +Visitez _Mon lien+ et charger ici la page _https://a-lec.org/ +``` + +### Fichiers +Définir en METAS + +``` +file: Mon fichier : FILENAME : ALT-TEXT +``` + +Dans l'article... +``` +__Mon fichier +``` + +### Images +Définir en METAS + +``` +image: 1 : FILENAME : ALT-TEXT +image: 2 : FILENAME : ALT-TEXT +``` + +Dans l'article... +Définir le marqueur ```_image``` sur une seule ligne et spécifiez les +valeurs séparées par ```:```. ```+``` indique l'ouverture dans une +nouvelle fenêtre. Seuls le "numéro d'image" est obligatoire + +- Numero d'image +- Alignement: l,r,(g,d également),c pour gauche, droite, centre) +- - maclasse au lieu de l,r,c pour utiliser la classe css "maclasse" +- - + (class="center") +- Longueur width: (avec unité) +- - + (taille originale) +- Largeur height: (avec unité) +- - + (longueur définie, largeur originale) +- Champ non vide: Lien de l'image dans un nouvel onglet + +Exemple d'images affichées l'une à côté de l'autre + +``` +( +_image:1 +_image:2:c:640px:25% +_image:3:maclass:320px:240px:+ +) +``` + +Exemple d'images affichées l'une en dessous de l'autre, dont la première +s'ouvrir dans un nouvel onglet avec sa taille originale et la classe css +center + +``` +( +_image:1:+ +) +( +_image:2:c:1920px:25% +) +``` + +### Block-Code depuis un fichier +Définir en METAS + +``` +code: python : FILENAME : Alt Text +``` + +Dans l'article... +``` +_code:python +``` + +### IMPORT de code brut (sera exécuté par le navigateur) +Définir en METAS + +``` +brut : 1 : FILENAME +``` + +Dans l'article... +``` +_brut:1 +``` + +### Citation simple +Définissez un bloc pour la citation. Utilisez ```---``` +Vous pouvez définir une classe CSS spécifique ```--- ma-classe-css``` + +Dans l'article... + +``` +--- +( +Une citation simple dans un paragraphe +) +--- +``` + +### Citation avancée +Dans l'article... Stallman est une classe CSS +``` +--- Stallman +_cite : Richard Matthew Stallman +_link : https://stallman.org/ +_lang : en +( +In the free/libre software movement, we develop software that respects +users' freedom, so we and you can escape from software that doesn't. I +could have made money this way, and perhaps amused myself writing code. +But I knew that at the end of my career, I would look back on years of +building walls to divide people, and feel I had spent my life making the +world a worse place +) +--- +``` + +### Citation avancée : données optionnelles +Ajoutez ces marqueurs, si connus dans la citation + +``` +_year: 2021 +_book: Esperanza 64 +``` + + +### Créer des listes +L'arborescence est "infinie". +- Définir le début d'une liste par ```<<``` et sa fin par ```>>``` +- Définir une classe CSS après ```<< ``` + +Dans l'article... +- utilisez ```=``` pour définir une liste simple (ul) +- utilisez ```+``` pour définir une liste ordonnée (ol) +- Mixez les 2 (dans la limite de ma patience :D) + +``` +( +Voici une liste simple +<< += Fruits : *mangez-en* +== Kiwis +== Fraises +=== pas mûres +== Bananes +=== Plantins += Légumes +== Haricots +=== Rouges +=== Verts +>> +) + +Voici une liste mixe avec sa classe "couverture" +<< couverture += Livre 1 ++ Chapitre 1 ++ Chaptire 2 +++ Résumé du Ch 2 += Livre 2 ++ Chapitre 1 +>> +``` + +### Ajouter des lignes vides +Vous pouvez ajouter des ```
``` dans votre rédaction, mais pour une +lecture plus propre de votre article, vous pouvez utiliser le caractère +```|``` **au tout début d'une nouvelle ligne**. Pratique dans les +paragraphes. + +Dans l'article... + +``` +#1 Mon titre +( +Ceci est un long paragraphe (Un peu d'imagination...) +| +Retour "forcé" à la ligne +) +``` diff --git a/var/lib/gsl/help/comment_installer-GSL.md b/var/lib/gsl/help/comment_installer-GSL.md new file mode 100644 index 0000000..ff0a0f5 --- /dev/null +++ b/var/lib/gsl/help/comment_installer-GSL.md @@ -0,0 +1,84 @@ +# Comment installer GSL: Statique Littératueur +------------------------------------------------------------------------ + +- Un script d'installation install.sh est prévu, mais pas encore proposé. +- Un .deb peut être créé (merci neox) depuis le make de l'archive + +## Installation manuelle +- git clone https://git.a-lec.org/echolib/gsl && cd gsl +- Commencez par créer les dossiers de base (voir ci-dessous) +- Donnez leur les droits nécessaires + +GSL n'utilise pas de droits sudo, et a besoin pour écrire certains +fichiers et créer certains dossiers d'être propriétaire ou d'avoir les +droits en écriture des dossiers + +``` +# Pour le dossier du binaire +sudo rsync -a usr/local/bin/gsl /usr/local/bin/gsl +sudo chown USER:GROUP/usr/local/bin/gsl + +# Pour les dossiers de scripts +sudo mkdir -p "/var/lib/gsl" +sudo chown -R USER:GROUP "/var/lib/gsl" +rsync -a var/lib/gsl/ /var/lib/gsl/ + +# Pour le dossier de logs +sudo mkdir -p "/var/log/gsl" +sudo chown -R USER:GROUP "/var/log/gsl" + +# Pour le dossier de configuration +sudo mkdir -p /etc/gsl +sudo chown -R USER:GROUP "/etc/gsl" + +# Pour l'autocompletion des articles dans la commande +sudo rsync -a usr/share/bash-completion/completions/gsl /usr/share/bash-completion/completions/gsl +sudo chown USER:GROUP "/usr/share/bash-completion/completions/gsl" +``` + +Attention: GSL aura besoin de créer des sous-dossier dans le serveur, +renseigné dans le questionnaire. (i.e. /var/www/). Il faut donc lui +donner les droits + +# Arborescence des dossiers utilisés par GSL +------------------------------------------------------------------------ +Note: ```+``` indique que GSL créera ces dossiers + +- /etc/gsl +- /var/log/gsl +- /var/lib/gsl +- - /help/ +- - /scripts/ +- - /domains +- - - /DOMAIN +- - - - /templates/ + +- - - - /files/ + +- - - - /images/ + +- - - - /X-tra + +- - - - - /sidebar + +- - /db +- - - /DOMAIN + + +- /SRV (i.e. /var/www) +- - /DOMAIN +- - - /wip +- - - - /TEMPLATE (sync wip (command) from /var/lib/gsl/domains/DOMAIN/) +- - - /www +- - - - /TEMPLATE (sync www (command) from /var/lib/gsl/domains/DOMAIN/) + + +# Fichiers créés par GSL +------------------------------------------------------------------------ + +- /var/log/gsl +- - gsl.log +- - Y-M-D-H-M-S.gsl.log (backup when clean ; removed with clean all) +- /var/lib/gsl +- - /domains +- - - DOMAIN +- - - - authors.db +- - - - DOMAIN.conf +- - /db/ +- - - domains.db (registred domains) +- - - DOMAIN/ +- - - - (file).gsl.db (Un par article) diff --git a/var/lib/gsl/help/gsl_help.md b/var/lib/gsl/help/gsl_help.md new file mode 100644 index 0000000..73aef23 --- /dev/null +++ b/var/lib/gsl/help/gsl_help.md @@ -0,0 +1,74 @@ +# GSL: Statique Littérateur + +$ gsl (ARG) + readme : Show README.md instructions + help | -h (OPT) : This Help and how to + install | -i : Show process installation + authors | -a : Add/Remove authors for this DOMAIN + setdir | -d : Set a directory for article's DOMAIN + write | -w : Write a Post + tpl | -T : Create your template + param | -p : Configure some parameters + css : Show used CSS classes + tips | -t : Show tips and advises you should know + + new | -N : Generic OPT to add/create + domain : Configure your DOMAIN + author : Same as gsl author edit + (TYPE) (NAME) : Create an article with (TYPE) named (NAME).gsl + + setdir | -D : Show current directory DOMAIN or set it + + log | -L (OPTS) : Show logs from all sessions + clean | -C : Logs saved to {DATE}.gsl.log and cleaned + all : clean all saved logs, keep current + -i | -w | -e : from levels (infos, warnings, errors) + -s : from last session only + (TERM) : (TERM) : case insensitive, regex 'T1.*T2' + (i.e. $ gsl log -e -s code) + + author | -A : List authors from DOMAIN in PWD folder + edit : Add/Remove ! ONE author per line + + edit | -E : Open in default EDITOR (FILE) or with nano + conf : Domain configuration file + author : Same as gsl author edit + domain : Domains registred database + (FILE) : (FILE) ; .gsl + + db (FILE) : Show DB statuses from (FILE) + + sync (OPT) : Sync Templates to www and wip + wip : Only to wip server (also done with make) + www : Only to www server (also done with www) + + + check | -C (OPTIONS) : Check Post(s) errors from PWD folder + -N : Check only articles not in DB + -F : Force Check again ; Recreate in Database + (FILE) : Only this (FILE) + + make | -M (OPTIONS) : Make all HTML articles or only (FILE) + -F : Force Make again + (FILE) : Only this (FILE) + + www (OPT1) (OPT2) : Add/Remove Post(s) in www server + (OPT1): + sync : Same as "sync www" + add : Add all/(FILE) to www server + rmove : remove all/(FILE) from www server + (OPT2): + all : Select all post with wip statuses + (FILE) : Select specific post (if wip status) + + wip : Same as www for wip + + sidebar | -S : Show Posts in list (ARG) (POS) (FILE) + (ARG): + add | -a : Put article at (POS). Remove last, roll from (POS) + replace | -r : Replace (POS) with article + latest | -l : Create sidebar with latest (remove all existing) + + -v : Show local versionn + --version : Like -v + changes + -vv : Shown local and repo Versions diff --git a/var/lib/gsl/help/how_to-CSS_classes.md b/var/lib/gsl/help/how_to-CSS_classes.md new file mode 100644 index 0000000..c7048ca --- /dev/null +++ b/var/lib/gsl/help/how_to-CSS_classes.md @@ -0,0 +1,95 @@ +# CSS Classes and IDs +```xxx``` is your choosen CSS acronym for your DOMAIN +Note: if "myclass" or "myID" is not defined, class or ID is not used + +## Legacy HTML +### body +myID is set in article with css: myID +TYPE is set in article with type: page|post +- body: xxx_TYPE myID + +## Article Content +### Metas (author, date...) + +### Titles h1-h6 +X is 1 to 6 +- xxx_title xxx_title-X + +### div between titles +X is 1 to 6 from current title +- xxx_content_hX + +### Between markers (code, emphasis, strong...) +- bold: xxx_bold +- strong: xxx_strong +- emphasis: xxx_em +- strike: xxx_strike +- inline code: xxx_icode + +### Paragraphs +myclass is the content value used (i.e.```( myclass```) +- xxx_p myclass + +### Links +- xxx_link +- xxx_link xxx_link-window (if "+" for target) + +### Links from file +- xxx_link-file +- xxx_link-file xxx_link-file-window (if "+" for target) + +### Image and image link +myclass is from content marker (i.e. _image:1:myclass:90:90:+) +- link: xxx_image-link myclass +- img: xxx_image xxx_image-(left,right,cente) +- - If myclass replace xxx_image-(left...) by myclass + +### pre-codes from source file +X is the NAME/NBR registred in header +- pre: xxx_code-block xxx_code-block-X +- span line: xxx_code-line +- span content: xxx_code-content +- p after pre: xxx_code-p +- link source: xxx_code-link + +### Liste (ol | ul | li) +X is the item mark nbr (i.e. "+++" = 3, "=" = 1) +myclass is the registred value after << (i.e. << myclass). Only used at +the begining bloc. +- ol: xxx_list xxx_list-ol xxx_myclass xxx_myclass-ol +- ul: xxx_list xxx_list-ul xxx_myclass xxx_myclass-ul +- li: a-lec_li a-lec_li-X + +### Quotes +myclass is the registred value after "---" (i.e. --- myclass) +myclass is used on +- ```
``` (if no "_cite") +- - blockquote: xxx_quote myclass +- ```
``` if "_cite" +- - figure: xxx_quote-fig myclass + +## Sidebar Content +- aside: xxx_sidebar +- - div: xxx__wrapper +- - - nav: xxx_latest-posts +- - - - h1: xxx_latest-posts +- - - - ul: xxx_latest-posts +- - - - - li: xxx_list-post-item +- - - - - a: xxx_list-post-link +- - - - - - span: xxx_list-post-title +- - - - - - div: xxx__list-post-metas +- - - - - - div: xxx__list-post-info + +## Header content +- header: xxx_banner +- - div: xxx_site-logo +- - div: xxx_site-title +- - - h1: xxx_site-name +- - - h2: xxx_site-description + +## Footer content +- footer: xxx_footer (ID) +- - div: xxx_footer-infos (ID) +- - div: xxx_footer-about (ID) + + diff --git a/var/lib/gsl/help/how_to-Tips_Advises.md b/var/lib/gsl/help/how_to-Tips_Advises.md new file mode 100644 index 0000000..20fe0fe --- /dev/null +++ b/var/lib/gsl/help/how_to-Tips_Advises.md @@ -0,0 +1,34 @@ +# Tips and Advises +## Configuration +- CSS acronym will always be in lower case + +## ABBR +- short name (HEADER): must be in CAPS LOCK (abbr: LEC : Libre en communs) +- short name (CONTENT): must contain a space (" LEC", " LEC ", "LEC ") + +## Files (Images, codes, scripts...) +You can create sub-directories in DOMAIN/files or DOMAIN/images +If you do so, in your article HEADER, set FILENAME with sub-dirs, but +do NOT begin with / +``` +# File put in /var/lib/gsl/domains/DOMAIN/images/dir/dir1/pic.png +image: 1 : dir/dir1/pic.png +``` + +## Images: set style and target +``` +# Open in new tab pic, keep origin sizes +_image:1:+ + +# Open pic in new tab, using your css class and with width in pixel +# (height is kept) +_image:1:c:640px:+ +``` + +## Make (changes in source file) +If you change the content of a file (script code, image...), you will +have to make -F your article, and do www add after + +## Sidebar +If your remove a www or wip page, and you put it in sidebar, +do not forget to replace it with another article diff --git a/var/lib/gsl/help/how_to-add_remove_authors.md b/var/lib/gsl/help/how_to-add_remove_authors.md new file mode 100644 index 0000000..20f038d --- /dev/null +++ b/var/lib/gsl/help/how_to-add_remove_authors.md @@ -0,0 +1,4 @@ +# To add/remove authors: +- cd to your article folder +- gsl author edit +- Set one author per line ! diff --git a/var/lib/gsl/help/how_to-parameters_conf.md b/var/lib/gsl/help/how_to-parameters_conf.md new file mode 100644 index 0000000..ba38ab3 --- /dev/null +++ b/var/lib/gsl/help/how_to-parameters_conf.md @@ -0,0 +1,7 @@ +# Edit the file: /etc/gsl.conf + +## Show logs by time or level (level ="") +- gsl_logs_order=time + +## Minimum Size of a post (default ="180") +- gsl_article_min_Size=250 diff --git a/var/lib/gsl/help/how_to-set_directory_for_articles.md b/var/lib/gsl/help/how_to-set_directory_for_articles.md new file mode 100644 index 0000000..69cac93 --- /dev/null +++ b/var/lib/gsl/help/how_to-set_directory_for_articles.md @@ -0,0 +1,7 @@ +# To set a dedicated folder for your articles +- cd myfolder ; to go into your folder of choice +- gsl setdir ; to choose your domain ; + +If your directory is configured, it will be mentionned, else: +- You'll be asked to choose a reegistred one +- You can now create articles. filename must be a .gsl diff --git a/var/lib/gsl/help/template-comment-creer.md b/var/lib/gsl/help/template-comment-creer.md index f62eeb4..7dd7de8 100644 --- a/var/lib/gsl/help/template-comment-creer.md +++ b/var/lib/gsl/help/template-comment-creer.md @@ -34,6 +34,7 @@ gsl make -F ``` ## Listes de classes utilisées. + Rappel: les classes et IDs commencent par votre ACRONYM configuré, lors de la création d'un domaine avec ```gsl new```, suivi par ```_```. Pour une meilleure lisibilité, votre ACRONYM est marqué xxx. @@ -44,10 +45,10 @@ Pour une meilleure lisibilité, votre ACRONYM est marqué xxx. - - body: xxx_page - - header: xxx_banner - - logo dans header: xxx_site-logo -- - title dans header: xxxsite-title +- - title dans header: xxx_site-title - - name dans header: xxx_site-name - - Description dans header: xxx_site-description -- - ```
``` avant ```
```: xxxspage-wrapper +- - ```
``` avant ```
```: xxx_page-wrapper - - article: xxx_SLUG (SLUG est le "slug: SLUG" de l'article) - - div metas (auteur, date...): xxx_metas - - p dans div metas: xxx_auteur @@ -55,10 +56,12 @@ Pour une meilleure lisibilité, votre ACRONYM est marqué xxx. ### Dans ```
``` - CLASS= +- hX: xxx_title-X - - div après chaque titre ``````: xxx_content-p xxx_content-pX - - p dans div content-p: xxx_paragraph -- - - si contenu ```( 2```: xxx_paragraph-2 +- - - si contenu ```( 1z```: xxx_paragraph-1z - - code pour les inline-code avec ```¤...¤```: xxx_icode +- strikee: xxx_strike - - li (liste) en fonction du nombre N de ```= | +```: xxx__list-li x_list-N - - ul (liste) simple: xxx_list-ul - - ol (liste) ordonnée: xxx_list-ol diff --git a/var/lib/gsl/helps/gsl_help b/var/lib/gsl/helps/gsl_help deleted file mode 100644 index bf1b2fa..0000000 --- a/var/lib/gsl/helps/gsl_help +++ /dev/null @@ -1,64 +0,0 @@ -# GSL: Statique Littérateur - -$ gsl [ARG] - readme : Show README.md instructions - help | -h [OPT] : This Help - install : Show process installation - new : Adding a DOMAIN - write | -w : How to write a Post - template | -t : Tips to create your template - - new | -N : Add and configure a new DOMAIN - - log | -L [OPTS] : Show logs from all sessions - clean | -C : Logs saved to {DATE}.gsl.log and cleaned - -i | -w | -e : from levels (infos, warnings, errors) - -s : from last session only - [TERM] : [TERM] : case insensitive, regex 'T1.*T2' - (i.e. $ gsl log -e -s code) - - author | -A [OPT] : List authors from DOMAIN set in PWD folder - add : Add author(s) for DOMAIN - remove : Remove author(s) for DOMAIN - - create [TYPE] [NAME] : Create an article with [TYPE] named [NAME].gsl - - edit | -E : Open in default EDITOR [FILE] or with nano - conf : Domain configuration file - [FILE] : [FILE] (.gsl) - - db [FILE] : Show DB statuses from [FILE] - - sync [OPT] : Sync Templates to www and wip - wip : Only to wip server (also done with make) - www : Only to www server (also done with www) - - - check | -C [OPT] [FILE] : Check Posts errors from PWD folder or [FILE] - -F : Force check again - - make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE] - to HTML file in server - -F : Force Make again - - www [OPT1] [OPT2] : Add/Remove Post from www server - [OPT1]: - add : Add all/[FILE] to www server - rmove : remove all/[FILE] from www server - [OPT2]: - all : Select all post with wip statuses - [FILE] : Select specific post (if wip status) - - - sidebar | -S [ARG] [FILE]: Show Posts in list - [ARG]: - add | -A : Must set a Position number before [FILE] - Max posts in list is set in gsl.conf - Replace post position if post not exists in list - remove | -R : No Position to set, just [FILE]. - add/remove will build last-posts-list.html - create | -C : rebuild last-posts-list.html - - -v : Show local versionn - --version : Like -v + changes - -vv : Shown local and repo Versions diff --git a/var/lib/gsl/helps/gsl_help_install b/var/lib/gsl/helps/gsl_help_install deleted file mode 100644 index 73ac72e..0000000 --- a/var/lib/gsl/helps/gsl_help_install +++ /dev/null @@ -1,33 +0,0 @@ -# GSL: Installation ------------------------------------------------------------------------- - -To avoid sudo, you should give permissions to USER - -## --Prefix for DOMAIN configuration (set according to user choice): -- HOME: ~/.config/gsl -- GLOBAL: /var/lib/gsl -- Folder: --Prefix/domains/ (created with $ gsl new) - -### DOMAIN Datas from Prefix: -- Folder: --Prefix/DOMAIN/ (Created by GSL) -- - Files: DOMAIN.conf, authors.db (Created by GSL) -- - Folder: --Prefix/DOMAIN/templates/ (css, logos...) (Created by GSL) - -## Destination Folder: /etc/gsl/ -- File: gsl.conf - -## Destination Folder: /var/lib/gsl/ -- Folder: db (Created by GSL) -- Folder: helps -- Folder: scripts -- File: README.md - -## Destination Folder: /var/log/gsl -- File: gsl.log (Created and managed by GSL $ gsl log clean...) - -## Destination Folder: /usr/local/bin -- File: gsl - -## Destination Folder: /usr/share/bash-completion/completions/gsl -- File: gsl - diff --git a/var/lib/gsl/helps/gsl_help_stats b/var/lib/gsl/helps/gsl_help_stats deleted file mode 100644 index 78b1ec8..0000000 --- a/var/lib/gsl/helps/gsl_help_stats +++ /dev/null @@ -1,21 +0,0 @@ -# Stats are one Post per line - Format : txt - Separator : | - -# Fields: - 1 : Post Filename - 2 : Words - 3 : Paragraphs - 4 : Abbr - 5 : Header Links - 6 : Header Images - 7 : Header Files - 8 : Citations - 9 : Block-code Files - 10 : Posted Links - 11 : Italic - 12 : Strong - 13 : Bold - 14 : Inline-Code - 15 : Posted files - diff --git a/var/lib/gsl/helps/gsl_help_write_post b/var/lib/gsl/helps/gsl_help_write_post deleted file mode 100644 index aeb84af..0000000 --- a/var/lib/gsl/helps/gsl_help_write_post +++ /dev/null @@ -1,129 +0,0 @@ -# How to Write a Post ------------------------------------------------------------------------- - -Post has 2 sections : Before and After #1. #1 is the FIRST Title of your -post. #(1-6) are HTML titles (

to

). -- Before #1 is used to set METAs HEADERS to configure your Post. -- From #1 is the CONTENT of your Post - -## NEEDED HEADERS (before #1) -Register METAs for HTML Page content - -``` -title: POST TITLE -slug: POST-TITLE (if space in slug GSL will convert them) -info: DESCRIPTION (about the Post) -author: NAME (must be registred ($ gsl author add) -date: YYYY-MM-DD -tags: TAG1,OTHER TAG2,TAG3 (comma separated) -``` - -### Admin Header -Admin can define specific type of content. If no type defined, GSL will -add at first line the default value: "type: post". - -TYPE: -- post < classic content -- page < used to define main index, 404, about... - -``` -type: TYPE -``` - -GSL will create html file according to slug. Do not add .html to slug. -- post < /slug/index.html -- page < /slug.html - -## Optional HEADERS (before #1) -Register METAs for CONTENT. " : " field separator - -``` -abbr: SHORT : LONG -file: NAME : FILENAME : Alt Text -link: NAME : URL : Alt Text -code: NBR : FILENAME : Alt Text -image: NBR : FILENAME : ALT-TEXT -``` - -## CONTENT Post: -In Content Post, markers (i.e. __My Great file) must be on the SAME line. -For ABBRs, just write SHORT in your content - -``` -# Paragraphs -At begining of new line, open with ( and close with ) -Set till 3 different classes with ( 1 ( 2 ( 3 -( 2 -This is a paragraph with class 2 -) - -# Register in Header. link: My Great Link : URL : Alt text -_My Great Link -_My Great Link+ # Open in new tab - -# Register in Header. file: My Great file : FILENAME : ALT-TEXT -__My Great file - -# Register in Header. image: 1 : FILENAME : ALT-TEXT -_image:1:[OPT l|r|c (left, right, center, alignment)] -_image:1:r - -# Block-Code File: Register in Header. code: 1 : FILENAME : Alt Text -_code:1 - -# Write in STRONG -**this strong content** -this un**believe**able content -this border**line** content - -# BOLD -*this bold content* -... - -# Write in ITALIC -/this em text/ - -# Inline-code (¤ = alt-gr + $ on FR keyboard) -¤push()¤ - -# Simple Blockquote: Use 3 "-" ---- -( -A simple great quote -) ---- - -# Advanced Blockquote ---- -_cite : Richard Matthew Stallman -_link : https://stallman.org/ -_lang : en -( -In the free/libre software movement, we develop software that respects -users' freedom, so we and you can escape from software that doesn't. I -could have made money this way, and perhaps amused myself writing code. -But I knew that at the end of my career, I would look back on years of -building walls to divide people, and feel I had spent my life making the -world a worse place -) ---- - -# For advanced blockquotes, you can also add, if known: -_year: 2021 -_book: Esperanza 64 - -# Create Lists -Use = to create an item. You can use infinite sub-items, but each Item -of a list MUST be on the same Line -( -Let's start a list -= Item 1 is *great* -== sub-item 1 -== sub-item 2 -=== sub-sub-item 1 of sub-item 2 -== sub-item 3 -= Item 2 -== sub-item 1 of Item 2 -This list is ended -) -``` diff --git a/var/lib/gsl/helps/gsl_infos_new_website b/var/lib/gsl/helps/gsl_infos_new_website deleted file mode 100644 index 15d06cd..0000000 --- a/var/lib/gsl/helps/gsl_infos_new_website +++ /dev/null @@ -1,19 +0,0 @@ -# GSL: Statique Littérateur - - GSL can manage multiple websites, based on their DOMAIN (example.org) Name - When adding, set your new DOMAIN, for Global or Home Use - - # --prefix: Domain configuration saved to - - Home case : /home/USER/.config/gsl/domains/ - - Global case: /var/lib/gsl/domains/ - - - Website datas - : --prefix/DOMAIN/DOMAIN.conf - - - Website templates, where you give .css, logo, footer.html... - : --prefix/DOMAIN/templates - -# Adding a folder for your posts ('gsl new' command will ask to create one): - - Add/Create or go into a folder (i.e. /home/USER/Documents/Mytexts) - - Set an empty file in this folder named gsl.DOMAIN (i.e. gsl.example.com) - - Save in this folder your posts in files with .gsl extension (i.e. mygreatpost.gsl) diff --git a/var/lib/gsl/helps/gsl_tips b/var/lib/gsl/helps/gsl_tips deleted file mode 100644 index db94603..0000000 --- a/var/lib/gsl/helps/gsl_tips +++ /dev/null @@ -1,4 +0,0 @@ -# Tips: what to (not) do -## Do NOT: -- put "^" in titles (#1-6) - diff --git a/var/lib/gsl/new-version.md b/var/lib/gsl/new-version.md new file mode 100644 index 0000000..74e97ab --- /dev/null +++ b/var/lib/gsl/new-version.md @@ -0,0 +1,138 @@ +## [0.0.9] + +## Please, see help (and documentations in help folder) + +### Add +- New code about everywhere, more comments, cleaner +- nano dependence +- Check installed configuration at launch +- Dedicated functions for ARGUMENTS in specific files category +- - check: gsl__post_checkers +- - make,sidebar: gsl__post_makers +- - sync,www,wip gsl__srv_manager +- - log: gsl__log_manager +- - db: gsl__db_manager +- - author,new,setdir: gsl__domain_manager +- - edit: gsl__edit_file +- - stats: gsl__stats + +### Installation +- new files: +- - gsl__srv_manager: for all about server +- - gsl__version: for -v, -vv, --version options +- - gsl__domain_manager: for OPT author, new, setdir +- - gsl__edit_file: functions to edit some configuration files +- - gsl__do_commons: Common functions to filter article lines +- - gsl__HTML_template: functions to create HTML pages +- New empty folder in installation: +- - /var/lib/gsl/db: for all DBs (.gitkepp) +- - /var/lib/gsl/domains: for all domains (.gitkeep) +- - /var/log/gsl: for logs files (.gitkeep) +- New help folder in +- - /var/lib/gsl/help (removed "helps" one) + +### Logs +- Better logs harmony +- New fields in log for article filename and domain name +- Specific number of characters spaces in some log fields +- More verbose +- "automatic" level log set from called functions +- Colored levels: war (yellow), err (red) + +### Databases +- Dedicated per article +- Folder: /var/lib/gsl/db/ +- New file format: domains.db +- More datas with new stats. Quicker sourced datas +- Dedicated articles in sub-directory "DOMAIN" +- Check if corrupted DB +- Database and wip files won't be removed if errors in article +- If corrupted Database, try restoring www & wip statuses at new check + +### Changes +- Changes in mapping process: +- - Processes get needed headers FIRST, then split article in 2 sections +- DOMAIN Profile is only in /var/lib/gsl/domains/DOMAIN/ +- Variables in DOMAIN.conf file has no more "gsl_" +- Some translated words in HTML page from lang set DOMAIN (fr || en) +- Between markers (code): put "everything" you want +- New CSS classes: see gsl help css or documentation +- Mark image (i.e. "_image:1:mycss:50%:25%:+)" +- - define your own css class 'mycss' +- - define unity ("%","px"... with height and witdth) +- New lists. Mix "+" (ol) and "=" (ul) and write an item on several lines +- Between hX titles: new div css (none if empty content) +- Changing article Type will remove old wip file (not www file !) +- sync: Logs not shown but added +- stats properties file is now in /www (online) + +### Process check [argument] +- slug: log err if already exists (log war if not well formated) + +### new ARGUMENTS +- new (page|post) (name): Create article, show its content + check it +- new domain: New domain configuration creator +- edit domains: Set/Edit registred domains database +- edit author: Same as author edit +- author edit: Opens nano to Add/Remove authors (one per line) by DOMAIN +- setdir: Set current folder for your DOMAIN (show if one) +- check -N: Only check newer articles not in DB +- clean all: Remove all backups (only) files +- sidebar: add|replace|latest|oldest (See gsl help) +- www sync: Same as sync www +- wip ...: Same as www but for wip + +### Markers +- css: MYCLASS Customize each article with your CSS (optional) +- brut: Insert brut code from file +- - In article header: "NBR : FILENAME"`` +- - In article content: "_brut: NBR" +- "_image:VALUE:MYCSS:WIDTH:HEIGHT:TARGET" (no target=no HTML link) +- Strong mark: '•...•' (alt+gr + ;) on french azerty keyboard) +- Bold mark: '·...·' (alt+gr + :) on french azerty keyboard) +- Emphasis mark: '”...”' (alt+gr + n) on french azerty keyboard) +- Strike mark: '×...×' (alt+gr + shift + ;) on french azerty keyboard +- ```<<``` and ```>>``` as "start" and "close" marker for lists + +### Template +- included basic header, metas and footer +- All about template is in /var/lib/gsl/scripts/gsl__HTML_template +- - No more header.html in templates folder +- - - Edit your own in create__HTML_header() function +- In /var/lib/gsl/domains/DOMAIN/templates/ +- - Auto created metas.html and footer.html if not exist +- - Edit your own footer.html +- - Edit your own metas per DOMAIN for HTML `````` in metas.html +- - - included basic pre-registred meta from datas article +- - No CSS styles included: create your own (see classes and IDs used in doc) +- For all changes here, after gsl make, use gsl sync... + +### Sidebar +- No more /var/lib/gsl/domains/DOMAIN/templates/last-posts-list.html +- - Remove it with files xxx.X in /var/lib/gsl/domains/DOMAIN/X-tra/ +- New HTML file: /var/lib/gsl/domains/DOMAIN/templates/sidebar.html +- - Created with files /var/lib/gsl/domains/DOMAIN/X-tra/sidebar/(POS).html +- articles are sorted from epoch date (in DB) with false time at check + +### Statoolinfos (added properties for www status) +- gsl.articles +- gsl.articles.pages +- gsl.articles.posts +- gsl.authors +- gsl.articles.tags +- gsl.articles.words +- gsl.articles.quotes +- gsl.articles.paragraphs +- gsl.articles.links +- gsl.articles.links.online +- gsl.articles.lists +- gsl.articles.lists.items +- gsl_articles.images + +### CRITIK +- Remove all files in /var/lib/gsl/db/ +- Use: ```gsl new domain```, give your registred DOMAIN name +- - Answer Y to autofix old configurations files and folders +- - Do it for each DOMAIN you registred +- - will add site_max_list=5 (default) in domain configuration file +- Use ```gsl check``` in your articles folder diff --git a/var/lib/gsl/scripts/gsl__HTML_template b/var/lib/gsl/scripts/gsl__HTML_template new file mode 100644 index 0000000..832ae76 --- /dev/null +++ b/var/lib/gsl/scripts/gsl__HTML_template @@ -0,0 +1,255 @@ +#!/bin/bash +# file: gsl__HTML_template +# Folder: /var/lib/gsl/scripts +# By echolib (XMPP: im@echolib.re) +# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + + +#====================================================================== +# HTML code for +# +# You can edit this function and create your needed HTML code +# After editing DO: gsl make -F +# for all your pages to be updated +#====================================================================== +create__HTML_header() { +cat < + + +
+

+ + $site_title + +

+ +

$site_about

+
+ +EOHEADER +} + + +#====================================================================== +# HTML code in
+# /domains/DOMAIN/templates/footer.html +# ! DO NOT EDIT this function +# It creates file -IF NOT EXISTS- +# +# Add / Edit your own +# Create or Edit file /domains/DOMAIN/templates/footer.html +# After editing DO: gsl make -F +# for all your pages to be updated +#====================================================================== +create__HTML_footer() { +cat < "$gsl_dir_domain_tpl/footer.html" + +EOFOOTER +} + + +#====================================================================== +# Translate some static words according to site_lang +#====================================================================== +create__HTML_translation() { +if [[ `grep -i "fr" <<<"$site_lang"` ]];then + gsl_welcome="Page d'accueil de" + gsl_written="Écrit par" + gsl_about=" À propos de" + gsl_gen="Propulsé par" + gsl_the="Le" + gsl_by="par" + gsl_read="Lire l'article de" + +else + gsl_welcome="Welcome page of" + gsl_written="Written by" + gsl_bout="About" + gsl_gen="Generated with" + gsl_the="The" + gsl_by="by" + gsl_read="Read the post of" +fi +} + + +#====================================================================== +# Page Template +#====================================================================== +create__HTML_page() { +create__HTML_translation + +! [[ -f "$gsl_dir_domain_tpl/metas.html" ]] \ + && create__HTML_metas + +! [[ -f "$gsl_dir_domain_tpl/footer.html" ]] \ + && create__HTML_footer + +# Create sub-directories if post only +[[ $article_Type == "post" ]] \ + && mkdir -p "$gsl_srv_wip/$article_Slug" + +cat < "$gsl_srv_post_wip" + + + +$(cat "$gsl_dir_domain_tpl/metas.html") + + + + + + + + + + + + $article_Title - $site_title + + + +$(create__HTML_header) + +
+
+ +
+

$gsl_written $article_Author - $article_Date

+
+ +$(cat "$gsl_tmp_post") + +
+ + +
+ +$(cat "$gsl_dir_domain_tpl/footer.html") + + + +EOPAGE + +gsl__logs_print -i -S -wip \ + "Created HTML $article_Type" \ + "$gsl_srv_post_wip" +} + + +#====================================================================== +# METAS in +# /domains/DOMAIN/templates/metas.html +# ! DO NOT EDIT this function +# It creates file -IF NOT EXISTS- +# +# Edit your values in the file.... +# After editing DO: gsl make -F +# for all your pages to be updated +#====================================================================== +create__HTML_metas() { +cat < "$gsl_dir_domain_tpl/metas.html" + + + + + + + + +EOMETAS +} + + +#====================================================================== +# Called from sidebar__create in gsl__post_makers +# file: /var/lib/gsl/domains/DOMAIN/X-tra/sidebar/[POSITION].html +# You can edit this HTML code for your needs +# It can get all Values from Database post +# $1: file ($sidebar_HTML_item - see above) +#====================================================================== +create__HTML_sidebar_item() { +cat < "$1" +
  • + + + $article_Title + + + + + +
  • +EOSIDEBARITEM +} + + +#====================================================================== +# Called from sidebar__create in gsl__post_makers +# $1: log process +# $2: file: /var/lib/gsl/domains/DOMAIN/templates/sidebar.html +#====================================================================== +create__HTML_sidebar() { +gsl_post="sidebar.html" +[[ -f "$2" ]] \ + && rm -f "$2" \ + && gsl__logs_print -w -s $1 \ + "Removed to Set new one" \ + "$2" + +for i in `seq 1 $site_max_list` +do + [[ -f "$gsl_dir_domain_sidebar/$i.html" ]] \ + && cat "$gsl_dir_domain_sidebar/$i.html" \ + >> "$2" +done + +gsl__logs_print -i -s "$1" \ + "Created" \ + "$2" +} diff --git a/var/lib/gsl/scripts/gsl__auth_manager b/var/lib/gsl/scripts/gsl__auth_manager deleted file mode 100644 index 4525520..0000000 --- a/var/lib/gsl/scripts/gsl__auth_manager +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -# file: gsl__auth_manager -# Folder: /var/lib/gsl/scripts -# By echolib -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - -#======================================================================= -# Manage Authors from DOMAIN -#======================================================================= -gsl__authors_check() { -gsl_save_dir_ndd=`grep "$gsl_find_domain" "$gsl_file_db_domains"` -gsl_file_auth_ndd="$gsl_save_dir_ndd/$gsl_filename_auth" - -if [[ -f "$gsl_file_auth_ndd" ]];then - [[ -z `grep '[^[:space:]]' "$gsl_file_auth_ndd"` ]] \ - && echo "# Domain: $gsl_find_domain" \ - && echo "! No Registred authors yet..." \ - && return 1 -fi - -touch "$gsl_file_auth_ndd" -} - -#======================================================================= -# List Authors from DOMAIN -#======================================================================= -gsl__authors_list() { - -case "$1" in - check) - gsl__authors_check || return - return - ;; - *) - gsl__authors_check || return - ;; -esac - -echo -e "\n# Authors Registred:" -while read -r "line_nbr" "author" -do - echo " $line_nbr: $author" -done < <(cat -n "$gsl_file_auth_ndd") -} - -#======================================================================= -# Add Author(s) for DOMAIN to authors.db in Profile User -#======================================================================= -gsl__authors_add() { -gsl__authors_list add - -printf '\n%s\n%s\n%s\n \n' \ - "# You can add one or more Authors" \ - " Use comma (,) delimiter (i.e. Joe Foo,Jane)" \ - " || empty field to cancel" - -echo -ne "# Add author(s) name : " && IFS="," read -a gsl_new_authors -[[ "$gsl_new_authors" ]] || return - -gsl_nbr_authors=${#gsl_new_authors[@]} -for i in `seq 0 $(( gsl_nbr_authors - 1 ))` -do - echo "${gsl_new_authors[i]}" >> "$gsl_file_auth_ndd" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Author" \ - "Added" \ - "${gsl_new_authors[i]} for domain $gsl_find_domain" \ - "$gsl_file_auth_ndd" -done - -gsl__authors_list -} - -#======================================================================= -# Remove Author(s) for DOMAIN from authors.db in Profile User -#======================================================================= -gsl__authors_remove() { -gsl__authors_list remove || exit 1 - -printf '\n%s\n%s\n%s\n \n' \ - "# You can REMOVE one or more Authors" \ - " Enter numbers (space delimiter)" \ - " || empty field to cancel" - -read -rp "! Which numbers author to REMOVE ? " gsl_rm_authors -gsl_rm_authors=($gsl_rm_authors) - -gsl_nbr_authors=`cat $gsl_file_auth_ndd | wc -l` -for line in ${gsl_rm_authors[@]} -do - [[ $line =~ ^[0-9]+$ ]] || continue - (( $line < 1 )) && continue - (( $line > $gsl_nbr_authors )) && continue - - if [[ $rm_line ]];then - ! (( $line == 1 )) && line=$(( line - 1 )) - fi - gsl_rm_author=`awk -v n="$line" 'NR == n' "$gsl_file_auth_ndd"` - sed -i "${line}d" "$gsl_file_auth_ndd" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Author" \ - "Removed" \ - "$gsl_rm_author for domain $gsl_find_domain" \ - "$gsl_file_auth_ndd" - echo " - Removed > $gsl_rm_author <" - rm_line=true -done - -gsl__authors_list -} diff --git a/var/lib/gsl/scripts/gsl__db_manager b/var/lib/gsl/scripts/gsl__db_manager index 566dc48..9071887 100644 --- a/var/lib/gsl/scripts/gsl__db_manager +++ b/var/lib/gsl/scripts/gsl__db_manager @@ -1,186 +1,231 @@ #!/bin/bash # file: gsl__db_manager # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 +#====================================================================== +# Get arguments from COMMAND (db) +# $1 File +#====================================================================== +db__OPTIONS() { +author__check || exit 0 # Check if authors registresd + +! [[ "$1" ]] \ + && gsl__invalid_option "$1" "[File]" + +if__file "$1" post +[[ -f "$gsl_dir_db_domain/$gsl_this_post.db" ]] \ + && cat "$gsl_dir_db_domain/$gsl_this_post.db" \ + || echo "! No DB yet for $gsl_this_post. Check it first." +exit +} + + #====================================================================== # Get Post Hash & Status From Database #====================================================================== -gsl__db_get_post_datas() { -gsl_db_post_hash=0 - -if [[ -f "$gsl_file_db_post" ]];then - - gsl_db_post_hash=` - awk -F: 'NR == 1 {print $3}' \ - "$gsl_file_db_post"` - - ! [[ "$gsl_db_post_hash" ]] \ - && gsl_db_post_hash=0 - - gsl_db_post_status=` - awk -F: 'NR == 2 {print $2}' \ - "$gsl_file_db_post"` +DB__datas() { +if ! [[ -f "$gsl_file_db_post" ]];then + gsl__logs_print -w -D -f \ + "Article not yet checked" \ + "$gsl_file_db_post" + article_is_new=true else - # if check process, do not show (useless) - case "$1" in - check) true ;; - *) - gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "File" \ - "Missing for $gsl_post. Check it first" \ - "$gsl_file_db_post" - gsl_checker_war=true - ;; - esac + # Check corrupted file + Hash_DB=`cksum "$gsl_file_db_post" | awk '{print $1}'` + if ! [[ -f $gsl_file_db_post_hash.$Hash_DB ]];then + db_corrupt=true + [[ `grep "article_Status_www=" "$gsl_file_db_post"` \ + || `grep "article_Status_wip=" "$gsl_file_db_post"` ]] \ + || return + fi + + source "$gsl_file_db_post" fi } -#====================================================================== -# Get Post Hash and Compare from Database -#====================================================================== -gsl__db_compare_post_hash() { -gsl_checker_war=true - -if (( $gsl_post_hash == $gsl_db_post_hash ));then - - gsl__logs_print \ - "$gsl_log_i" \ - "File" \ - "Hash" \ - "$gsl_post checked with hash:$gsl_db_post_hash" \ - "${PWD}/$gsl_post" - -else - - gsl_post_new_hash=true - case "$gsl_db_post_hash" in - 0) - gsl__logs_print \ - "$gsl_log_w" \ - "File" \ - "New" \ - "$gsl_post not yet checked" \ - "${PWD}/$gsl_post" - gsl_checker_war=true - ;; - *) - gsl__logs_print \ - "$gsl_log_w" \ - "File" \ - "Hash" \ - "$gsl_post Changed ($gsl_post_hash) !" \ - "${PWD}/$gsl_post" - gsl_checker_war=true - ;; - esac - -fi -} #====================================================================== -# Set Post Status in Database according to proceess +# Compare post Hash from Database #====================================================================== -gsl__db_set_post_status() { +DB__compare_hash() { case "$1" in - chk) - case "$gsl_db_post_status" in - "") - gsl_db_post_status=$1 - ;; - esac + check) + gsl_do_check=true + [[ $article_is_new ]] && return + + [[ $db_corrupt ]] && gsl_force_check=true - if ! [[ "$gsl_force_check" ]];then - [[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash + if [[ $article_Errors == "no" ]];then + if (( $article_Hash == $article_Status_chk ));then + if ! [[ $gsl_force_check ]];then + gsl__logs_print -w -g -C \ + "Already done ; Use -F to force" \ + "$PWD/$gsl_post" + unset gsl_do_check + fi + + else + gsl__logs_print -w -g \ + "Compare" \ + "Old Hash: $article_Status_chk" \ + "${PWD}/$gsl_post" + fi fi - gsl__db_create_post "$gsl_db_post_status" ;; + + make|www) + [[ $db_corrupt ]] \ + && gsl__logs_print -e -D -f \ + "Corrupted ; Check again first" \ + "$gsl_file_db_post" \ + && return + + [[ $article_is_new ]] && return + [[ $article_Errors == "yes" ]] \ + && gsl__logs_print -e -A -inv \ + "Found errors ; Cannot continue" \ + "$PWD/$gsl_post" \ + && return - wip) - case "$gsl_db_post_status" in - chk|www) - sed -i "2s/.*/Status:$1/" "$gsl_file_db_post" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "File" \ - "Status:$1 ; $gsl_post" \ - "$gsl_file_db_post" - gsl_checker_war=true - ;; - esac - ;; - - www) - case "$gsl_db_post_status" in - wip) - sed -i "2s/.*/Status:$1/" "$gsl_file_db_post" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "File" \ - "Status:$1 ; $gsl_post" \ - "$gsl_file_db_post" - gsl_checker_war=true - ;; - esac + gsl_do_make=true ;; esac } -#====================================================================== -# Create DB File from Data Post -#====================================================================== -gsl__db_create_post() { -if [[ "$gsl_checker_err" ]];then - [[ -f "$gsl_file_db_post" ]] \ - && rm -f "$gsl_file_db_post" \ - && gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "File" \ - "Remove ; error in $gsl_post" \ - "$gsl_file_db_post" - return -fi +#====================================================================== +# Logger +#====================================================================== +DB__create_log() { +gsl__logs_print -i -D -c \ + "$article_Type ; Hash: $article_Hash" \ + "$gsl_file_db_post" +} + + +#====================================================================== +# Set Post Statuses (chk, wip, www) in Database according to proceess +#====================================================================== +DB__set_status() { +case "$1" in + chk) + article_Status_chk="article_Status_chk=$article_Hash" + ! [[ $article_Status_wip ]] \ + && article_Status_wip="article_Status_wip=0" \ + || article_Status_wip="article_Status_wip=$article_Status_wip" + + ! [[ $article_Status_www ]] \ + && article_Status_www="article_Status_www=0" \ + || article_Status_www="article_Status_www=$article_Status_www" + + DB__create_datas + DB__create_sum + ;; + + wip) + sed -i "s/article_Status_wip=.*/article_Status_wip=$article_Hash/" \ + "$gsl_file_db_post" + DB__create_sum + ;; + + wip-del) + sed -i "s/article_Status_wip=.*/article_Status_wip=0/" \ + "$gsl_file_db_post" + DB__create_sum + ;; + + www) + sed -i "s/article_Status_www=.*/article_Status_www=$article_Hash/" \ + "$gsl_file_db_post" + DB__create_sum + ;; + + www-del) + sed -i "s/article_Status_www=.*/article_Status_www=0/" \ + "$gsl_file_db_post" + DB__create_sum + ;; +esac +} + + +#====================================================================== +# Create DB File for this article +#====================================================================== +DB__create_datas() { +! [[ -d "$gsl_dir_db_domain" ]] \ + && mkdir -p "$gsl_dir_db_domain" + +[[ -f "$gsl_file_db_post" ]] \ + && rm -f "$gsl_file_db_post" + +rm -f "$gsl_file_db_post_hash."* touch "$gsl_file_db_post" # Main Print -printf '%s\n%s\n%s\n' \ - "$gsl_post_type:${PWD}/$gsl_post:$gsl_post_hash:$gsl_post_size" \ - "Status:$1" \ - "`cat "$gsl_db_tmp"`" \ - > "$gsl_file_db_post" +cat << EODB > "$gsl_file_db_post" +# File +article_domain="$domain_name" +article_URI="${PWD}/$gsl_post" +$article_Status_chk +$article_Status_wip +$article_Status_www +article_epoch=$date_epoch -# Stats Print -printf '\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ - "Stats" \ - "Author:$gsl_header_author" \ - "Date:$gsl_header_date" \ - "Words:$gsl_stat_words" \ - "Parag:$gsl_stat_p" \ - "Links:$gsl_stat_link:$gsl_stat_links" \ - "Strongs:$gsl_stat_strongs" \ - "Bolds:$gsl_stat_bolds"\ - "Italics:$gsl_stat_italics" \ - "Abbrs:$gsl_stat_abbr:$gsl_stat_abbrs" \ - "Images:$gsl_stat_image" \ - "Files:$gsl_stat_file:$gsl_count_files" \ - "Cites:$gsl_stat_bq" \ - "ICodes:$gsl_stat_icode" \ - "FCodes:$gsl_stat_fcode" \ - >> "$gsl_file_db_post" +# Article +article_Errors="$article_Errors" +article_Type=$gsl_post_type +article_CSS="$gsl_post_css" +article_Date="$gsl_post_date" +article_Title="$gsl_post_title" +article_Info="$gsl_post_info" +article_Slug="$gsl_post_slug" +article_Author="$gsl_post_author" +article_Tags="$gsl_post_tags" -gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "File" \ - "Create datas from $gsl_post (status: $1)" \ - "$gsl_file_db_post" +# Import +$(cat "$gsl_tmp_db") + +# Stats +stat_Titles=$gsl_stat_titles +stat_Tags=$gsl_stat_tags +stat_Words=$gsl_stat_words +stat_Paragraphs=$gsl_stat_p +stat_Links=$gsl_stat_links +stat_Links_Online=$gsl_stat_links_online +stat_ABBRS=$gsl_stat_abbrs +stat_Strongs=$gsl_stat_strongs +stat_Bolds=$gsl_stat_bolds +stat_Emphasis=$gsl_stat_italics +stat_Strikes=$gsl_stat_strikes +stat_Icodes=$gsl_stat_icodes +stat_Lists=$gsl_stat_lists +stat_Lists_Items=$gsl_list_items +stat_Quotes=$gsl_stat_bq +stat_Images=$gsl_stat_images +stat_max_Images=$gsl_total_images +stat_Flinks=$gsl_stat_flinks +stat_Fcodes=$gsl_stat_fcodes +stat_max_Fcodes=$gsl_total_fcodes +stat_Fbruts=$gsl_stat_fbruts +stat_max_Fbruts=$gsl_total_fbruts +EODB +} + + +#====================================================================== +# Create DB File.HASH for this article (avoid corruption) +#====================================================================== +DB__create_sum() { +if [[ -f "$gsl_file_db_post" ]];then + Hash_DB=`cksum "$gsl_file_db_post" | awk '{print $1}'` + rm -f "$gsl_file_db_post_hash."* + touch "$gsl_file_db_post_hash.$Hash_DB" + source "$gsl_file_db_post" + DB__create_log "$1" +fi } diff --git a/var/lib/gsl/scripts/gsl__do_commons b/var/lib/gsl/scripts/gsl__do_commons index 6bcbe53..9c72a7d 100644 --- a/var/lib/gsl/scripts/gsl__do_commons +++ b/var/lib/gsl/scripts/gsl__do_commons @@ -1,216 +1,107 @@ #!/bin/bash # file: gsl__do_commons # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -#======================================================================= -# Get NEEDED DATAS from HEADERS -#======================================================================= -gsl__get_needed_headers() { -gsl_post_type=`gsl__get_header "$gsl_marker_type" "$gsl_post"` -gsl_header_title=`gsl__get_header "$gsl_marker_title" "$gsl_post"` -gsl_header_slug=`gsl__get_header "$gsl_marker_slug" "$gsl_post"` -gsl_header_author=`gsl__get_header "$gsl_marker_author" "$gsl_post"` -gsl_header_date=`gsl__get_header "$gsl_marker_date" "$gsl_post"` -gsl_header_info=`gsl__get_header "$gsl_marker_info" "$gsl_post"` -gsl_header_tags=`gsl__get_header "$gsl_marker_tags" "$gsl_post"` + +#====================================================================== +# Set/Get NEEDED DATAS from META HEADERS +# $1: process +# $2: file: (gsl_tmp_head) +#====================================================================== +get__needed_headers() { +gsl__logs_print -i -g \ + "Get" \ + "Needed Metas from header" \ + "$2" + +read__line_with "^$gsl_marker_type" "$1" \ + "$gsl_marker_type" "meta" "$2" + +read__line_with "^$gsl_marker_slug" "$1" \ + "$gsl_marker_slug" "meta" "$2" + +read__line_with "^$gsl_marker_title" "$1" \ + "$gsl_marker_title" "meta" "$2" + +read__line_with "^$gsl_marker_info" "$1" \ + "$gsl_marker_info" "meta" "$2" + +read__line_with "^$gsl_marker_author" "$1" \ + "$gsl_marker_author" "meta" "$2" + +read__line_with "^$gsl_marker_tags" "$1" \ + "$gsl_marker_tags" "meta" "$2" + +read__line_with "^$gsl_marker_date" "$1" \ + "$gsl_marker_date" "meta" "$2" + +read__line_with "^$gsl_marker_css" "$1" \ + "$gsl_marker_css" "meta" "$2" } + #====================================================================== -# Check | Make in Loop from header datas $1: process $2:marker $3:file +# Read line with +# $1: TERM +# $2: process +# $3: marker +# $4: type (meta/metas) +# $5: file +# From "meta" ; check only one marker ; get fields +# From "metas" ; check multiple markers ; get fields +# From content ; read line ; no need to get fields #====================================================================== -gsl__do_header() { -while read -r "gsl_header_content_line" +read__line_with() { +# meta must be set, and no more than one value +if [[ "$2" == "check" && "$4" == "meta" ]];then + meta_nbr=`grep -n "$1" "$5" | wc -l` + if (( $meta_nbr == 0 ));then + if [[ "$3" == "$gsl_marker_css" ]];then + gsl__logs_print -w -h \ + "$gsl_marker_css" \ + "Body template: css not customized" \ + "$PWD/$gsl_post" + gsl_post_css="" + + else + gsl__logs_print -e -h \ + "$3" \ + "Unused needed marker" \ + "${PWD}/$gsl_post" + return + fi + + elif (( $meta_nbr > 1 ));then + gsl__logs_print -e -h \ + "$3" \ + "Set only one marker ; Found $meta_nbr" \ + "${PWD}/$gsl_post" + return + fi +fi + +# Read line filtered +while IFS=: read -r "ln" "gsl_line" do - gsl__get_header_fields "$2" - case "$1" in - check) - case "$2" in - "$gsl_marker_link") gsl__check_link ;; - "$gsl_marker_abbr") gsl__check_abbr ;; - "$gsl_marker_file") gsl__check_file ;; - "$gsl_marker_image") gsl__check_image ;; - "$gsl_marker_code") gsl__check_fcode ;; - esac - ;; - - make) - case "$2" in - "$gsl_marker_link") gsl__make_link ;; - "$gsl_marker_abbr") gsl__make_abbr ;; - "$gsl_marker_image") gsl__make_image ;; - esac + # Get values if meta(s) + case "$4" in + meta|metas) + header_f1=`awk -F" : " '{print $1}' <<<"$gsl_line"` + header_f0=`awk -F": " '{print $1}' <<<"$header_f1"` + header_f1=`awk -F": " '{print $2}' <<<"$header_f1"` + header_f2=`awk -F" : " '{print $2}' <<<"$gsl_line"` + header_f3=`awk -F" : " '{print $3}' <<<"$gsl_line"` ;; esac -done < <(gsl__get_header "$2" "$3") -} - -#====================================================================== -# Do Strongs && Bolds + Get STATS | $1: Process $2:File -#====================================================================== -gsl__do_strongs_bolds() { -case "$1" in - "stats") - gsl_stat_strongs=0 - gsl_stat_bolds=0 - ;; - -esac - -while read -r "strong" -do - if [[ "$strong" ]] && \ - [[ `grep "$gsl_mark_strong$strong$gsl_mark_strong" "$2"` ]];then - - case "$1" in - "stats") - ((gsl_stat_strongs++)) - ;; - "make") - # Check if in Inline-Code - [[ `awk -v l="$n" 'NR == l' "$2" \ - | grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)"` \ - =~ "$strong" ]] \ - && continue - - echo -ne "\r\033[2K: Converting Strong... $strong" - gsl_strong="$gsl_mark_strong$strong$gsl_mark_strong" - gsl_html_strong="$strong" - sed -i "s|$gsl_strong|$gsl_html_strong|g" "$2" - ;; - esac - - fi -done < <(grep -oP "(?<=$gsl_mark_strong).*?(?=$gsl_mark_strong)" "$2") - - -# Bolds -while IFS=: read -r "n" "bold" -do - if [[ "$bold" ]] && \ - [[ `grep "$gsl_mark_bold$bold$gsl_mark_bold" "$2"` ]];then - - case "$1" in - "stats") - ((gsl_stat_bolds++)) - echo -ne "\r\033[2K: Counting Bolds... $gsl_stat_bolds" - ;; - - "make") - gsl_bold="$gsl_mark_bold$bold$gsl_mark_bold" - # Check if in Inline-Code - [[ `awk -v l="$n" 'NR == l' "$2" \ - | grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)"` \ - =~ "$bold" ]] \ - && continue - - echo -ne "\r\033[2K: Converting Bold... Line $n: $bold" - gsl_html_bold="$bold" - sed -i "s|$gsl_bold|$gsl_html_bold|g" "$2" - ;; - esac - fi -done < <(grep -oPn "(?<=$gsl_mark_bold).*?(?=$gsl_mark_bold)" "$2") - -case "$1" in - "stats") - gsl_stat_bolds=$((gsl_stat_bolds - gsl_stat_strongs)) - ;; -esac -} - -#====================================================================== -# Do Italics + Get STATS | $1: Process $2:File -#====================================================================== -gsl__do_italics() { -gsl_stat_italics=0 - -while IFS=: read -r "n" "italic" -do - - [[ `awk -v l="$n" 'NR == l && $1 ~ "link"' "$2"` ]] \ - && continue - - if [[ "$italic" ]] && \ - [[ `grep "$gsl_mark_italic$italic$gsl_mark_italic" "$2"` ]];then - - case "$1" in - "stats") - ((gsl_stat_italics++)) - ;; - "make") - # Check if in Inline-Code - [[ `awk -v l="$n" 'NR == l' "$2" \ - | grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)"` \ - =~ "$italic" ]] \ - && continue - - this_word=` - awk -v l="$n" 'NR == l' "$2" \ - | grep -o "[^[:space:]]*$italic[^[:space:]]*"` - - case "$this_word" in - "_http"*|"_xmpp"*|"_ftp"*) - continue - ;; - esac - - gsl_italic="$gsl_mark_italic$italic$gsl_mark_italic" - gsl_html_italic="$italic" - - echo -ne "\r\033[2K: Converting Italic... $italic" - sed -i "s|$gsl_italic|$gsl_html_italic|g" "$2" - ;; - esac - fi -done < <(grep -oPn "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2") -} - -#====================================================================== -# Do Italics + Get STATS | $1: Process $2:File -#====================================================================== -gsl__do_icode() { -gsl_stat_icode=0 - -case "$1" in - "stats") - gsl_mark_icode=`grep -o "$gsl_mark_code" "$2" | wc -l` - gsl_stat_icode=$(( gsl_mark_icode / 2 )) - ;; - - "make") - gsl_html_icode_o="" - gsl_html_icode_c="" - - while IFS=: read -r "n" "line" - do - unset gsl_icode_open - for i in $(seq 1 ${#line}) - do - case "${line:i-1:1}" in - "$gsl_mark_code") - [[ "$gsl_icode_open" ]] \ - && gsl_html_line+="$gsl_html_icode_c" \ - && unset gsl_icode_open && continue - - gsl_icode_open=true - gsl_html_line+="$gsl_html_icode_o" - ;; - *) - gsl_html_line+="${line:i-1:1}" - ;; - esac - done - - echo -ne "\r\033[2K: Converting inline-codes..." - sed -i "${n}d" "$2" - sed -i "${n}i$gsl_html_line" "$2" - unset gsl_html_line - - done < <(grep -n "$gsl_mark_code" "$2") - ;; -esac + # From process, do + case "$2" in + check) check__headers_from_filter "$1" "$2" "$3" "$4" ;; + make) make__headers_from_filter "$1" "$3" "$5" "$6" "$7" "$8" ;; + esac + +done < <(grep -n "$1" "$5") } diff --git a/var/lib/gsl/scripts/gsl__domain_manager b/var/lib/gsl/scripts/gsl__domain_manager new file mode 100644 index 0000000..52884a5 --- /dev/null +++ b/var/lib/gsl/scripts/gsl__domain_manager @@ -0,0 +1,471 @@ +#!/bin/bash +# file: gsl__domain_manager +# Folder: /var/lib/gsl/scripts +# By echolib (XMPP: im@echolib.re) +# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + + +#====================================================================== +#---------------------------------------------------------------------- +# AUTHORS SECTION +#---------------------------------------------------------------------- +#====================================================================== +#====================================================================== +# Get arguments from COMMAND (author) +# $1: conf | edit | ""|list +#====================================================================== +author__OPTIONS() { +domain__check +author__check "nocheck" + +case "$1" in + list|"") cat "$gsl_file_domain_authors" ;; + edit) nano "$gsl_file_domain_authors" ;; + *) gsl__invalid_option "$2" "add|remove" ;; +esac +exit +} + + +#======================================================================= +# Manage Authors from DOMAIN +#======================================================================= +author__check() { +touch "$gsl_file_domain_authors" + +[[ "$1" == "nocheck" ]] \ + && return + +# For all Arguments except author, check if empty +if [[ -z `grep '[^[:space:]]' "$gsl_file_domain_authors"` ]];then + echo "! Domain: $domain_name ; No Registred authors yet" + return 1 +fi +} + + +#====================================================================== +#---------------------------------------------------------------------- +# Set DOMAIN current folder SECTION +#---------------------------------------------------------------------- +#====================================================================== +#====================================================================== +# Get arguments from COMMAND (-PWD) +#====================================================================== +setdir__OPTIONS() { +domain__check setdir +[[ "$domain_name" ]] \ + && echo "# Domain registred for this folder: $domain_name" \ + && exit + +domain_nbr_max=`cat "$gsl_file_db_domains" | wc -l` +cat -n "$gsl_file_db_domains" +ask_domain=`echo -e "\n# Which domain to set for this folder ? "` +read -rp "$ask_domain" domain_nbr + +! [[ $domain_nbr ]] \ + && echo "# Maybe later..." \ + && exit + +[[ $domain_nbr =~ [^[:digit:]] ]] \ + && echo "! Please, choose à domain number" \ + && exit + +(( $domain_nbr == 0 || $domain_nbr > $domain_nbr_max )) \ + && echo "! No domain $domain_nbr" \ + && exit + +domain_set=`awk -v l="$domain_nbr" 'NR==l' "$gsl_file_db_domains"` +touch "gsl.$domain_set" +gsl setdir +exit +} + + +#====================================================================== +#---------------------------------------------------------------------- +# GET DOMAIN SECTION +#---------------------------------------------------------------------- +#====================================================================== +#====================================================================== +# Get domain_name from PWD dir +#====================================================================== +domain__check() { +# Mismatch folder set +domains_nbr=` +find . -maxdepth 1 -not -type d \ + -iname "gsl.*.*" 2>/dev/null \ + | wc -l` + +if (( $domains_nbr > 1 ));then + echo "! Too much domains registred in $PWD: Set only one per folder" + exit + +elif (( $domains_nbr == 0 ));then + echo "! No registred domain set in $PWD" + + # setdir OPTIONS: return || exit + [[ "$1" == setdir ]] \ + && return \ + || exit +fi + +# Set domain name +domain_name=`find . -maxdepth 1 -not -type d -iname "gsl.*" 2>/dev/null` +domain_name=${domain_name#.\/gsl.*} + +# Check Database if empty or DOMAIN not in (domains.db) +if ! [[ -f "$gsl_file_db_domains" ]] || \ + [[ -z `grep '[^[:space:]]' "$gsl_file_db_domains"` ]];then + echo "! Domains database is empty ; Type: gsl new domain" + exit + +elif ! [[ `grep "$domain_name" $gsl_file_db_domains` ]];then + echo "! Domain $domain_name not in database: $gsl_file_db_domains" + exit +fi + +# setdir OPTIONS ; return here +[[ "$1" == setdir ]] && return + +# Settings from DOMAIN +gsl_dir_domain="$gsl_dir_domains/$domain_name" +gsl_file_domain_authors="$gsl_dir_domain/authors.db" +gsl_file_domain_conf="$gsl_dir_domain/$domain_name.conf" +if__file "$gsl_file_domain_conf" source + +gsl_dir_domain_tpl="$gsl_dir_domain/templates" +gsl_dir_domain_files="$gsl_dir_domain/files" +gsl_dir_domain_images="$gsl_dir_domain/images" +gsl_dir_domain_listings="$gsl_dir_domain/X-tra" +gsl_dir_domain_sidebar="$gsl_dir_domain_listings/sidebar" + +gsl_dir_db_domain="$gsl_dir_db/$domain_name" + +gsl_dir_srv="$site_server" +gsl_dir_srv_ndd="$site_server/$site_ndd" +gsl_dir_srv_wip="$site_server/$site_ndd/wip" +gsl_dir_srv_www="$site_server/$site_ndd/www" +} + + +#====================================================================== +#---------------------------------------------------------------------- +# Set NEW DOMAIN SECTION +#---------------------------------------------------------------------- +#====================================================================== +#====================================================================== +# Get arguments from COMMAND (new) +#====================================================================== +new__OPTIONS() { +echo "$1 $2" +case "$1" in + domain) + new__domain "$2" + ;; + + page|post) + domain__check + new__article "$1" "$2" + ;; + + author) + domain__check + author__OPTIONS edit + ;; + + *) + gsl__invalid_option "$1" "page|post|domain|author" ;; +esac +} + + +#====================================================================== +# Create an "empty" article +#====================================================================== +new__article() { +[[ -f "$2.gsl" ]] \ + && echo "! $2.gsl already exists" \ + && exit + +[[ `grep -i "fr" <<<"$site_lang"` ]] \ + && cur_date=`date +%d-%m-%Y` \ + || cur_date=`date +%Y-%m-%d` + +cat < "$2.gsl" +type: $1 +#css: +title: +slug: +info: +author: +date: $cur_date +tags: + +#abbr: COURT : LONG +#file: NOM : NOM-DU-FICHIER : Text alternatif +#link: NOM : URL : Text alternatif +#code: NUMERO : NOM-DU-FICHIER : Text alternatif +#brut: NUMERO : NOM-DU-FICHIER +#image: NUMERO : NOM-DU-FICHIER : TEXT-ALTERNATIF + +#1 +EONEWARTICLE + +echo +cat "$2.gsl" +echo +gsl check "$2.gsl" +exit +} + + +#====================================================================== +# New Domain creator ; set config DOMAIN file +#====================================================================== +new__domain() { + + answer__check() { + ! [[ "$1" ]] \ + && echo "# Abandon" \ + && exit + } + +clear +cat <> "$domain_profile" + echo "! Configuration changed to new compatible version" + gsl_sleep=true + fi + + if ! [[ -f "$gsl_file_db_domains" ]];then + touch "$gsl_file_db_domains" && \ + echo "! Creating new Database domains" + gsl_sleep=true + fi + + if ! [[ `grep "$set_ndd" "$gsl_file_db_domains"` ]];then + echo "$set_ndd" >> "$gsl_file_db_domains" + echo "! $set_ndd added to new Database: $gsl_file_db_domains" + gsl_sleep=true + fi + + [[ "$gsl_sleep" ]] && sleep 2 + nano "$domain_profile" + exit +fi + +# HTTP(S) +#------------------- +echo -e "\n# https or or http. Answer Y for https" +read -rp "- Use HTTPS ? " set_protocole +answer__check "$set_protocole" + +case "$gsl_set_protocole" in + Y|y) set_url="https://$gsl_set_ndd" ;; + *) set_url="http://$gsl_set_ndd" ;; +esac + +# Webserver +#------------------- +echo -e "\n# i.e. /var/www (will create [URI]/$set_ndd/)" +read -erp "- Webserver URI ? " set_server +answer__check "$set_server" + +[[ ${set_server: -1} == "/" ]] \ + && set_server=${set_server::-1} + +# Website title +#------------------- +echo -e "\n# i.e. My beautiful website" +read -rp "- Website Title ? " set_title +answer__check "$set_title" + +# Website Description +#------------------- +echo -e "\n# i.e. writings about my website" +read -rp "- Website Description ? " set_about +answer__check "$set_about" + +# Contact mail +#------------------- +echo -e "\n# i.e. contact@$set_ndd" +read -rp "- Contact Mail ? " set_mail +answer__check "$set_mail" + +# Website Keywords +#------------------- +echo -e "\n# i.e. freedom,software (Will be used on each article !)" +read -rp "- Website Keywords ? " set_keys +answer__check "$set_keys" + +# Website Lang +#------------------- +echo -e "\n# i.e. fr (or en-GB...)" +read -rp "- Website Lang ? " set_lang +answer__check "$set_lang" + +# Copyright +#------------------- +echo -e "\n# i.e. 2022 $set_ndd CC BY-SA" +read -rp "- Website Copyright ? " set_cr +answer__check "$set_cr" + +# Logo filename +#------------------- +echo -e "\n# i.e. logo.png (put in $gsl_dir_domains/$set_ndd/templates)" +read -rp "- Website logo (file NAME) ? " set_logo +answer__check "$set_logo" + +# List Name (last posts) +#------------------- +echo -e "\n# i.e. My last posts" +read -rp "- Title List Name ? " set_listname +answer__check "$set_listname" + +# CSS Acronym +#------------------- +css_ex=${set_ndd%.*} +echo -e "\n# i.e. $css_ex (Will create HTML classes like ${css_ex}_paragraph" +read -rp "- CSS Acronym ? " set_css +answer__check "$set_css" +set_css=${set_css,,} + +# Author reference +#------------------- +echo -e "\n# i.e. https://mastodon.home/$set_ndd (Used for meta rel='me')" +read -rp "- External Author URL ? " set_auth_url +answer__check "$set_auth_url" + +# Sidebar max list +#------------------- +echo -e "\n# i.e. 5 ; Numbers of post in sidebar" +read -rp "- Sidebar max list ? " set_max_list +answer__check "$set_max_list" +[[ "$set_max_list" = *[!0-9]* ]] || \ +[[ "$set_max_list" == "0" ]] \ + && echo "! $set_max_list: invalid number..." \ + && exit + +#--------------- +# Resuming datas +#--------------- +cat << EORESUME +# New domain Values... +: Webserver: $set_server +: URL: $set_url +: Domain: $set_ndd +: Title: $set_title +: Description: $set_about +: Contact: $set_mail +: Keywords: $set_keys +: Language: $set_lang +: Copyright: $set_cr +: Logo File $set_logo +: Title List: $set_listname +: CSS Acronym: $set_css +: Ext Profile: $set_auth_url +: Sidebar list: $set_max_list + +EORESUME + +echo "# Save configuration to $domain_profile" +read -rp "- Confirm ? " set_confirm + +! [[ "$set_confirm" == [Yy] ]] \ + && echo "Abandon." \ + && exit + +domain_name="$set_ndd" +gsl_dir_domain="$gsl_dir_domains/$domain_name" +domain__create_conf + +echo +cat "$gsl_dir_help/how_to-set_directory_for_articles.md" +echo +cat "$gsl_dir_help/how_to-add_remove_authors.md" +echo +exit +} + + +#====================================================================== +# Check configuration directories from DOMAIN +# $1: lite (if exists and writeable) +# : full (Sown details in table) +# : new (Write new configuration for DOMAIN) +#====================================================================== +domain__create_conf() { +mkdir -p "$gsl_dir_domain" +mkdir -p "$gsl_dir_domains/$domain_name" +mkdir -p "$gsl_dir_domain/templates" +mkdir -p "$gsl_dir_domain/files" +mkdir -p "$gsl_dir_domain/images" +mkdir -p "$gsl_dir_domain/X-tra" +mkdir -p "$gsl_dir_domain/X-tra/sidebar" +mkdir -p "$gsl_dir_db/$domain_name" + +mkdir -p "$set_server" +mkdir -p "$set_server/$domain_name" +mkdir -p "$set_server/$domain_name/wip" +mkdir -p "$set_server/$domain_name/www" + +touch "$gsl_dir_domains/$domain_name/authors.db" + +cat << EOCONF > "$domain_profile" +site_server="$set_server" +site_url="$set_url" +site_ndd="$set_ndd" +site_title="$set_title" +site_about="$set_about" +site_mail="$set_mail" +site_keys="$set_keys" +site_lang="$set_lang" +site_cr="$set_cr" +site_logo="$set_logo" +site_listname="$set_listname" +site_css="${set_css}" +site_auth_url="$set_auth_url" +site_max_list=$set_max_list +EOCONF + +! [[ -f "$gsl_file_db_domains" ]] \ + && touch "$gsl_file_db_domains" \ + && echo "! Creating new Database domains" + +! [[ `grep "$set_ndd" "$gsl_file_db_domains"` ]] \ + && echo "$set_ndd" >> "$gsl_file_db_domains" \ + && echo "! $set_ndd added to new Database: $gsl_file_db_domains" + +echo "# Domain: $set_ndd ; configured in $domain_profile" +} diff --git a/var/lib/gsl/scripts/gsl__edit_file b/var/lib/gsl/scripts/gsl__edit_file new file mode 100644 index 0000000..2118960 --- /dev/null +++ b/var/lib/gsl/scripts/gsl__edit_file @@ -0,0 +1,62 @@ +#!/bin/bash +# file: gsl__edit_file +# Folder: /var/lib/gsl/scripts +# By echolib (XMPP: im@echolib.re) +# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + + +#====================================================================== +# Get arguments from COMMAND (edit) +# $2: FILE | conf +# $3: FILE +#====================================================================== +edit__file_OPTIONS() { +! [[ "$1" ]] \ + && gsl__invalid_option "$1" "[File]|conf|author|domain" + +case "$1" in + conf) gsl_this_post="$gsl_file_domain_conf" ;; + author) author__OPTIONS edit ;; + domain) gsl_this_post="$gsl_file_db_domains" ;; + *) if__gsl_post;if__file "$PWD/$1" post ;; +esac + +gsl_post=`basename "$gsl_this_post"` + +if ! [[ "$EDITOR" ]];then + if__command nano + EDITOR=`which nano` + EDITOR+=" --linenumbers" + +elif [[ "$EDITOR" =~ "nano" ]];then + EDITOR+=" --linenumbers" +fi + +gsl__logs_print -i -B -P \ + "edit with $EDITOR" \ + "$gsl_this_post" + +gsl_proc="edit" +article__sum "$gsl_this_post" +article_Hash_old=$article_Hash + +$EDITOR "$gsl_this_post" + +article__sum "$gsl_this_post" +if (( $article_Hash != $article_Hash_old ));then + gsl_log_infos="Changed ; Hash: $article_Hash" + gsl_log_level="-w" + +else + gsl_log_infos="Unchanged" + gsl_log_level="-i" +fi + +gsl__logs_print "$gsl_log_level" -f -e \ + "$gsl_log_infos" \ + "$gsl_this_post" + +gsl__logs_print -i -E -P \ + "edit with $EDITOR" \ + "$gsl_this_post" +} diff --git a/var/lib/gsl/scripts/gsl__log_manager b/var/lib/gsl/scripts/gsl__log_manager index f8f0f59..7074b6e 100644 --- a/var/lib/gsl/scripts/gsl__log_manager +++ b/var/lib/gsl/scripts/gsl__log_manager @@ -1,9 +1,83 @@ #!/bin/bash # file: gsl__log_manager # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + +#====================================================================== +# Get arguments from COMMAND (log) +# $2: arguments list +#====================================================================== +log__OPTIONS() { +while test "$2" +do + case "$2" in + clean|-C) + shift + if [[ "$2" == "all" ]];then + rm -f "$gsl_dir_logs/"*".gsl.log" + echo "! Clean all saved logs" + exit + fi + + [[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \ + && echo "# No logs to show. File is empty." \ + && exit + + gsl_date_logs=`date +%F-%H-%M-%S` + mv "$gsl_file_logs" "$gsl_dir_logs/$gsl_date_logs.gsl.log" + rm -f "$gsl_file_logs" + printf '%s %s %s\n' \ + "# Logs saved to" \ + "$gsl_dir_logs/$gsl_date_logs.gsl.log" \ + "and cleaned" + exit + ;; + + *) + [[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \ + && echo "# No logs to show. File is empty." \ + && exit + + case "$2" in + -s) gsl_logs_last_session=true ;; + -e) gsl_logs_err=true ;; + -i) gsl_logs_inf=true ;; + -w) gsl_logs_war=true ;; + *) gsl_logs_search="$2" ;; + esac + ;; + esac + shift +done + +gsl__logs_show +exit +} + + +#====================================================================== +# Print in log starting process +# $1; process +#====================================================================== +log__process_begin() { +gsl__logs_print -i -B -P \ + "$1" \ + "$PWD" +} + + +#====================================================================== +# Print in log ending process +# $1; oricess +#====================================================================== +log__process_end() { +gsl__logs_print -i -E -P \ + "$1" \ + "$PWD" +} + #---------------------------------------------------------------------- # Print in log file #---------------------------------------------------------------------- @@ -13,13 +87,56 @@ gsl__logs_print() { #3: Process #4: Infos #5: File -printf '%s %s\t%s\t%s\t%s\t%s\n' \ + +case "$1" in + -i) log_f1="$gsl_log_i";CL=${NC} ;; + -w) log_f1="$gsl_log_w";CL=${CY};gsl_checker_war=true ;; + -e) log_f1="$gsl_log_e";CL=${CR};gsl_checker_err=true ;; + *) log_f1="$1";; +esac + +case "$2" in + -h) log_f2="Header" ;; + -c) log_f2="Content" ;; + -g) log_f2="GSL" ;; + -B) log_f2="Starting" ;; + -E) log_f2="Stopping" ;; + -A) log_f2="Article" ;; + -srv) log_f2="Server" ;; + -st) log_f2="Stats" ;; + -R) log_f2="Removed" ;; + -D) log_f2="Database" ;; + -sdb) log_f2="Sidebar" ;; + *) log_f2="$2" ;; +esac + +case "$3" in + -c) log_f3="Created" ;; + -f) log_f3="file" ;; + -e) log_f3="Edit" ;; + -h) log_f3="Hash" ;; + -C) log_f3="Check" ;; + -M) log_f3="Make" ;; + -P) log_f3="Process" ;; + -wip) log_f3="wip" ;; + -www) log_f3="www" ;; + -src) log_f3="Source" ;; + -sk) log_f3="Skip" ;; + -inv) log_f3="Invalid" ;; + *) log_f3="$3" ;; +esac + +printf '%b%s %s %-7s\t%-7s\t%-38s\t%s\t%s\t%s%b\n' \ + "${CL}" \ "`date +%F' '%T`" \ - "$1" \ - "$2" \ - "$3" \ + "$log_f1" \ + "$log_f2" \ + "$log_f3" \ "$4" \ + "$gsl_post" \ + "$domain_name" \ "$5" \ + "${NC}" \ >> "$gsl_file_logs" } @@ -42,24 +159,25 @@ if [[ "$gsl_logs_last_session" ]];then grep -n "Starting" "$gsl_file_logs" \ | tail -1 \ | awk -F: '{print $1}'` - # echo + awk -v sl="$gsl_log_start_line" \ 'NR >= sl' \ "$gsl_file_logs" \ | grep "$gsl_logs_filter" \ | grep -Ei "$gsl_logs_search" \ - | column -t -s$'\t' + | column -t -s$'\t' -o' ' + else - while read -r "gsl_log_content" - do - # Let's read clear sessions - [[ "$gsl_log_content" =~ "Starting" ]] \ - && echo - - echo "$gsl_log_content" - done < <(cat "$gsl_file_logs" \ - | grep "$gsl_logs_filter" \ - | grep -Ei "$gsl_logs_search" \ - | column -t -s$'\t') + while read -r "gsl_log_content" + do + # Let's read clear sessions + [[ "$gsl_log_content" =~ "Starting" ]] \ + && echo + + echo "$gsl_log_content" + done < <(cat "$gsl_file_logs" \ + | grep "$gsl_logs_filter" \ + | grep -Ei "$gsl_logs_search" \ + | column -t -s$'\t' -o' ') fi } diff --git a/var/lib/gsl/scripts/gsl__new_website b/var/lib/gsl/scripts/gsl__new_website deleted file mode 100644 index 8e067d6..0000000 --- a/var/lib/gsl/scripts/gsl__new_website +++ /dev/null @@ -1,511 +0,0 @@ -#!/bin/bash -# file: gsl__new_website -# Folder: /var/lib/gsl/scripts -# By echolib -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - - -#======================================================================= -# -# Configure new WEBSITE from DOMAIN -# -#======================================================================= -gsl__new_website() { -gsl__if_file "$gsl_dir_helps/gsl_infos_new_website" read - -clear -cat $gsl_dir_helps/gsl_infos_new_website -printf '\n%s\n%s\n%s\n' \ - "# Configuration of a new website..." \ - "# Cancel with empty field" \ - "# You will be asked to confirm at the end" - -#======================================================================= -# Domain URL -#======================================================================= -printf '\n%s\n %s\n' \ - "# URL: www.example.com" \ - "(https:// will be added if missing or force with http://)" -read -rp \ - ": Website URL ? " \ - gsl_set_url - -[[ ${gsl_set_url: -1} == "/" ]] \ - && gsl_set_url=${gsl_set_url::-1} - -gsl__check_settings $gsl_set_url || return - -gsl_https='https://' -case "$gsl_set_url" in - "https://"*) - gsl_set_ndd=${gsl_set_url/$gsl_https/} - ;; - "http://"*) - gsl_http="http://" - gsl_set_ndd=${gsl_set_url/$gsl_http/} - ;; - *) - gsl_set_ndd="$gsl_set_url" - gsl_https+=$gsl_set_url - gsl_set_url=$gsl_https - ;; -esac - -# Domain NAME -gsl_set_ndd=`awk -F"." '{print $(NF-1)"."$NF}' <<< $gsl_set_ndd` -gsl_set_file_ndd="$gsl_set_ndd.conf" - -[[ -f "$gsl_dir_user_domains/$gsl_set_ndd/$gsl_set_file_ndd" ]] \ - && gsl_profile="$gsl_dir_user_domains/$gsl_set_ndd/$gsl_set_file_ndd" \ - && gsl_set_user_conf="Y" - -[[ -f "$gsl_dir_global_domains/$gsl_set_ndd/$gsl_set_file_ndd" ]] \ - && gsl_profile="$gsl_dir_global_domains/$gsl_set_ndd/$gsl_set_file_ndd" \ - && gsl_set_user_conf="N" - -if [[ "$gsl_profile" ]];then - gsl__logs_print \ - "$gsl_log_w" \ - "New" \ - "Profile" \ - "Found configuration from $gsl_set_ndd" \ - "$gsl_profile" - - echo -e "\n! A Profile exists: $gsl_profile" - read -rp ": Continue (Y|*) " gsl_continue - case "$gsl_continue" in - Y|y) - source "$gsl_profile" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "New" \ - "Profile" \ - "Load configuration from $gsl_set_ndd" \ - "$gsl_profile" - gsl_profile_exists=true - ;; - *) - return - ;; - esac -fi - -#======================================================================= -# Webserver URI -#======================================================================= -[[ $gsl_profile_exists ]] \ - && echo -e "\n# Webserver registred: $gsl_site_server" \ - || echo -e "\n# Webserver: /var/www (Or maybe elsewhere...)" - -read -erp \ - ": Webserver URI ? " \ - gsl_set_server - -[[ ${gsl_set_server: -1} == "/" ]] \ - && gsl_set_server=${gsl_set_server::-1} - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_server" ]];then - [[ "$gsl_site_server" ]] \ - && gsl_set_server="$gsl_site_server" \ - || gsl__check_settings $gsl_set_server || return - fi -else - gsl__check_settings $gsl_set_server || return -fi - -#======================================================================= -# Personal use or global use ? -#======================================================================= -if ! [[ "$gsl_set_user_conf" ]];then - echo -e "\n# Save Domain in Home or Global" - read -rp \ - ": Home Use (y/n) ? " \ - gsl_set_user_conf -fi - -case "$gsl_set_user_conf" in - y|Y) - gsl_save_dir_ndd="$gsl_dir_user_domains/$gsl_set_ndd" - gsl_save_conf_ndd="$gsl_save_dir_ndd/$gsl_set_file_ndd" - gsl_ask="# Save to $gsl_save_conf_ndd (y|*) ? " - ;; - n|N) - gsl_save_dir_ndd="$gsl_dir_global_domains/$gsl_set_ndd" - gsl_save_conf_ndd="$gsl_save_dir_ndd/$gsl_set_file_ndd" - gsl_ask="# Save to $gsl_save_conf_ndd (y|*) ? " - ;; - *) echo "! Abandon... Maybe next time" && return ;; -esac - -#======================================================================= -# Website Title -#======================================================================= -[[ $gsl_profile_exists ]] \ - && echo -e "\n# Title registred: $gsl_site_title" \ - || echo -e "\n# Title: My Compagny (or My beautiful website)" - -read -rp \ - ": Website Title ? " \ - gsl_set_title - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_title" ]];then - [[ "$gsl_site_title" ]] \ - && gsl_set_title="$gsl_site_title" \ - || gsl__check_settings $gsl_set_title || return - fi -else - gsl__check_settings $gsl_set_title || return -fi - -#======================================================================= -# Website Description -#======================================================================= -[[ $gsl_profile_exists ]] \ - && echo -e "\n# Description registred: $gsl_site_about" \ - || echo -e "\n# Description: writings about this website" - -read -rp \ - ": Website Description ? " \ - gsl_set_about - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_about" ]];then - [[ "$gsl_site_about" ]] \ - && gsl_set_about="$gsl_site_about" \ - || gsl__check_settings $gsl_set_about || return - fi -else - gsl__check_settings $gsl_set_about || return -fi - -#======================================================================= -# Contact Mail -#======================================================================= -[[ $gsl_profile_exists ]] \ - && echo -e "\n# Mail registred: $gsl_site_mail" \ - || echo -e "\n# Mail: contact@example.com" - -read -rp \ - ": Contact Mail ? " \ - gsl_set_mail - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_mail" ]];then - [[ "$gsl_site_mail" ]] \ - && gsl_set_mail="$gsl_site_mail" \ - || gsl__check_settings $gsl_set_mail || return - fi -else - gsl__check_settings $gsl_set_mail || return -fi - -#======================================================================= -# Website Keywords -#======================================================================= -if [[ $gsl_profile_exists ]];then - printf '\n%s\n %s\n' \ - "# GENERIC pages Keywords registred: $gsl_site_keys" \ - "! Will be used on each post !" -else - printf '\n%s\n %s\n' \ - "# GENERIC pages Keywords: geek stuff,free (comma separated)" \ - "! Will be used on each post !" -fi - -read -rp \ - ": Website Keywords for all Pages ? " \ - gsl_set_keys - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_keys" ]];then - [[ "$gsl_site_keys" ]] \ - && gsl_set_keys="$gsl_site_keys" \ - || gsl__check_settings $gsl_set_keys || return - fi -else - gsl__check_settings $gsl_set_keys || return -fi - -#======================================================================= -# Language -#======================================================================= -[[ $gsl_profile_exists ]] \ - && echo -e "\n# Language registred: $gsl_site_lang" \ - || echo -e "\n# Language: fr (or en-GB...)" - -read -rp \ - ": Website Lang ? " \ - gsl_set_lang - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_lang" ]];then - [[ "$gsl_site_lang" ]] \ - && gsl_set_lang="$gsl_site_lang" \ - || gsl__check_settings $gsl_set_lang || return - fi -else - gsl__check_settings $gsl_set_lang || return -fi - -#======================================================================= -# Copyright -#======================================================================= -[[ $gsl_profile_exists ]] \ - && echo -e "\n# Copyright registred: $gsl_site_cr" \ - || echo -e "\n# Copyright: 2022 TITLE CC-BY-SA" - -read -rp \ - ": Website Copyright ? " \ - gsl_set_cr - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_cr" ]];then - [[ "$gsl_site_cr" ]] \ - && gsl_set_cr="$gsl_site_cr" \ - || gsl__check_settings $gsl_set_cr || return - fi -else - gsl__check_settings $gsl_set_cr || return -fi - - -#======================================================================= -# Website Logo -#======================================================================= -if [[ $gsl_profile_exists ]];then - printf '\n%s\n %s\n' \ - "# logo registred: $gsl_site_logo" \ - "Put it in $gsl_save_dir_ndd/templates/" -else - printf '\n%s\n %s\n' \ - "# logo: my-logo.png" \ - "Put it in $gsl_save_dir_ndd/templates/" -fi - -read -rp \ - ": Website logo file NAME ? " \ - gsl_set_logo - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_logo" ]];then - [[ "$gsl_site_logo" ]] \ - && gsl_set_logo="$gsl_site_logo" \ - || gsl__check_settings $gsl_set_logo || return - fi -else - gsl__check_settings $gsl_set_logo || return -fi - - -#======================================================================= -# Last Posts listing name header -#======================================================================= -if [[ $gsl_profile_exists ]];then - printf '\n%s\n %s\n' \ - "# Title List Name registred: $gsl_site_listname" \ - "Title List to show before last posts" -else - printf '\n%s\n %s\n' \ - "# Title List Name: My Last Posts" \ - "Title List to show before last posts" -fi - -read -rp \ - ": Title List Name ? " \ - gsl_set_listname - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_listname" ]];then - [[ "$gsl_site_listname" ]] \ - && gsl_set_listname="$gsl_site_listname" \ - || gsl__check_settings $gsl_set_listname || return - fi -else - gsl__check_settings $gsl_set_listname || return -fi - -#======================================================================= -# CSS Acronym -#======================================================================= -if [[ $gsl_profile_exists ]];then - printf '\n%s\n %s\n' \ - "# CSS (short) Acronym registred: $gsl_site_css" \ - "Will create specific HTML classes like ${gsl_site_css}_paragraph" -else - printf '\n%s\n %s\n' \ - "# CSS (short) Acronym: myweb !No need to end with _" \ - "Will create specific HTML classes like myweb_paragraph" -fi - -read -rp \ - ": CSS Acronym ? " \ - gsl_set_css - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_css" ]];then - [[ "$gsl_site_css" ]] \ - && gsl_set_css="$gsl_site_css" \ - || gsl__check_settings $gsl_set_css || return - fi -else - gsl__check_settings $gsl_set_css || return -fi - -#======================================================================= -# Author Reference -#======================================================================= -if [[ $gsl_profile_exists ]];then - printf '\n%s\n %s\n' \ - "# Author/Compagny URL Profile registred: $gsl_site_auth_url" \ - "Used for meta rel='me'" -else - printf '\n%s\n %s\n' \ - "# Author/Compagny URL Profile: https://..." \ - "Used for meta rel='me'" -fi - -read -rp \ - ": Author URL Profile ? " \ - gsl_set_auth_url - -if [[ $gsl_profile_exists ]];then - if ! [[ "$gsl_set_auth_url" ]];then - [[ "$gsl_site_auth_url" ]] \ - && gsl_set_auth_url="$gsl_site_auth_url" \ - || gsl__check_settings $gsl_set_auth_url || return - fi -else - gsl__check_settings $gsl_set_auth_url || return -fi - -#======================================================================= -# Folder for Posts -#======================================================================= -printf '\n%s\n %s\n %s\n' \ - "# You can set here a folder for your writings' Posts" \ - "Leave Empty to manually do it later (see help)" \ - "Autocompletion /NEWFOLDER (name of choice)" - -read -erp \ - ": Where will you add your files' [post].gsl ? " \ - gsl_dir_user_posts - -#======================================================================= -# Show Resume -#======================================================================= -clear -printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ - "# New Website configurations..." \ - ": Webserver|$gsl_set_server" \ - ": URL|$gsl_set_url" \ - ": Domain|$gsl_set_ndd" \ - ": Title|$gsl_set_title" \ - ": Description|$gsl_set_about" \ - ": Contact|$gsl_set_mail" \ - ": Keywords|$gsl_set_keys" \ - ": Language|$gsl_set_lang" \ - ": Copyright|$gsl_set_cr" \ - ": Logo File|$gsl_set_logo" \ - ": Title List|$gsl_set_listname" \ - ": CSS Acro|$gsl_set_css" \ - ": Author URL|$gsl_set_auth_url" \ - ": User folder writings' Posts|$gsl_dir_user_posts" \ - | column -t -s'|' - - -#======================================================================= -# Ask to Confirm -#======================================================================= -echo -read -rp "$gsl_ask " gsl_set_confirm - -case "$gsl_set_confirm" in - y|Y) - gsl__logs_print \ - "$gsl_log_w" \ - "New" \ - "Profile" \ - "Confirmed configuration from $gsl_set_ndd" \ - "$gsl_save_conf_ndd" - - if ! [[ -d "$gsl_save_dir_ndd" ]];then - mkdir -p "$gsl_save_dir_ndd" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "New" \ - "Profile" \ - "Create Folder configuration for $gsl_set_ndd" \ - "$gsl_save_dir_ndd/" - fi - - # Create et set a folder for writings' posts - if [[ $gsl_dir_user_posts ]];then - mkdir -p "$gsl_dir_user_posts" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "New" \ - "Profile" \ - "Create Folder Posts for $gsl_set_ndd" \ - "$gsl_dir_user_posts/" - - touch "$gsl_dir_user_posts/gsl.$gsl_set_ndd" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "New" \ - "Profile" \ - "Folder set with gsl.$gsl_set_ndd" \ - "$gsl_dir_user_posts/" - fi - ;; - - *) - return - ;; -esac - -#======================================================================= -# Save config -#======================================================================= -printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ - "gsl_site_server=\"$gsl_set_server\"" \ - "gsl_site_url=\"$gsl_set_url\"" \ - "gsl_site_ndd=\"$gsl_set_ndd\"" \ - "gsl_site_title=\"$gsl_set_title\"" \ - "gsl_site_about=\"$gsl_set_about\"" \ - "gsl_site_mail=\"$gsl_set_mail\"" \ - "gsl_site_keys=\"$gsl_set_keys\"" \ - "gsl_site_lang=\"$gsl_set_lang\"" \ - "gsl_site_cr=\"$gsl_set_cr\"" \ - "gsl_site_logo=\"$gsl_set_logo\"" \ - "gsl_site_listname=\"$gsl_set_listname\"" \ - "gsl_site_css=\"$gsl_set_css\"" \ - "gsl_site_auth_url=\"$gsl_set_auth_url\"" \ - > "$gsl_save_conf_ndd" && \ -gsl__logs_print \ - "$gsl_log_w" \ - "New" \ - "Profile" \ - "Write configuration for $gsl_set_ndd" \ - "$gsl_save_conf_ndd" - -if ! [[ `grep "$gsl_save_dir_ndd" "$gsl_file_db_domains"` ]];then - echo "$gsl_save_dir_ndd" >> "$gsl_file_db_domains" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "New" \ - "Profile" \ - "Add $gsl_save_dir_ndd to DB for $gsl_set_ndd" \ - "$gsl_file_db_domains" -fi -} - -#======================================================================= -# Check if no Response from $@ -#======================================================================= -gsl__check_settings() { -[[ "$@" ]] && return -echo "! Abandon... Maybe next time" -exit -} diff --git a/var/lib/gsl/scripts/gsl__page_creator b/var/lib/gsl/scripts/gsl__page_creator deleted file mode 100644 index a452876..0000000 --- a/var/lib/gsl/scripts/gsl__page_creator +++ /dev/null @@ -1,295 +0,0 @@ -#!/bin/bash -# file: gsl__page_creator -# Folder: /var/lib/gsl/scripts -# By echolib -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - -#---------------------------------------------------------------------- -# -------------------------------------------------- -# From: gsl__all_makers | Create HTML Page -# -------------------------------------------------- -#---------------------------------------------------------------------- - -#---------------------------------------------------------------------- -# MAIN -#---------------------------------------------------------------------- -gsl__page_creator() { -#gsl__page_prepare_datas -gsl__check_templates -gsl__html_meta_head -gsl__page_create - -# Show html result in terminal -#cat -n "$gsl_srv_wip_page" -} - -#====================================================================== -# Sync Files from Templates to webserver -#====================================================================== -gsl__srv_sync() { -# Sync Files and Folders -mkdir -p "$1" -for folder in `find $gsl_this_conf_domain/* -type d` -do - rsync -a --delete "$folder" "$1" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Server" \ - "Sync" \ - "$folder" \ - "$1" -done -} - -#---------------------------------------------------------------------- -# Get Datas for Post/Page -#---------------------------------------------------------------------- -gsl__page_prepare_datas() { -# Set wip folder from domain -gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" -gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www" - -# Post or Page -case "$gsl_post_type" in - post) - gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug/index.html" - gsl_srv_www_page="$gsl_srv_www/$gsl_header_slug/index.html" - gsl__check_srv_files "$gsl_srv_wip_page" wip - gsl__check_srv_files "$gsl_srv_www_page" www - gsl_uri=".." - ;; - page) - gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug.html" - gsl_srv_www_page="$gsl_srv_www/$gsl_header_slug.html" - gsl__check_srv_files "$gsl_srv_wip_page" wip - gsl__check_srv_files "$gsl_srv_www_page" www - gsl_uri="." - ;; -esac - -gsl_uri_site_logo="$gsl_uri/templates/$gsl_site_logo" -} - -#---------------------------------------------------------------------- -# Check if Post / Pages exists in server -#---------------------------------------------------------------------- -gsl__check_srv_files() { -if [[ -f "$1" ]];then - gsl__logs_print \ - "$gsl_log_i" \ - "SRV" \ - "$2" \ - "$gsl_post_type $gsl_post exists" \ - "$1" - -else - gsl__logs_print \ - "$gsl_log_w" \ - "SRV" \ - "$2" \ - "$gsl_post_type $gsl_post not yet created" \ - "$1" - gsl_checker_war=true -fi -} - -#---------------------------------------------------------------------- -# Create Final HTML Post/Page -#---------------------------------------------------------------------- -gsl__page_create() { -cat << EOPAGE > "$gsl_srv_wip_page" - - - -`cat "$gsl_html_meta"` - - - - -`cat "$gsl_dir_domain_tpl/header.html"` - -
    -
    - -
    -

    Écrit par $gsl_header_author le $gsl_header_date

    -
    - -`cat "$gsl_a11y_post"` -
    - - -
    - -`cat "$gsl_dir_domain_tpl/footer.html"` - - - -EOPAGE - -gsl__logs_print \ - "$gsl_log_w" \ - "SRV" \ - "wip" \ - "$gsl_post_type $gsl_post created" \ - "$gsl_srv_wip_page" -gsl_checker_war=true - -# No more needed html meta file -rm -f "$gsl_html_meta" -} - -#---------------------------------------------------------------------- -# Create META head for Post/Page -#---------------------------------------------------------------------- -gsl__html_meta_head() { -# Create file with metas to be included in Post/Page -gsl_html_meta=`mktemp` -cat << EOMETAS >> "$gsl_html_meta" - - - - - - - - $gsl_header_title - $gsl_site_title - - - - - - - - - - - - -EOMETAS -} - -#----------------------------------------------------------------------- -# Create Generic Header -#----------------------------------------------------------------------- -gsl__html_header() { -cat << EOHEADER >> "$gsl_dir_domain_tpl/header.html" -
    - -
    -

    - - $gsl_site_title - -

    -

    $gsl_site_info

    -
    -
    -EOHEADER -} - -#----------------------------------------------------------------------- -# Create Generic Footer -#----------------------------------------------------------------------- -gsl__html_footer() { -cat << EOFOOTER >> "$gsl_dir_domain_tpl/header.html" -
    -
    -EOFOOTER -} - -#----------------------------------------------------------------------- -# Check for files in templates folder -#----------------------------------------------------------------------- -gsl__check_templates() { -# Create generic HEADER if not exists -! [[ "$gsl_dir_domain_tpl/header.html" ]] \ - && gsl__html_header - -# Create generic FOOTER if not exists -! [[ "$gsl_dir_domain_tpl/footer.html" ]] \ - && gsl__html_footer -} - -#====================================================================== -# Sidebar Posts list Manager | $1=Process | $2=Position | $3=Post -#====================================================================== -gsl__page_sidebar() { -gsl_post="$gsl_this_post" -gsl__post_begin -gsl__get_needed_headers -gsl__page_prepare_datas - -if [[ -f "$gsl_srv_wip_page" ]] || - [[ -f "$gsl_srv_www_page" ]];then - gsl__logs_print \ - "$gsl_log_i" \ - "Sidebar" \ - "$gsl_listing_process" \ - "to list, position $2 ; $3 from domain $gsl_find_domain" \ - "$gsl_listing_file.$2" -else - gsl__logs_print \ - "$gsl_log_i" \ - "Sidebar" \ - "$gsl_listing_process" \ - "make $3 from domain $gsl_find_domain first" \ - "$gsl_dir_domain_listings/" - return -fi - -case "$gsl_post_type" in - post) gsl_bpost_url="$gsl_header_slug/index.html" ;; - page) gsl_bpost_url="$gsl_header_slug.html" ;; -esac - -touch "$gsl_listing_file.$2" -cat << EOPostSide > "$gsl_listing_file.$2" -
  • - $gsl_header_title - - -
  • -EOPostSide - -gsl__page_sidebar_create -} - -#====================================================================== -# Sidebar Create from list in X-tra to file last-posts-list.html -#====================================================================== -gsl__page_sidebar_create() { -[[ -f "$gsl_dir_domain_tpl/last-posts-list.html" ]] \ - && rm -f "$gsl_dir_domain_tpl/last-posts-list.html" - -touch "$gsl_dir_domain_tpl/last-posts-list.html" && \ -gsl__logs_print \ - "$gsl_log_w" \ - "Sidebar" \ - "Create" \ - "Build new list" \ - "$gsl_dir_domain_tpl/last-posts-list.html" - -gsl_checker_war=true -while read -r "postroller" -do - cat "$gsl_dir_domain_listings/$postroller" \ - >> "$gsl_dir_domain_tpl/last-posts-list.html" -done < <(ls -1X "$gsl_dir_domain_listings/") -} diff --git a/var/lib/gsl/scripts/gsl__post_checkers b/var/lib/gsl/scripts/gsl__post_checkers index 8d535b4..c5f6cfa 100644 --- a/var/lib/gsl/scripts/gsl__post_checkers +++ b/var/lib/gsl/scripts/gsl__post_checkers @@ -1,613 +1,826 @@ #!/bin/bash # file: gsl__post_checkers # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -#---------------------------------------------------------------------- -# -------------------------------------------------- -# From: gsl__loop_posts | MAIN checkers from modules -# -------------------------------------------------- -#---------------------------------------------------------------------- -gsl__all_checkers() { -# Init Stats -gsl_stat_abbr=0 -gsl_stat_abbrs=0 -gsl_stat_link=0 -gsl_stat_links=0 -gsl_stat_file=0 -gsl_count_files=0 -gsl_stat_image=0 -gsl_stat_fcode=0 -gsl_db_tmp=`mktemp` +#====================================================================== +# Get arguments from COMMAND (check) +# $2 -F (to force) or File +# $3 File +#====================================================================== +check__OPTIONS() { +gsl_proc="check" -gsl__check_h1 || return -gsl__post_content_only +while test "$2" +do + case "$2" in + -F) + gsl_force_check=true + log_info_force="Force " + ;; + + -N) + unset gsl_force_check + gsl_check_newer=true + ;; -gsl__check_type -gsl__check_headers -gsl__check_paragraphs "$gsl_tmp_post" -gsl__check_blockquote "$gsl_tmp_post" + *".gsl") + if__file "$2" post + gsl_post="$2" + post_only="$2" + ;; -gsl__do_header check "$gsl_marker_link" "$gsl_post" -gsl__do_header check "$gsl_marker_abbr" "$gsl_post" -gsl__do_header check "$gsl_marker_file" "$gsl_post" -gsl__do_header check "$gsl_marker_image" "$gsl_post" -gsl__do_header check "$gsl_marker_code" "$gsl_post" -gsl__stat_words "$gsl_tmp_post" -gsl__do_strongs_bolds stats "$gsl_tmp_post" -gsl__do_italics stats "$gsl_tmp_post" -gsl__do_icode stats "$gsl_tmp_post" + *) + gsl__invalid_option "$2" "-F|-N|(FILE)" + ;; + esac +shift +done -rm -f "$gsl_tmp_post" +if ! [[ "$gsl_post" ]];then + log_info_all=" ALL" + [[ $gsl_check_newer ]] \ + && log_info_all+=" NEWER" +fi -echo -ne "\r\033[2K" +log__process_begin "${log_info_force}Check${log_info_all}" +posts__loop check -gsl__db_set_post_status chk -rm -f "$gsl_db_tmp" +# For logs ; set post or unset if all +[[ $log_info_all ]] && unset gsl_post +[[ $post_only ]] && gsl_post="$post_only" + +log__process_end "${log_info_force}Check${log_info_all}" } + +#====================================================================== +# From post__loop() ; get and CHECK headers values +# Called from read__line_with() in gsl__do_commons +# $1: marker +# $2: type (meta/metas) +#====================================================================== +check__headers_from_filter() { +case "$4" in + meta) + check__meta_header "$3" + ;; + + metas|content) + case "$3" in + "title") check__titles ;; + "link") check__link ;; + "abbr") check__abbr ;; + "image") check__file_image ;; + "flink") check__file_link ;; + "fcode") check__file_code ;; + "fbrut") check__file_brut ;; + "icode") check__icode ;; + "strong") check__strong ;; + "bold") check__bold ;; + "em") check__emphasis ;; + "strike") check__strike ;; + esac + ;; +esac +} + + +#====================================================================== +# Call in posts_loop() for process before Checkers() +# Check if error in meta marker +# From get__needed_headers() in gsl__do_commons +# $1: marker +#====================================================================== +check__meta_header() { +if ! [[ "$header_f1" ]];then + gsl__logs_print -e -h \ + "$1" \ + "Not set" \ + "$PWD/$gsl_post" + return 1 +fi + +case "$1" in + "$gsl_marker_type") + gsl_post_type="$header_f1" + + case "$gsl_post_type" in + page|post) + gsl__logs_print -i -h \ + "$1" \ + "Set to '$gsl_post_type'" \ + "${PWD}/$gsl_post" + ;; + *) + gsl__logs_print -e -h \ + "$1" \ + "Wrong '$gsl_post_type' ; $gsl_log_act_type" \ + "${PWD}/$gsl_post" + ;; + esac + ;; + + "$gsl_marker_css") + gsl_post_css=" $header_f1" + gsl__logs_print -i -h \ + "$1" \ + "Body template: $header_f1" \ + "$PWD/$gsl_post" + ;; + + "$gsl_marker_title") + gsl_post_title="$header_f1" + ;; + + "$gsl_marker_date") + gsl_post_date="$header_f1" + if [[ `grep -i "fr" <<<"$site_lang"` ]];then + gsl_test_date='^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]+$' + gsl_log_content="DD-MM-YYYY" + else + gsl_test_date='^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]+$' + gsl_log_content="YYYY-MM-DD" + fi + + if [[ "$gsl_post_date" =~ $gsl_test_date ]];then + gsl_date_m=`awk -F- '{print $2}' <<<"$gsl_post_date"` + (( "$gsl_date_m" > 12 )) \ + && gsl__logs_print -e -h \ + "$1" \ + "'$gsl_post_date' ; Month: $gsl_date_m > 12..." \ + "${PWD}/$gsl_post" + else + gsl__logs_print -e -h \ + "$1" \ + "Mismatch '$gsl_post_date' ; not $gsl_log_content" \ + "${PWD}/$gsl_post" + fi + + # timestamp date to db too (sidebar sort) + false_time=`date +%T` + if [[ `grep -i "fr" <<<"$site_lang"` ]];then + gsl_date_y=`awk -F- '{print $3}' <<<"$gsl_post_date"` + gsl_date_d=`awk -F- '{print $1}' <<<"$gsl_post_date"` + + else + gsl_date_y=`awk -F- '{print $1}' <<<"$gsl_post_date"` + gsl_date_d=`awk -F- '{print $3}' <<<"$gsl_post_date"` + fi + date_epoch="$gsl_date_y-$gsl_date_m-$gsl_date_d $false_time" + date_epoch=`date +%s -u -d "$date_epoch"` + ;; + + "$gsl_marker_slug") + gsl_post_slug="$header_f1" + gsl_post_slug_src="$gsl_post_slug" + gsl_hash_slug_src=`cksum <<<"$gsl_post_slug_src"` + + # Type page with "/" in + if [[ "$gsl_post_type" == "page" ]] && \ + [[ `grep '/' <<<"$gsl_post_slug"` ]];then + gsl_post_slug=${gsl_post_slug////-} + gsl__logs_print -w -h \ + "$1" \ + "Has '/' for type $gsl_post_type ; Replaced with '-'" \ + "${PWD}/$gsl_post" + fi + + # Ensure no ending / for slug + gsl_post_slug=${gsl_post_slug/%\//} + + # Has space + gsl_post_slug=${gsl_post_slug// /-} + gsl_hash_slug=`cksum <<<"$gsl_post_slug"` + if ! [[ "$gsl_hash_slug" == "$gsl_hash_slug_src" ]];then + mark_slug_src="$gsl_marker_slug $gsl_post_slug_src" + mark_slug_new="$gsl_marker_slug $gsl_post_slug" + sed -i \ + "s^$mark_slug_src^$mark_slug_new^" \ + "$gsl_post" + gsl__logs_print -w -h \ + "$1" \ + "Changed to: '$gsl_post_slug'" \ + "${PWD}/$gsl_post" + + article__sum "$gsl_post" + fi + + # Already used slug + while read -r "file_db" + do + gsl_slug_db_hash=` + awk -F= '/article_Hash_DB/ {print $2}' \ + "$file_db"` + gsl_slug_db_type=` + awk -F= '/article_Type/ {print $2}' \ + "$file_db"` + + ! [[ "$gsl_slug_db_type" == "$gsl_post_type" ]] \ + && continue + + [[ "$gsl_slug_db_hash" == "$article_Hash_DB" ]] \ + && continue + + gsl__logs_print -e -h \ + "$1" \ + "'$header_f1' already in use ; change it" \ + "$file_db" + break + done < <(grep -sl "article_Slug=\"$gsl_post_slug\"" \ + $gsl_dir_db_domain/*.db) + ;; + + "$gsl_marker_author") + gsl_post_author="$header_f1" + if ! [[ `grep "^$gsl_post_author$" "$gsl_file_domain_authors"` ]];then + gsl__logs_print -e -h \ + "$1" \ + "'$gsl_post_author' ; not registred !" \ + "${PWD}/$gsl_post" + fi + ;; + + "$gsl_marker_info") + gsl_post_info="$header_f1" + if (( ${#gsl_post_info} <= 18 ));then + gsl__logs_print -w -h \ + "$1" \ + "'$gsl_post_info' ; not too short ?" \ + "${PWD}/$gsl_post" + fi + ;; + + "$gsl_marker_tags") + gsl_post_tags="$header_f1" + gsl_stat_tags=`awk -F, '{print NF}' <<<$gsl_post_tags` + ;; +esac +} + + +#====================================================================== +# -------------------------------- +# Do all checkers From: loop_posts +# -------------------------------- +#====================================================================== +Checkers() { +get__needed_headers "check" "$gsl_tmp_head" +! [[ $gsl_do_check ]] && return + +stats__init # init stats values +gsl_tmp_db=`mktemp` # Create tmp DB for found files to add then to DB + +# Check for links +read__line_with "^$gsl_marker_link" "check" \ + "link" "metas" "$gsl_tmp_head" + +# Check abbrs +read__line_with "^$gsl_marker_abbr" "check" \ + "abbr" "metas" "$gsl_tmp_head" + +# Check images +read__line_with "^$gsl_marker_image" "check" \ + "image" "metas" "$gsl_tmp_head" + +# Check files +read__line_with "^$gsl_marker_flink" "check" \ + "flink" "metas" "$gsl_tmp_head" + +# Check filesCODE +read__line_with "^$gsl_marker_fcode" "check" \ + "fcode" "metas" "$gsl_tmp_head" + +# Check for brut code file +read__line_with "^$gsl_marker_fbrut" "check" \ + "fbrut" "metas" "$gsl_tmp_head" + +# Check for content titles +read__line_with "^#[1-6]" "check" \ + "title" "content" "$gsl_tmp_post" + +# Check icode marks match +read__line_with "$gsl_mark_icode" "check" \ + "icode" "content" "$gsl_tmp_post" + +# Check strong marks match +read__line_with "$gsl_mark_strong" "check" \ + "strong" "content" "$gsl_tmp_post" + +# Check bold marks match +read__line_with "$gsl_mark_bold" "check" \ + "bold" "content" "$gsl_tmp_post" + +# Check emphasis marks match +read__line_with "$gsl_mark_em" "check" \ + "em" "content" "$gsl_tmp_post" + +# Check strike (line-through) marks match +read__line_with "$gsl_mark_strike" "check" \ + "strike" "content" "$gsl_tmp_post" + +# Independant modules +check__paragraphs "$gsl_tmp_post" # Check for paragraphs markers +check__lists "$gsl_tmp_post" # Check for lists markers +check__blockquote "$gsl_tmp_post" # Check for blockquote markers + +# Errors => remove from DB and srv WIP +[[ "$gsl_checker_err" ]] \ + && article_Errors="yes" \ + || article_Errors="no" + +Stat__words "$gsl_tmp_post" +DB__set_status chk + +# Remove temp files +rm -f "$gsl_tmp_post" \ + "$gsl_tmp_head" \ + "$gsl_tmp_db" +} + + #---------------------------------------------------------------------- # ------------------------------------------------- # Modules checkers # ------------------------------------------------- #---------------------------------------------------------------------- #====================================================================== -# Check Post for begining content +# Checking titles #====================================================================== -gsl__check_h1() { -echo -ne ": Searching for begining #1..." +check__titles() { +((gsl_stat_titles++)) +mark_title=`awk '{print $1}' <<<"$gsl_line"` +content_title=`awk '{print $2}' <<<"$gsl_line"` +post_ln=$((ln + gsl_post_begin - 1)) -gsl_post_begin=` -grep -n "#1" $gsl_post \ - | head -1 \ - | awk -F: '{print $1}'` +[[ "$content_title" ]] && return -if ! [[ "$gsl_post_begin" ]];then - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "Begins" \ - "Unused: #1 TITLE" \ - "${PWD}/$gsl_post" - gsl_checker_err=true -fi +gsl__logs_print -e -c \ + "Title" \ + "Line: $post_ln ; No content for $mark_title" \ + "${PWD}/$gsl_post" } -#====================================================================== -# Check/Set Post Type -#====================================================================== -gsl__check_type() { -echo -ne "\r\033[2K: Searching for Post TYPE..." -case "$gsl_post_type" in - page|post) - gsl__logs_print \ - "$gsl_log_i" \ - "Header" \ - "$gsl_marker_type" \ - "$gsl_post Set as $gsl_post_type" \ +#====================================================================== +# Check link +#====================================================================== +check__link() { +if ! [[ "$header_f1" && "$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_link" \ + "Line: $ln not set ; $gsl_log_act_link" \ + "${PWD}/$gsl_post" + return +fi + +if ! [[ "$header_f3" ]];then + gsl__logs_print -w -h \ + "$gsl_marker_link" \ + "Line: $ln No Alt-Text ; $gsl_log_act_link" \ "${PWD}/$gsl_post" +fi + +if ! [[ `grep "\<_$header_f1\>" "$gsl_tmp_post"` ]];then + gsl__logs_print -e -c \ + "$gsl_marker_link" \ + "Line: $ln ; Unused: '_$header_f1'" \ + "${PWD}/$gsl_post" + return +fi + +# Get Online status +case "$header_f2" in + "http"*) + url_status=` + timeout 2 \ + curl -o /dev/null --silent --head --write-out \ + '%{http_code}' \ + "$header_f2" 2>/dev/null \ + || url_status="T"` ;; + *) - gsl_post_type="post" - sed -i "1i$gsl_marker_type$gsl_post_type" \ - "$gsl_post" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "Header" \ - "$gsl_marker_type" \ - "$gsl_post Set as Default $gsl_post_type" \ - "${PWD}/$gsl_post" - gsl__get_sum "$gsl_post" + url_status=NS ;; esac -} -#====================================================================== -# Check for paragraphs ( and ) | $1: File -#====================================================================== -gsl__check_paragraphs() { -echo -ne "\r\033[2K: Searching for Paragraphs..." +# Analyse Online Status +case "$url_status" in + 1*|2*|3*) + gsl__logs_print -i -h \ + "$gsl_marker_link" \ + "Online: $url_status ; ${header_f2:0:30}..." \ + "${PWD}/$gsl_post" + ((gsl_stat_links_online++)) + ;; -gsl_post_p_open=` -awk -v op="$gsl_mo_p" \ - '$1 == op' \ - "$1" \ - | wc -l` - -gsl_post_p_close=` -awk -v cp="$gsl_mc_p" \ - '$1 == cp' \ - "$1" \ - | wc -l` - -if (( "$gsl_post_p_open" == 0 ));then - - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "Paragraphs" \ - "Unused: ( and ) at begining lines" \ - "${PWD}/$gsl_post" - gsl_checker_err=true - return - -fi - -if (( "$gsl_post_p_open" == "$gsl_post_p_close" ));then - - gsl_stat_p="$gsl_post_p_open" + NS) + gsl__logs_print -w -h \ + "$gsl_marker_link" \ + "No status ; ${header_f2:0:30}..." \ + "${PWD}/$gsl_post" + ;; -else + T) + gsl__logs_print -w -h \ + "$gsl_marker_link" \ + "Timeout ; ${header_f2:0:30}..." \ + "${PWD}/$gsl_post" + ;; - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ + ""|*) + gsl__logs_print -w -h \ + "$gsl_marker_link" \ + "Offline: $url_status ; ${header_f2:0:30}..." \ + "${PWD}/$gsl_post" + ;; +esac + +# Stat: Count +((gsl_stat_links++)) +} + + +#====================================================================== +# Check paragraphs markers +#====================================================================== +check__paragraphs() { +gsl_post_po=` +grep "^$gsl_mark_p_start$\|^$gsl_mark_p_start " "$1" \ + | wc -l` +gsl_post_pc=` +grep "^$gsl_mark_p_close$" "$1" \ + | wc -l` + +if (( "$gsl_post_po" == 0 ));then + gsl__logs_print -w -c \ "Paragraphs" \ - "Mismatch: (=$gsl_post_p_open ; )=$gsl_post_p_close" \ + "Unused '$gsl_mark_p_start' & '$gsl_mark_p_close' at begining lines" \ "${PWD}/$gsl_post" - gsl_checker_err=true - return - -fi -} - -#====================================================================== -# Check for blockquotes: --- | $1: File -#====================================================================== -gsl__check_blockquote() { -echo -ne "\r\033[2K: Searching for BLOCKQUOTEs..." - -gsl_post_blockquotes_nbr=` -awk -v bq="$gsl_mark_blockquote" \ - '$1 == bq' \ - "$1" \ - | wc -l` - -gsl_post_blockquotes_nbr_r=$(( $gsl_post_blockquotes_nbr % 2 )) - -if [[ "$gsl_post_blockquotes_nbr_r" -eq 0 ]];then - - gsl_stat_bq=$(( $gsl_post_blockquotes_nbr / 2 )) - -else - - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "Citations" \ - "Mismatch: --- not paired" \ - "${PWD}/$gsl_post" - gsl_checker_err=true -fi -} - -#====================================================================== -# From gsl__do_header: Check Link -#====================================================================== -gsl__check_link() { -# Get & Check Header CONTENT -gsl__check_header_fields \ - "Header" "$gsl_marker_link" "$gsl_log_act_link" \ -|| return - -echo -ne "\r\033[2K: Searching for Links... $gsl_post_hf_1" - -# No ALT TEXT ? -gsl__check_header_field3 "Header" "$gsl_marker_link" - -gsl_count_links=` -gsl__get_content_line "_$gsl_post_hf_1" "$gsl_post" | wc -l` - -if (( "$gsl_count_links" > 0 ));then - - # Check URL - case "$gsl_post_hf_2" in - http*) - gsl_url_status=` - timeout 2 curl -o /dev/null --silent --head --write-out \ - '%{http_code}' \ - "$gsl_post_hf_2" 2>/dev/null` - ;; - *) - gsl_url_status=408 - ;; - esac - - case "$gsl_url_status" in - 1*|2*|3*) - gsl__logs_print \ - "$gsl_log_i" \ - "Header" \ - "$gsl_marker_link" \ - "Online:$gsl_url_status ${gsl_post_hf_2:0:40}..." \ - "${PWD}/$gsl_post" - ;; - 4*) - gsl__logs_print \ - "$gsl_log_w" \ - "Header" \ - "$gsl_marker_link" \ - "Not checked: ${gsl_post_hf_2:0:40}..." \ - "${PWD}/$gsl_post" - gsl_checker_war=true - ;; - ""|*) - gsl__logs_print \ - "$gsl_log_w" \ - "Header" \ - "$gsl_marker_link" \ - "Offline:$gsl_url_status ${gsl_post_hf_2:0:40}..." \ - "${PWD}/$gsl_post" - - # Decomment below if you want the offline link avoiding convertion - #gsl_checker_err=true - gsl_checker_war=true - return - ;; - esac - - # Stats - ((gsl_stat_link++)) - gsl_stat_links=$(( gsl_stat_links + gsl_count_links )) - -else - - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "Link" \ - "Unused: _$gsl_post_hf_1" \ - "${PWD}/$gsl_post" - gsl_checker_err=true - -fi -} - -#====================================================================== -# From gsl__do_header: Check ABBR -#====================================================================== -gsl__check_abbr() { -gsl__check_header_fields \ - "Content" "$gsl_log_h_abbr" "$gsl_log_act_abbr" \ -|| return - -echo -ne "\r\033[2K: Searching for ABBRs... $gsl_post_hf_1" - -gsl_count_abbrs=` -gsl__get_content_line "$gsl_post_hf_1" "$gsl_post" | wc -l` - -if (( "$gsl_count_abbrs" > 0 ));then + gsl_stat_p="0" - ((gsl_stat_abbr++)) - gsl_stat_abbrs=$(( gsl_stat_abbrs + gsl_count_abbrs )) +elif (( "$gsl_post_po" == "$gsl_post_pc" ));then + gsl_stat_p="$gsl_post_po" else + gsl__logs_print -e -c \ + "Paragraphs" \ + "Mismatch '$gsl_mark_p_start' & '$gsl_mark_p_close' ; not paired" \ + "${PWD}/$gsl_post" +fi +} - # Missing CONTENT - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ + +#====================================================================== +# Check paragraphs markers +#====================================================================== +check__lists() { +gsl_post_lo=`grep "^<<$\|^<< " "$1" | wc -l` +gsl_post_lc=`grep "^>>$" "$1" | wc -l` + +if (( "$gsl_post_lo" == "$gsl_post_lc" ));then + gsl_stat_lists="$gsl_post_lo" + +else + gsl__logs_print -e -c \ + "Lists" \ + "Mismatch '<<' & '>>' ; not paired" \ + "${PWD}/$gsl_post" +fi +} + + +#====================================================================== +# Check blockquotes markers +#====================================================================== +check__blockquote() { +gsl_post_bq=`grep "^$gsl_mark_blockquote" "$1" | wc -l` +gsl_post_bq_paired=$(( $gsl_post_bq % 2 )) + +if [[ "$gsl_post_bq_paired" -eq 0 ]];then + gsl_stat_bq=$(( gsl_post_bq / 2 )) + +else + gsl__logs_print -e -c \ + "Blockquote" \ + "Mismatch: '$gsl_mark_blockquote' ; not paired" \ + "${PWD}/$gsl_post" +fi +} + + +#====================================================================== +# Check ABBR +#====================================================================== +check__abbr() { +if ! [[ "$header_f1" && "$header_f2" ]];then + gsl__logs_print -e -h \ "$gsl_marker_abbr" \ - "Unused: $gsl_post_header_field_1" \ + "Line: $ln not set ; $gsl_log_act_abbr" \ "${PWD}/$gsl_post" - gsl_checker_err=true +# must be in caps lock +elif ! [[ "$header_f1" == ${header_f1^^} ]];then + gsl__logs_print -e -c \ + "$gsl_marker_abbr" \ + "Line: $ln ; '$header_f1' not UPPER case" \ + "${PWD}/$gsl_post" + +# ! forget space ↓ +elif ! [[ `grep -E " $header_f1|^$header_f1 " "$gsl_tmp_post"` ]];then + gsl__logs_print -e -c \ + "$gsl_marker_abbr" \ + "Line: $ln ; Unused: '$header_f1'" \ + "${PWD}/$gsl_post" + +else + ((gsl_stat_abbrs++)) fi } + #====================================================================== -# From gsl__do_header: Check Files +# Check Flink #====================================================================== -gsl__check_file() { -gsl__check_header_fields \ - "Content" "$gsl_log_h_file" "$gsl_log_act_file" \ -|| return - -echo -ne "\r\033[2K: Searching for Content Files... $gsl_post_hf_1" - -gsl__check_header_field3 "Content" "$gsl_log_h_file" "$gsl_marker_file" - -# File exists in folder -if ! [[ -f "$gsl_dir_domain_files/$gsl_post_hf_2" ]];then - - gsl__logs_print \ - "$gsl_log_e" \ - "Header" \ - "$gsl_marker_file" \ - "Not found: $gsl_post_hf_2" \ - "$gsl_dir_domain_files/$gsl_post_hf_2" - gsl_checker_err=true - -else - -# Register file to DB with hash - gsl_file_csum=` - cksum "$gsl_dir_domain_files/$gsl_post_hf_2" \ - | awk '{print $1}'` - - printf '%s\n' \ - "File:$gsl_dir_domain_images/$gsl_post_hf_2:$gsl_file_csum" \ - >> "$gsl_db_tmp" - -fi - -# Exists in Content -gsl_count_files=` -gsl__get_content_line "__$gsl_post_hf_1" "$gsl_post" | wc -l` - -if (( $gsl_count_files > 0 ));then - - ((gsl_stat_file++)) - -else - - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "$gsl_log_c_file" \ - "Unused: __$gsl_post_hf_1" \ +check__file_link() { +if ! [[ "$header_f1" && "$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_flink" \ + "Line: $ln not set ; $gsl_log_act_flink" \ "${PWD}/$gsl_post" - gsl_checker_err=true - + return fi + +if ! [[ "$header_f3" ]];then + gsl__logs_print -w -h \ + "$gsl_marker_flink" \ + "Line: $ln No Alt-Text ; $gsl_log_act_flink" \ + "${PWD}/$gsl_post" +fi + +if ! [[ `grep "\<__$header_f1\>" "$gsl_tmp_post"` ]];then + gsl__logs_print -e -c \ + "$gsl_marker_flink" \ + "Unused: '__$header_f1'" \ + "${PWD}/$gsl_post" + gsl_flink_err=true +fi + +if ! [[ -f "$gsl_dir_domain_files/$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_flink" \ + "Not found: $header_f2" \ + "$gsl_dir_domain_docs/$header_f2" + gsl_flink_err=true +fi + +[[ $gsl_flink_err ]] && return + +# Register file to DB +printf '%s\n' \ + "# Flink_URI:$gsl_dir_domain_fles/$header_f2" \ + >> "$gsl_tmp_db" + +# Stat +((gsl_stat_flinks++)) } + #====================================================================== -# From gsl__do_header: Check Files +# Check images #====================================================================== -gsl__check_image() { -gsl__check_header_fields \ - "Header" "$gsl_marker_image" "$gsl_log_act_image" \ -|| return - -gsl__check_header_field3 \ - "Header" "$gsl_marker_image" "$gsl_marker_image" \ -|| return - -echo -ne "\r\033[2K: Searching for Images... $gsl_post_hf_1" - -# File exists in folder -if ! [[ -f "$gsl_dir_domain_images/$gsl_post_hf_2" ]];then - - gsl__logs_print \ - "$gsl_log_e" \ - "Header" \ +check__file_image() { +if ! [[ "$header_f1" && "$header_f2" && "$header_f3" ]];then + gsl__logs_print -e -h \ "$gsl_marker_image" \ - "Not found: $gsl_post_hf_2" \ - "$gsl_dir_domain_images/$gsl_post_hf_2" - gsl_checker_err=true - -else - -# Register file to DB with hash - gsl_file_csum=` - cksum "$gsl_dir_domain_images/$gsl_post_hf_2" \ - | awk '{print $1}'` - - printf '%s\n' \ - "Image:$gsl_dir_domain_images/$gsl_post_hf_2:$gsl_file_csum" \ - >> "$gsl_db_tmp" - -fi - -# Exists in Content -gsl_count_images=` -gsl__get_content_line "_image:$gsl_post_hf_1" "$gsl_post" | wc -l` - -if (( $gsl_count_images > 0 ));then - - ((gsl_stat_image++)) - -else - - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "Image" \ - "Unused: _image:$gsl_post_hf_1" \ + "Line: $ln not set ; $gsl_log_act_image" \ "${PWD}/$gsl_post" - gsl_checker_err=true - -fi -} - -#====================================================================== -# From gsl__do_header: Check Files -#====================================================================== -gsl__check_fcode() { - -gsl__check_header_fields \ - "Header" "$gsl_log_h_code" "$gsl_log_act_code" \ -|| return - -echo -ne "\r\033[2K: Searching for File Codes... $gsl_post_hf_1" - -gsl__check_header_field3 "Content" "$gsl_log_h_code" "$gsl_marker_code" \ - -# File exists in folder -if ! [[ -f "$gsl_dir_domain_files/$gsl_post_hf_2" ]];then - - gsl__logs_print \ - "$gsl_log_e" \ - "Header" \ - "$gsl_marker_code" \ - "Not found: $gsl_post_hf_2" \ - "$gsl_dir_domain_files/$gsl_post_hf_2" - gsl_checker_err=true - -else - -# Register file to DB with hash - gsl_file_csum=` - cksum "$gsl_dir_domain_files/$gsl_post_hf_2" \ - | awk '{print $1}'` - - printf '%s\n' \ - "FCode:$gsl_dir_domain_filess/$gsl_post_hf_2:$gsl_file_csum" \ - >> "$gsl_db_tmp" - + return fi -# Exists in Content -gsl_count_fcodes=` -gsl__get_content_line "_code:$gsl_post_hf_1" "$gsl_post" | wc -l` - -if (( $gsl_count_fcodes > 0 ));then - - ((gsl_stat_fcode++)) - -else - - gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "Code" \ - "Unused: _code:$gsl_post_hf_1" \ +if ! [[ `grep "_image:$header_f1" "$gsl_tmp_post"` ]];then + gsl__logs_print -e -c \ + "$gsl_marker_image" \ + "Unused: '_image:$header_f1'" \ "${PWD}/$gsl_post" - gsl_checker_err=true - + gsl_image_err=true fi + +if ! [[ -f "$gsl_dir_domain_images/$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_image" \ + "Not found: $header_f2" \ + "$gsl_dir_domain_images/$header_f2" + gsl_image_err=true +fi + +[[ $gsl_image_err ]] && return + +# Register file to DB +printf '%s\n' \ + "# Image_URI:$gsl_dir_domain_images/$header_f2" \ + >> "$gsl_tmp_db" + +# Stat +((gsl_stat_images++)) } -#====================================================================== -# Stat: Count words -#====================================================================== -gsl__stat_words() { -echo -ne "\r\033[2K: Counting Words..." -gsl_stat_words=`cat "$1" | wc -w` -gsl_stat_words=$(( $gsl_stat_words - 2*$gsl_stat_p )) +#====================================================================== +# Check fcode: file code to convert and import in content +#====================================================================== +check__file_code() { +if ! [[ "$header_f1" && "$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_fcode" \ + "Line: $ln not set ; $gsl_log_act_fcode" \ + "${PWD}/$gsl_post" + return +fi + +if ! [[ "$header_f3" ]];then + gsl__logs_print -w -h \ + "$gsl_marker_fcode" \ + "Line: $ln No Alt-Text ; $gsl_log_act_fcode" \ + "${PWD}/$gsl_post" +fi + +if ! [[ `grep "$gsl_mark_fcode:$header_f1" "$gsl_tmp_post"` ]];then + gsl__logs_print -e -c \ + "$gsl_marker_fcode" \ + "Unused: '$gsl_mark_fcode:$header_f1'" \ + "${PWD}/$gsl_post" + gsl_fcode_err=true +fi + +if ! [[ -f "$gsl_dir_domain_files/$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_fcode" \ + "Not found: $header_f2" \ + "$gsl_dir_domain_precodes/$header_f2" + gsl_fcode_err=true +fi + +[[ $gsl_fcode_err ]] && return + +# Register file to DB +printf '%s\n' \ + "# Fcode_URI:$gsl_dir_domain_files/$header_f2" \ + >> "$gsl_tmp_db" + +# Stat +((gsl_stat_fcodes++)) } + #====================================================================== -# Check Post for MISSING & VALID Content HEADERS +# Check fbrut : brut file to import in content #====================================================================== -gsl__check_headers() { -echo -ne "\r\033[2K: Searching HEADERS..." -#-------------------------------- -# Check if Missing NEEDED HEADERS -#-------------------------------- -# Title -echo -ne "\r\033[2K: Searching HEADERS... $gsl_header_title" -gsl__check_needed_headers \ - "$gsl_header_title" \ - "$gsl_marker_title" \ - "POST TITLE" +check__file_brut() { +if ! [[ "$header_f1" && "$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_fbrut" \ + "Line: $ln not set ; $gsl_log_act_fbrut" \ + "${PWD}/$gsl_post" + return +fi -# Slug -echo -ne "\r\033[2K: Searching HEADERS... $gsl_header_slug" -gsl__check_needed_headers \ - "$gsl_header_slug" \ - "$gsl_marker_slug" \ - "POST-TITLE" \ -&& gsl_slug_err=true +if ! [[ `grep "$gsl_mark_fbrut:$header_f1" "$gsl_tmp_post"` ]];then + gsl__logs_print -e -c \ + "$gsl_marker_fbrut" \ + "Unused: '$gsl_mark_fbrut:$header_f1'" \ + "${PWD}/$gsl_post" + gsl_fbrut_err=true +fi -# Author -echo -ne "\r\033[2K: Searching HEADERS... $gsl_header_author" -gsl__check_needed_headers \ - "$gsl_header_author" \ - "$gsl_marker_author" \ - "REGISTRED NAME" \ -&& gsl_author_err=true +if ! [[ -f "$gsl_dir_domain_files/$header_f2" ]];then + gsl__logs_print -e -h \ + "$gsl_marker_fbrut" \ + "Not found: $header_f2" \ + "$gsl_dir_domain_files/$header_f2" + gsl_fbrut_err=true +fi + +[[ $gsl_fcode_err ]] && return + +# Register file to DB +printf '%s\n' \ + "# Fbrut_URI:$gsl_dir_domain_files/$header_f2" \ + >> "$gsl_tmp_db" + +# Stat +((gsl_stat_fbruts++)) +} + + +#====================================================================== +# Check iCode marks match nbr + stats +#====================================================================== +check__icode() { +post_ln=$((ln + gsl_post_begin - 1)) +mark_icode_nbr="${gsl_line//[^$gsl_mark_icode]}" +mark_icode_nbr=${#mark_icode_nbr} +mark_icode_paired=$(( $mark_icode_nbr % 2 )) + +if [[ "$mark_icode_paired" -eq 0 ]];then + stat_icode_nbr=$(( mark_icode_nbr / 2 )) + gsl_stat_icodes=$(( gsl_stat_icodes + stat_icode_nbr )) -# Date -echo -ne "\r\033[2K: Searching HEADERS... $gsl_header_date" -# Date format check in fr or INternational ? -if [[ `grep -i "fr" <<<"$gsl_site_lang"` ]];then - gsl_log_content="DD-MM-YYYY" - gsl_test_date='^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]+$' else - gsl_log_content="YYYY-MM-DD" - gsl_test_date='^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]+$' -fi -gsl__check_needed_headers \ - "$gsl_header_date" \ - "$gsl_marker_date" \ - "$gsl_log_content" \ -&& gsl_date_err=true - -# Description -echo -ne "\r\033[2K: Searching HEADERS... ${gsl_header_info:0:40}..." -gsl__check_needed_headers \ - "$gsl_header_info" \ - "$gsl_marker_info" \ - "DESCRIPTION" - -# Tags -echo -ne "\r\033[2K: Searching HEADERS... ${gsl_header_tags:0:40}..." -gsl__check_needed_headers \ - "$gsl_header_tags" \ - "$gsl_marker_tags" \ - "TAG1,OTHER TAG2,TAG3" - -#-------------------------------- -# Check for VALID Content HEADERS -#-------------------------------- -# Author registred -if ! [[ "$gsl_author_err" ]] && \ - ! [[ `grep "$gsl_header_author" "$gsl_file_auth_ndd"` ]];then - - gsl__logs_print \ - "$gsl_log_e" \ - "Header" \ - "$gsl_marker_author" \ - "$gsl_header_author not registred for domain $gsl_find_domain" \ - "${PWD}/$gsl_post" - gsl_checker_err=true - -fi - -# Date Format YYYY-MM-DD -if ! [[ "$gsl_date_err" ]] && \ - ! [[ "$gsl_header_date" =~ $gsl_test_date ]];then - - gsl__logs_print \ - "$gsl_log_e" \ - "Header" \ - "$gsl_marker_date" \ - "$gsl_header_date not $gsl_log_content" \ - "${PWD}/$gsl_post" - gsl_checker_err=true - gsl_date_mismatch=true - -fi -if ! [[ $gsl_date_mismatch ]];then - gsl_date_m=`awk -F- '{print $2}' <<<"$gsl_header_date"` - [[ "$gsl_date_m" -gt 12 ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Header" \ - "$gsl_marker_date" \ - "$gsl_header_date : Month > 12..." \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true -fi - -# Slug format title-post -if ! [[ "$gsl_slug_err" ]];then - gsl_header_slug_test=${gsl_header_slug// /-} - - if ! [[ "$gsl_header_slug" == "$gsl_header_slug_test" ]];then - - gsl_new_header_slug="$gsl_marker_slug$gsl_header_slug_test" - sed -i \ - "s|$gsl_marker_slug$gsl_header_slug|$gsl_new_header_slug|" \ - "$gsl_post" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "Header" \ - "$gsl_marker_slug" \ - "Changed: $gsl_header_slug_test" \ - "${PWD}/$gsl_post" - - gsl__get_sum "$gsl_post" - gsl_header_slug=$gsl_header_slug_test - gsl_checker_war=true - - fi - + gsl__logs_print -e -c \ + "iCode" \ + "Line: $post_ln ; '$gsl_mark_icode...$gsl_mark_icode' not paired" \ + "$PWD/$gsl_post" +fi +} + + +#====================================================================== +# Check stronng marks match nbr + stats +#====================================================================== +check__strong() { +post_ln=$((ln + gsl_post_begin - 1)) +mark_strong_nbr="${gsl_line//[^$gsl_mark_strong]}" +mark_strong_nbr=${#mark_strong_nbr} +mark_strong_paired=$(( $mark_strong_nbr % 2 )) + +if [[ "$mark_strong_paired" -eq 0 ]];then + stat_strong_nbr=$(( mark_strong_nbr / 2 )) + gsl_stat_strongs=$(( gsl_stat_strongs + stat_strong_nbr )) + +else + gsl__logs_print -e -c \ + "Strong" \ + "Line: $post_ln ; '$gsl_mark_strong...$gsl_mark_strong' not paired" \ + "$PWD/$gsl_post" +fi +} + + +#====================================================================== +# Check Bold marks match nbr + stats +#====================================================================== +check__bold() { +post_ln=$((ln + gsl_post_begin - 1)) +mark_bold_nbr="${gsl_line//[^$gsl_mark_bold]}" +mark_bold_nbr=${#mark_bold_nbr} +mark_bold_paired=$(( $mark_bold_nbr % 2 )) + +if [[ "$mark_bold_paired" -eq 0 ]];then + stat_bold_nbr=$(( mark_bold_nbr / 2 )) + gsl_stat_bolds=$(( gsl_stat_bolds + stat_bold_nbr )) + +else + gsl__logs_print -e -c \ + "Bold" \ + "Line: $post_ln ; '$gsl_mark_bold...$gsl_mark_bold' not paired" \ + "$PWD/$gsl_post" +fi +} + + +#====================================================================== +# Check Bold marks match nbr + stats +#====================================================================== +check__emphasis() { +post_ln=$((ln + gsl_post_begin - 1)) +mark_em_nbr="${gsl_line//[^$gsl_mark_em]}" +mark_em_nbr=${#mark_em_nbr} +mark_em_paired=$(( $mark_em_nbr % 2 )) + +if [[ "$mark_em_paired" -eq 0 ]];then + stat_em_nbr=$(( mark_em_nbr / 2 )) + gsl_stat_italics=$(( gsl_stat_italics + stat_em_nbr )) + +else + gsl__logs_print -e -c \ + "Emphasis" \ + "Line: $post_ln ; '$gsl_mark_em...$gsl_mark_em' not paired" \ + "$PWD/$gsl_post" +fi +} + + +#====================================================================== +# Check strike (lt) marks match nbr + stats +#====================================================================== +check__strike() { +post_ln=$((ln + gsl_post_begin - 1)) +mark_lt_nbr="${gsl_line//[^$gsl_mark_strike]}" +mark_lt_nbr=${#mark_lt_nbr} +mark_lt_paired=$(( $mark_lt_nbr % 2 )) + +if [[ "$mark_lt_paired" -eq 0 ]];then + stat_lt_nbr=$(( mark_lt_nbr / 2 )) + gsl_stat_strikes=$(( gsl_stat_strikes + stat_lt_nbr )) + +else + gsl__logs_print -e -c \ + "Strike" \ + "Line: $post_ln ; '$gsl_mark_strike...$gsl_mark_strike' not paired" \ + "$PWD/$gsl_post" fi } diff --git a/var/lib/gsl/scripts/gsl__post_makers b/var/lib/gsl/scripts/gsl__post_makers index b9d6ba5..a95904e 100644 --- a/var/lib/gsl/scripts/gsl__post_makers +++ b/var/lib/gsl/scripts/gsl__post_makers @@ -1,743 +1,1125 @@ #!/bin/bash # file: gsl__post_makers # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -#======================================================================= -# --------- -# MAIN CALL -# --------- -#======================================================================= - -#======================================================================= -# From: gsl__loop_posts | Convert Post from modules to HTML -#======================================================================= -gsl__all_makers() { -# Code readability a11y -gsl_a11y_post=`mktemp` - -# Get content only, not header in a file -gsl__post_content_only - -# Get base uri from post/page type: -case "$gsl_post_type" in - post) gsl_uri=".." ;; - page) gsl_uri="." ;; -esac - -gsl__do_italics "make" "$gsl_tmp_post" # First -gsl__do_header "make" "$gsl_marker_link" "$gsl_post" -gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post" -gsl__make_newline -gsl__make_files -gsl__do_strongs_bolds "make" "$gsl_tmp_post" -gsl__make_list - -gsl__do_icode "make" "$gsl_tmp_post" -gsl__make_titles -gsl__do_header "make" "$gsl_marker_image" "$gsl_post" -gsl__make_paragraphs - -# From File_Code -gsl_fcode_nbr=`grep "$gsl_mark_fcode" "$gsl_tmp_post" | wc -l` -if (( $gsl_fcode_nbr > 0 ));then - for fcode in `seq 1 $gsl_fcode_nbr` - do - gsl__make_fcode - done -fi - -gsl__check_cites -gsl__make_a11y -echo -ne "\r\033[2K" - -rm -f "$gsl_tmp_post" # No more Needed tmp file post - -# Create SRV folder according to post type -[[ "$gsl_post_type" == "post" ]] \ - && mkdir -p "$gsl_srv_wip/$gsl_header_slug/" \ - && gsl__logs_print \ - "$gsl_log_w" \ - "SRV" \ - "wip" \ - "Create folder: $gsl_header_slug" \ - "$gsl_srv_wip/$gsl_header_slug/" \ - && gsl_checker_war=true - -# Create HTML Page using gsl_a11y_post -gsl__page_creator -gsl__db_set_post_status wip - -rm -f "$gsl_a11y_post" # No more Needed a11y post -} - -#======================================================================= -# --------------------------------------------- -# Tools and prepapre tmp file from CONTENT Post -# --------------------------------------------- -#======================================================================= - -#======================================================================= -# Get line nbr from TMP CONTENT Post... $1: TERM | $2: File -#======================================================================= -gsl__get_mark_content_line() { -awk -v s="$1" \ - '$0 ~ s {print NR}' \ - "$2" || return -} - -#======================================================================= -# --------------------------------- -# Converters -# --------------------------------- -#======================================================================= +#---------------------------------------------------------------------- +# --------------- +# SIDEBAR Section +# --------------- #---------------------------------------------------------------------- #====================================================================== -# Convert List.Get first/last line item / repeat till no more mark +# Get arguments from COMMAND (sidebar) +# $1: process +# $2: position +# $3: file #====================================================================== -# Loop till no more list marker -gsl__make_list() { -if [[ `awk -v mls="\$gsl_mark_listo" \ - 'match($1,mls) {print NR,$0;exit}' \ - "$gsl_tmp_post"` ]] || \ - [[ `awk -v mls="\$gsl_mark_list" \ - 'match($1,mls) {print NR,$0;exit}' \ - "$gsl_tmp_post"` ]];then - gsl__make_list_read_by_block -fi -return +sidebar__OPTIONS() { + + # Check OPTIONS except for "latest" + # --------------------------------- + sidebar__check_args() { + # Position + [[ "$1" = *[!0-9]* ]] \ + && gsl__invalid_option "$1" "position (1 to $site_max_list)" + + (( "$1" == "0" || "$1" > "$site_max_list" )) \ + && gsl__invalid_option "$1" "position (1 to $site_max_list)" + + position="$1" + + # file post + if__file "$2" post + gsl_post="$2" + ! [[ -f "$gsl_dir_db_domain/$gsl_this_post.db" ]] \ + && echo "! Article not check yet" \ + && exit + } + +case "$1" in + add|-a) + sidebar__check_args "$2" "$3" + ;; + + replace|-r) + sidebar__check_args "$2" "$3" + ;; + + latest|-l|oldest|-o) + db__if_file;position="1 to $site_max_list" + ;; + + *) + gsl__invalid_option "$1" "add|replace|latest|oldest" + ;; +esac + +# Start process +create__HTML_translation +sidebar__create "$1" "$position" } -# ===================================================================== -# Read list by block, create tmp file, convert in HTML, replace block -# ln: line number | ml: marker list -# ===================================================================== -gsl__make_list_read_by_block() { -unset list_lb list_le -# Making tmp block file list -gsl_file_block_list=`mktemp` -while read -r "ln" "ml" "content" +#====================================================================== +# Sidebar: create /templates/sidebar.html +# $1: process +# $2: Position +# $3: DB file +#====================================================================== +sidebar__create() { +log__process_begin "Sidebar" + +gsl__logs_print -i -s $1 \ + "Position: $2 in final sidebar" \ + "$gsl_dir_domain_tpl/sidebar.html" + +mkdir -p "$gsl_dir_domain_sidebar" +case "$1" in + latest|-l) sort_arg='-k2' ;; + oldest|-o) sort_arg='-k2r' ;; +esac + +case "$1" in + latest|-l|oldest|-o) + sidebar_pos=0 + while read -r "sorted_file" + do + ((sidebar_pos++)) + sidebar_HTML_item="$gsl_dir_domain_sidebar/$sidebar_pos.html" + db_name=`awk -F: '{print $1}' <<<"$sorted_file"` + source "$db_name" + gsl_post=`basename "$article_URI"` + + gsl__logs_print -i -sdb $1 \ + "Position: $sidebar_pos ; $article_epoch" \ + "$sidebar_HTML_item" + + srv__files datas + create__HTML_sidebar_item "$sidebar_HTML_item" + done < <(grep "Date" "$gsl_dir_db_domain/"*.gsl.db \ + | sort -t= $sort_arg \ + | head -n $site_max_list) + ;; + + replace|-r) + gsl__logs_print -i -sdb $1 \ + "Position: $2" \ + "$gsl_dir_domain_sidebar/$2.html" + + source "$gsl_dir_db_domain/$gsl_this_post.db" + create__HTML_sidebar_item "$gsl_dir_domain_sidebar/$2.html" + ;; + + add|-a) + for i in `seq $site_max_list -1 $2` + do + if (( $i == $site_max_list)) && + [[ -f "$gsl_dir_domain_sidebar/$i.html" ]];then + rm -f "$gsl_dir_domain_sidebar/$i.html" + + else + [[ -f "$gsl_dir_domain_sidebar/$i.html" ]] \ + && mv "$gsl_dir_domain_sidebar/$i.html" \ + "$gsl_dir_domain_sidebar/$(( i + 1 )).html" + fi + done + + gsl__logs_print -i -sdb $1 \ + "Position: $2" \ + "$gsl_dir_domain_sidebar/$2.html" + + source "$gsl_dir_db_domain/$gsl_this_post.db" + create__HTML_sidebar_item "$gsl_dir_domain_sidebar/$2.html" + ;; +esac + +create__HTML_sidebar "$1" "$gsl_dir_domain_tpl/sidebar.html" + +gsl__logs_print -w -sdb "Tips" \ + "Do not forget to sync ; use gsl sync" \ + "$gsl_dir_domain_tpl/sidebar.html" + +unset gsl_post +log__process_end "Sidebar" +} + + +#---------------------------------------------------------------------- +# ------------ +# MAKE Section +# ------------ +#---------------------------------------------------------------------- +#====================================================================== +# Get arguments from COMMAND (make) +#====================================================================== +make__OPTIONS() { +gsl_proc="wip" + +while test "$2" do - case "$ml" in - "$gsl_mark_list"*|"$gsl_mark_listo"*) - case "$ml" in - "$gsl_mark_list"*) - gsl_html_uol="ul" - ;; - "$gsl_mark_listo"*) - gsl_html_uol="ol" - ;; - esac - ! [[ $list_lb ]] && list_lb="$ln" - echo "$ml $content" >> "$gsl_file_block_list" + case "$2" in + -F) + gsl_force_make=true + log_info_force="Force " ;; - ""|*) - if [[ $list_lb ]];then - list_le=$ln - echo "" >> "$gsl_file_block_list" + + *".gsl") + if__file "$2" post + gsl_post="$2" + post_only="$2" + ;; + + -N) + gsl_make_newer=true + unset gsl_force_make + ;; + + *) + [[ "$gsl_post" ]] || [[ $gsl_force_make ]] \ + && echo "! Unused argument: $2" \ + || gsl__invalid_option "$2" "-F|(FILE)" + ;; + esac + shift +done + +[[ "$gsl_post" ]] || log_info_all=" ALL" + +log__process_begin "${log_info_force}Make${log_info_all}" +posts__loop make + +# For logs ; set post or unset if all +[[ $log_info_all ]] && unset gsl_post +[[ $post_only ]] && gsl_post="$post_only" + +log__process_end "${log_info_force}Make${log_info_all}" +} + + +#======================================================================= +# From: posts__loop() ; Convert Post to HTML +# But, before: Compare hash ans existing files +#======================================================================= +Makers() { +# Check if hashes not match +! [[ "$gsl_do_make" ]] && return + +# OPT: -F (force) +gsl_do_make=true +if [[ "$gsl_force_make" ]];then + if [[ "$gsl_srv_wip_file" ]];then + gsl__logs_print -w -g -M \ + "WIP: Force again HTML $article_Type" \ + "$PWD/$gsl_post" + fi + +# Not force +else + # if file exists (value is true) + if [[ "$gsl_srv_wip_file" ]];then + gsl__logs_print -w -g -M \ + "WIP: Already done ; Use -F to force" \ + "$gsl_srv_post_wip" + unset gsl_do_make + fi +fi + +! [[ "$gsl_do_make" ]] && return + + +#---------------------------------------------------------------------- +# Set HTML to replace first marker +# Closed HTML are static > in gsl.conf +#---------------------------------------------------------------------- +HTML_icode_start="" +HTML_strong_start="" +HTML_em_start="" +HTML_strike_start="" +HTML_bold_start="" + +#---------------------------------------------------------------------- +# makers modules +#---------------------------------------------------------------------- +# Titles +read__line_with "^#[1-6]" "make" "title" "content" "$gsl_tmp_post" + +# Paragraphs +make__paragraphs "$gsl_mark_p_start " "$gsl_mark_p_close" "$gsl_tmp_post" + +# New Line (convert | in
    ) +make__br "$gsl_mark_newline" "$gsl_tmp_post" + +# abbr +read__line_with "^$gsl_marker_abbr" "make" \ + "abbr" "metas" "$gsl_tmp_head" + +# links +read__line_with "^$gsl_marker_link" "make" \ + "link" "metas" "$gsl_tmp_head" + +# flink +read__line_with "^$gsl_marker_flink" "make" \ + "flink" "metas" "$gsl_tmp_head" + +#---------------------------------------------------------------------- +# Convert words between marks (icode, strong, emphasis, bolds) +# If these markers are in inline code, replace by temp marker + sed back +# Strong +make__loop_line "$gsl_mark_strong" "between" "$gsl_tmp_post" \ + "$HTML_strong_start" "$HTML_strong_close" "ß" +# Bold +make__loop_line "$gsl_mark_bold" "between" "$gsl_tmp_post" \ + "$HTML_bold_start" "$HTML_bold_close" "ð" +# Emphasis +make__loop_line "$gsl_mark_em" "between" "$gsl_tmp_post" \ + "$HTML_em_start" "$HTML_em_close" "đ" +# Strike +make__loop_line "$gsl_mark_strike" "between" "$gsl_tmp_post" \ + "$HTML_strike_start" "$HTML_strike_close" "ŋ" +# ! At last do : iCodes +make__loop_line "$gsl_mark_icode" "between" "$gsl_tmp_post" \ + "$HTML_icode_start" "$HTML_icode_close" + +# For lines having markers in inline-code, replace temp markers +if [[ ${incode_line[@]} ]];then + for ln in ${incode_line[@]} + do + sed -i "${ln}s^ß^•^g" "$gsl_tmp_post" # Strong + sed -i "${ln}s^ð^·^g" "$gsl_tmp_post" # Bold + sed -i "${ln}s^đ^”^g" "$gsl_tmp_post" # Emphasis + sed -i "${ln}s^ŋ^×^g" "$gsl_tmp_post" # Strike + done +fi +#---------------------------------------------------------------------- + +# Image +read__line_with "^$gsl_marker_image" "make" \ + "image" "metas" "$gsl_tmp_head" + +# lists +make__lists "$gsl_tmp_post" + +# Quotes +make__quotes "$gsl_tmp_post" + +# File code +read__line_with "^$gsl_marker_fcode" "make" \ + "fcode" "metas" "$gsl_tmp_head" + +# At the very end, make brut codes +read__line_with "^$gsl_marker_fbrut" "make" \ + "fbrut" "metas" "$gsl_tmp_head" + +# a11y + div between titles +make__div_title "$gsl_tmp_post" + + +# a11y (tabulation) +spc=' ' # 8 spaces. Main content (2*4) +sed -i -e "s|^|$spc|" "$gsl_tmp_post" + +# Create wip HTML page +create__HTML_page + +rm -f "$gsl_tmp_post" +DB__set_status "wip" +} + + +#====================================================================== +# Loop called by each content module, till nothing found +# $1: marker +# $2: mark (between) +# $3: file +# $4: HTML Start +# $5: HTML Close +#====================================================================== +make__loop_line() { +read__line_with \ + "$1" "make" \ + "$2" "content" \ + "$3" "$4" "$5" "$6" + +! [[ "$gsl_line" ]] && return +} + + +#====================================================================== +# Filter content +# Called from read__line_with() in gsl__do_commons +# $1: marker +# $2: mark +# $3: file +# $4: HTML start +# $5: HTML close +#====================================================================== +make__headers_from_filter() { +case "$2" in + title) make__titles "$3" ;; + between) make__words "$1" "$2" "$3" "$4" "$5" "$6" ;; + abbr) make__abbrs "$5" "$gsl_tmp_post" ;; + link|flink) make__links "$gsl_tmp_post" "$2" ;; + fcode) make__file_codes "$gsl_tmp_post" ;; + fbrut) make__file_bruts "$gsl_tmp_post" ;; + image) make__file_images "$gsl_tmp_post" ;; +esac +} + + +#====================================================================== +# From make loop_line() +# Convert words between marks (strong, icode, emphasis) +# $1: marker +# #2: mark (betwee) +# $3: file +# $4: HTML start +# $5: HTML close +# $6: temp marker (if legacy in inline code) +#====================================================================== +make__words() { +icm=0 +for (( i=0; i<${#gsl_line}; i++ )) +do + + # For markers not "inline-code", set characters to bypass + case "${gsl_line:$i:1}" in + "$gsl_mark_icode") + if [[ "$1" != "$gsl_mark_icode" ]];then + icm=$(( icm + 1 )) + incode=true;incode_s=$i + icm_p=$(( $icm % 2 )) + [[ $icm_p -eq 0 ]] && unset incode + fi + ;; + esac + + case "${gsl_line:$i:1}" in + "$1") + if [[ $incode ]] && (( "$i" > $incode_s ));then + # Get line containing temp markers and replace + [[ `grep "$ln" <<<"${incode_line[@]}"` ]] || incode_line+=($ln) + sed -i -r "${ln}s|^(.{"$i"})"$1"|\1$6|" "$3" + continue + fi + + if [[ $open ]];then + unset open + sed -i -r "${ln}s|^(.{"$i"})"$1"|\1$5|" "$3" + break + + else + open=true + sed -i -r "${ln}s|^(.{"$i"})"$1"|\1$4|" "$3" break fi ;; esac -done < <(cat -n "$gsl_tmp_post") - -# Convert block_list -echo -ne "\r\033[2K: Converting list block... $list_lb-$list_le" -gsl__make_list_convert - -# Remove in gsl_tmp_post block list and replace with $gsl_file_html_list -diff_lines=$(( list_le - list_lb )) -#seq $list_lb $list_le -for rml in `seq 1 $diff_lines` -do - sed -i "${list_lb}d" "$gsl_tmp_post" done -sed -i "$((list_lb -1))r $gsl_file_html_list" "$gsl_tmp_post" -# No more needed html file list -rm -f "$gsl_file_html_list" - -# No more needed block list file -rm -f "$gsl_file_block_list" - -# Go again if new list found -gsl__make_list +make__loop_line "$1" "$2" "$3" "$4" "$5" "$6" } -# ===================================================================== -# Create TMP HTML block list file -# ===================================================================== -gsl__make_list_convert() { -gsl_file_html_list=`mktemp` -# mln: marker list number | pmln: previous list mark number - gsl__make_list_count_prev_mark() { - pml=`gawk -v pln=$(( ln -1 )) 'NR == pln {print $1}' "$gsl_file_block_list"` - pmln=${#pml} +#====================================================================== +# Make HTML Titles +# $1: file (from $5 of read__line_with) +#====================================================================== +make__titles() { +while read -r "t" "content" +do + tn=${t: -1} + HTML_title=` + printf '%s%s%s\n' \ + "" \ + "$content" \ + ""` + + sed -i "${ln}s^.*^$HTML_title^" "$1" +done <<<"$gsl_line" +} + + +#====================================================================== +# Make HTML paragraphs +# $1: marker open +# $2: marker close +# $3: file +#====================================================================== +make__paragraphs() { +[[ `grep "^$2$" "$3"` ]] \ + && sed -i "s,^$2$,$HTML_p_close,g" "$3" \ + || return + +while read -r "lnpm" "class" +do + ln=`awk -F: '{print $1}' <<<$lnpm` + pm=`awk -F: '{print $2}' <<<$lnpm` + + if [[ $class ]];then + HTML_p="

    " + sed -i "${ln}s^$pm $class^$HTML_p^" "$3" + + else + HTML_p="

    " + sed -i "${ln}s^$pm^$HTML_p^" "$3" + fi +done < <(grep -n '^($\|^'"$1" "$3") +} + + +#====================================================================== +# Convert new line "|" to
    ($HTML_br) +# $1: marker +# $2: file +#====================================================================== +make__br() { +[[ `grep "^$1$" "$2"` ]] \ + && sed -i "s,^$1$,$HTML_br,g" "$2" +} + + +#====================================================================== +# HTML abbr: SHORT must have 1 space before/after, or both +# $1: file header +# $2: file post +#====================================================================== +make__abbrs() { +! [[ "$header_f1" ]] && return + +abbr_title="title=\"$header_f2\"" +abbr_class="class=\"${site_css}_abbr\"" +abbr_words="$header_f1" + +sed -i "s^ $header_f1 ^ $abbr_words ^g" "$2" +sed -i "s^$header_f1 ^$abbr_words ^g" "$2" +sed -i "s^ $header_f1^ $abbr_words^g" "$2" +} + + +#====================================================================== +# HTML link: + to open in new window +# $1: file post +# $2: mark type +#====================================================================== +make__links() { +! [[ "$header_f1" ]] && return + +[[ "$header_f3" ]] \ + && link_title=" title=\"$header_f3\"" + +# link or flink +case "$2" in + "link") + mt="$gsl_mark_link" + cssn="link" + unset luri + ;; + + "flink") + mt="$gsl_mark_flink" + cssn="link-file" + luri="${srv_uri}files/" + ;; +esac + +link_class="class=\"${site_css}_$cssn\"" +link_class2="class=\"${site_css}_$cssn ${site_css}_$cssn-window\"" +link_words=` +printf '%s%s%s\n' \ + "" \ + "$header_f1"` + +link_words2=` +printf '%s%s%s\n' \ + "" \ + "$header_f1"` + +sed -i "s^$mt${header_f1}+^$link_words2^g" "$1" +sed -i "s^$mt$header_f1^$link_words^g" "$1" +} + + +#====================================================================== +# HTML code : create tmp file with source code +# converted in HTML version with

    , and replace mark with tmp file
    +# $1: file post
    +#======================================================================
    +make__file_codes() {
    +pre_class="class=\"${site_css}_code-block ${site_css}_code-block-$header_f1\""
    +pre_css_line="class=\"${site_css}_code-line\""
    +pre_css_content="class=\"${site_css}_code-content\""
    +pre_css_source="class=\"${site_css}_code-link\""
    +pre_css_p="class=\"${site_css}_code-p\""
    +
    +# No Alt-Text ; generate
    +if [[ "$header_f3" ]];then
    +  pre_title=" title=\"Code: source\""
    +
    +else
    +  header_f3="Code: source"
    +fi
    +
    +gsl_tmp_code=`mktemp`
    +cat << EOCODE > "$gsl_tmp_code"
    +
    +$(while read -r "code_ln" "code_content"
    +  do
    +    printf '%2s%s%s\n' "" \
    +           "$code_ln" \
    +           "$code_content"
    +  done < <(cat -n "$gsl_dir_domain_files/$header_f2"))
    +
    +

    + + $header_f3 + +

    +EOCODE + + # for/from make__file_codes (Replace mark till no more) + # $1: file post + #------------------------------------------------- + make__file_codes_replace() { + lncode=` + grep -n "$gsl_mark_fcode:$header_f1" "$1" \ + | head -n1 \ + | awk -F: '{print $1}'` + + [[ "$lncode" ]] || return + + sed -i "${lncode}r $gsl_tmp_code" "$1" + sed -i "${lncode}d" "$1" + make__file_codes_replace "$1" } -mln_indent=0 -while read -r "ln" "ml" "content" -do - mln=${#ml} - (( $mln_indent < $mln )) \ - && mln_indent=$mln \ - && mln_indent_close=$((mln_indent * 3 - 3)) - - gsl__make_list_count_prev_mark - diff_pmln_mln=$(( mln - pmln )) - - #echo "$mln (pmln=$pmln ; diff: $diff_pmln_mln)" >> "$gsl_file_html_list" - if (( $diff_pmln_mln == 0 ));then - - printf "%$((mln * 3))s%s\n" \ - "" \ - "
  • $content
  • " \ - >> "$gsl_file_html_list" - - elif (( $diff_pmln_mln > 0 ));then - - printf "%$((mln * 3 - 3))s%s\n%$((mln * 3))s%s\n" \ - "" \ - "<$gsl_html_uol class=\"${gsl_site_css}_list-$gsl_html_uol\">" \ - "" \ - "
  • $content
  • " \ - >> "$gsl_file_html_list" - - elif (( $diff_pmln_mln < 0 ));then - - for i in `seq $diff_pmln_mln -1` - do - if [[ "$content" ]];then - - printf "%${mln_indent_close}s%s\n%${mln_indent_close}s%s\n" \ - "" \ - "" \ - "" \ - "
  • $content
  • " \ - >> "$gsl_file_html_list" - - else - - printf "%${mln_indent_close}s%s\n" \ - "" \ - "" \ - >> "$gsl_file_html_list" - - fi - - mln_indent_close=$((mln_indent_close - 3)) - (( $mln_indent_close < 0 )) && mln_indent_close=0 - - done - fi -done < <(cat -n "$gsl_file_block_list") -} -#---------------------------------------------------------------------- - - -#====================================================================== -# Replace gsl_mark_fcode -#====================================================================== -gsl__make_fcode() { -while IFS=: read -r "line" "mark" "nbr" -do - # Get File - gsl_file_fcode=` - grep "${gsl_marker_code}$nbr" "$gsl_post" \ - | awk -F" : " '{print $2}'` - - echo -ne "\r\033[2K: Converting Block-Codes... $gsl_file_fcode" - - gsl_css_class="${gsl_site_css}_block-code" - - # Create tmp file from block-code, adding span for line numbers in css - gsl_file_bcode=`mktemp` - while read -r "gsl_bcode_line" - do - echo "$gsl_bcode_line" >> "$gsl_file_bcode" - done < <(cat "$gsl_dir_domain_files/$gsl_file_fcode") - - gsl_file_tmp_code=`mktemp` - printf '%s %s\n%b\n%s\n' \ - "
    " \
    -         "$(cat "$gsl_file_bcode")" \
    -         "
    " \ - > "$gsl_file_tmp_code" - - # Replace in tmp post and delete mark - sed -i "${line}r $gsl_file_tmp_code" "$gsl_tmp_post" - sed -i "${line}d" "$gsl_tmp_post" - rm -f "$gsl_file_tmp_code" - rm -f "$gsl_file_bcode" -done < <(grep -n "$gsl_mark_fcode" "$gsl_tmp_post" | head -n 1) +make__file_codes_replace "$1" +rm -f "$gsl_tmp_code" } #====================================================================== -# From gsl__do_header: Make Link +# Replace marks with brut file. Must be done at the end ! +# $1: file post #====================================================================== -gsl__make_link() { -gsl_post_hf_1="${gsl_post_hf_1}" -gsl_post_hf_1_t="${gsl_post_hf_1}+" +make__file_bruts() { +lncode=` +grep -n "$gsl_mark_fbrut:$header_f1" "$1" \ + | head -n1 \ + | awk -F: '{print $1}'` -[[ "$gsl_post_hf_3" ]] \ - && gsl_html_link_title=" title=\"$gsl_post_hf_3\"" +[[ "$lncode" ]] || return -# target blank -gsl_html_link_t=` -printf '%s%s%s%s' \ - "" \ - "$gsl_post_hf_1" \ - ""` - -echo -ne "\r\033[2K: Converting Link... $gsl_post_hf_1" -sed -i "s|_${gsl_post_hf_1_t}|$gsl_html_link_t|g" "$gsl_tmp_post" - -# No Target -gsl_html_link=` -printf '%s%s%s' \ - "" \ - "$gsl_post_hf_1" \ - ""` - -sed -i "s|_${gsl_post_hf_1}|$gsl_html_link|g" "$gsl_tmp_post" -unset gsl_post_hf_3 gsl_html_link_title +sed -i "${lncode}r $gsl_dir_domain_files/$header_f2" "$1" +sed -i "${lncode}d" "$1" +make__file_bruts "$1" } + #====================================================================== -# From gsl__do_header: Make ABBRS +# Make images +# $1: file post #====================================================================== -gsl__make_abbr() { -echo -ne "\r\033[2K: Converting ABBR... $gsl_post_hf_1" +make__file_images() { +this_image=`grep -n "$gsl_mark_image:$header_f1" "$1"` +[[ "$this_image" ]] || return -gsl_html_long="$gsl_post_hf_1" -sed -i "s|$gsl_post_hf_1|$gsl_html_long|" "$gsl_tmp_post" -} +mark_image=${this_image#*:} -#======================================================================= -# Find and convert Titles #1-6 + block dib -#======================================================================= -gsl__make_titles() { -gsl_file_block_titles=`mktemp` - -while read -r "ln" "t" "content" -do - echo -ne "\r\033[2K: Converting Block Title... $t $content" - if [[ $ln_o ]];then - if [[ $ln_c ]];then - ln_o=$ln_c - ln_c=$ln - else - ln_c=$ln - fi - else - ln_o=$ln - tn=${t: -1} - echo "$content" >> "$gsl_file_block_titles" - fi - -if [[ $ln_c ]];then - tn=${t: -1} - if [[ `awk -v o="$ln_o" -v c="$ln_c" \ - 'NR > o && NR < c' \ - "$gsl_tmp_post"` ]];then - echo "
    " \ - >> "$gsl_file_block_titles" - awk -v o="$ln_o" -v c="$ln_c" \ - 'NR > o && NR < c && $0' \ - "$gsl_tmp_post" \ - >> "$gsl_file_block_titles" - echo -e "
    \n" \ - >> "$gsl_file_block_titles" - fi - echo "$content" >> "$gsl_file_block_titles" -fi - -done < <(awk '$1 ~ /#/ {print NR,$0}' "$gsl_tmp_post") - -# Doing the last title block content -last_line=`cat "$gsl_tmp_post" | wc -l` -if [[ `awk -v o="$ln_o" -v c="$last_line" \ - 'NR > o && NR <= c' \ - "$gsl_tmp_post"` ]];then - echo "
    " \ - >> "$gsl_file_block_titles" - awk -v o="$ln_c" -v c="$last_line" \ - 'NR > o && NR <= c' \ - "$gsl_tmp_post" \ - >> "$gsl_file_block_titles" - echo "
    " >> "$gsl_file_block_titles" -fi - -cat "$gsl_file_block_titles" > "$gsl_tmp_post" -rm -f "$gsl_file_block_titles" -} - - -#======================================================================= -# Find and convert paragraphs (3 different css styles) -#======================================================================= -gsl__make_paragraphs() { -echo -ne "\r\033[2K: Converting Paragraphs..." - -while read -r "ln" "content" -do - case "$content" in - ")") - sed -i "${ln}s,.*,

    ," \ - "$gsl_tmp_post" - ;; - - "("*) - gsl_css_id=` - awk -v l="$ln" \ - 'NR == l {print $2}' \ - "$gsl_tmp_post"` - - if [[ "$gsl_css_id" ]] && \ - [[ `grep '^[-0-9a-zA-Z]*$' <<<"$gsl_css_id"` ]];then - gsl_css_id="-$gsl_css_id" - fi - gsl_html_par_id="

    " - - sed -i "${ln}s,.*,$gsl_html_par_id," \ - "$gsl_tmp_post" - ;; - - *) - continue - ;; - esac -done < <(cat -n "$gsl_tmp_post") -} - -#----------------------------------------------------------------------- -#======================================================================= -# Find BLOCKQUOTES -#======================================================================= -gsl__check_cites() { -echo -ne "\r\033[2K: Searching and converting Citations..." - -unset gsl_lines_nbr - -gsl_lines_nbr=(` -gsl__get_mark_content_line \ -"$gsl_mark_blockquote" \ -"$gsl_tmp_post"`) -gsl_lines_nbr=(${gsl_lines_nbr[0]} ${gsl_lines_nbr[1]}) - -! [[ "$gsl_lines_nbr" ]] \ - && return - - for i in `seq 1 ${#gsl_lines_nbr[@]}` - do - if [[ "$gsl_cite_start" ]];then - unset gsl_cite_start - gsl_cite_line_stop=${gsl_lines_nbr[(($i-1))]} - gsl__make_cite - else - gsl_cite_start=true - gsl_cite_line_start=${gsl_lines_nbr[(($i-1))]} - fi - done - gsl__check_cites -} - -#======================================================================= -# Replace and Convert this blockquote -#======================================================================= -gsl__make_cite() { - -gsl_file_tmp_cite=`mktemp` # File to Put whole Blockquote -gsl_file_tmp_cite_content=`mktemp` # File to Put Blockquote CONTENT only -gsl_file_tmp_cite_html=`mktemp` # File to Put final HTML blockquote - -# Put whole blockquote in file -awk -v o="$gsl_cite_line_start" -v c="$gsl_cite_line_stop" \ - 'NR >= o && NR <= c' \ - "$gsl_tmp_post" \ - > "$gsl_file_tmp_cite" - -# No more DATAS needed for next if any -unset ${!gsl_bq_@} ${!gsl_html_cite_@} - -# Get DATAS from blockquote -while read -r "gsl_content_line" -do - case "$gsl_content_line" in - ---*) - continue - ;; - _cite*) - gsl_bq_author=`awk -F" : " '{print $2}' <<< "$gsl_content_line"` - ;; - _book*) - gsl_bq_book=`awk -F" : " '{print $2}' <<< "$gsl_content_line"` - ;; - _lang*) - gsl_bq_lang=`awk -F" : " '{print $2}' <<< "$gsl_content_line"` - gsl_html_cite_lang=" lang=\"$gsl_bq_lang\"" - ;; - _year*) - gsl_bq_year=`awk -F" : " '{print $2}' <<< "$gsl_content_line"` - ;; - _link*) - gsl_bq_link=`awk -F" : " '{print $2}' <<< "$gsl_content_line"` - gsl_html_cite_link=" cite=\"$gsl_bq_link\"" - ;; - *) - [[ "$gsl_bq_author" ]] \ - && echo " $gsl_content_line" >> "$gsl_file_tmp_cite_content" \ - || echo " $gsl_content_line" >> "$gsl_file_tmp_cite_content" - ;; - esac -done < <(cat "$gsl_file_tmp_cite") - -[[ "$gsl_bq_book" ]] \ - && gsl_bq_ref=" - $gsl_bq_book" - -[[ "$gsl_bq_year" ]] \ - && gsl_bq_ref+=" ($gsl_bq_year)" - -[[ "$gsl_bq_book" ]] \ - && gsl_html_cite_book=" title=\"Book:$gsl_bq_ref\"" - -! [[ "$gsl_bq_link" ]] && [[ "$gsl_bq_book" ]] \ - && gsl_html_cite_link=" cite=\"$gsl_bq_book$gsl_bq_year\"" - -rm -f "$gsl_file_tmp_cite" # No more whole blockquote file needed -gsl_file_tmp_cite=`mktemp` # File to put Converted HTML DATAS - -# Advanced or simple blockquote -[[ "$gsl_bq_author" ]] \ - && gsl__make_cite_advanced \ - || gsl__make_cite_simple - -# Insert html blockquote file in Post -sed -i "${gsl_cite_line_stop}r $gsl_file_tmp_cite_html" "$gsl_tmp_post" - -# Remove useless lines -gsl_cite_total_lines=$(( $gsl_cite_line_stop - gsl_cite_line_start )) -for i in `seq 0 $gsl_cite_total_lines` -do - sed -i "${gsl_cite_line_start}d" "$gsl_tmp_post" -done - -rm -f "$gsl_file_tmp_cite_content" # No more blockquote CONTENT needed -rm -f "$gsl_file_tmp_cite_html" # No more html blockquote file needed -} - -#======================================================================= -# from gsl__post_maker_cite : ADVANCED blockquote -#======================================================================= -gsl__make_cite_advanced() { -gsl_css_class="class=\"${gsl_site_css}_quote\"" - -cat << EOCITE > "$gsl_file_tmp_cite_html" -

    -
    -$(cat "$gsl_file_tmp_cite_content") -
    -
    - - $gsl_bq_author$gsl_bq_ref - -
    -
    -EOCITE -} - -#======================================================================= -# from gsl__post_maker_cite : SIMPLE blockquote -#======================================================================= -gsl__make_cite_simple() { -gsl_css_class="${gsl_site_css}_simple-quote" - -cat << EOCITE > "$gsl_file_tmp_cite_html" -
    -$(cat "$gsl_file_tmp_cite_content") -
    -EOCITE -} -#----------------------------------------------------------------------- - -#----------------------------------------------------------------------- -# Convert HTML: Images -#----------------------------------------------------------------------- -gsl__make_image() { -gsl_this_mark="$gsl_mark_image:$gsl_post_hf_1" - -while IFS=: read -r "line_nbr" \ +while IFS=: read -r "ln" \ "marker" \ - "this_image" \ - "align_image" \ + "f1" \ + "class" \ "width" \ "height" \ "target" do - - # Get this marker - gsl_this_mark=`awk -v ln="$line_nbr" 'NR == ln' $gsl_tmp_post` - - #align_image=`awk -F: '{print $3}' <<< "$this_image"` - case "$align_image" in - R|r|D|d) gsl_html_class="class=\"${gsl_site_css}_image_right\"" ;; - L|l|G|g) gsl_html_class="class=\"${gsl_site_css}_image_left\"" ;; - C|c) gsl_html_class="class=\"${gsl_site_css}_image_center\"";; - *) gsl_html_class="class=\"${gsl_site_css}_image_center\"";; + case "$class" in + R|r|D|d) image_class="${site_css}_image-right" ;; + G|g|L|l) image_class="${site_css}_image-left" ;; + C|c|D|d) image_class="${site_css}_image-center" ;; + "+") image_class="${site_css}_image-center";target=true ;; + "") image_class="${site_css}_image-center";unset width height ;; + *) image_class="$class";link_class=" $class" ;; esac - gsl_html_src="src=\"$gsl_uri/images/$gsl_post_hf_2\"" - gsl_html_alt="alt=\"$gsl_post_hf_3\" title=\"$gsl_post_hf_3\"" - [[ "$width" ]] && gsl_html_width=" style=\"width:${width}px;\"" - [[ "$height" ]] && gsl_html_height=" style=\"height:${height}px;\"" + case "$width" in + "+") target=true;unset height ;; + esac - gsl_html_image=` - printf '%s %s %s%s%s' \ - ""` + case "$height" in + "+") target=true ;; + esac + + image_css="class=\"${site_css}_image $image_class\"" + image_src="src=\"${srv_uri}images/$header_f2\"" + image_alt="alt=\"$header_f3\" title=\"$header_f3\"" - [[ "$target" ]] \ - && gsl_html_image="$gsl_html_image" + [[ "$width" ]] && image_width=" style=\"width:${width};\"" + [[ "$height" ]] && image_height=" style=\"height:${height};\"" + + HTML_image=` + printf '%s%s\n' \ + ""` - echo -ne "\r\033[2K: Converting Image... Line:$line_nbr $gsl_this_mark" - sed -i "${line_nbr}s|$gsl_this_mark|$gsl_html_image|" "$gsl_tmp_post" + if [[ "$target" ]];then + image_clink="class=\"${site_css}_image-link$link_class\"" + HTML_image=` + printf '%s%s%s%s\n' \ + "" \ + "$HTML_image" \ + ""` + fi +done <<<"$this_image" -done < <(grep -n "$gsl_this_mark" "$gsl_tmp_post") +sed -i "${ln}s^$mark_image^$HTML_image^" "$1" +make__file_images "$1" } -#----------------------------------------------------------------------- -# Convert HTML: Files -#----------------------------------------------------------------------- -gsl__make_files() { -echo -# Set HTML Base Link -case "$gsl_post_type" in - post) gsl_bfile_url="../files" ;; - page) gsl_bfile_url="files" ;; -esac - -while read -r "gsl_this_file" +#====================================================================== +# Lists (independant module) +# repeat for each ^>> found +# Put bloc list in a file: gsl_tmp_list_brut +# Convert list to HTML in a new file: gsl_tmp_list_HTML +# Replace gsl bloc with new file +# $1: file +#====================================================================== +make__lists() { +# Check for last bloc Item list +[[ `grep '^>>' "$1"` ]] || return + +unset mark list mn sign muo_class my_class + +# Define start and close line number +list_ln_start=`grep -n "^<<" "$1" | head -n 1 | awk -F: '{print $1}'` +list_ln_close=`grep -n "^>>" "$1" | head -n 1 | awk -F: '{print $1}'` + +#---------------------------------------------------------------------- +# Put gsl block list in tmp file +#---------------------------------------------------------------------- +gsl_tmp_list_brut=`mktemp` +awk -v lns="$list_ln_start" -v lnc="$list_ln_close" \ + 'NR >= lns && NR <= lnc {print}' \ + "$1" \ + > "$gsl_tmp_list_brut" + +# File to print HTML List +gsl_tmp_list_HTML=`mktemp` + +# Define CSS class +li_class="${site_css}_li ${site_css}_li-" +uo_class="${site_css}_list ${site_css}_list-" + +# Custom class for bloc only +my_class=`awk 'NR == 1 {print $2}' "$gsl_tmp_list_brut"` +[[ $my_class ]] \ + && muo_class=" ${site_css}_list-$my_class ${site_css}_list-$my_class-" + +#---------------------------------------------------------------------- +# Define list in arrays +#---------------------------------------------------------------------- +i=0;l=0 +while read -r "ln" "mark" "content" do - gsl_this_file=${gsl_this_file/$gsl_marker_file/} - - gsl_filetxt=` - awk -F" : " \ - '{print $1}' \ - <<< "$gsl_this_file"` - - gsl_filename=` - awk -F" : " \ - '{print $2}' \ - <<< "$gsl_this_file"` - - gsl_filealt=` - awk -F" : " \ - '{print $3}' \ - <<< "$gsl_this_file"` - - [[ "$gsl_filealt" ]] \ - && gsl_HTML_file_title=" title=\"$gsl_filealt\"" + ((i++)) + mark[$i]="${mark}" + sign[$i]="${mark:0:1}" + line[$i]="$ln" + mn[$i]="${#mark}" + case "$mark" in + "="*) list[$i]="ul" ;; + "+"*) list[$i]="ol" ;; + esac +done < <(awk '($1 ~ "=" || $1 ~ "+" || $1 ~ ">>" ) \ + {print NR,$0}' \ + "$gsl_tmp_list_brut") - # Convert file to link - gsl_mark_file="$gsl_mark_file$gsl_filetxt" - gsl_HTML_file_link=` - printf '%s%s%s%s%s%s' \ - "" \ - "$gsl_filetxt" \ - ""` + + # Generic prints li + # ----------------- + make__list_li() { + printf "%$((sp + 2))s%s\n" "" \ + "
  • ${content[$n]}
  • " \ + | awk -v sp="$((sp+2))" \ + 'NR == 1 {print $0};NR > 1 {printf "%" sp "s%s\n", "", $0}' \ + >> "$gsl_tmp_list_HTML" + } - echo -ne "\r\033[2K: Converting File... $gsl_mark_file" - sed -i "s|$gsl_mark_file|$gsl_HTML_file_link|g" \ - "$gsl_tmp_post" - -done < <(grep "$gsl_marker_file" "$gsl_post") -} - -#----------------------------------------------------------------------- -# Convert Inline-code -#----------------------------------------------------------------------- -gsl__make_inline_codes() { -gsl_HTML_inline_code="" -sed -i "s|$gsl_mo_code|$gsl_HTML_inline_code|g" \ - "$gsl_tmp_post" -sed -i "s|$gsl_mc_code||g" \ - "$gsl_tmp_post" -} - -#----------------------------------------------------------------------- -# Reading Code ; making readability -#----------------------------------------------------------------------- -gsl__make_a11y() { -echo -ne "\r\033[2K: Reading HTML Code for readability..." - - gsl__make_a11y_add_space() { - gsl_set_space=$(( gsl_set_space * 2 )) - gsl_space=`printf "%${gsl_set_space}s" ""` - awk -v b="$gsl_start_line" \ - -v c="$gsl_stop_line" \ - -v space="$gsl_space" \ - 'NR > b && NR < c {print space $0}' \ - "$gsl_tmp_post" \ - >> "$gsl_a11y_post" + # Generic print ul | ol (open current) + # ------------------------------------ + make__list_open_n() { + l=$(( l + 1 )) + printf "%${sp}s%s\n" "" \ + "<${list[n]}>" \ + >> "$gsl_tmp_list_HTML" } -gsl_last_title_line=` -grep -n "= cts && NR < ctc {print $0}' \ + "$gsl_tmp_list_brut" \ + | awk '{ sub(/^[ \t]+/, ""); print }'` - if (( $gsl_line_nbr > $gsl_last_title_line ));then - gsl_stop_line=`cat "$gsl_tmp_post" | wc -l` - gsl__make_a11y_add_space + content[$n]=${content[$n]/${mark[$n]}/} + content[$n]=`awk '{sub(/^[ \t]+/, ""); print}' <<<"${content[$n]}"` + + # Define HTML ul | ol from previous item list + # ---------------------------------------- + # Define a11y tabulation for each item + sp=$(( ${mn[$n]} * 2 - 2 )) + + # ---------- + # First Item + # ---------- + if (( $n == 1 ));then + uo_class+="${list[n]}" + [[ $my_class ]] \ + && muo_class+="${list[n]}" - # print last line and stop - awk -v last="$gsl_stop_line" -v space="$gsl_space" \ - 'NR == last {print space $0}' \ - "$gsl_tmp_post" \ - >> "$gsl_a11y_post" - break - fi + l=$(( l + 1 )) + printf "%${sp}s%s\n" "" \ + "<${list[n]} class=\"$uo_class$muo_class\">" \ + >> "$gsl_tmp_list_HTML" + printf "%$((sp + 2))s%s\n" "" \ + "
  • ${content[$n]}
  • " \ + >> "$gsl_tmp_list_HTML" + + # --------- + # Last Item + # --------- + elif (( $n == $i ));then + sp=$(( ${mn[$(( n - 1 ))]} * 2 - 2 )) + + # --------------------- + # Same sign | Last Item + # --------------------- + if [[ ${sign[1]} == ${sign[$(( n - 1 ))]} ]];then + for c in `seq 1 ${mn[$(( n - 1 ))]}` + do + printf "%${sp}s%s\n" "" \ + "" \ + >> "$gsl_tmp_list_HTML" + sp=$(( sp - 2 )) + l=$(( l - 1 )) + done + + # --------------------- + # Diff sign | Last Item + # --------------------- + else + printf "%${sp}s%s\n" "" \ + "" \ + >> "$gsl_tmp_list_HTML" + l=$(( l - 1 )) + + for c in `seq 1 ${mn[$(( n - 1 ))]}` + do + l=$(( l - 1 )) + sp=$(( sp - 2 )) + (( $sp < 0 )) && sp=0 + printf "%${sp}s%s\n" "" \ + "" \ + >> "$gsl_tmp_list_HTML" + done + fi - case "$gsl_line" in - " ${mark[$(( n - 1 ))]} | ${sign[$(( n - 1 ))]}" + + # ---------------------------- + # Same Diff from previous Item + # ---------------------------- + if (( $md == 0 ));then + + # --------------------- + # Same sign | Same Item + # --------------------- + if [[ ${sign[n]} == ${sign[$(( n - 1 ))]} ]];then + make__list_li + + # --------------------- + # Diff sign | Same Item + # --------------------- + else + make__list_open_n + make__list_li + fi + + # ------------------------- + # NEW Item UP from previous + # ------------------------- + elif (( $md > 0 ));then + + # ----------------------- + # Same sign | New Item UP + # ----------------------- + if [[ ${sign[n]} == ${sign[$(( n - 1 ))]} ]];then + make__list_open_n + make__list_li + + # ----------------------- + # Diff sign | New item UP + # ----------------------- + else + make__list_open_n + make__list_li fi - gsl_set_space=`expr substr "$gsl_line" 3 1` - gsl_start_line=$gsl_line_nbr - unset gsl_stop_line - printf '%s\n' "$gsl_line" >> "$gsl_a11y_post" - ;; - esac -done < <(cat -n "$gsl_tmp_post") + + # --------------------------- + # New Item DOWN from previous + # --------------------------- + else + bsp=$(( ${mn[$(( n - 1 ))]} * 2 - 2 )) + + # ------------------------- + # Same sign | New Item Down + # ------------------------- + if [[ ${sign[n]} == ${sign[$(( n - 1 ))]} ]];then + for c in `seq 1 ${md/-/}` + do + printf "%${bsp}s%s\n" "" \ + "" \ + >> "$gsl_tmp_list_HTML" + bsp=$(( bsp - 2 )) + l=$(( l - 1 )) + done + make__list_li + + # ------------------------- + # Diff sing | New Item Down + # ------------------------- + else + l=$(( l + 1 )) + for c in `seq 1 $(( ${md/-/} + 1 ))` + do + printf "%${bsp}s%s\n" "" \ + "" \ + >> "$gsl_tmp_list_HTML" + bsp=$(( bsp - 2 )) + l=$(( l - 1 )) + done + make__list_li + fi + fi + fi +done + +# Delete source lines and insert HTML file +del_ln=`seq $list_ln_start $list_ln_close | wc -l` +for i in `seq 1 $del_ln` +do + sed -i "${list_ln_start}d" "$1" +done +sed -i "$((list_ln_start - 1))r$gsl_tmp_list_HTML" "$1" + +rm -f "$gsl_tmp_list_brut" +rm -f "$gsl_tmp_list_HTML" + +make__lists "$gsl_tmp_post" } -#----------------------------------------------------------------------- -# Create a new line from | to
    -#----------------------------------------------------------------------- -gsl__make_newline() { -while read -r "nbrline" "nl" "content" + +#====================================================================== +# Quotes (independant module) +# $1: file +#====================================================================== +make__quotes() { +# Get block quote +unset ${!quote@} my_class ${!q_@} +while IFS=: read -r "ln" "mk" do - echo -ne "\r\033[2K: Converting New Line... | >
    " - sed -i "${nbrline}s,|,
    ," "$gsl_tmp_post" -done < <(awk -v nl="|" '$1==nl {print NR,$0}' "$gsl_tmp_post") -echo -ne "\r\033[2K" + [[ $quote_ln_start ]] \ + && quote_ln_close="$ln" \ + || quote_ln_start="$ln" +done < <(grep -n "^---" "$1" | head -n 2) + +[[ $quote_ln_close ]] || return + +# Put in a file brut block quote +gsl_tmp_quote_brut=`mktemp` +awk -v lns="$quote_ln_start" -v lnc="$quote_ln_close" \ + 'NR >= lns && NR <= lnc {print}' \ + "$1" \ + > "$gsl_tmp_quote_brut" + +# Define custom CSS class +my_class=`awk 'NR == 1 {print $2}' "$gsl_tmp_quote_brut"` +[[ $my_class ]] \ + && my_class=" $my_class" +sed -i "1d" "$gsl_tmp_quote_brut" +sed -i "`cat "$gsl_tmp_quote_brut" | wc -l`d" "$gsl_tmp_quote_brut" + + # Get metadatas from quote + #------------------------- + make__quotes_set() { + grep "$1" "$gsl_tmp_quote_brut" | awk -F" : " '{print $2}' + } + + # Delete useless line from source + #-------------------------------- + make__quotes_rmln() { + [[ "$2" ]] || return + q_ln=`grep -n "$1" "$gsl_tmp_quote_brut" | awk -F: '{print $1}'` + sed -i "${q_ln}d" "$gsl_tmp_quote_brut" + } + +q_link=`make__quotes_set '^_link : '` && \ +make__quotes_rmln '^_link : ' "$q_link" +q_lang=`make__quotes_set '^_lang : '` && \ +make__quotes_rmln '^_lang : ' "$q_lang" +q_auth=`make__quotes_set '^_cite : '` && \ +make__quotes_rmln '^_cite : ' "$q_auth" +q_book=`make__quotes_set '^_book : '` && \ +make__quotes_rmln '^_book : ' "$q_book" +q_year=`make__quotes_set '^_year : '` && \ +make__quotes_rmln '^_year : ' "$q_year" + +# Put in a file HTML quote +gsl_tmp_quote_HTML=`mktemp` + +[[ "$q_auth" ]] && q_ref="$q_auth " +[[ "$q_book" ]] && q_book="- $q_book" +[[ "$q_year" ]] && q_year="($q_year)" + +# Define HTML +[[ "$q_link" ]] && q_HTML_link="href=\"$q_link\" target=\"_blank\"" +[[ "$q_lang" ]] && q_HTML_lang=" lang=\"$q_lang\"" +[[ "$q_link" ]] && q_HTML_cite=" cite=\"$q_link\"" + +q_CSS="class=\"${site_css}_quote$my_class\"" +q_CSS_fig="class=\"${site_css}_quote-fig$my_class\"" +q_CSS_link="class=\"${site_css}_quote-link\"" + +if [[ "$q_book" && "$q_year" ]];then + q_ref+="$q_book$q_year" + q_data=" $q_book$q_year" + q_TITLE=" title=\"$q_ref\"" + +elif [[ "$q_book" ]] && ! [[ "$q_year" ]];then + q_ref+="$q_book" + q_data=" $q_book" + q_TITLE=" title=\"$q_ref\"" + +elif [[ "$q_year" ]] && ! [[ "$q_book" ]];then + q_ref+="$q_year" + q_data=" $q_year" + q_TITLE=" title=\"$q_ref\"" +fi + +# Make HTML file +if [[ "$q_auth" ]];then +# case figure +cat < "$gsl_tmp_quote_HTML" +
    + +$(while read -r "line" + do + printf '%4s%s\n' "" "$line" + done < <(cat "$gsl_tmp_quote_brut")) +
    +
    + + $q_auth$q_data + +
    +
    +EOQUOTE + +else +# Simple quote +cat < "$gsl_tmp_quote_HTML" +
    +$(while read -r "line" + do + printf '%4s%s\n' "" "$line" + done < <(cat "$gsl_tmp_quote_brut")) +
    +EOQUOTE +fi + +# Remove source lines and insert HTML file +del_ln=`seq $quote_ln_start $quote_ln_close | wc -l` +for i in `seq 1 $del_ln` +do + sed -i "${quote_ln_start}d" "$1" +done +sed -i "$((quote_ln_start - 1))r$gsl_tmp_quote_HTML" "$1" + +#cat "$gsl_tmp_quote_brut" +rm -f "$gsl_tmp_quote_brut" +rm -f "$gsl_tmp_quote_HTML" + +make__quotes "$gsl_tmp_post" +} + + +#====================================================================== +# div container between titles +# $1: file +#====================================================================== +make__div_title() { +max_lines=`cat "$1" | wc -l` + +# Mark if betwee +while IFS=: read -r "ln" "content" +do + [[ $title_start ]] \ + && title_close="$ln" \ + || title_start="$ln" + + ! [[ $title_close ]] && continue + + if [[ -z `awk -v lns="$title_start" -v lnc="$title_close" \ + 'NR > lns && NR < lnc' "$1"` ]];then + sed -i -e "${title_start}s|^|NODIV|" "$1" + + else + sed -i -e "${title_close}s|$|ENDIV|" "$1" + fi + + title_start=$title_close;unset title_close +done < <(grep "^" + sed -i "$(( ln + n ))i$div_title" "$1" +done < <(grep "^" "$1" + (( n++ )) +done < <(grep -n 'ENDIV$' "$1") +echo "" >> "$1" +sed -i "s^NODIV^^g" "$1" +sed -i "s^ENDIV^^g" "$1" } diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index 0d30a99..cf5e6aa 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -1,231 +1,220 @@ #!/bin/bash # file: gsl__post_manager # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -#----------------------------------------------------------------------- -# ----------------------------------------------------------- -# MAIN LOOP. Read from Post list. Do according to Post Status -# ----------------------------------------------------------- -#----------------------------------------------------------------------- -gsl__loop_posts() { -gsl__check_nbr_posts -(( $gsl_nbr_posts == 0 )) \ - && gsl__logs_print \ - "$gsl_log_w" \ - "Files" \ - "Not found" \ - "Nothing to do" \ - "${PWD}" \ - && gsl_checker_war=true \ - && return - -gsl__logs_print \ - "$gsl_log_i" \ - "Files" \ - "Found" \ - "$gsl_nbr_posts" \ - "${PWD}" +#====================================================================== +# --------------------------------- +# LOOP. Read ALL .gsl files in $PWD +# --------------------------------- +#====================================================================== +posts__loop() { for gsl_post in `ls -1 *.gsl 2>/dev/null` do - # Check specific asked Post - if [[ "$gsl_this_post" ]];then - ! [[ "$gsl_post" == "$gsl_this_post" ]] \ + # Do specific asked Post + [[ "$gsl_this_post" ]] && ! [[ "$gsl_post" == "$gsl_this_post" ]] \ + && continue + + # Set DB files (here, for newer post) + gsl_file_db_post="$gsl_dir_db_domain/$gsl_post.db" + gsl_file_db_post_hash="$gsl_dir_db_domain/.$gsl_post.db" + + # check newer only + [[ $gsl_check_newer ]] && [[ -f "$gsl_file_db_post" ]] \ && continue - fi - gsl__get_sum "$gsl_post" - - # Post too small / Should miss headers - if (( "$gsl_post_size" <= $gsl_post_min_size ));then - gsl__logs_print \ - "$gsl_log_w" \ - "File" \ - "Content" \ - "Not enough datas $gsl_post ($gsl_post_size < $gsl_post_min_size)" \ - "${PWD}/$gsl_post" - gsl_checker_war=true - continue - fi - - # Set DB Post file - gsl_file_db_post="$gsl_dir_db/$gsl_post.db" - gsl__db_get_post_datas "$1" - gsl__db_compare_post_hash - - gsl__post_begin - gsl__get_needed_headers - gsl__page_prepare_datas - - if [[ "$gsl_post_new_hash" ]];then - unset gsl_db_post_status - gsl_checker_war=true - if [[ -f "$gsl_srv_wip_page" ]];then - rm -f "$gsl_srv_wip_page" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "wip" \ - "Delete" \ - "$gsl_post_type ; $gsl_post has changed !" \ - "$gsl_srv_wip_page" - fi - - if [[ -f "$gsl_file_db_post" ]];then - rm -f "$gsl_file_db_post" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "Delete" \ - "file ; $gsl_post has changed !" \ - "$gsl_file_db_post" - fi - fi + article__sum "$gsl_post" || continue + article__splitter || return + DB__datas "$1" + DB__compare_hash "$1" + [[ "$article_Type" ]] \ + && srv__files datas # From COMMAND [OPT] case "$1" in - check) - if ! [[ "$gsl_force_check" ]];then - ! [[ "$gsl_post_new_hash" ]] && continue - fi - - gsl__logs_print \ - "$gsl_log_i" \ - "Reading" \ - "File" \ - "$gsl_post" \ - "${PWD}" - gsl__all_checkers - ;; - - make) - case "$gsl_db_post_status" in - chk) - gsl__all_makers - ;; - - *) - if ! [[ "$gsl_post_new_hash" ]];then - # Should not be used... - [[ "$gsl_force_make" ]] \ - && gsl__all_makers \ - && continue - - if [[ -f "$gsl_srv_wip_page" ]];then - gsl__logs_print \ - "$gsl_log_w" \ - "Post" \ - "Make" \ - "$gsl_post already Converted" \ - "$gsl_file_db_posts" - gsl_checker_war=true - continue - fi - fi - ;; - esac - ;; - - www) - gsl_checker_war=true - case "$2" in - add) - case "$gsl_db_post_status" in - wip|www) - rsync -a --delete \ - "$gsl_srv_wip_page" "$gsl_srv_www_page" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "SRV" \ - "www" \ - "Synced: $gsl_post_type $gsl_post" \ - "$gsl_srv_www_page" - gsl__db_set_post_status www - ;; - *) - gsl__logs_print \ - "$gsl_log_e" \ - "Post" \ - "Status" \ - "$gsl_db_post_status: $gsl_post not Converted" \ - "$gsl_file_db_posts" - gsl_checker_err=true - ;; - esac - ;; - remove) - case "$gsl_post_type" in - post) - ! [[ -d "$gsl_srv_www_page" ]] \ - && return - gsl_rm_c="rm -rf" - ;; - page) - ! [[ -f "$gsl_srv_www_page" ]] \ - && return - gsl_rm_c="rm -f" - ;; - esac - $gsl_rm_c "$gsl_srv_www_page" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "SRV" \ - "www" \ - "REMOVED $gsl_post_type $gsl_post" \ - "$gsl_srv_www_page" - gsl__db_set_post_status wip - ;; - esac - ;; + check) Checkers ;; + make) Makers ;; + www) WWW__validate "$2" ;; + wip) WIP__remove "$2" ;; esac + + # In DB, show logs for server + if [[ "$article_Type" ]];then + if [[ $article_new_hash ]];then + [[ "$old_Type" ]] \ + && log_content="new TYPE" \ + || log_content="new content" + wip__remove "$log_content" + fi + + srv__files datas + srv__files logs + fi + + unset ${!article_@} done + +# Remove split files +[[ -f "$gsl_tmp_post" ]] && rm -f "$gsl_tmp_post" +[[ -f "$gsl_tmp_head" ]] && rm -f "$gsl_tmp_head" } -#----------------------------------------------------------------------- -# -------------------- -# Doing some checkings -# -------------------- -#----------------------------------------------------------------------- -#======================================================================= -# Check NAME post from [OPT] ; should be from autocompletion -#======================================================================= -gsl__check_opt_post() { -if [[ `ls -1 *.gsl | grep "$1"` ]];then - gsl_this_post="$1" -else - echo "! $1 Not Found" - exit -fi -} - -#======================================================================= -# Check if posts from PWD folder -#======================================================================= -gsl__check_nbr_posts() { +#====================================================================== +#--------------------- +# Tools for post files +#--------------------- +#====================================================================== +#====================================================================== +# Check if .gsl files +#====================================================================== +if__gsl_post() { gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l` - (( $gsl_nbr_posts == 0 )) \ - && echo "! No Posts found with .gsl extension" \ + && echo "! No .gsl file in this folder" \ && exit } -#====================================================================== -# Create TMP file > Get Content Post Only (after #1) -#====================================================================== -gsl__post_content_only() { -gsl_tmp_post=`mktemp` -awk -v l="$gsl_post_begin" \ - 'NR >= l' \ - "$gsl_post" \ - > "$gsl_tmp_post" -} -gsl__post_begin() { +#====================================================================== +# Get line from first title to split header & content +#====================================================================== +article__splitter() { gsl_post_begin=` awk -v m="#1" \ 'match($1,m) {print NR;exit}' \ "$gsl_post"` + +if ! [[ "$gsl_post_begin" ]];then + gsl__logs_print -e -c \ + "Begins" \ + "Unused: '#1' TITLE" \ + "${PWD}/$gsl_post" + return 1 +fi + +file__header_only +file__post_only + +gsl__logs_print -i -g \ + "Split" \ + "line: $gsl_post_begin ; Header + Content" \ + "$gsl_tmp_head + $gsl_tmp_post" +} + + +#====================================================================== +# Create TMP file > Get Headers metas Only (before #1) +#====================================================================== +file__header_only() { +gsl_tmp_head=`mktemp` +awk -v l="$gsl_post_begin" \ + 'NR < l' \ + "$gsl_post" \ + > "$gsl_tmp_head" +} + + +#====================================================================== +# Create TMP file > Get Content Post Only (after #1) +#====================================================================== +file__post_only() { +gsl_tmp_post=`mktemp` +awk -v l="$gsl_post_begin" \ + 'NR >= l' \ + "$gsl_post" \ + > "$gsl_tmp_post" +} + + +#====================================================================== +# Get Size & cksum Hash from File... $1: File +#====================================================================== +article__sum() { +article_Sum=`cksum "$1"` +article_Hash=`awk '{print $1}' <<< "$article_Sum"` +article_Size=`awk '{print $2}' <<< "$article_Sum"` + +case "$gsl_proc" in + create|edit) return ;; +esac + +# Post too small ? +if (( "$article_Size" <= $gsl_article_min_Size ));then + gsl__logs_print -w -A -sk \ + "Not enough content ($article_Size < $gsl_article_min_Size)" \ + "${PWD}/$1" + return 1 +fi + +gsl__logs_print -i -A -src \ + "Hash: $article_Hash ; Size: $article_Size" \ + "${PWD}/$1" +} + + +#====================================================================== +# Get arguments from COMMAND (create) +# $2: post type +# $3: post name +#====================================================================== +new__article_OPTIONS() { +gsl__find_domain +author__check || exit 0 + +# exit if no postname +! [[ "$3" ]] \ + && gsl__invalid_option "$3" "Please set a name for your $2" + +gsl_postname="$3" +case "$gsl_postname" in + *".gsl") gsl_postname=${gsl_postname/%.gsl/} +esac + +# File exists +[[ -f "$gsl_postname.gsl" ]] \ + && echo "! $PWD/$gsl_postname.gsl already exists..." \ + && exit + +gsl_proc="create" +[[ `grep -i "fr" <<<"$gsl_site_lang"` ]] \ + && gsl_today=`printf '%(%d-%m-%Y)T'` \ + || gsl_today=`date +%F` + +gsl_post="$gsl_postname.gsl" +log__process_begin "Create $2" + +touch "$PWD/$gsl_post" +cat << EONEWP >> "$PWD/$gsl_post" +type: $2 +title: +slug: +info: +author: +tags: +date: $gsl_today + +# Uncomment and fill +#link: NAME : URL : Alt-Text +#image: NBR : URI : ALT-TEXT +#abbr: SHORT : LONG + +#1 +·Bold· •Strong• ”Emphasis” ×Stile× ¤cat -n "$PWD/$gsl_postname.gsl"¤ +EONEWP + +get__post_sum "$gsl_post" +gsl__logs_print -i -f -src \ + "Hash: $gsl_post_hash ; Size: $gsl_post_size" \ + "$PWD/$gsl_post" + +log__process_end "Create $2" + +cat -n "$PWD/$gsl_post" +echo +gsl check "$gsl_post" +exit } diff --git a/var/lib/gsl/scripts/gsl__sidebar b/var/lib/gsl/scripts/gsl__sidebar deleted file mode 100644 index a4a24d2..0000000 --- a/var/lib/gsl/scripts/gsl__sidebar +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# file: gsl__sidebar -# Folder: /var/lib/gsl/scripts -# By echolib -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - -#====================================================================== -# Sidebar Manager | $1=call | $2=process | $3=POS/Post | $4=Post -#====================================================================== -gsl__sidebar() { -case "$2" in - "") - ls -1X "$gsl_dir_domain_listings" - exit - ;; - - create|-C) - ! [[ `ls -1 "$gsl_dir_domain_listings"` ]] \ - && echo "! No post in list: $gsl_dir_domain_listings" \ - && exit - - gsl__page_sidebar_create - ;; - - add|-A) - # $2=process | $3=Position | $4=post - gsl_listing_process="add" - ! [[ "$3" ]] \ - && echo "! Set a number <= $gsl_list_max_posts ; see help" \ - && exit - - ! [[ `expr "x$3" : "x[0-9]*$"` -gt 0 ]] \ - && gsl__list_bad_arg nbr $3 - - ! (( $3 <= $gsl_list_max_posts )) \ - && gsl__list_bad_arg nbr $3 - - ! [[ "$4" ]] \ - && gsl__list_bad_arg file - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "$1 ; $2 ; position $3 ; $4 from domain $gsl_find_domain" \ - "$gsl_dir_domain_tpl/last-posts-list.html" - - gsl__if_file "$4" post - gsl_listing_file="$gsl_dir_domain_listings/$4.list" - gsl_post_old_inlist=`ls -1 "$gsl_dir_domain_listings/" | grep ".list.$3"` - - if [[ `ls -1 "$gsl_listing_file"* 2>/dev/null` ]];then - # Post exists (maybe with different position) - gsl__logs_print \ - "$gsl_log_w" \ - "Sidebar" \ - "Post" \ - "$gsl_listing_process $4 ; already in list !" \ - "$gsl_dir_domain_listings/" - gsl_checker_war=true - - elif [[ "$gsl_post_old_inlist" ]];then - # Another post exists at this position. - # Remove and create new in roller - rm -f "$gsl_dir_domain_listings/$gsl_post_old_inlist" - gsl__logs_print \ - "$gsl_log_w" \ - "Sidebar" \ - "Post" \ - "$gsl_listing_process $4 ; replace $gsl_post_old_inlist !" \ - "$gsl_dir_domain_listings/$gsl_post_old_inlist" - gsl_checker_war=true - gsl__page_sidebar $2 $3 $4 - else - # Not gound in list, create for roller - gsl__page_sidebar $2 $3 $4 - fi - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "$1 ; $2 ; position $3 ; $4 from domain $gsl_find_domain" \ - "$gsl_dir_domain_tpl/last-posts-list.html" - ;; - - remove|-R) - gsl_listing_process="remove" - ! [[ "$3" ]] \ - && gsl__list_bad_arg file $3 - - gsl__if_file "$3" post - - gsl__logs_print \ - "$gsl_log_i" \ - "Starting" \ - "Process" \ - "$1 ; $2 ; $3 from domain $gsl_find_domain" \ - "$gsl_dir_domain_tpl/last-posts-list.html" - - gsl_post_rm_list=`ls -1 "$gsl_dir_domain_listings/" | grep "$3.list"` - rm -f "$gsl_dir_domain_listings/$gsl_post_rm_list" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "Sidebar" \ - "$2" \ - "$3 from domain $gsl_find_domain in list" \ - "$gsl_dir_domain_listings/$gsl_post_rm_list" - gsl_checker_war=true - - gsl__page_sidebar_create - - gsl__logs_print \ - "$gsl_log_i" \ - "Stopping" \ - "Process" \ - "$1 ; $2 ; $3 from domain $gsl_find_domain" \ - "$gsl_dir_domain_tpl/last-posts-list.html" - ;; - - *) - echo "! Bad argument: add|-A/remove|-R" - exit - ;; -esac -} - -#====================================================================== -# Sidebar Return bad argument -#====================================================================== -gsl__list_bad_arg() { - case "$1" in - nbr) - echo "! $2 is not a number <= $gsl_list_max_posts ; see help" - ;; - file) - echo "! Set post [FILE]" - ;; - esac - exit -} diff --git a/var/lib/gsl/scripts/gsl__srv_manager b/var/lib/gsl/scripts/gsl__srv_manager new file mode 100644 index 0000000..7645994 --- /dev/null +++ b/var/lib/gsl/scripts/gsl__srv_manager @@ -0,0 +1,335 @@ +#!/bin/bash +# file: gsl__srv_manager +# Folder: /var/lib/gsl/scripts +# By echolib (XMPP: im@echolib.re) +# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + + +#====================================================================== +# w<< (ARGUMENT) +# $1: process +# $2: file / all +#====================================================================== +srv__OPTIONS() { +case "$2" in + sync) sync__OPTIONS $1 ;; + add) true ;; + remove) true ;; + *) gsl__invalid_option "$2" "add|remove|sync" +esac + +case "$3" in + *".gsl") + if__file "$3" post + gsl_post="$3" + post_only="$3" + case "$1" in + wip) + gsl make "$3" + exit + ;; + esac + ;; + + all) + case "$1" in + www) + echo "! You're about to put online all wip articles" + read -rp "- Continue (YES|*)" www_confirm + case "www_confirm" in + YES) gsl_www="$3" ;; + *) echo "# Abandon"; exit ;; + esac + ;; + + wip) + gsl make + exit + ;; + esac + ;; + + "") + gsl__invalid_option "$3" "all|file" + ;; +esac + +www_process=true + +[[ "$gsl_post" ]] || log_info_all=" ALL" + +log__process_begin "Server ($1 online)${log_info_all}" +posts__loop "$1" "$2" + +# For logs ; set post or unset if all +[[ $log_info_all ]] && unset gsl_post +[[ $post_only ]] && gsl_post="$post_only" + +log__process_end "Server ($1 online)${log_info_all}" +} + + +#====================================================================== +# wip: remove online +#====================================================================== +WIP__remove() { +case "$1" in + remove) + if [[ -f "$gsl_srv_post_wip" ]];then + rm -f "$gsl_srv_post_wip" && \ + gsl__logs_print -w -srv wip \ + "Article deleted ; no more online" \ + "$gsl_srv_post_wip" + + find "$gsl_srv_wip" -type d -empty -delete && \ + gsl__logs_print -w -srv wip \ + "Cleaned empty directories" \ + "$gsl_srv_wip" + + DB__set_status "wip-del" + fi + return + ;; +esac +} + + +#====================================================================== +# www: Valid online +#====================================================================== +WWW__validate() { +case "$1" in + remove) + if [[ -f "$gsl_srv_post_www" ]];then + rm -f "$gsl_srv_post_www" && \ + gsl__logs_print -w -srv www \ + "Article deleted ; no more online" \ + "$gsl_srv_post_www" + + find "$gsl_srv_www" -type d -empty -delete && \ + gsl__logs_print -w -srv www \ + "Cleaned empty directories" \ + "$gsl_srv_www" + + DB__set_status "www-del" + fi + return + ;; +esac + +if ! [[ $article_Status_chk ]];then + gsl__logs_print -e -srv www \ + "Article not yet checked" \ + "$PWD/$gsl_post" + return + +elif (( $article_Status_chk != $article_Status_wip ));then + gsl__logs_print -e -srv www \ + "Article not yet converted with make" \ + "$gsl_srv_post_wip" + return + +elif (( $article_Status_chk == $article_Status_www )) && \ + [[ -f "$gsl_srv_post_www" ]];then + gsl__logs_print -w -srv www \ + "Article already online" \ + "$gsl_srv_post_www" + return + +else + if (( $article_Status_chk == $article_Status_wip ));then + [[ "$article_Slug" =~ "/" ]] \ + && mkdir -p "$gsl_slug_dir_www" + + rsync -a "$gsl_srv_post_wip" "$gsl_srv_post_www" && \ + gsl__logs_print -i -srv www \ + "Article validated online" \ + "$gsl_srv_post_www" && \ + DB__set_status "www" + fi +fi +} + + +#====================================================================== +# Get arguments from COMMAND (sync) +# $2: process (wip|www|"") +#====================================================================== +sync__OPTIONS() { +gsl_srv_wip="$site_server/$site_ndd/wip" +gsl_srv_www="$site_server/$site_ndd/www" + +case "$1" in + ""|www|wip) + ! [[ "$1" ]] \ + && srv_proc="wip+www" \ + || srv_proc="$1" + + log__process_begin "Sync $srv_proc" + case "$1" in + "") + sync__srv "$srv_proc" "$gsl_srv_wip" + sync__srv "$srv_proc" "$gsl_srv_www" + ;; + www) + sync__srv "$srv_proc" "$gsl_srv_www" + ;; + wip) + sync__srv "$srv_proc" "$gsl_srv_wip" + ;; + esac + log__process_end "Sync $srv_proc" + ;; + + *) + gsl__invalid_option "$2" "www|wip" + ;; +esac +exit +} + + +#====================================================================== +# Sync Files from Templates to webserver +# $1: process (wip|www|wip+www) +# $2: Folder +#====================================================================== +sync__srv() { +# Sync Files and Folders +mkdir -p "$2" +rsync -a --delete "$gsl_dir_domain_tpl" "$2" +rsync -a --delete "$gsl_dir_domain_files" "$2" +rsync -a --delete "$gsl_dir_domain_images" "$2" +rsync -a --delete "$gsl_dir_domain_listings" "$2" + +gsl__logs_print -i -srv $1 \ + "Sync: $gsl_dir_domain/" \ + "$2/" +} + + +#====================================================================== +# Set Post/Page file for www+wip from page type and slug +# Find server post/page file and log +#====================================================================== +srv__files() { +gsl_srv_wip="$site_server/$site_ndd/wip" +gsl_srv_www="$site_server/$site_ndd/www" + +case "$1" in + datas) + unset srv_uri + case "$article_Type" in + post) + gsl_srv_post_wip="$gsl_srv_wip/$article_Slug/index.html" + gsl_srv_post_www="$gsl_srv_www/$article_Slug/index.html" + gsl_slug_file="$article_Slug/index.html" + gsl_slug_dir_wip=${gsl_srv_post_wip%\/*} + gsl_slug_dir_www=${gsl_srv_post_www%\/*} + + # Count sub directories + sub_uri="${article_Slug//[^\/]}" + srv_uri+=`printf '%0.s../' $(seq 0 ${#sub_uri})` + ;; + + page) + gsl_srv_post_wip="$gsl_srv_wip/$article_Slug.html" + gsl_srv_post_www="$gsl_srv_www/$article_Slug.html" + gsl_slug_file="$article_Slug.html" + + srv_uri='./' + ;; + + *) + return + ;; + esac + + # wip file ? + if [[ -f "$gsl_srv_post_wip" ]];then + [[ "$article_Status_wip" == "$article_Status_chk" ]] \ + && wip_status="(current)" \ + || wip_status="(old)" + + gsl_srv_wip_file=true + + else + unset gsl_srv_wip_file + fi + + # www file ? + if [[ -f "$gsl_srv_post_www" ]];then + [[ "$article_Status_www" == "$article_Status_chk" ]] \ + && www_status="(current)" \ + || www_status="(old)" + + gsl_srv_www_file=true + + else + unset gsl_srv_www_file + fi + ;; + + logs) + # WIP file + if [[ $gsl_srv_wip_file ]];then + gsl__logs_print -i -srv -wip \ + "HTML $article_Type Found $wip_status" \ + "$gsl_srv_post_wip" + + else + gsl__logs_print -w -srv -wip \ + "HTML $article_Type not created yet" \ + "$gsl_srv_post_wip" + fi + + # WWW file + if [[ $gsl_srv_www_file ]];then + gsl__logs_print -i -srv -www \ + "HTML $article_Type Found $www_status" \ + "$gsl_srv_post_www" + else + gsl__logs_print -w -srv -www \ + "HTML $article_Type not created yet" \ + "$gsl_srv_post_www" + fi + ;; +esac +} + +#====================================================================== +# Remove WIP page +# If error from check and exists +#====================================================================== +wip__remove() { +! [[ -f "$gsl_srv_post_wip" ]] && return + +log_Type="in $article_Slug" + +# Remove from old slug, if new article Type set +[[ "$old_Type" ]] \ + && article_Type="$old_Type" \ + && article_Slug="$old_Slug" \ + && log_Type="from old $old_Type" + +rm -f "$gsl_srv_post_wip" && \ +gsl__logs_print -w -S -wip \ + "Article deleted ; no more preview" \ + "$gsl_srv_post_wip" + +find "$gsl_srv_wip" -type d -empty -delete && \ +gsl__logs_print -w -S -wip \ + "Cleaned empty directories" \ + "$gsl_srv_wip" + +gsl__logs_print -w -R -wip \ + "Found $1 $log_Type" \ + "$gsl_srv_post_wip" + +if [[ "$old_Type" ]];then + unset old_Type old_Slug log_Type + + [[ -f "$gsl_file_db_post" ]] \ + && source "$gsl_file_db_post" +fi +} diff --git a/var/lib/gsl/scripts/gsl__stats b/var/lib/gsl/scripts/gsl__stats index 5468309..5feb670 100644 --- a/var/lib/gsl/scripts/gsl__stats +++ b/var/lib/gsl/scripts/gsl__stats @@ -1,118 +1,144 @@ #!/bin/bash # file: gsl__stats # Folder: /var/lib/gsl/scripts -# By echolib +# By echolib (XMPP: im@echolib.re) # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -gsl__get_stats() { -gsl_stats_article_all=0 # All non error -# Status -gsl_stats_articles_www=0 # All www -gsl_stats_articles_pages_www=0 # All page www -gsl_stats_articles_posts_www=0 # All page www - -gsl_stats_articles_wip=0 # All wip -gsl_stats_articles_pages_wip=0 -gsl_stats_articles_posts_wip=0 - -gsl_stats_articles_chk=0 # All wip -gsl_stats_articles_pages_chk=0 -gsl_stats_articles_posts_chk=0 - -# Author -gsl_auth_max=0 -while read -r "N" "AUTHOR" -do - gsl_auth[$N]="$AUTHOR" - gsl_this_auth[$N]=0 - ((gsl_auth_max++)) -done < <(cat -n "$gsl_this_conf_domain/$gsl_filename_auth") - -# Counting -while read -r "file_gsl_db" -do - ((gsl_stats_article_all++)) - gsl_file_uri_db="$gsl_dir_db/$file_gsl_db" - - # Author - gsl_auth_name=`grep "Author:" $gsl_file_uri_db | awk -F: '{print $2}'` - for a in `seq 1 $gsl_auth_max` - do - [[ ${gsl_auth[$a]} == "$gsl_auth_name" ]] \ - && ((gsl_this_auth[$a]++)) - done - - # Online - if [[ `grep "Status:www" $gsl_file_uri_db` ]];then - ((gsl_stats_articles_www++)) - - [[ `grep "page:" $gsl_file_uri_db` ]] \ - && ((gsl_stats_articles_pages_www++)) - - [[ `grep "post:" $gsl_file_uri_db` ]] \ - && ((gsl_stats_articles_posts_www++)) - - # WIP - elif [[ `grep "Status:wip" $gsl_file_uri_db` ]];then - ((gsl_stats_articles_wip++)) - - [[ `grep "page:" $gsl_file_uri_db` ]] \ - && ((gsl_stats_articles_pages_wip++)) - - [[ `grep "post:" $gsl_file_uri_db` ]] \ - && ((gsl_stats_articles_posts_wip++)) - - # CHK - elif [[ `grep "Status:chk" $gsl_file_uri_db` ]];then - ((gsl_stats_articles_chk++)) - - [[ `grep "page:" $gsl_file_uri_db` ]] \ - && ((gsl_stats_articles_pages_chk++)) - - [[ `grep "post:" $gsl_file_uri_db` ]] \ - && ((gsl_stats_articles_posts_chk++)) - fi - -done < <(ls -1 "$gsl_dir_db" | grep ".gsl.db") - -# Creating statoolinfos file -#gsl.articles=nombre d'articles -#gsl.articles.pages=nombre d'articles type page -#gsl.articles.posts=nombre d'articles type page -#gsl.authors=nombre d'auteurs - -#gsl.articles.words= -#gsl.articles.quotes= -#gsl.articles.paragraphs= - - -printf '%s\n%s\n%s\n%s\n' \ - "gsl.articles=$gsl_stats_articles_www" \ - "gsl.articles.pages=$gsl_stats_articles_pages_www" \ - "gsl.articles.posts=$gsl_stats_articles_posts_www" \ - "gsl.authors=$gsl_auth_max" \ - > "$gsl_file_sti" && \ -echo "> Génération des stats (Statoolinfos): $gsl_file_sti" - -# Show stats -echo -e "# Total (no error): $gsl_stats_article_all" -for a in `seq 1 $gsl_auth_max` -do - echo "- ${gsl_auth[$a]}: ${gsl_this_auth[a]}" -done - -echo -printf '%s\n%s%s%s\n%s%s%s\n%s%s%s\n' \ - "CHK|WIP|WWW" \ - "All: $gsl_stats_articles_chk|" \ - "All: $gsl_stats_articles_wip|" \ - "All: $gsl_stats_articles_www" \ - "Pages: $gsl_stats_articles_pages_chk|" \ - "Pages: $gsl_stats_articles_pages_wip|" \ - "Pages: $gsl_stats_articles_pages_www" \ - "Posts: $gsl_stats_articles_posts_chk|" \ - "Posts: $gsl_stats_articles_posts_wip|" \ - "Posts: $gsl_stats_articles_posts_wip" \ - | column -t -s'|' +#====================================================================== +# Init Stats | Called from Checkers() +#====================================================================== +stats__init() { +gsl_stat_po=0;gsl_stat_pc=0 # paragraphs +gsl_stat_bq=0 +gsl_stat_abbrs=0 +gsl_stat_links=0 +gsl_stat_links_online=0 +gsl_stat_flinks=0 +gsl_stat_images=0 +gsl_stat_fcodes=0 +gsl_stat_fbruts=0 +gsl_stat_strongs=0 +gsl_stat_bolds=0 +gsl_stat_italics=0 +gsl_stat_icodes=0 +gsl_stat_strikes=0 +gsl_stat_titles=0 +} + + +#====================================================================== +# Called from stats ; Counting datas from db +#====================================================================== +stats__datas() { +gsl_file_sti="$site_server/$domain_name/www/gsl-sti.properties" + +# Basic +stat_authors_max=`cat "$gsl_file_domain_authors" | wc -l` + +# Init WWW stats +stat_articles_www=0 +stat_articles_pages_www=0 +stat_articles_posts_www=0 +stat_articles_tags_www=0 +stat_articles_words_www=0 +stat_articles_quotes_www=0 +stat_articles_paragraphs_www=0 +stat_articles_links_www=0 +stat_articles_links_online_www=0 +stat_articles_lists_www=0 +stat_articles_lists_items_www=0 +stats_articles_max_images_www=0 + +# Counting Stats +while IFS=: read -r "filename" "status" +do + source "$filename" + ! (( $article_Status_www> 0 )) && continue + + ((stat_articles_www++)) + + case "$article_Type" in + post) ((stat_articles_posts_www++)) ;; + page) ((stat_articles_pages_www++)) ;; + esac + + stat_articles_tags_www=$(( stat_articles_tags_www + stat_Tags )) + stat_articles_words_www=$((stat_articles_words_www + stat_Words )) + stat_articles_quotes_www=$((stat_articles_quotes_www + stat_Quotes )) + stat_articles_paragraphs_www=$((stat_articles_paragraphs_www + stat_Paragraphs )) + stat_articles_links_www=$(( stat_articles_links_www + stat_Links )) + stat_articles_links_online_www=$(( stat_articles_links_online_www + stat_Links_Online )) + stat_articles_lists_www=$(( stat_articles_lists_www + stat_Lists )) + stat_articles_lists_items_www=$(( stat_articles_lists_items_www + stat_Lists_Items )) + stats_articles_max_images_www=$(( stats_articles_max_images_www + stat_max_Images )) + + unset ${!article_@} +done < <(grep -H "article_Status_www" "$gsl_dir_db_domain/"*.db) + +cat < "$gsl_file_sti" +gsl.articles = $stat_articles_www +gsl.articles.pages = $stat_articles_pages_www +gsl.articles.posts = $stat_articles_posts_www +gsl.authors = $stat_authors_max +gsl.articles.tags = $stat_articles_tags_www +gsl.articles.words = $stat_articles_words_www +gsl.articles.quotes = $stat_articles_quotes_www +gsl.articles.paragraphs = $stat_articles_paragraphs_www +gsl.articles.links = $stat_articles_links_www +gsl.articles.links.online = $stat_articles_links_online_www +gsl.articles.lists = $stat_articles_lists_www +gsl.articles.lists.items = $stat_articles_lists_items_www +gsl_articles.images = $stats_articles_max_images_www +EOSTATS + +echo "# Statoolinfos: $gsl_file_sti" +exit +} + + +#====================================================================== +# Stat: Count words and misc | Done with check command +# $1: gsl_tmp_èpost +#====================================================================== +Stat__words() { +# Global Words +gsl_stat_words=`cat "$1" | wc -w` +gsl_total_images=`grep "_image:" $1 | wc -l` +gsl_total_fcodes=`grep "_code:" $1 | wc -l` +gsl_total_fbruts=`grep "_brut:" $1 | wc -l` + +# Lists +(( $gsl_stat_lists > 0 )) \ + && gsl_list_items=`grep "^=\|^+" "$1" | wc -l` \ + || gsl_list_items=0 + +# Quotes +(( $gsl_stat_bq > 0 )) \ + && gsl_bq_items=`grep "^_year\|^_cite\|_lang\|_book\|_link" "$1" | wc -w` \ + || gsl_bq_items=0 + +echo "bq items> $gsl_bq_items" +gsl_stat_words=\ +$(( gsl_stat_words \ + - 2*gsl_stat_p \ + - 2*gsl_stat_bq \ + - 2*gsl_stat_lists \ + - gsl_list_items \ + - gsl_bq_items \ + - gsl_stat_titles \ + - gsl_total_fbrut \ + - gsl_total_fcode \ + - gsl_total_images \ +)) + +gsl_log_stats=` +printf '%s %s %s\n' \ + "W=$gsl_stat_words ; T=$gsl_stat_titles ; P=$gsl_stat_p ;" \ + "I=$gsl_total_images ; Q=$gsl_stat_bq ;" \ + "L=$gsl_stat_lists ($gsl_list_items)"` + +gsl__logs_print -i -st -c \ + "$gsl_log_stats" \ + "${PWD}/$gsl_post" } diff --git a/var/lib/gsl/scripts/gsl__tools b/var/lib/gsl/scripts/gsl__tools deleted file mode 100644 index ea68327..0000000 --- a/var/lib/gsl/scripts/gsl__tools +++ /dev/null @@ -1,280 +0,0 @@ -#!/bin/bash -# file: gsl__tools -# Folder: /var/lib/gsl/scripts -# By echolib -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - -#======================================================================= -# Check Needed Folders, and create needed files -#======================================================================= -# Folders -gsl__create_ff() { -for gsl_folder in "$gsl_dir_db" \ - "$gsl_dir_logs" -do - if ! [[ -d "$gsl_folder" ]];then - echo ": Creating $gsl_folder and give permissions to $USER" - sudo mkdir -p "$gsl_folder" && \ - sudo chown -R $USER:$USER "$gsl_folder" - fi -done - -# Files -for gsl_file in "$gsl_file_logs" \ - "$gsl_file_db_domains" -do - ! [[ -f "$gsl_file" ]] && touch "$gsl_file" -done -} - -#======================================================================= -# Check if PWD is configure for DOMAIN -#======================================================================= -gsl__find_domain() { -gsl_nbr_domains=` -find . -maxdepth 1 -not -type d -type f \ - -iname "gsl.*.*" 2>/dev/null \ - | wc -l` - -(( $gsl_nbr_domains > 1 )) \ - && echo "! Too much domains registred here: Set only One per folder" \ - && exit $gsl_nbr_domains -(( $gsl_nbr_domains == 0 )) \ - && echo "! No registred domain here: change or set folder. See help new" \ - && exit - -gsl_find_domain=` -find . -maxdepth 1 -not -type d -type f \ - -iname "gsl.*.*" 2>/dev/null` - -gsl_find_domain=` -awk -F"." '{print $(NF-1)"."$NF}' \ - <<< $gsl_find_domain` - -gsl_find_domain=${gsl_find_domain,,} -gsl__check_domain "$gsl_find_domain" -} - -#======================================================================= -# Check and set domain from DB -#======================================================================= -gsl__check_domain() { -gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"` - -! [[ "$gsl_this_conf_domain" ]] \ - && echo "! Domain Not found: $1" \ - && exit - -gsl_dir_domain_tpl="$gsl_this_conf_domain/templates" -gsl_dir_domain_files="$gsl_this_conf_domain/files" -gsl_dir_domain_images="$gsl_this_conf_domain/images" -gsl_dir_domain_listings="$gsl_this_conf_domain/X-tra" - -for gsl_new_dir in `set -o posix ; set \ - | grep "gsl_dir_domain" \ - | awk -F= '{print $2}'` -do - if ! [[ -d "$gsl_new_dir" ]];then - mkdir -p "$gsl_new_dir" 2>/dev/null && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Folder" \ - "Init..." \ - "Created" \ - "$gsl_new_dir" - fi -done - -gsl__if_file "$gsl_this_conf_domain/$gsl_find_domain.conf" source -} - -#----------------------------------------------------------------------- -# -------------- -# Tools for Post -# -------------- -#----------------------------------------------------------------------- - -#======================================================================= -# Get Size & cksum Hash from File... $1 hash/size $2: File -#======================================================================= -gsl__get_sum() { -gsl_post_sum=`cksum "$1"` -gsl_post_hash=`awk '{print $1}' <<< "$gsl_post_sum"` -gsl_post_size=`awk '{print $2}' <<< "$gsl_post_sum"` -} - -#======================================================================= -# Get line nbr from TERM in FIle... $1: TERM | $2: File -#======================================================================= -gsl__get_line() { -awk -v s="$1" \ - 'match($0,s) {print NR}' \ - "$2" -} - -#======================================================================= -# Get everything after the marker... $1: marker | $2: File -#======================================================================= -gsl__get_header() { -awk -F"$1" -v marker="$1" -v l="$gsl_post_begin" \ - 'NR < l && $0 ~ marker {print $2}' \ - "$2" 2>/dev/null -} - -#======================================================================= -# Get line nbr from CONTENT Post... $1: TERM | $2: File -#======================================================================= -gsl__get_content_line() { -grep -n "$1" "$2" | awk -F: '{print $1}' || return -} - -#======================================================================= -# Get CONTENT Post with markers... $1: Open Marker | $2: Close Marker -#======================================================================= -gsl__get_content_with_markers() { -gsl__get_content_finder \ - -o "$1" \ - -b "$gsl_post_header_field_1" \ - -c "$2" \ - -f "$gsl_post" \ - | tail -1 \ - || return -} - -#======================================================================= -# Get CONTENT with marks | ! find from ONE line content -#======================================================================= -gsl__get_content_finder() { -# Get [OPTs] -while (( "$#" )) - do - case "$1" in - -o) mk_o="$2" ;; # Open marker - -c) mk_c="$2" ;; # Close Marker - -b) mk_b="$2" ;; # Between markers - -f) file="$2" ;; # In whole file - -v) ivar="$2" ;; # In variable - -n) line="n" ;; # Give found line number - esac - shift -done - -! [[ "$file" ]] && ! [[ "$ivar" ]] && return 1 -! [[ "$mk_o" ]] && ! [[ "$mk_c" ]] && return 1 -! [[ "$mk_b" ]] && mk_b='.*' - -if [[ "$file" ]];then - grep -oP$line "(?<=$mk_o)$mk_b?(?=$mk_c)" "$file" && return -elif [[ "$ivar" ]];then - grep -oP$line "(?<=$mk_o)$mk_b?(?=$mk_c)" <<< "$ivar" && return -fi -} - -#======================================================================= -# Get NEEDED HEADERS | $1 VAR CONTENT $2 LOG Proc $3 LOG Act -#======================================================================= -gsl__check_needed_headers() { -! [[ "$1" ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Content" \ - "$2" \ - "Missing: $3" \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true -} - -#======================================================================= -# Get fields from variable... $1: field | $2: variable -#======================================================================= -gsl__get_header_field() { -awk -F" : " -v f="$1" \ - 'NFS=f {print $NFS}' \ - <<< "$2" -} - -#======================================================================= -# Get HEADER Fields + line nbr $1:marker -#======================================================================= -gsl__get_header_fields() { -gsl_post_hf_1=`gsl__get_header_field 1 "$gsl_header_content_line"` -gsl_post_hf_2=`gsl__get_header_field 2 "$gsl_header_content_line"` -gsl_post_hf_3=`gsl__get_header_field 3 "$gsl_header_content_line"` -gsl_post_hf_l=`gsl__get_line "$1$gsl_post_hf_1" "$gsl_post"` -} - -#======================================================================= -# Check NEEDED Fields from HEADER -#======================================================================= -gsl__check_header_fields() { -if ! [[ "$gsl_post_hf_1" ]] || \ - ! [[ "$gsl_post_hf_2" ]];then - - gsl__logs_print \ - "$gsl_log_e" \ - "$1" \ - "$2" \ - "Line:$gsl_post_hf_l > $3" \ - "${PWD}/$gsl_post" - gsl_checker_err=true - return -fi -} - -#======================================================================= -# Check OPTIONAL Field 3 from HEADER -#======================================================================= -gsl__check_header_field3() { -if ! [[ "$gsl_post_hf_3" ]];then - case "$3" in - "$gsl_marker_image") - gsl__logs_print \ - "$gsl_log_e" \ - "$1" \ - "$2" \ - "Line:$gsl_post_hf_l > No ALT TEXT !" \ - "${PWD}/$gsl_post" - gsl_checker_err=true - ;; - *) - gsl__logs_print \ - "$gsl_log_w" \ - "$1" \ - "$2" \ - "Line:$gsl_post_hf_l > No Alt Text" \ - "${PWD}/$gsl_post" - gsl_checker_war=true - ;; - esac -fi -} - -#====================================================================== -# A very simple debugger that show some values -#====================================================================== -gsl__debug() { -printf '\n%s\n%s\n%s\n%s\n' \ - "D> 1. '$1'" \ - "D> 2. '$2'" \ - "D> 3. '$3'" \ - "D> 4. '$4'" -sleep .5 -} - -#====================================================================== -# Basic: create a page/post named $3 from command line with date -#====================================================================== -gsl__create_article() { -touch "$PWD/$3.gsl" -cat << EONEWP >> "$PWD/$3.gsl" -type: $1 -title: -slug: -info: -author: -tags: -date: $2 - -#1 -EONEWP -} diff --git a/var/lib/gsl/scripts/gsl__version b/var/lib/gsl/scripts/gsl__version new file mode 100644 index 0000000..526b848 --- /dev/null +++ b/var/lib/gsl/scripts/gsl__version @@ -0,0 +1,33 @@ +#!/bin/bash +# file: gsl__version +# Folder: /var/lib/gsl/scripts +# By echolib (XMPP: im@echolib.re) +# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 + + +#====================================================================== +# Version checker of GSL with less or more details +#====================================================================== +version__OPTIONS() { +case "$1" in + -v) + awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/$app_name" + exit + ;; + + -vv) + v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"` + echo -n "# $app_name Current: $v_cur | " + if__command curl + v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'` + echo -ne "Online: $v_onl\n" + exit + ;; + + --version) + awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/$app_name" + if__file "$gsl_dir_lib/new-version.md" read + exit + ;; +esac +} diff --git a/var/log/.gitkeep b/var/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/var/log/gsl/.gitkeep b/var/log/gsl/.gitkeep new file mode 100644 index 0000000..e69de29