slitaz-pizza rev 7
Add the web interface
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Mar 24 23:12:44 2012 +0100 (2012-03-24) |
parents | 28218999e1ce |
children | 46e01beb351a |
files | web/db.conf web/favicon.ico web/images/archive.png web/images/down.png web/images/download.png web/images/info.png web/images/iso.png web/images/logo.png web/images/monitor.png web/images/paypal.png web/images/tazpkg.png web/lib/footer.html web/lib/functions.js web/lib/header.html web/lib/libpizza web/pizza.cgi web/pkgs.cgi web/rootfs.cgi web/style.css |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/web/db.conf Sat Mar 24 23:12:44 2012 +0100 1.3 @@ -0,0 +1,13 @@ 1.4 +# Pizza web interface DB files. 1.5 + 1.6 +chroot="$PIZZA/chroot" 1.7 +pkgs="${chroot}$SLITAZ/packages" 1.8 +cache="${chroot}$SLITAZ/cache" 1.9 +queue="${chroot}$SLITAZ/queue" 1.10 +tmpdir="${chroot}$SLITAZ/tmp" 1.11 +public="$VHOST/public" 1.12 +activity="$cache/activity" 1.13 +builds="$cache/builds" 1.14 + 1.15 +#htmldoc="/usr/share/doc/pizza" 1.16 +htmldoc="/home/slitaz/pizza/doc"
2.1 Binary file web/favicon.ico has changed
3.1 Binary file web/images/archive.png has changed
4.1 Binary file web/images/down.png has changed
5.1 Binary file web/images/download.png has changed
6.1 Binary file web/images/info.png has changed
7.1 Binary file web/images/iso.png has changed
8.1 Binary file web/images/logo.png has changed
9.1 Binary file web/images/monitor.png has changed
10.1 Binary file web/images/paypal.png has changed
11.1 Binary file web/images/tazpkg.png has changed
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/web/lib/footer.html Sat Mar 24 23:12:44 2012 +0100 12.3 @@ -0,0 +1,9 @@ 12.4 +<!-- End content --> 12.5 +</div> 12.6 + 12.7 +<div id="footer"> 12.8 + Copyright (C) 2012 <a href="http://www.slitaz.org">SliTaz GNU/Linux</a> 12.9 +</div> 12.10 + 12.11 +</body> 12.12 +</html>
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/web/lib/functions.js Sat Mar 24 23:12:44 2012 +0100 13.3 @@ -0,0 +1,47 @@ 13.4 +// SliTaz Pizza Javascript functions. 13.5 +// 13.6 + 13.7 +// Check form to avoid empty values and bad email. 13.8 +function checkForm() { 13.9 + if(document.forms["pizza"]["flavor"].value == "") 13.10 + { 13.11 + alert("Please enter SliTaz pizza flavor name"); 13.12 + document.forms["pizza"]["flavor"].focus(); 13.13 + return false; 13.14 + } 13.15 + if(document.forms["pizza"]["desc"].value == "") 13.16 + { 13.17 + alert("Please fill up the flavor description"); 13.18 + document.forms["pizza"]["desc"].focus(); 13.19 + return false; 13.20 + } 13.21 + var x=document.forms["pizza"]["mail"].value; 13.22 + var atpos=x.indexOf("@"); 13.23 + var dotpos=x.lastIndexOf("."); 13.24 + if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) 13.25 + { 13.26 + alert("Missing or not a valid email address"); 13.27 + return false; 13.28 + } 13.29 +} 13.30 + 13.31 +// Notification messages 13.32 +function setOpacity(notifyId, opacityLevel) { 13.33 + var notifyStyle = document.getElementById(notifyId).style; 13.34 + notifyStyle.opacity = opacityLevel / 100; 13.35 + notifyStyle.filter = 'alpha(opacity='+opacityLevel+')'; 13.36 +} 13.37 + 13.38 +function fadeNotify(notifyId, startOpacity, stopOpacity, duration) { 13.39 + var speed = Math.round(duration / 100); 13.40 + var timer = 2000; 13.41 + for (var i=startOpacity; i>=stopOpacity; i--) { 13.42 + setTimeout("setOpacity('"+notifyId+"',"+i+")", timer * speed); 13.43 + timer++; 13.44 + } 13.45 +} 13.46 + 13.47 +function hideNotify() { 13.48 + document.getElementById('notify').style.display = 'none'; 13.49 +} 13.50 +
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/web/lib/header.html Sat Mar 24 23:12:44 2012 +0100 14.3 @@ -0,0 +1,25 @@ 14.4 +<!DOCTYPE html> 14.5 +<html lang="en"> 14.6 +<head> 14.7 + <meta charset="utf-8" /> 14.8 + <title>SliTaz Pizza</title> 14.9 + <link rel="stylesheet" type="text/css" href="style.css" /> 14.10 + <link rel="shortcut icon" href="favicon.ico" /> 14.11 + <script type="text/javascript" src="lib/functions.js"></script> 14.12 +</head> 14.13 +<body> 14.14 + 14.15 +<div id="header"> 14.16 + <div id="logo"></div> 14.17 + <div id="network"> 14.18 + <a href="http://www.slitaz.org/">Home</a> 14.19 + <a href="http://scn.slitaz.org/">Community</a> 14.20 + <a href="http://forum.slitaz.org/">Forum</a> 14.21 + <a href="./">Pizza:</a> 14.22 + <a href="./?info">Info</a> 14.23 + <a href="./?rss">RSS</a> 14.24 + </div> 14.25 + <h1><a href="./">SliTaz Pizza</a></h1> 14.26 +</div> 14.27 + 14.28 +<div id="content">
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/web/lib/libpizza Sat Mar 24 23:12:44 2012 +0100 15.3 @@ -0,0 +1,57 @@ 15.4 +#!/bin/sh 15.5 +# 15.6 +# Common functions for Pizza CGI/SHell web interface. 15.7 +# 15.8 + 15.9 +[ -f "/etc/slitaz/pizza.conf" ] && . /etc/slitaz/pizza.conf 15.10 +[ -f "../pizza.conf" ] && . ../pizza.conf 15.11 +. ./db.conf 15.12 +. /usr/lib/slitaz/httphelper 15.13 +header 15.14 + 15.15 +# xHTML header. 15.16 +cat lib/header.html || exit 1 15.17 + 15.18 +# Status function. 15.19 +status() { 15.20 + if [ $? = 0 ]; then 15.21 + echo " <span class="span-ok">OK</span>" 15.22 + else 15.23 + echo " <span class="span-red">Failed</span>" 15.24 + fi 15.25 +} 15.26 + 15.27 +# Put some colors in log and DB files. 15.28 +highlighter() { 15.29 + case $1 in 15.30 + log) 15.31 + sed -e 's#OK#<span class="span-ok">OK</span>#g' \ 15.32 + -e 's#Failed#<span class="span-red">Failed</span>#g' ;; 15.33 + activity) 15.34 + sed s"#^\([^']* : \)#<span class='log-date'>\0</span>#"g ;; 15.35 + esac 15.36 +} 15.37 + 15.38 +# Log activities, we want first letter capitalized. 15.39 +log() { 15.40 + grep ^[A-Z] | \ 15.41 + sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity 15.42 +} 15.43 + 15.44 +# Usage: error string 15.45 +error() { 15.46 + echo "<span class="span-red">ERROR: $@</span>" 15.47 +} 15.48 + 15.49 +# Pizza notification function: notify "message" "icon" 15.50 +notify() { 15.51 + img=info 15.52 + [ "$2" ] && img=$2 15.53 + cat << EOT 15.54 +<script type="text/javascript"> 15.55 + document.write('<div id="notify"><img src="images/$img.png" />$1</div>'); 15.56 + fadeNotify('notify', 100, 0, 300); 15.57 + setTimeout('hideNotify()', 6200); 15.58 +</script> 15.59 +EOT 15.60 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/web/pizza.cgi Sat Mar 24 23:12:44 2012 +0100 16.3 @@ -0,0 +1,369 @@ 16.4 +#!/bin/sh 16.5 +# 16.6 +# SliTaz Pizza CGI/web interface - Let's me have a pizza :-) 16.7 +# Please KISS, it is important and keep speed in mind. Thanks, Pankso. 16.8 +# 16.9 + 16.10 +# Output a RSS feed of latest build isos. 16.11 +if [ "$QUERY_STRING" == "rss" ]; then 16.12 + . /etc/slitaz/pizza.conf 16.13 + pubdate=$(date "+%a, %d %b %Y %X") 16.14 + cat << EOT 16.15 +Content-Type: text/xml 16.16 + 16.17 +<?xml version="1.0" encoding="utf-8" ?> 16.18 +<rss version="2.0"> 16.19 +<channel> 16.20 + <title>SliTaz Pizza</title> 16.21 + <description>The SliTaz Pizza cooker feed</description> 16.22 + <link>$PIZZA_URL</link> 16.23 + <lastBuildDate>$pubdate GMT</lastBuildDate> 16.24 + <pubDate>$pubdate GMT</pubDate> 16.25 +EOT 16.26 + for rss in $(ls -1t $PIZZA/chroot${SLITAZ}/xml/*.xml | head -n 12) 16.27 + do 16.28 + cat $rss 16.29 + done 16.30 + cat << EOT 16.31 +</channel> 16.32 +</rss> 16.33 +EOT 16.34 + exit 0 16.35 +fi 16.36 + 16.37 +# Content negotiation for Gettext 16.38 +IFS="," 16.39 +for lang in $HTTP_ACCEPT_LANGUAGE 16.40 +do 16.41 + lang=${lang%;*} lang=${lang# } lang=${lang%-*} 16.42 + [ -d "$lang" ] && break 16.43 + case "$lang" in 16.44 + en) lang="C" ;; 16.45 + fr) lang="fr_FR" ;; 16.46 + esac 16.47 +done 16.48 +unset IFS 16.49 +export LANG=$lang LC_ALL=$lang 16.50 + 16.51 +# Internationalization: $(gettext "") 16.52 +. /usr/bin/gettext.sh 16.53 +TEXTDOMAIN='pizza' 16.54 +export TEXTDOMAIN 16.55 + 16.56 +. lib/libpizza 16.57 + 16.58 +# 16.59 +# Commands 16.60 +# 16.61 + 16.62 +case " $(GET) " in 16.63 + *\ start\ *) 16.64 + # 16.65 + # First step 16.66 + # 16.67 + date=$(date "+%Y%m%d") 16.68 + id=$date-$$ 16.69 + cat << EOT 16.70 +<h2>$(gettext "First step")</h2> 16.71 +<p> 16.72 + $(gettext "Chosse your distribution name and the one you want to use as 16.73 + base. We need our mail to notify you when your SliTaz Flavor is built 16.74 + and if any things goes wrong.") 16.75 +</p> 16.76 +<form method="get" action="pkgs.cgi" name="pizza" onsubmit="return checkForm();"> 16.77 +<table> 16.78 + <tbody> 16.79 + <tr> 16.80 + <td>$(gettext "Flavor name")</td> 16.81 + <td><input type="text" name="flavor" size="40" /></td> 16.82 + </tr> 16.83 + <tr> 16.84 + <td>$(gettext "Short description")</td> 16.85 + <td><input type="text" name="desc" size="40" /></td> 16.86 + </tr> 16.87 + <tr> 16.88 + <td>$(gettext "Email")</td> 16.89 + <td><input type="text" name="mail" size="40" /></td> 16.90 + </tr> 16.91 + <tr> 16.92 + <td>$(gettext "Based on")</td> 16.93 + <td> 16.94 + <select name="skel"> 16.95 + <option value="base"> 16.96 + Base - $(gettext "Text mode system")</option> 16.97 + <option value="justx"> 16.98 + Justx - $(gettext "X without GTK or QT")</option> 16.99 + <option value="gtkonly"> 16.100 + Gtkonly - $(gettext "Clean GTK desktop")</option> 16.101 + <option value="core"> 16.102 + Core - $(gettext "Default SliTaz desktop")</option> 16.103 + </select> 16.104 + </td> 16.105 + </tr> 16.106 + </tbody> 16.107 +</table> 16.108 +<pre> 16.109 +Uniq ID : $id 16.110 +</pre> 16.111 +<div class="next"> 16.112 + <input type="hidden" name="id" value="$id" /> 16.113 + <input type="submit" value="$(gettext "Continue")"> 16.114 +</div> 16.115 +</form> 16.116 +EOT 16.117 + ;; 16.118 + *\ gen\ *) 16.119 + # 16.120 + # Generate step 16.121 + # 16.122 + id="$(GET id)" 16.123 + . $tmpdir/slitaz-$id/receipt 16.124 + addfiles=$(find $tmpdir/slitaz-$id/addfiles -type f | wc -l) 16.125 + [ "$addfiles" ] || addfiles=0 16.126 + packages=$(cat $tmpdir/slitaz-$id/packages.list | wc -l) 16.127 + cat << EOT 16.128 +<h2>$(gettext "Generate")</h2> 16.129 +<p> 16.130 + Last chance to stop process or start over. Next step will pack your 16.131 + flavor and add it to the build queue. Here you can also add note to 16.132 + your receipt flavor, this will be displayed on your flavor ID page 16.133 + and can be used to give more infos to other users and SliTaz developers. 16.134 +</p> 16.135 +<pre> 16.136 +Uniq ID : $id 16.137 +Flavor : $FLAVOR 16.138 +Short desc : $SHORT_DESC 16.139 +Maintainer : $MAINTAINER 16.140 +Packages : $packages 16.141 +Addfiles : $addfiles 16.142 +</pre> 16.143 +<form method="get" action="./"> 16.144 +<div class="box"> 16.145 + Note: 16.146 + <input type="text" name="note" style="width: 720px;" /> 16.147 +</div> 16.148 + <div class="next"> 16.149 + <input type="submit" name="cancel" value="$(gettext "Cancel")"> 16.150 + <input type="hidden" name="addfiles" value="$addfiles" /> 16.151 + <input type="hidden" name="id" value="$id" /> 16.152 + <input type="submit" name="pack" value="$(gettext "Build flavor")"> 16.153 + </div> 16.154 +</form> 16.155 +EOT 16.156 + ;; 16.157 + *\ cancel\ *) 16.158 + id="$(GET id)" 16.159 + echo "<p>Removing temporary files for: $id</p>" 16.160 + [ -d "$tmpdir/slitaz-$id" ] && rm -rf $tmpdir/slitaz-$id/ 16.161 + cat << EOT 16.162 +<form method="get" action="./"> 16.163 + <input type="submit" name="start" value="$(gettext "Start over")"> 16.164 +</form> 16.165 +EOT 16.166 + ;; 16.167 + *\ pack\ *) 16.168 + # 16.169 + # Pack distro step 16.170 + # 16.171 + id="$(GET id)" 16.172 + receipt="$tmpdir/slitaz-$id/receipt" 16.173 + addfiles="$(GET addfiles)" 16.174 + log="$tmpdir/slitaz-$id/distro.log" 16.175 + note="$(GET note)" 16.176 + inqueue=$(ls $queue | wc -l) 16.177 + . $receipt 16.178 + cat << EOT 16.179 +<h2>$(gettext "Packing:") $FLAVOR</h2> 16.180 +<pre> 16.181 +EOT 16.182 + if ! fgrep ADDFILES $receipt; then 16.183 + echo "ADDFILES=\"$addfiles\"" >> $receipt 16.184 + fi 16.185 + if ! fgrep NOTE $receipt; then 16.186 + echo "NOTE=\"$note\"" >> $receipt 16.187 + fi 16.188 + 16.189 + # The rootcd README 16.190 + echo -n "Creating SliTaz cdrom README..." 16.191 + date=$(date '+%Y-%m-%d %H:%M') 16.192 + mkdir -p $tmpdir/slitaz-$id/rootcd 16.193 + cp $DATA/README.distro $tmpdir/slitaz-$id/rootcd/README 16.194 + sed -i s"/_DATE_/$date/" $tmpdir/slitaz-$id/rootcd/README 16.195 + status 16.196 + 16.197 + echo -n "Creating flavor tarball..." 16.198 + cd $tmpdir && tar cjf $FLAVOR.tar.bz2 slitaz-$id 16.199 + mkdir -p $public/slitaz-$id 16.200 + mv $FLAVOR.tar.bz2 $public/slitaz-$id 16.201 + status 16.202 + 16.203 + # Keep a public receipt copy and move everything from tmp to queue. 16.204 + echo "Flavor packed : $(date '+%Y-%m-%d %H:%M')" | tee -a $log 16.205 + echo -n "Moving $id to Pizza build queue..." 16.206 + mv -f $tmpdir/slitaz-$id/distro.log $public/slitaz-$id 16.207 + cp -f $tmpdir/slitaz-$id/receipt $public/slitaz-$id 16.208 + mv $tmpdir/slitaz-$id $queue 16.209 + status 16.210 + 16.211 + if [ "$inqueue" == "1" ]; then 16.212 + gettext "Your ISO will be built on next Pizza Bot run" 16.213 + else 16.214 + eval_gettext "Ther is \$inqueue flavors in queue" 16.215 + fi 16.216 + echo "" 16.217 + echo "New flavor added to queue: <a href='?id=$id'>$id</a>" | log 16.218 + cat << EOT 16.219 +</pre> 16.220 +<div> 16.221 + <img src="images/archive.png" alt="[ tarball ]" /> 16.222 + $(gettext "Download tarball: ") 16.223 + <a href="public/slitaz-$id/$FLAVOR.tar.bz2">$FLAVOR.tar.bz2</a> 16.224 + - Browse <a href="public/slitaz-$id/">the flavor</a> 16.225 +</div> 16.226 +<div class="next"> 16.227 + <form method="get" action="./"> 16.228 + <input type="hidden" name="id" value="$id" /> 16.229 + <input type="submit" value="$(gettext "Status")"> 16.230 + </form> 16.231 +</div> 16.232 +EOT 16.233 + ;; 16.234 + *\ id\ *) 16.235 + # 16.236 + # ID Status page 16.237 + # 16.238 + id="$(GET id)" 16.239 + [ -f "$queue/slitaz-$id/receipt" ] && . $queue/slitaz-$id/receipt 16.240 + [ -f "public/slitaz-$id/receipt" ] && . public/slitaz-$id/receipt 16.241 + log="$public/slitaz-$id/distro.log" 16.242 + if [ ! -d "public/slitaz-$id" ]; then 16.243 + echo "Sorry, can't found flavor ID: $id" 16.244 + cat lib/footer.html && exit 0 16.245 + fi 16.246 + if [ -f "$public/slitaz-$id/$FLAVOR.iso" ]; then 16.247 + dir="public/slitaz-$id" 16.248 + list="$dir/packages.list" 16.249 + iso="$dir/$FLAVOR.iso" 16.250 + msg="$(gettext "Download ISO:") <a href='$dir/$FLAVOR.iso'>$FLAVOR.iso</a> 16.251 + [ <a href='$dir/$FLAVOR.md5'>md5</a> ]" 16.252 + else 16.253 + list="$queue/slitaz-$id/packages.list" 16.254 + msg="$(gettext "Flavor is building or still in the build queue")" 16.255 + fi 16.256 + pkgslist=$(cat $list | wc -l) 16.257 + pkgsinst=$(cat $installed | wc -l) 16.258 + [ "$pkgsinst" ] || pkgsinst=0 16.259 + [ "$ISO_SIZE" ] || ISO_SIZE="N/A" 16.260 + [ "$ROOTFS_SIZE" ] || ROOTFS_SIZE="N/A" 16.261 + cat << EOT 16.262 +<h2>$(gettext "Status for:") $FLAVOR</h2> 16.263 +<p> 16.264 + $(gettext "Flavor description:") $SHORT_DESC 16.265 +</p> 16.266 +<pre> 16.267 +Uniq ID : $id 16.268 +Flavor : $FLAVOR 16.269 +Packages : $pkgslist in list - $pkgsinst installed 16.270 +Rootfs size : $ROOTFS_SIZE 16.271 +ISO size : $ISO_SIZE 16.272 +</pre> 16.273 + 16.274 +<div> 16.275 + <img src="images/iso.png" alt="[ iso ]" /> $(echo $msg) 16.276 +</div> 16.277 +<div> 16.278 + <img src="images/archive.png" alt="[ tarball ]" /> 16.279 + $(gettext "Download tarball:") 16.280 + <a href="public/slitaz-$id/$FLAVOR.tar.bz2">$FLAVOR.tar.bz2</a> 16.281 +EOT 16.282 + if [ -f "$public/slitaz-$id/$FLAVOR.flavor" ]; then 16.283 + cat << EOT 16.284 + - Flavor file: <a href="public/slitaz-$id/$FLAVOR.flavor">$FLAVOR.flavor</a> 16.285 +EOT 16.286 + fi 16.287 + cat << EOT 16.288 + - Browse <a href="public/slitaz-$id/">the flavor</a> 16.289 +</div> 16.290 +EOT 16.291 + if [ "$NOTE" ]; then 16.292 + echo "<div class="note">$NOTE</div>" 16.293 + fi 16.294 + if [ -f "$log" ]; then 16.295 + echo '<h2>Distro log</h2>' 16.296 + echo '<pre>' 16.297 + fgrep 'Build time' $log 16.298 + cat $log | highlighter log 16.299 + echo '</pre>' 16.300 + fi ;; 16.301 + *\ help\ *) 16.302 + echo "<h2>$(gettext "Help")</h2>" 16.303 + echo "<b>TODO: HTML faq/doc</b>" 16.304 + echo '<pre>' 16.305 + cat /usr/share/doc/pizza/README 16.306 + echo '</pre>' ;; 16.307 + *\ info\ *) 16.308 + # English only :-) 16.309 + if mount | fgrep -q slitaz/public; then 16.310 + mounted="Public is mounted" 16.311 + else 16.312 + mounted="WARRNING: Public is not mounted" 16.313 + fi 16.314 + echo '<h2><img src="images/monitor.png" alt="" />Pizza Info</h2>' 16.315 + echo '<pre>' 16.316 + [ "$mounted" ] && echo "$mounted" 16.317 + echo -n "Public flavors : " && ls -1 public | wc -l 16.318 + echo -n "Public size : " && du -sh public | awk '{print $1}' 16.319 + echo -n "Tmp size : " && du -sh $tmpdir | awk '{print $1}' 16.320 + echo '</pre>' ;; 16.321 + *) 16.322 + # 16.323 + # Main page 16.324 + # 16.325 + inqueue=$(ls $queue | wc -l) 16.326 + builds=$(cat $builds) 16.327 + pubiso=$(ls -1 public | wc -l) 16.328 + [ "$builds" ] || builds=0 16.329 + cat << EOT 16.330 +<h2>$(gettext "Welcome")</h2> 16.331 +<p> 16.332 + SliTaz Pizza let you create your own SliTaz ISO flavor online. The 16.333 + ISO image can be burnt on a cdrom or installed on an USB media. 16.334 + Please read the SliTaz Pizza 16.335 + <a href="?help">Help</a> before starting a new flavor. 16.336 +</p> 16.337 +<pre> 16.338 +Flavors: $inqueue in queue - $builds builds - $pubiso public 16.339 +</pre> 16.340 + 16.341 +<div class="start"> 16.342 + <form method="get" action="./"> 16.343 + <input type="hidden" name="start" value="flavor" /> 16.344 + <input type="submit" value="$(gettext "Create a new flavor")"> 16.345 + </form> 16.346 +</div> 16.347 + 16.348 +<h2>Activity</h2> 16.349 +<pre> 16.350 +$(tac $activity | head -n 12 | highlighter activity) 16.351 +</pre> 16.352 + 16.353 +EOT 16.354 + echo "<h2>$(gettext "Latest builds")</h2>" 16.355 + echo '<pre>' 16.356 + for flavor in $(ls -1t public | head -n 12) 16.357 + do 16.358 + if [ -f "public/$flavor/receipt" ]; then 16.359 + . ./public/$flavor/receipt 16.360 + [ -f "public/$flavor/$FLAVOR.iso" ] && \ 16.361 + cat << EOT 16.362 +$VERSION : <a href="public/$flavor/$FLAVOR.iso">$FLAVOR.iso</a> ($ISO_SIZE) 16.363 +EOT 16.364 + fi 16.365 + done 16.366 + echo '</pre>' ;; 16.367 +esac 16.368 + 16.369 +# HTML footer. 16.370 +cat lib/footer.html 16.371 + 16.372 +exit 0
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/web/pkgs.cgi Sat Mar 24 23:12:44 2012 +0100 17.3 @@ -0,0 +1,142 @@ 17.4 +#!/bin/sh 17.5 +# 17.6 +# SliTaz Pizza CGI/web interface - Let's me have a pizza :-) 17.7 +# Packages step 17.8 +# 17.9 + 17.10 +. lib/libpizza 17.11 + 17.12 +id="$(GET id)" 17.13 +flavor="$(GET flavor)" 17.14 +skel="$(GET skel)" 17.15 +desc="$(GET desc)" 17.16 +mail="$(GET mail)" 17.17 +add="$(GET add)" 17.18 +log="$tmpdir/slitaz-$id/distro.log" 17.19 +list="$tmpdir/slitaz-$id/packages.list" 17.20 + 17.21 +# 17.22 +# Functions 17.23 +# 17.24 + 17.25 +list_pkgs() { 17.26 + # Pizza use local packages synced with mirror each night. 17.27 + pkgsdesc="$SLITAZ/$SLITAZ_VERSION/packages/packages.desc" 17.28 + [ ! -f "$pkgsdesc" ] && echo "Missing: $pkgsdesc" 17.29 + for pkg in $(cat $list) 17.30 + do 17.31 + IFS="|" 17.32 + grep "^$pkg |" $pkgsdesc | cut -f 1,2,3 -d "|" | \ 17.33 + while read PACKAGE VERSION SHORT_DESC 17.34 + do 17.35 + cat << EOT 17.36 +<tr> 17.37 + <td><input type="checkbox" name="pkg" value="$PACKAGE" /></td> 17.38 + <td>$PACKAGE</td> 17.39 + <td>$VERSION</td> 17.40 + <td>$SHORT_DESC</td> 17.41 +</tr> 17.42 +EOT 17.43 + done 17.44 + done 17.45 +} 17.46 + 17.47 +# Gen an empty receipt for new flavor. 17.48 +empty_receipt() { 17.49 + cat > $tmpdir/slitaz-$id/receipt << EOT 17.50 +# SliTaz flavor receipt. 17.51 + 17.52 +FLAVOR="" 17.53 +SHORT_DESC="" 17.54 +VERSION="$(date "+%Y%m%d")" 17.55 +MAINTAINER="" 17.56 + 17.57 +ID="" 17.58 +SKEL="" 17.59 + 17.60 +EOT 17.61 +} 17.62 + 17.63 +# 17.64 +# Actions 17.65 +# 17.66 + 17.67 +case " $(GET) " in 17.68 + *\ add\ *) 17.69 + for pkg in $add 17.70 + do 17.71 + if ! grep -q ^${pkg}$ $list; then 17.72 + echo "$pkg" >> $list 17.73 + fi 17.74 + done ;; 17.75 + *\ rm\ *) 17.76 + cmdline=$(echo ${QUERY_STRING#pkg=} | sed s'/&/ /g') 17.77 + cmdline=${cmdline%id=*} 17.78 + pkgs=$(echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//) 17.79 + for pkg in $pkgs 17.80 + do 17.81 + sed -i "/^${pkg}$/"d $list 17.82 + done ;; 17.83 + *) 17.84 + # No space in flavor name please. 17.85 + flavor=$(echo $flavor | sed s'/ //'g) 17.86 + # Javascript can be disable in browser. 17.87 + [ ! "$flavor" ] && echo "Missing flavor name" && exit 0 17.88 + [ ! "$mail" ] && echo "Missing email address" && exit 0 17.89 + [ ! "$skel" ] && echo "Missing SliTaz skeleton" && exit 0 17.90 + [ ! "$desc" ] && echo "Missing short desciption" && exit 0 17.91 + mkdir -p $tmpdir/slitaz-$id 17.92 + cp -f $cache/packages.$skel $list 17.93 + echo "Receipt created : $(date '+%Y-%m-%d %H:%M')" > $log 17.94 + empty_receipt 17.95 + sed -i \ 17.96 + -e s"/FLAVOR=.*/FLAVOR=\"slitaz-$flavor\"/" \ 17.97 + -e s"/MAINTAINER=.*/MAINTAINER=\"$mail\"/" \ 17.98 + -e s"/SKEL=.*/SKEL=\"$skel\"/" \ 17.99 + -e s"/SHORT_DESC=.*/SHORT_DESC=\"$desc\"/" \ 17.100 + -e s"/ID=.*/ID=\"$id\"/" $tmpdir/slitaz-$id/receipt ;; 17.101 +esac 17.102 + 17.103 +# 17.104 +# Source the receipt and display page. 17.105 +# 17.106 +. $tmpdir/slitaz-$id/receipt 17.107 + 17.108 +nb=$(cat $list | wc -l) 17.109 +cat << EOT 17.110 +<h2>Packages ($nb)</h2> 17.111 + 17.112 +<form method="get" action="pkgs.cgi"> 17.113 + <table> 17.114 + <tbody> 17.115 + $(list_pkgs) 17.116 + </tbody> 17.117 + </table> 17.118 + <div> 17.119 + <input type="hidden" name="id" value="$id" /> 17.120 + <input type="submit" name="rm" value="$(gettext "Remove package(s)")"> 17.121 +</form> 17.122 + 17.123 +<form method="get" action="pkgs.cgi" style="float: right;"> 17.124 + <input type="text" name="add" /> 17.125 + <input type="hidden" name="id" value="$id" /> 17.126 + <input type="submit" name="pkgs" value="$(gettext "Add package(s)")"> 17.127 +</form> 17.128 + 17.129 +<pre> 17.130 +Uniq ID : $id 17.131 +Flavor : $FLAVOR 17.132 +Short desc : $SHORT_DESC 17.133 +</pre> 17.134 +<div class="next"> 17.135 + <form method="get" action="rootfs.cgi"> 17.136 + <input type="hidden" name="id" value="$id" /> 17.137 + <input type="submit" value="$(gettext "Continue")"> 17.138 + </form> 17.139 +</div> 17.140 +EOT 17.141 + 17.142 +# HTML footer. 17.143 +cat lib/footer.html 17.144 + 17.145 +exit 0
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/web/rootfs.cgi Sat Mar 24 23:12:44 2012 +0100 18.3 @@ -0,0 +1,151 @@ 18.4 +#!/bin/sh 18.5 +# 18.6 +# SliTaz Pizza CGI/web interface - Let's me have a pizza :-) 18.7 +# SliTaz rootfs step 18.8 +# 18.9 + 18.10 +. lib/libpizza 18.11 +log="$tmpdir/slitaz-$id/distro.log" 18.12 + 18.13 +# Internationalization: $(gettext "") 18.14 +. /usr/bin/gettext.sh 18.15 +TEXTDOMAIN='pizza' 18.16 +export TEXTDOMAIN 18.17 + 18.18 +# Handle rootfs.* file upload. 18.19 +tarball_handler() { 18.20 + echo "<pre>" 18.21 + echo "File name : $tarball" 18.22 + echo "File size : $size Bytes" 18.23 + gettext "Moving rootfs tarball to slitaz-$id" 18.24 + upload=$tmpdir/slitaz-$id/upload-$$ 18.25 + mkdir -p $upload && cd $upload 18.26 + mv $tmpname "$upload/$tarball" && rm -rf $(dirname $tmpname) 18.27 + chmod a+r $upload/$tarball 18.28 + status 18.29 + 18.30 + # Ectract into the tmp upload dir. 18.31 + gettext "Extracting archive for sanity checks..." 18.32 + case "$tarball" in 18.33 + *.tar.gz) tar xzf $tarball && status ;; 18.34 + *.tar.bz2) tar xjf $tarball && status ;; 18.35 + *.tar.lzma) tar xaf $tarball && status ;; 18.36 + *) echo && error "Unsupported tarball format" && rm -rf $upload 18.37 + esac 18.38 + 18.39 + # Upload dir is removed if bad tarball so we stop here. Now be a bit 18.40 + # restrictive using only rootfs as archive name and check FSH in root. 18.41 + # Dont allow files in /dev /proc /sys /tmp /mnt 18.42 + if [ -d "$upload/rootfs" ]; then 18.43 + gettext "Checking Filesystem Standard..." 18.44 + for i in $(ls $upload/rootfs) 18.45 + do 18.46 + case "$i" in 18.47 + bin|boot|etc|home|init|lib|root|sbin|usr|var) continue ;; 18.48 + *) echo "Bad FSH path for: $i" && rm -rf $upload ;; 18.49 + esac 18.50 + done && status 18.51 + # Dont allow too big rootfs content. 18.52 + size=$(du -s $upload/rootfs | awk '{print $1}') 18.53 + gettext "Checking uploaded rootfs size..." 18.54 + if [ "$size" -lt "$MAX_UPLOAD" ]; then 18.55 + status 18.56 + else 18.57 + echo && error "Tarball is too big" 18.58 + rm -rf $upload 18.59 + fi 18.60 + fi 18.61 + 18.62 + # So now it time to move the addfile to flavor files. 18.63 + if [ -d "$upload/rootfs" ]; then 18.64 + echo "Additionnal rootfs: accepted" | tee -a $log 18.65 + mkdir -p $tmpdir/slitaz-$id 18.66 + mv $upload/rootfs $tmpdir/slitaz-$id 18.67 + rm -rf $tmpdir/slitaz-$id/upload-* 18.68 + fi 18.69 + echo "</pre>" 18.70 + rm -rf $upload 18.71 +} 18.72 + 18.73 +# 18.74 +# Actions 18.75 +# 18.76 + 18.77 +case " $(FILE) " in 18.78 + *\ wallpaper\ *) 18.79 + id="$(POST id)" 18.80 + tmpname="$(FILE wallpaper tmpname)" 18.81 + wallpaper="$(FILE wallpaper name)" 18.82 + size="$(FILE wallpaper size)" 18.83 + if echo $wallpaper | fgrep -q .jpg; then 18.84 + images=$tmpdir/slitaz-$id/rootfs/usr/share/images 18.85 + mkdir -p $images 18.86 + mv $tmpname $images/slitaz-background.jpg 18.87 + chmod a+r $images/*.jpg 18.88 + notify "$(gettext "Added image:") $wallpaper ($size Bytes)" "info" 18.89 + else 18.90 + notify "$(gettext "Unsupported image format")" "error" 18.91 + fi ;; 18.92 + *\ tarball\ *) 18.93 + id="$(POST id)" 18.94 + tmpname="$(FILE tarball tmpname)" 18.95 + tarball="$(FILE tarball name)" 18.96 + size="$(FILE tarball size)" ;; 18.97 + *) 18.98 + id="$(GET id)" ;; 18.99 +esac 18.100 + 18.101 +# 18.102 +# Source receipt and display page with additonal rootfs or file upload. 18.103 +# 18.104 +. $tmpdir/slitaz-$id/receipt 18.105 +cat << EOT 18.106 +<h2>Rootfs</h2> 18.107 +<form method="post" action="rootfs.cgi" enctype="multipart/form-data"> 18.108 + 18.109 +<p> 18.110 + SliTaz root filesystem modification can be done via an easy to use form, 18.111 + a single tarball or by uploading file one by one in the wanted directory. 18.112 +</p> 18.113 + 18.114 +<h3>$(gettext "Easy customization")</h3> 18.115 + 18.116 + $(gettext "Desktop Wallpaper"): 18.117 + <input type="file" name="wallpaper" size="40" /> 18.118 + <input type="submit" value="Upload" /> 18.119 + 18.120 +<h3>$(gettext "Rootfs tarball")</h3> 18.121 +<p> 18.122 + The files in the rootfs archive must have the same directory structure 18.123 + than any standard SliTaz or Linux system. For example if you wish to 18.124 + have a custom boot configuration file, you will have: rootfs/etc/rcS.conf. 18.125 + Accepted tarball format are: <strong>tar.gz tar.bz2 tar.lzma</strong> 18.126 + and the archived directory must be named rootfs with a valid file system 18.127 + hierachy such as: /usr/bin /etc /var/www 18.128 +</p> 18.129 + 18.130 + Rootfs tarball: 18.131 + <input type="file" name="tarball" size="40" /> 18.132 + <input type="hidden" name="id" value="$id" /> 18.133 + <input type="submit" value="Upload" /> 18.134 +</form> 18.135 + 18.136 +$([ "$tarball" ] && tarball_handler) 18.137 + 18.138 +<pre> 18.139 +Uniq ID : $id 18.140 +Flavor : $FLAVOR 18.141 +Short desc : $SHORT_DESC 18.142 +</pre> 18.143 +<div class="next"> 18.144 + <form method="get" action="./"> 18.145 + <input type="hidden" name="id" value="$id" /> 18.146 + <input type="submit" name="gen" value="$(gettext "Continue")"> 18.147 + </form> 18.148 +</div> 18.149 +EOT 18.150 + 18.151 +# HTML footer. 18.152 +cat lib/footer.html 18.153 + 18.154 +exit 0
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/web/style.css Sat Mar 24 23:12:44 2012 +0100 19.3 @@ -0,0 +1,182 @@ 19.4 +/* CSS style for SliTaz Pizza */ 19.5 + 19.6 +html { height: 102%; } 19.7 +body { font: 13px sans-serif, vernada, arial; margin: 0; } 19.8 +h1 { margin: 0; padding: 8px; color: #fff; font-size: 20px; } 19.9 +h1 a { color: #fff; text-decoration: none; } 19.10 +h2 { color: #444; } h3 { color: #666; font-size: 130%; } 19.11 +a { text-decoration: underline; color: #215090; } 19.12 +a:hover { text-decoration: none; } 19.13 +img { vertical-align: middle; } 19.14 +h2 img { padding: 0px 6px 6px 0px; } 19.15 + 19.16 +pre { 19.17 + background-color: #f8f8f8; 19.18 + border: 1px solid #ddd; 19.19 + padding: 10px; 19.20 + overflow: auto; 19.21 + font-size: 98%; 19.22 +} 19.23 +table { 19.24 + background-color: #f8f8f8; 19.25 + border: 1px solid #ddd; 19.26 + width: 100%; 19.27 + margin: 0px 0px 20px 0px; 19.28 + padding: 10px; 19.29 +} 19.30 +/* HTML 5 dont allow size="40" but it's buggy on FF 19.31 + * input[type="file"] { width: 240px; margin: 0 5px; } */ 19.32 + 19.33 +/* Header */ 19.34 + 19.35 +#header { 19.36 + background: #351a0a; 19.37 + height: 40px; 19.38 + border-bottom: 8px solid #ffad02; 19.39 + /*border-bottom: 8px solid #d66018;*/ 19.40 +} 19.41 + 19.42 +#header h1 { 19.43 + margin: 0; 19.44 + padding: 8px 0 0 42px; 19.45 + width: 250px; 19.46 +} 19.47 + 19.48 +#header h1 a { 19.49 + color: white; 19.50 + text-decoration: none; 19.51 + font-size: 20px; 19.52 + font-style: italic; 19.53 +} 19.54 + 19.55 +#header h1 a:hover, #network a:hover { 19.56 + color: #d66018; 19.57 +} 19.58 + 19.59 +/* Logo */ 19.60 + 19.61 +#logo { 19.62 + background: url(images/logo.png) no-repeat left; 19.63 + position: absolute; 19.64 + float: left; 19.65 + left: 0px; 19.66 + top: 0px; 19.67 + width: 40px; 19.68 + height: 40px; 19.69 +} 19.70 + 19.71 +/* Header links */ 19.72 + 19.73 +#network { 19.74 + float: right; 19.75 + padding: 12px 5px 0; 19.76 + font-size: 12px; 19.77 +} 19.78 + 19.79 +#network a { 19.80 + padding: 0 6px; 19.81 + color: #fff; 19.82 + font-weight: bold; 19.83 + text-decoration: none; 19.84 +} 19.85 + 19.86 +/* Notification box */ 19.87 + 19.88 +#notify { 19.89 + /*font-weight: bold;*/ 19.90 + background-color: #351a0a; 19.91 + border: 1px solid #ffad02; 19.92 + color: #fff; 19.93 + cursor: help; 19.94 + position: absolute; 19.95 + top: 58px; 19.96 + right: 10px; 19.97 + width: auto; 19.98 + padding: 6px 12px; 19.99 +} 19.100 +#notify img { margin-right: 10px; } 19.101 + 19.102 +/* Content */ 19.103 + 19.104 +#content { 19.105 + margin: 40px auto; 19.106 + text-align: justify; 19.107 + width: 780px; 19.108 +} 19.109 + 19.110 +.note { 19.111 + margin: 20px; 19.112 + padding: 20px; 19.113 + background-color: #eaeaea; 19.114 + border: 2px solid #ccc; 19.115 +} 19.116 + 19.117 +.box { margin: 20px 0; } 19.118 +.next { float: right; } 19.119 + 19.120 +.span-ok { color: green; } 19.121 +.span-red { color: red; } 19.122 +.log-date { color: #666; font-size: 95%; } 19.123 + 19.124 +/* Form */ 19.125 + 19.126 +form { display: inline; } 19.127 +input[type="submit"], input[type="text"], textarea, select { 19.128 + color: #444444; 19.129 + border: 1px solid #cccccc; 19.130 + padding: 4px; 19.131 + margin: 4px 0px; 19.132 + font-size: 14px; 19.133 + line-height: 1.2em; 19.134 + background-image: -webkit-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5); 19.135 + background-image: -moz-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5); 19.136 + -webkit-appearance: none; 19.137 + -webkit-padding-end: 12px; 19.138 + -webkit-padding-start: 6px; 19.139 +} 19.140 + 19.141 +input[type="text"] { background: #fefefe; border: 2px solid #ccc; 19.142 + width: 460px; } 19.143 +/*input[type="file"] { border: 2px solid #ddd; }*/ 19.144 +/*input[type="checkbox"] { background: #fefefe; }*/ 19.145 + 19.146 +/* Be compatible with old FF and Webkit version. */ 19.147 +input[type="submit"] { 19.148 + -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1); 19.149 + -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1); 19.150 + box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1); 19.151 +} 19.152 + 19.153 +input[type="submit"]:hover { 19.154 + cursor: pointer; 19.155 + color: black; 19.156 +} 19.157 + 19.158 +select { 19.159 + background-image: url(images/down.png), 19.160 + -webkit-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5); 19.161 + background-position: center right; 19.162 + background-repeat: no-repeat; 19.163 +} 19.164 + 19.165 +/* Round corner */ 19.166 + 19.167 +pre, table, input, textarea, select, .note, .box, #notify { 19.168 + -moz-border-radius: 4px; 19.169 + -webkit-border-radius: 4px; 19.170 + border-radius: 4px; 19.171 +} 19.172 + 19.173 +/* Footer */ 19.174 + 19.175 +#footer { 19.176 + text-align: center; 19.177 + margin-top: 80px; 19.178 + padding: 20px; 19.179 + /*border-top: 1px solid #ddd;*/ 19.180 + font-size: 90%; 19.181 +} 19.182 + 19.183 +#footer a { padding: 0 2px; } 19.184 + 19.185 +::-webkit-scrollbar-track { color: #fefefe; }