# HG changeset patch # User Christophe Lincoln # Date 1391214531 -3600 # Node ID 854c4a8f0972752cd5f9d641919657c13db994b0 # Parent 8d24e0cbcdab7b44be22d81224b20943973d5b41 Improve dashboard and plugin integration diff -r 8d24e0cbcdab -r 854c4a8f0972 plugins/blog/blog.cgi --- a/plugins/blog/blog.cgi Fri Jan 31 00:48:32 2014 +0100 +++ b/plugins/blog/blog.cgi Sat Feb 01 01:28:51 2014 +0100 @@ -10,7 +10,7 @@ blog_tools() { cat << EOT
- $(gettext "New post") + $(gettext "New post") Dashboard $([ "$index" == "blog" ] && echo "Index") $([ "$HG" == "yes" ] && echo "Hg Log") @@ -80,30 +80,36 @@ html_footer && exit 0 fi -case " $(GET) " in - *\ blogedit\ *) - d="$(GET d)" - header - html_header - user_box - if ! check_auth && admin_user; then - gettext "You must be admin to create a new Blog post" - html_footer && exit 0 - fi - # New post - if [ "$d" == "new" ]; then - date=$(date '+%Y-%m-%d') - last=$(ls $blog | sort -r -n | head -n 1) - nb=${last%.txt} - d=$(($nb + 1)) - conf=$(echo -e "\n\nAUTHOR=\"$user\"\nDATE=\"$date\"\n\n==== Title ====") - fi - cat << EOT +# +# Handle GET requests +# + +if [ "$(GET blog)" ]; then + case " $(GET blog) " in + *\ edit\ *) + d="$(GET d)" + header + html_header + user_box + if ! check_auth && admin_user; then + gettext "You must be admin to create a new Blog post" + html_footer && exit 0 + fi + # New post + if [ "$d" == "new" ]; then + date=$(date '+%Y-%m-%d') + last=$(ls $blog | sort -r -n | head -n 1) + nb=${last%.txt} + d=$(($nb + 1)) + conf=$(echo -e "\n\nAUTHOR=\"$user\"\nDATE=\"$date\"\n\n====Title====") + fi + cat << EOT

$(gettext "Blog post"): $d

-
- + + + $(gettext "Code Helper:") @@ -111,46 +117,46 @@
EOT - html_footer && exit 0 ;; - - *\ blogsave\ *) - d="$(GET blogsave)" - if check_auth && admin_user; then - [ -d "$blog" ] || mkdir -p ${blog} - # New post ? - if [ ! -f "${blog}/${d}.txt" ]; then - echo "New Blog post: Read it!" \ - | log_activity - fi - # Write content to file - sed "s/$(echo -en '\r') /\n/g" > ${blog}/${d}.txt << EOT + html_footer && exit 0 ;; + + *\ save\ *) + d="$(GET d)" + if check_auth && admin_user; then + [ -d "$blog" ] || mkdir -p ${blog} + # New post ? + if [ ! -f "${blog}/${d}.txt" ]; then + echo "New Blog post: Read it!" \ + | log_activity + fi + # Write content to file + sed "s/$(echo -en '\r') /\n/g" > ${blog}/${d}.txt << EOT $(GET content) EOT - fi - header "Location: $script?blog" ;; - - *\ blog\ *) - d="Blog posts" - count="20" - header - html_header - user_box - # Blog tools for admin users - if check_auth && admin_user; then - blog_tools - fi - # Exit if plugin is disabled - if [ ! -d "$blog" ]; then - echo "

" - gettext "Blog plugin is not yet active."; echo "

" - html_footer && exit 0 - fi - # Single post - if [ "$(GET blog)" != "blog" ]; then - show_post "$(GET blog)" - else - show_posts ${count} - fi - html_footer - exit 0 ;; -esac + fi + header "Location: $script?blog" ;; + + *) + d="Blog posts" + count="20" + header + html_header + user_box + # Blog tools for admin users + if check_auth && admin_user; then + blog_tools + fi + # Exit if plugin is disabled + if [ ! -d "$blog" ]; then + echo "

" + gettext "Blog plugin is not yet active."; echo "

