tinycm rev 60
Improve dashboard and plugin integration
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Feb 01 01:28:51 2014 +0100 (2014-02-01) |
parents | 8d24e0cbcdab |
children | ea608c745b41 |
files | plugins/blog/blog.cgi plugins/cloud/cloud.conf plugins/dashboard/dashboard.cgi plugins/export/export.cgi plugins/keygen/keygen.conf style.css |
line diff
1.1 --- a/plugins/blog/blog.cgi Fri Jan 31 00:48:32 2014 +0100 1.2 +++ b/plugins/blog/blog.cgi Sat Feb 01 01:28:51 2014 +0100 1.3 @@ -10,7 +10,7 @@ 1.4 blog_tools() { 1.5 cat << EOT 1.6 <div id="tools"> 1.7 - <a href="$script?blogedit&d=new">$(gettext "New post")</a> 1.8 + <a href="$script?blog=edit&d=new">$(gettext "New post")</a> 1.9 <a href="$script?dashboard">Dashboard</a> 1.10 $([ "$index" == "blog" ] && echo "<a href='$script?d=index'>Index</a>") 1.11 $([ "$HG" == "yes" ] && echo "<a href='$script?hg'>Hg Log</a>") 1.12 @@ -80,30 +80,36 @@ 1.13 html_footer && exit 0 1.14 fi 1.15 1.16 -case " $(GET) " in 1.17 - *\ blogedit\ *) 1.18 - d="$(GET d)" 1.19 - header 1.20 - html_header 1.21 - user_box 1.22 - if ! check_auth && admin_user; then 1.23 - gettext "You must be admin to create a new Blog post" 1.24 - html_footer && exit 0 1.25 - fi 1.26 - # New post 1.27 - if [ "$d" == "new" ]; then 1.28 - date=$(date '+%Y-%m-%d') 1.29 - last=$(ls $blog | sort -r -n | head -n 1) 1.30 - nb=${last%.txt} 1.31 - d=$(($nb + 1)) 1.32 - conf=$(echo -e "\n\nAUTHOR=\"$user\"\nDATE=\"$date\"\n\n==== Title ====") 1.33 - fi 1.34 - cat << EOT 1.35 +# 1.36 +# Handle GET requests 1.37 +# 1.38 + 1.39 +if [ "$(GET blog)" ]; then 1.40 + case " $(GET blog) " in 1.41 + *\ edit\ *) 1.42 + d="$(GET d)" 1.43 + header 1.44 + html_header 1.45 + user_box 1.46 + if ! check_auth && admin_user; then 1.47 + gettext "You must be admin to create a new Blog post" 1.48 + html_footer && exit 0 1.49 + fi 1.50 + # New post 1.51 + if [ "$d" == "new" ]; then 1.52 + date=$(date '+%Y-%m-%d') 1.53 + last=$(ls $blog | sort -r -n | head -n 1) 1.54 + nb=${last%.txt} 1.55 + d=$(($nb + 1)) 1.56 + conf=$(echo -e "\n\nAUTHOR=\"$user\"\nDATE=\"$date\"\n\n====Title====") 1.57 + fi 1.58 + cat << EOT 1.59 <h2>$(gettext "Blog post"): $d</h2> 1.60 1.61 <div id="edit"> 1.62 - <form method="get" action="$script" name="editor"> 1.63 - <input type="hidden" name="blogsave" value="$d" /> 1.64 + <form method="get" action="$script?" name="editor"> 1.65 + <input type="hidden" name="blog" value="save" /> 1.66 + <input type="hidden" name="d" value="$d" /> 1.67 <textarea name="content">${conf}$(cat "$blog/$d.txt")</textarea> 1.68 <input type="submit" value="$(gettext "Post content")" /> 1.69 $(gettext "Code Helper:") 1.70 @@ -111,46 +117,46 @@ 1.71 </form> 1.72 </div> 1.73 EOT 1.74 - html_footer && exit 0 ;; 1.75 - 1.76 - *\ blogsave\ *) 1.77 - d="$(GET blogsave)" 1.78 - if check_auth && admin_user; then 1.79 - [ -d "$blog" ] || mkdir -p ${blog} 1.80 - # New post ? 1.81 - if [ ! -f "${blog}/${d}.txt" ]; then 1.82 - echo "New Blog post: <a href='$script?blog=$d'>Read it!</a>" \ 1.83 - | log_activity 1.84 - fi 1.85 - # Write content to file 1.86 - sed "s/$(echo -en '\r') /\n/g" > ${blog}/${d}.txt << EOT 1.87 + html_footer && exit 0 ;; 1.88 + 1.89 + *\ save\ *) 1.90 + d="$(GET d)" 1.91 + if check_auth && admin_user; then 1.92 + [ -d "$blog" ] || mkdir -p ${blog} 1.93 + # New post ? 1.94 + if [ ! -f "${blog}/${d}.txt" ]; then 1.95 + echo "New Blog post: <a href='$script?blog=$d'>Read it!</a>" \ 1.96 + | log_activity 1.97 + fi 1.98 + # Write content to file 1.99 + sed "s/$(echo -en '\r') /\n/g" > ${blog}/${d}.txt << EOT 1.100 $(GET content) 1.101 EOT 1.102 - fi 1.103 - header "Location: $script?blog" ;; 1.104 - 1.105 - *\ blog\ *) 1.106 - d="Blog posts" 1.107 - count="20" 1.108 - header 1.109 - html_header 1.110 - user_box 1.111 - # Blog tools for admin users 1.112 - if check_auth && admin_user; then 1.113 - blog_tools 1.114 - fi 1.115 - # Exit if plugin is disabled 1.116 - if [ ! -d "$blog" ]; then 1.117 - echo "<p class='error box'>" 1.118 - gettext "Blog plugin is not yet active."; echo "</p>" 1.119 - html_footer && exit 0 1.120 - fi 1.121 - # Single post 1.122 - if [ "$(GET blog)" != "blog" ]; then 1.123 - show_post "$(GET blog)" 1.124 - else 1.125 - show_posts ${count} 1.126 - fi 1.127 - html_footer 1.128 - exit 0 ;; 1.129 -esac 1.130 + fi 1.131 + header "Location: $script?blog" ;; 1.132 + 1.133 + *) 1.134 + d="Blog posts" 1.135 + count="20" 1.136 + header 1.137 + html_header 1.138 + user_box 1.139 + # Blog tools for admin users 1.140 + if check_auth && admin_user; then 1.141 + blog_tools 1.142 + fi 1.143 + # Exit if plugin is disabled 1.144 + if [ ! -d "$blog" ]; then 1.145 + echo "<p class='error box'>" 1.146 + gettext "Blog plugin is not yet active."; echo "</p>" 1.147 + html_footer && exit 0 1.148 + fi 1.149 + # Single post 1.150 + if [ "$(GET blog)" != "blog" ]; then 1.151 + show_post "$(GET blog)" 1.152 + else 1.153 + show_posts ${count} 1.154 + fi ;; 1.155 + esac 1.156 + html_footer && exit 0 1.157 +fi
2.1 --- a/plugins/cloud/cloud.conf Fri Jan 31 00:48:32 2014 +0100 2.2 +++ b/plugins/cloud/cloud.conf Sat Feb 01 01:28:51 2014 +0100 2.3 @@ -4,6 +4,7 @@ 2.4 SHORT_DESC="Online file storage" 2.5 MAINTAINER="devel@slitaz.org" 2.6 2.7 +# This is a tool for auth users 2.8 DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?cloud'>Cloud files</a>" 2.9 2.10 # Configurable variables used in plugin.cgi
3.1 --- a/plugins/dashboard/dashboard.cgi Fri Jan 31 00:48:32 2014 +0100 3.2 +++ b/plugins/dashboard/dashboard.cgi Sat Feb 01 01:28:51 2014 +0100 3.3 @@ -5,28 +5,28 @@ 3.4 . /usr/lib/slitaz/httphelper 3.5 3.6 if [ "$(GET dashboard)" ]; then 3.7 - d="Dashboard" 3.8 - header 3.9 - html_header 3.10 - user_box 3.11 - users=$(ls -1 $PEOPLE | wc -l) 3.12 - docs=$(find $wiki -type f | wc -l) 3.13 - wikisize="$(du -sh $wiki | awk '{print $1}')" 3.14 - cachesize="$(du -sh $cache | awk '{print $1}')" 3.15 - [ "$HG" != "yes" ] && hg=$(gettext "disabled") 3.16 - [ "$HG" == "yes" ] && hg=$(gettext "enabled") 3.17 - # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS 3.18 + d="Dashboard" 3.19 + header 3.20 + html_header 3.21 + user_box 3.22 + users=$(ls -1 $PEOPLE | wc -l) 3.23 + docs=$(find $wiki -type f | wc -l) 3.24 + wikisize="$(du -sh $wiki | awk '{print $1}')" 3.25 + cachesize="$(du -sh $cache | awk '{print $1}')" 3.26 + [ "$HG" != "yes" ] && hg=$(gettext "disabled") 3.27 + [ "$HG" == "yes" ] && hg=$(gettext "enabled") 3.28 + # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS 3.29 + ADMIN_TOOLS="" 3.30 + DASHBOARD_TOOLS="" 3.31 + for p in $(ls $plugins) 3.32 + do 3.33 + . $plugins/$p/$p.conf 3.34 + done 3.35 + if check_auth && ! admin_user; then 3.36 ADMIN_TOOLS="" 3.37 - DASHBOARD_TOOLS="" 3.38 - for p in $(ls $plugins) 3.39 - do 3.40 - . $plugins/$p/$p.conf 3.41 - done 3.42 - if check_auth && ! admin_user; then 3.43 - ADMIN_TOOLS="" 3.44 - fi 3.45 - if check_auth; then 3.46 - cat << EOT 3.47 + fi 3.48 + if check_auth; then 3.49 + cat << EOT 3.50 <div id="tools"> 3.51 <a href='$script?log'>Activity log</a> 3.52 <a href='$script?ls'>Pages list</a> 3.53 @@ -45,14 +45,19 @@ 3.54 3.55 <h3>Admin users</h3> 3.56 EOT 3.57 - # Get the list of administrators 3.58 - for u in $(ls $PEOPLE) 3.59 - do 3.60 - user=${u} 3.61 - if admin_user; then 3.62 - echo "<a href='?user=$u'>$u</a>" 3.63 - fi 3.64 - done 3.65 + # Get the list of administrators 3.66 + for u in $(ls $PEOPLE) 3.67 + do 3.68 + user=${u} 3.69 + if admin_user; then 3.70 + echo "<a href='?user=$u'>$u</a>" 3.71 + fi 3.72 + done 3.73 + echo '</p>' 3.74 + 3.75 + # Only for admins 3.76 + if check_auth && admin_user; then 3.77 + # List all plugins 3.78 cat << EOT 3.79 <h3>$(gettext "Plugins")</h3> 3.80 <pre> 3.81 @@ -63,9 +68,9 @@ 3.82 echo "<a href='?$p'>$PLUGIN</a> - $SHORT_DESC" 3.83 done 3.84 echo '</pre>' 3.85 - else 3.86 + fi 3.87 + else 3.88 gettext "You must be logged in to view the dashboard." 3.89 - fi 3.90 - html_footer 3.91 - exit 0 3.92 + fi 3.93 + html_footer && exit 0 3.94 fi
4.1 --- a/plugins/export/export.cgi Fri Jan 31 00:48:32 2014 +0100 4.2 +++ b/plugins/export/export.cgi Sat Feb 01 01:28:51 2014 +0100 4.3 @@ -19,6 +19,10 @@ 4.4 header 4.5 html_header 4.6 user_box 4.7 + if ! check_auth && ! admin_user; then 4.8 + gettext "You must be admin to export content." 4.9 + html_footer && exit 0 4.10 + fi 4.11 cat << EOT 4.12 <h2>Export</h2> 4.13 <p>
5.1 --- a/plugins/keygen/keygen.conf Fri Jan 31 00:48:32 2014 +0100 5.2 +++ b/plugins/keygen/keygen.conf Sat Feb 01 01:28:51 2014 +0100 5.3 @@ -4,4 +4,9 @@ 5.4 SHORT_DESC="Secure key and password generator" 5.5 MAINTAINER="devel@slitaz.org" 5.6 5.7 +# This is public service or local tool. 5.8 +# Example url to add in a HTML template: http://site/index.cgi?keygen 5.9 + 5.10 +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?keygen'>Key gen</a>" 5.11 + 5.12 # Configurable variables used in plugin.cgi
6.1 --- a/style.css Fri Jan 31 00:48:32 2014 +0100 6.2 +++ b/style.css Sat Feb 01 01:28:51 2014 +0100 6.3 @@ -125,7 +125,6 @@ 6.4 position: absolute; 6.5 right: 20px; 6.6 top: 72px; 6.7 - 6.8 } 6.9 6.10 #search input[type="text"] { width: 180px; } 6.11 @@ -133,7 +132,7 @@ 6.12 /* Content */ 6.13 6.14 #content { 6.15 - margin: 50px auto; 6.16 + margin: 60px auto; 6.17 padding: 0 20px; 6.18 text-align: justify; 6.19 max-width: 680px; 6.20 @@ -214,7 +213,7 @@ 6.21 6.22 #tools { 6.23 position: absolute; 6.24 - top: 68px; 6.25 + top: 72px; 6.26 } 6.27 #tools a { text-decoration: none; margin: 4px 6px 4px 0px; } 6.28 6.29 @@ -280,10 +279,19 @@ 6.30 6.31 /* Plugins CSS */ 6.32 6.33 - 6.34 +/* Blog */ 6.35 .post-tools { 6.36 border-top: 1px dotted #ddd; 6.37 border-bottom: 1px dotted #ddd; 6.38 padding: 4px 0; } 6.39 .post-tools a { text-decoration: none; } 6.40 .post-tools a:hover { text-decoration: underline; } 6.41 + 6.42 +/* Forum */ 6.43 +#hashtags { font-size: 16px; font-weight: bold; } 6.44 +#hashtags a { text-decoration: none; padding: 0 4px; } 6.45 +.topic { padding: 6px; margin: 4px; } 6.46 +.topic span a { text-decoration: none; color: #666; 6.47 + font-weight: bold; padding-left: 2px; } 6.48 +.forum-msg { background-color: #eee; padding: 10px; 6.49 + border: 2px solid #ddd; width: 98%;}