New sidebar argument ; readme ; help ; fix www
This commit is contained in:
parent
d4a13105b4
commit
00d48233d0
41
README.md
41
README.md
|
@ -386,8 +386,8 @@ _book: Esperanza 64
|
|||
|
||||
|
||||
### Créer des listes
|
||||
L'arborescence est "infinie". Chaque contenu de la liste
|
||||
*doit être sur la même ligne*
|
||||
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
|
||||
|
@ -428,6 +428,26 @@ Retour "forcé" à la ligne
|
|||
|
||||
```
|
||||
|
||||
# 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
|
||||
|
||||
```
|
||||
# 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
|
||||
```
|
||||
|
||||
# HELP COMMAND
|
||||
```
|
||||
|
@ -465,12 +485,7 @@ $ gsl [ARG]
|
|||
make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE]
|
||||
to HTML file in server
|
||||
-F : Force Make again
|
||||
|
||||
post-list [OPT] [FILE] : Add post again from [FILE] to Last-Posts List
|
||||
(When converting new post, it will be added)
|
||||
Pin : Set Post from [FILE] to first in Last-Posts List
|
||||
Add : Add Post from [FILE] to last in Last-Posts List
|
||||
|
||||
|
||||
www [OPT1] [OPT2] : Add/Remove Post from www server
|
||||
[OPT1]:
|
||||
add : Add all/[FILE] to www server
|
||||
|
@ -479,6 +494,16 @@ $ gsl [ARG]
|
|||
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
|
||||
remove | -R : No Position to set, just [FILE].
|
||||
Replace post position if post not exists in list
|
||||
add/remove will build last-posts-list.html
|
||||
create | -C : rebuild last-posts-list.html
|
||||
|
||||
version | -v : Show local versionn
|
||||
-vv : Shown local and repo Versions
|
||||
```
|
||||
|
|
2
control
2
control
|
@ -1,5 +1,5 @@
|
|||
Package: egsl
|
||||
Version: 0.0.23
|
||||
Version: 0.0.3
|
||||
Section: custom
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Version: 0.0.23
|
||||
# Version: 0.0.3
|
||||
# file: gsl
|
||||
# Folder: /usr/local/bin
|
||||
# By echolib
|
||||
|
@ -369,91 +369,9 @@ case "$1" in
|
|||
"$PWD"
|
||||
;;
|
||||
|
||||
post-list)
|
||||
case "$2" in
|
||||
add)
|
||||
gsl_post_list="Add"
|
||||
;;
|
||||
pin)
|
||||
gsl_post_list="Pin"
|
||||
;;
|
||||
*)
|
||||
echo "! Bad Argument: $2"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
! [[ "$3" ]] \
|
||||
&& echo "! Missing argument: post [FILE]" \
|
||||
&& exit
|
||||
|
||||
gsl__if_file "$3" post
|
||||
|
||||
gsl__check_nbr_posts
|
||||
gsl__logs_print \
|
||||
"$gsl_log_i" \
|
||||
"Starting" \
|
||||
"Process" \
|
||||
"$1 ; $gsl_post_list $3 from domain $gsl_find_domain" \
|
||||
"$gsl_dir_domain_tpl/last-posts-list.html"
|
||||
|
||||
gsl__loop_posts post-list
|
||||
|
||||
gsl__logs_print \
|
||||
"$gsl_log_i" \
|
||||
"Stopping" \
|
||||
"Process" \
|
||||
"$1 ; $gsl_post_list $3 from domain $gsl_find_domain" \
|
||||
"$gsl_dir_domain_tpl/last-posts-list.html"
|
||||
;;
|
||||
|
||||
list|-l)
|
||||
case "$2" in
|
||||
add|-A) gsl_listing_process="add" ;;
|
||||
remove|-R) gsl_listing_process="remove" ;;
|
||||
""*) echo "! Bad argument: $2 ? OPT=add|-A/remove|-R";exit ;;
|
||||
esac
|
||||
|
||||
case "$3" in
|
||||
0*)
|
||||
echo "! Are you serious ?"
|
||||
exit
|
||||
;;
|
||||
$(( $3 <= $gsl_list_max_posts)))
|
||||
echo "> $3 is OK"
|
||||
;;
|
||||
*)
|
||||
echo "! Mysterious number"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
! [[ "$4" ]] \
|
||||
&& echo "! Set post [FILE]" \
|
||||
&& exit
|
||||
|
||||
gsl__if_file "$4" 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__loop_posts listing
|
||||
|
||||
gsl__logs_print \
|
||||
"$gsl_log_i" \
|
||||
"Stopping" \
|
||||
"Process" \
|
||||
"$1 ; $2 ; $3 from domain $gsl_find_domain" \
|
||||
"$gsl_dir_domain_tpl/last-posts-list.html"
|
||||
;;
|
||||
|
||||
www)
|
||||
! [[ "$2" ]] \
|
||||
&& echo "! Missing argument: OPT=add/remove" \
|
||||
&& echo "! Missing argument: add/remove" \
|
||||
&& exit
|
||||
|
||||
if__command rsync
|
||||
|
@ -488,7 +406,7 @@ case "$1" in
|
|||
;;
|
||||
esac
|
||||
;;
|
||||
=)
|
||||
*)
|
||||
gsl__if_file "$3" post
|
||||
;;
|
||||
esac
|
||||
|
@ -502,6 +420,7 @@ case "$1" in
|
|||
|
||||
gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www"
|
||||
gsl__srv_sync "$gsl_srv_www"
|
||||
|
||||
gsl__loop_posts www "$2"
|
||||
|
||||
gsl__logs_print \
|
||||
|
@ -512,6 +431,11 @@ case "$1" in
|
|||
"$gsl_site_server"
|
||||
;;
|
||||
|
||||
sidebar|-S)
|
||||
gsl__if_file "$gsl_dir_scripts/gsl__sidebar" source
|
||||
gsl__sidebar $1 $2 $3 $4
|
||||
;;
|
||||
|
||||
*)
|
||||
gsl help
|
||||
exit
|
||||
|
|
|
@ -386,8 +386,8 @@ _book: Esperanza 64
|
|||
|
||||
|
||||
### Créer des listes
|
||||
L'arborescence est "infinie". Chaque contenu de la liste
|
||||
*doit être sur la même ligne*
|
||||
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
|
||||
|
@ -428,6 +428,26 @@ Retour "forcé" à la ligne
|
|||
|
||||
```
|
||||
|
||||
# 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
|
||||
|
||||
```
|
||||
# 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
|
||||
```
|
||||
|
||||
# HELP COMMAND
|
||||
```
|
||||
|
@ -465,12 +485,7 @@ $ gsl [ARG]
|
|||
make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE]
|
||||
to HTML file in server
|
||||
-F : Force Make again
|
||||
|
||||
post-list [OPT] [FILE] : Add post again from [FILE] to Last-Posts List
|
||||
(When converting new post, it will be added)
|
||||
Pin : Set Post from [FILE] to first in Last-Posts List
|
||||
Add : Add Post from [FILE] to last in Last-Posts List
|
||||
|
||||
|
||||
www [OPT1] [OPT2] : Add/Remove Post from www server
|
||||
[OPT1]:
|
||||
add : Add all/[FILE] to www server
|
||||
|
@ -479,6 +494,16 @@ $ gsl [ARG]
|
|||
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
|
||||
remove | -R : No Position to set, just [FILE].
|
||||
Replace post position if post not exists in list
|
||||
add/remove will build last-posts-list.html
|
||||
create | -C : rebuild last-posts-list.html
|
||||
|
||||
version | -v : Show local versionn
|
||||
-vv : Shown local and repo Versions
|
||||
```
|
||||
|
|
|
@ -34,12 +34,7 @@ $ gsl [ARG]
|
|||
make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE]
|
||||
to HTML file in server
|
||||
-F : Force Make again
|
||||
|
||||
post-list [OPT] [FILE] : Add post again from [FILE] to Last-Posts List
|
||||
(When converting new post, it will be added)
|
||||
Pin : Set Post from [FILE] to first in Last-Posts List
|
||||
Add : Add Post from [FILE] to last in Last-Posts List
|
||||
|
||||
|
||||
www [OPT1] [OPT2] : Add/Remove Post from www server
|
||||
[OPT1]:
|
||||
add : Add all/[FILE] to www server
|
||||
|
@ -48,6 +43,16 @@ $ gsl [ARG]
|
|||
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
|
||||
remove | -R : No Position to set, just [FILE].
|
||||
Replace post position if post not exists in list
|
||||
add/remove will build last-posts-list.html
|
||||
create | -C : rebuild last-posts-list.html
|
||||
|
||||
version | -v : Show local versionn
|
||||
-vv : Shown local and repo Versions
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ case "$gsl_post_type" in
|
|||
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=".."
|
||||
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="."
|
||||
gsl_uri="."
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -81,6 +81,7 @@ if [[ -f "$1" ]];then
|
|||
"$2" \
|
||||
"$gsl_post_type $gsl_post exists" \
|
||||
"$1"
|
||||
|
||||
else
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
|
@ -92,145 +93,6 @@ else
|
|||
fi
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
# latest Posts listing Manager
|
||||
#======================================================================
|
||||
gsl__page_listing_create() {
|
||||
# Check if Post is in list ; Status Made
|
||||
gsl_checker_war=true
|
||||
gsl_listing_file="$gsl_dir_domain_listings/$gsl_post.list"
|
||||
|
||||
if [[ `ls -1 "$gsl_listing_file"* 2>/dev/null` ]];then
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Latest" \
|
||||
"$gsl_post_list $gsl_post ; already added to Listing" \
|
||||
"$gsl_dir_domain_listings/"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$gsl_post_list" in
|
||||
Pin)
|
||||
gsl_listing_start_n=1
|
||||
[[ $gsl_post_pin ]] \
|
||||
&& sed -i "s|gsl_post_pin.*|gsl_post_pin=$gsl_header_title|" \
|
||||
"$gsl_this_conf_domain/$gsl_find_domain.conf" \
|
||||
|| echo "gsl_post_pin=$gsl_header_title" \
|
||||
>> "$gsl_this_conf_domain/$gsl_find_domain.conf"
|
||||
;;
|
||||
Add)
|
||||
# Check if a post is pinned
|
||||
[[ $gsl_post_pin ]] \
|
||||
&& gsl_listing_start_n=2 \
|
||||
|| gsl_listing_start_n=1
|
||||
;;
|
||||
esac
|
||||
|
||||
gsl__page_listing_roller
|
||||
gsl__page_listing_create_file "$gsl_listing_file.$gsl_listing_start_n"
|
||||
|
||||
cat `ls -1r "$gsl_dir_domain_listings/"*.list.*` \
|
||||
> "$gsl_dir_domain_tpl/last-posts-list.html" \
|
||||
&& gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Latest" \
|
||||
"Create Listing (Merged .list.*)"\
|
||||
"$gsl_dir_domain_tpl/last-post-list.html"
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
# Create HTML List from selected Post
|
||||
#======================================================================
|
||||
gsl__page_listing_create_file() {
|
||||
# Set HTML Base Link
|
||||
case "$gsl_post_type" in
|
||||
post) gsl_bpost_url="$gsl_header_slug/index.html" ;;
|
||||
page) gsl_bpost_url="$gsl_header_slug.html" ;;
|
||||
esac
|
||||
|
||||
cat << EOPostSide > "$1"
|
||||
<li>
|
||||
<span class="${gsl_site_css}_list-post-title"><a href="$gsl_uri/$gsl_bpost_url" class="${gsl_site_css}_list-post-link">$gsl_header_title</a></span>
|
||||
<div class="${gsl_site_css}_list-post-metas">Le $gsl_header_date par $gsl_header_author</div>
|
||||
<div class="${gsl_site_css}_list-post-info">$gsl_header_info</div>
|
||||
</li>
|
||||
EOPostSide
|
||||
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Latest" \
|
||||
"$gsl_post_list $gsl_post to Listing" \
|
||||
"$1"
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
# latest Posts listing Rolling
|
||||
#======================================================================
|
||||
gsl__page_listing_roller() {
|
||||
|
||||
gsl__page_listing_file_mv() {
|
||||
for n in `seq $gsl_listing_start_n $(( gsl_listing_last_n )) | sort -r`
|
||||
do
|
||||
gsl_listing_this_post=`ls -1 "$gsl_dir_domain_listings/"*".list.$n"`
|
||||
gsl_listing_tmp_no_n=`echo ${gsl_listing_this_post%.*}`
|
||||
gsl_listing_new_post="$gsl_listing_tmp_no_n.$(( n + 1 ))"
|
||||
|
||||
mv "$gsl_listing_this_post" \
|
||||
"$gsl_listing_new_post"
|
||||
done
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Latest" \
|
||||
"Roll from Listing" \
|
||||
"$gsl_dir_domain_listings/*.list.*"
|
||||
}
|
||||
|
||||
# search for last listing number
|
||||
gsl_listing_last=`
|
||||
ls -1 "$gsl_dir_domain_listings/"*".list."* 2>/dev/null \
|
||||
| tail -1`
|
||||
|
||||
if [[ $gsl_listing_last ]];then
|
||||
|
||||
# A Post is Pinned
|
||||
if [[ $gsl_post_pin ]];then
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Latest" \
|
||||
"Remove Pin $gsl_listing_rm_post_name from Listing" \
|
||||
"$gsl_listing_rm_post_uri"
|
||||
fi
|
||||
|
||||
# Get Last listing number
|
||||
gsl_listing_last_n=${gsl_listing_last: -1}
|
||||
# Remove last file
|
||||
if (( $gsl_listing_last_n == $gsl_list_max_posts ));then
|
||||
gsl_listing_rm_post_uri=`
|
||||
ls -1 "$gsl_dir_domain_listings/"*".list.$gsl_list_max_posts"`
|
||||
gsl_listing_rm_post_name=`
|
||||
basename "$gsl_listing_rm_post_uri" | awk -F"." '{print $1"."$2}'`
|
||||
|
||||
rm -f "$gsl_dir_domain_listings/"*".list.$gsl_list_max_posts" && \
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Latest" \
|
||||
"Remove $gsl_listing_rm_post_name from Listing" \
|
||||
"$gsl_listing_rm_post_uri"
|
||||
gsl_listing_last_n=4
|
||||
fi
|
||||
|
||||
# Roll each ones + 1
|
||||
gsl__page_listing_file_mv
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Create Final HTML Post/Page
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -357,7 +219,6 @@ EOFOOTER
|
|||
# Check for files in templates folder
|
||||
#-----------------------------------------------------------------------
|
||||
gsl__check_templates() {
|
||||
#echo "D> $gsl_dir_domain_tpl"
|
||||
# Create generic HEADER if not exists
|
||||
! [[ "$gsl_dir_domain_tpl/header.html" ]] \
|
||||
&& gsl__html_header
|
||||
|
@ -368,10 +229,68 @@ gsl__check_templates() {
|
|||
}
|
||||
|
||||
#======================================================================
|
||||
# latest Posts listing Manager
|
||||
# Sidebar Posts list Manager | $1=Process | $2=Position | $3=Post
|
||||
#======================================================================
|
||||
gsl__page_sidebar() {
|
||||
gsl_listing_file="$gsl_dir_domain_listings/$gsl_post.list"
|
||||
echo "> $gsl_listing_file"
|
||||
ls -1 "$gsl_dir_domain_listings"
|
||||
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"
|
||||
<li>
|
||||
<span class="${gsl_site_css}_list-post-title"><a href="$gsl_uri/$gsl_bpost_url" class="${gsl_site_css}_list-post-link">$gsl_header_title</a></span>
|
||||
<div class="${gsl_site_css}_list-post-metas">Le $gsl_header_date par $gsl_header_author</div>
|
||||
<div class="${gsl_site_css}_list-post-info">$gsl_header_info</div>
|
||||
</li>
|
||||
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 -1 "$gsl_dir_domain_listings/" | sort -r)
|
||||
}
|
||||
|
|
|
@ -26,9 +26,6 @@ case "$gsl_post_type" in
|
|||
page) gsl_uri="." ;;
|
||||
esac
|
||||
|
||||
# Create Listng Page
|
||||
gsl__page_listing_create Add
|
||||
|
||||
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"
|
||||
|
|
|
@ -141,12 +141,11 @@ do
|
|||
|
||||
case "$gsl_listing_process" in
|
||||
add)
|
||||
echo "> Add $gsl_this_post to listing"
|
||||
gsl__page_sidebar
|
||||
;;
|
||||
|
||||
rem)
|
||||
echo "> Remove $gsl_this_post to listing"
|
||||
remove)
|
||||
gsl__page_sidebar
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
#!/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 -1 "$gsl_dir_domain_listings" | sort -r
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue