tinycm rev 6
Add plugins (skel and export)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Apr 11 15:59:53 2012 +0200 (2012-04-11) |
parents | af7569371649 |
children | 4067b670d4ee |
files | plugins/export/export.cgi plugins/export/export.conf plugins/skel/skel.cgi plugins/skel/skel.conf |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/plugins/export/export.cgi Wed Apr 11 15:59:53 2012 +0200 1.3 @@ -0,0 +1,99 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# TinyCM Plugin - Export to static content 1.7 +# 1.8 +. /usr/lib/slitaz/httphelper 1.9 + 1.10 +if [ "$(GET export)" ]; then 1.11 + d="Export" 1.12 + date=$(date "+%Y%m%d") 1.13 + tmpdir="$tmp/export/$$/wiki-$date" 1.14 + header 1.15 + html_header 1.16 + user_box 1.17 + cat << EOT 1.18 +<h2>Export</h2> 1.19 +<p> 1.20 +$(gettext "Export to HTML and ceate a tarball of your text content or 1.21 +uploaded files.") 1.22 +</p> 1.23 +<form method="get" action="$WEB_URL"> 1.24 + <select name="export"> 1.25 +EOT 1.26 + for c in $(ls -1 content/) 1.27 + do 1.28 + echo "<option value="$c">$c</option>" 1.29 + done 1.30 + cat << EOT 1.31 + </select> 1.32 + <input type="submit" value="$(gettext "Export")" /> 1.33 +</form> 1.34 +EOT 1.35 + # Functions 1.36 + css_path() { 1.37 + # Sed CSS style path in all documents 1.38 + sed -i s'/style.css/..\/style.css/' */*.html 1.39 + sed -i s'/style.css/..\/..\/style.css/' */*/*.html 1.40 + sed -i s'/style.css/..\/..\/..\/style.css/' */*/*/*.html 1.41 + } 1.42 + gen_tarball() { 1.43 + gettext "Creating tarball"; echo -n ": " 1.44 + cd $tmpdir && mkdir $TINYCM/$cache/export 1.45 + # Clean cache 1.46 + find $TINYCM/$cache/export -mtime +1 | xargs rm -rf 1.47 + tar czf $TINYCM/$cache/export/$export-$date.tar.gz $export 1.48 + cd $TINYCM/$cache/export && du -sh $export-$date.tar.gz 1.49 + } 1.50 + dl_link() { 1.51 + gettext "Download"; echo \ 1.52 + ": <a href='cache/export/$export-$date.tar.gz'>$export-$date.tar.gz</a>" 1.53 + } 1.54 + # Export requested content 1.55 + case " $(GET export) " in 1.56 + *\ uploads\ *) 1.57 + export="uploads" 1.58 + tmpdir="content" 1.59 + echo '<pre>' 1.60 + gettext "Exporting:"; echo " $export" 1.61 + gen_tarball 1.62 + echo '</pre>' 1.63 + dl_link ;; 1.64 + *) 1.65 + [ "$(GET export)" == "export" ] && exit 0 1.66 + export="$(GET export)" 1.67 + format="html" 1.68 + echo '<pre>' 1.69 + gettext "Exporting:"; echo " $export" 1.70 + gettext "Creating tmp directory:"; echo " PID $$ DATE $date" 1.71 + mkdir -p $tmpdir/$export 1.72 + gettext "Copying CSS style and images..."; echo 1.73 + cp -a style.css images $tmpdir/$export 1.74 + cd $content/$export 1.75 + for d in $(find . -type f | sed s'!./!!') 1.76 + do 1.77 + d=${d%.txt} 1.78 + [ "$d" == "help" ] && continue 1.79 + gettext "Exporting: "; echo "$d.txt" 1.80 + mkdir -p $tmpdir/$export/$(dirname $d) 1.81 + f=$tmpdir/$export/$d.html 1.82 + html_header > $f 1.83 + sed -i '/functions.js/'d $f 1.84 + sed -i '/favicon.ico/'d $f 1.85 + cat $d.txt | wiki_parser | sed \ 1.86 + -e '/functions.js/'d \ 1.87 + -e s'/?d=//'g \ 1.88 + -e s"#href='\([^']*\)*\>#\0.html#"g >> $f 1.89 + html_footer >> $f 1.90 + done 1.91 + cd $tmpdir/$export 1.92 + [ "$format" == "html" ] && css_path 1.93 + gen_tarball 1.94 + gettext "Removing temporary files..."; echo 1.95 + rm -rf $tmp/export/$$ 1.96 + echo '</pre>' 1.97 + dl_link ;; 1.98 + esac 1.99 + 1.100 + html_footer 1.101 + exit 0 1.102 +fi
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/plugins/export/export.conf Wed Apr 11 15:59:53 2012 +0200 2.3 @@ -0,0 +1,7 @@ 2.4 +# TinyCM Plugin configuration 2.5 + 2.6 +PLUGIN="Export Content" 2.7 +SHORT_DESC="Export Wiki and other content to HTML" 2.8 +MAINTAINER="devel@slitaz.org" 2.9 + 2.10 +# Configurable variables used in plugin.cgi
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/plugins/skel/skel.cgi Wed Apr 11 15:59:53 2012 +0200 3.3 @@ -0,0 +1,21 @@ 3.4 +#!/bin/sh 3.5 +# 3.6 +# TinyCM Plugin - Skeleton 3.7 +# 3.8 +. /usr/lib/slitaz/httphelper 3.9 + 3.10 +if [ "$(GET skel)" ]; then 3.11 + d="Skel" 3.12 + header 3.13 + html_header 3.14 + user_box 3.15 + echo "<h2>Plugin Skel</h2>" 3.16 + echo $(date) 3.17 + 3.18 + # Say we use files in $DATA/skel, sort them by date and simply cat 3.19 + # the files, this will create a simple blog :-) We may add post via 3.20 + # uploads or an HTML form. 3.21 + 3.22 + html_footer 3.23 + exit 0 3.24 +fi
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/plugins/skel/skel.conf Wed Apr 11 15:59:53 2012 +0200 4.3 @@ -0,0 +1,7 @@ 4.4 +# TinyCM Plugin configuration 4.5 + 4.6 +PLUGIN="Plugin Skeleton" 4.7 +SHORT_DESC="An example plugin for TinyCM" 4.8 +MAINTAINER="devel@slitaz.org" 4.9 + 4.10 +# Configurable variables used in plugin.cgi