JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix typo
[cmus-lan-control.git] / make_page.sh
1 #!/bin/bash
2
3 # Copyright (C) 2010 Jason Woofenden
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 HIDE_PREFIX="$HOME/music/"
19
20 # escape / and \ so we can pass this to sed
21 HIDE_PREFIX="`echo "$HIDE_PREFIX" | sed -e 's/\([\\\/]\)/\\\\\1/g'`"
22
23 if test "$1" '!=' ''
24 then
25         PLAYLIST="$1"
26 else
27         PLAYLIST="$HOME/.cmus/lib.pl"
28 fi
29
30 exec <"$PLAYLIST"
31
32 PLAY_LINK='<a href="do.php?action=play&amp;file='
33 PLAY_LINK2='">play</a>'
34 QUEUE_LINK='<a href="do.php?action=queue&amp;file='
35 QUEUE_LINK2='">queue</a>'
36
37 cat <<EOF
38 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
39     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
40
41 <html xmlns="http://www.w3.org/1999/xhtml">
42 <head>
43   <title>cmus command page</title>
44   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
45   <script type="text/javascript">
46     \$(function() {
47       var loading = \$('#loading');
48       \$('a').click(function(event) {
49         event.preventDefault();
50         loading.html('connecting...');
51         loading.load(this.href);
52       });
53     });
54   </script>
55 </head>
56
57 <body>
58 <div style="position: fixed; width: 100%; height: 20px; background: #ffc; padding: 3px; border: 2px solid #ee0; top: 0; left: 0"><a href="do.php?action=pause">pause</a> <a href="do.php?action=prev">prev</a> <a href="do.php?action=next">next</a> <a href="do.php?action=voldown">quieter</a> <a href="do.php?action=volup">louder</a>  &mdash; Status: <span id="loading">OK</span></div>
59 <div style="height: 25px"></div>
60 EOF
61
62 while read
63 do
64         FILEPATH="$REPLY"
65         DISPLAY="`echo "$REPLY" | sed -e "s/$HIDE_PREFIX//"`"
66         #echo sed -e "s/$HIDE_PREFIX//"
67         echo "<div>$DISPLAY $PLAY_LINK$FILEPATH$PLAY_LINK2 $QUEUE_LINK$FILEPATH$QUEUE_LINK2</div>"
68 done
69
70 cat <<EOF
71 </body>
72 </html>
73 EOF