" + html_footer && exit 0 + fi + # Single post + if [ "$(GET blog)" != "blog" ]; then + show_post "$(GET blog)" + else + show_posts ${count} + fi ;; + esac + html_footer && exit 0 +fi diff -r 8d24e0cbcdab -r 854c4a8f0972 plugins/cloud/cloud.conf --- a/plugins/cloud/cloud.conf Fri Jan 31 00:48:32 2014 +0100 +++ b/plugins/cloud/cloud.conf Sat Feb 01 01:28:51 2014 +0100 @@ -4,6 +4,7 @@ SHORT_DESC="Online file storage" MAINTAINER="devel@slitaz.org" +# This is a tool for auth users DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Cloud files" # Configurable variables used in plugin.cgi diff -r 8d24e0cbcdab -r 854c4a8f0972 plugins/dashboard/dashboard.cgi --- a/plugins/dashboard/dashboard.cgi Fri Jan 31 00:48:32 2014 +0100 +++ b/plugins/dashboard/dashboard.cgi Sat Feb 01 01:28:51 2014 +0100 @@ -5,28 +5,28 @@ . /usr/lib/slitaz/httphelper if [ "$(GET dashboard)" ]; then - d="Dashboard" - header - html_header - user_box - users=$(ls -1 $PEOPLE | wc -l) - docs=$(find $wiki -type f | wc -l) - wikisize="$(du -sh $wiki | awk '{print $1}')" - cachesize="$(du -sh $cache | awk '{print $1}')" - [ "$HG" != "yes" ] && hg=$(gettext "disabled") - [ "$HG" == "yes" ] && hg=$(gettext "enabled") - # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS + d="Dashboard" + header + html_header + user_box + users=$(ls -1 $PEOPLE | wc -l) + docs=$(find $wiki -type f | wc -l) + wikisize="$(du -sh $wiki | awk '{print $1}')" + cachesize="$(du -sh $cache | awk '{print $1}')" + [ "$HG" != "yes" ] && hg=$(gettext "disabled") + [ "$HG" == "yes" ] && hg=$(gettext "enabled") + # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS + ADMIN_TOOLS="" + DASHBOARD_TOOLS="" + for p in $(ls $plugins) + do + . $plugins/$p/$p.conf + done + if check_auth && ! admin_user; then ADMIN_TOOLS="" - DASHBOARD_TOOLS="" - for p in $(ls $plugins) - do - . $plugins/$p/$p.conf - done - if check_auth && ! admin_user; then - ADMIN_TOOLS="" - fi - if check_auth; then - cat << EOT + fi + if check_auth; then + cat << EOT
Activity log Pages list @@ -45,14 +45,19 @@

Admin users

EOT - # Get the list of administrators - for u in $(ls $PEOPLE) - do - user=${u} - if admin_user; then - echo "$u" - fi - done + # Get the list of administrators + for u in $(ls $PEOPLE) + do + user=${u} + if admin_user; then + echo "$u" + fi + done + echo '

' + + # Only for admins + if check_auth && admin_user; then + # List all plugins cat << EOT

$(gettext "Plugins")

@@ -63,9 +68,9 @@
 				echo "$PLUGIN - $SHORT_DESC"
 			done
 			echo '
' - else + fi + else gettext "You must be logged in to view the dashboard." - fi - html_footer - exit 0 + fi + html_footer && exit 0 fi diff -r 8d24e0cbcdab -r 854c4a8f0972 plugins/export/export.cgi --- a/plugins/export/export.cgi Fri Jan 31 00:48:32 2014 +0100 +++ b/plugins/export/export.cgi Sat Feb 01 01:28:51 2014 +0100 @@ -19,6 +19,10 @@ header html_header user_box + if ! check_auth && ! admin_user; then + gettext "You must be admin to export content." + html_footer && exit 0 + fi cat << EOT

Export

diff -r 8d24e0cbcdab -r 854c4a8f0972 plugins/keygen/keygen.conf --- a/plugins/keygen/keygen.conf Fri Jan 31 00:48:32 2014 +0100 +++ b/plugins/keygen/keygen.conf Sat Feb 01 01:28:51 2014 +0100 @@ -4,4 +4,9 @@ SHORT_DESC="Secure key and password generator" MAINTAINER="devel@slitaz.org" +# This is public service or local tool. +# Example url to add in a HTML template: http://site/index.cgi?keygen + +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Key gen" + # Configurable variables used in plugin.cgi diff -r 8d24e0cbcdab -r 854c4a8f0972 style.css --- a/style.css Fri Jan 31 00:48:32 2014 +0100 +++ b/style.css Sat Feb 01 01:28:51 2014 +0100 @@ -125,7 +125,6 @@ position: absolute; right: 20px; top: 72px; - } #search input[type="text"] { width: 180px; } @@ -133,7 +132,7 @@ /* Content */ #content { - margin: 50px auto; + margin: 60px auto; padding: 0 20px; text-align: justify; max-width: 680px; @@ -214,7 +213,7 @@ #tools { position: absolute; - top: 68px; + top: 72px; } #tools a { text-decoration: none; margin: 4px 6px 4px 0px; } @@ -280,10 +279,19 @@ /* Plugins CSS */ - +/* Blog */ .post-tools { border-top: 1px dotted #ddd; border-bottom: 1px dotted #ddd; padding: 4px 0; } .post-tools a { text-decoration: none; } .post-tools a:hover { text-decoration: underline; } + +/* Forum */ +#hashtags { font-size: 16px; font-weight: bold; } +#hashtags a { text-decoration: none; padding: 0 4px; } +.topic { padding: 6px; margin: 4px; } +.topic span a { text-decoration: none; color: #666; + font-weight: bold; padding-left: 2px; } +.forum-msg { background-color: #eee; padding: 10px; + border: 2px solid #ddd; width: 98%;}