]> git.plutz.net Git - serve0/commitdiff
introduced player preferences
authorpaul <paul@plutz.net>
Fri, 31 Jul 2015 15:42:27 +0000 (15:42 +0000)
committerpaul <paul@plutz.net>
Fri, 31 Jul 2015 15:42:27 +0000 (15:42 +0000)
svn path=/trunk/; revision=68

actions/preferences.sh [new file with mode: 0755]
actions/watch.sh
pages/common.sh
pages/list.sh
templates/common.css.sh
templates/list.html.sh
templates/preferences.html.sh [new file with mode: 0755]

diff --git a/actions/preferences.sh b/actions/preferences.sh
new file mode 100755 (executable)
index 0000000..1b76fbc
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/zsh
+
+cgi_post
+cgi_cookie
+
+fakemp4="$(printf %s "${_POST[fakemp4]}" |sed -rn '/^yes$/{p;q};ano' )"
+watch="$(printf %s   "${_POST[watch]}"   |sed -rn '/^(240p|480p|download|raspi|player)$/{p;q};aplayer' )"
+
+debug '== Setting Preferences =='
+debug "fakemp4 = $fakemp4"
+debug "watch   = $watch"
+
+set_cookie '+ 1 month' "fakemp4=${fakemp4}" HttpOnly
+set_cookie '+ 1 month' "watch=${watch}" HttpOnly
+
+redirect "$HTTP_REFERER"
index 04c023925962297ffe600556b0e4d40f82d4e6bf..8f1a18d272a04ad3e22fb291e805bcf8a33f379a 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/zsh
 
 cgi_refdata
+cgi_cookie
 info="${_GET[i]}"
 order="${_REF[o]}"
 search="${_REF[s]}"
@@ -8,10 +9,47 @@ filter="${_REF[f]}"
 page="${_REF[pn]}"
 
 watch_link=''
-[ -n "$info" ]   && watch_link="i=$(echo -n "${info}" |sed -r 's:%:%25:g;s:\&:%26:g;')&"
+[ -n "$info" ]   && watch_link="i=$(urlsave "${info}")&"
 [ -n "$order" ]  && watch_link="${watch_link}o=${order}&"
 [ -n "$search" ] && watch_link="${watch_link}s=${search}&"
 [ -n "$filter" ] && watch_link="${watch_link}f=${filter}&"
 [ -n "$page" ]   && watch_link="${watch_link}pn=${page}"
 
-echo -n "Location: ?p=view&${watch_link}\n\n"
+meta="${_DATA}/meta/$info.meta"
+head -n1 "$meta" |read length width height filename
+[ "$length" -gt 0 ] || length=0
+[ "$width"  -gt 0 ] || width=0
+[ "$height" -gt 0 ] || height=0
+
+linkinfo="$(urlsave "$info")"
+
+if [ "${_COOKIE[fakemp4]}" = yes ] && [ "${info##*.}" != mp4 ]; then
+  [ -e "${_DATA}/videos/${info%.*}.mp4" ] || ln -s "${_DATA}/videos/$info" "${_DATA}/mp4/${info%.*}.mp4"
+  videourl="$(urlsave "mp4/${info%.*}.mp4")"
+else
+  videourl="$(urlsave "videos/$info")"
+fi
+
+case "${_COOKIE[watch]}" in
+  raspi)
+    rpiaddr="http://pfostenpanne.helmchyn.no-ip.biz/?player=play&path="
+    [ $height -gt 480 -a $width -gt 480 ] && redirect "${rpiaddr}$(urlsave "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")" \
+                                          || redirect "${rpiaddr}$(urlsave "http://jupiter:8000/${videourl}")"
+  ;;
+  480p)
+    [ $height -gt 480 ] && redirect "?action=transcode&i=${linkinfo}&t=480" \
+                        || redirect "$videourl"
+  ;;
+  240p)
+    [ $height -gt 240 ] && redirect "?action=transcode&i=${linkinfo}&t=240" \
+                        || redirect "$videourl"
+  ;;
+  download)
+    redirect "$videourl"
+  ;;
+  *) redirect "?p=view&${watch_link}"
+  ;;
+esac
+
+
+
index b424dff0a914c360052a54e6dbf3f3b69422c0be..9e659bf1c5a3575c6050068fbf5310aec3d85aa7 100755 (executable)
@@ -62,37 +62,21 @@ _printVideo(){
     thumb="$(urlsave "thumbs/$info.jpg")"
     linkinfo="$(urlsave "$info")"
 
-    [ "$(($length % 60))" -lt 10 ] &&\
-      minutes="$(($length / 60)):0$(($length % 60))" ||\
-      minutes="$(($length / 60)):$(($length % 60))"
-
-    rpiaddr="pfostenpanne.helmchyn.no-ip.biz"
-    rpidull="http://${rpiaddr}/?player=play&path=http://jupiter:8000/${video}"
-    rpicgi="http://${rpiaddr}/?player=play&path=$(urlsave "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")"
-
-    [ $height -gt 480 -a $width -gt 480 ] && \
-       raspi="<a class=\"videolink alt raspi\" href=\"${rpicgi}\">RasPi</a>" \
-    || raspi="<a class=\"videolink alt raspi\" href=\"${rpidull}\">RasPi</a>"
-    [ $height -gt 480 ] && \
-      alt480="<a class=\"videolink alt 480p\" href=\"?action=transcode&i=${linkinfo}&t=480\">480p</a>" \
-    ||unset alt480
-    [ $height -gt 240 ] && \
-      alt240="<a class=\"videolink alt 240p\" href=\"?action=transcode&i=${linkinfo}&t=240\">240p</a>" \
-    ||unset alt240
+    [ "$(($length % 60))" -lt 10 ] && minutes="$(($length / 60)):0$(($length % 60))" \
+                                   || minutes="$(($length / 60)):$(($length % 60))"
 
     tee "$cache" <<VIDEOend
       <li class="thumb">
         <a class="watchlink" name="${linkinfo}" href="?action=watch&i=${linkinfo}">
-          <img src="$thumb">
+          <img src="$thumb" alt="Preview not yet available">
         </a>
-        <a class="videolink" href="$video">$info</a>
-        ${alt480} ${alt320} ${alt240} ${raspi}<br>
+        <h2>$info</h2>
         
         <input type="checkbox" name="tagsel" value="$info">
         <span class="info property">${minutes}min</span>
         <span class="info property">${width}x${height}</span>
-       $(echo -E "$tags" |sed -r 's:\|*([^|]+)\|*:<span class="info tag">\1</span>:g')
-      </div>
+       $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*:<span class="info tag">\1</span>:g')
+      </li>
 VIDEOend
   fi
 }
index a86f04c0a701d2b8bbf184fd251e7ac1cd2416ce..32b4b94dd4825d4812788e65d799fc48dfd5c481 100755 (executable)
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with Serve0.  If not, see <http://www.gnu.org/licenses/>. 
 
+cgi_cookie
 . $_EXEC/pages/common.sh
 
 filters="$(printf %s "${_GET[f]}" |sed -r 's;^!*\^*;;; s;\^*!*$;;; s;!+;!;g; s;\^+;^;g')"
index 02d02f3c45815d47680abf2b7175d70b3856be87..706ac85672c1bb2207009f07934b0de3cb647cf1 100755 (executable)
@@ -169,6 +169,11 @@ a.clearsearch, a.advanced, a.tagger, .pagination_nav {
 #thumblist .thumb img {
   width: 100%;
 }
+#thumblist .thumb h2 {
+  font-size: 1em;
+  font-weight: normal;
+  margin: 0;
+}
 #thumblist .thumb a {
   display: block;
 }
@@ -187,6 +192,8 @@ a.clearsearch, a.advanced, a.tagger, .pagination_nav {
   top: 0;
 }
 
+#preferences { display: none; }
+#preferences:target { display: block; z-index: 1; }
 #tagger { display: none; }
 #tagger:target { display: block; z-index: 1; }
 .footer {
index a4e50bb2a274b2fb67158021c411e748844dbef3..65a1e26d21de28d2b0bdbf531c98d604b56c02fd 100755 (executable)
@@ -48,8 +48,11 @@ cat <<EOF
     $(. $_EXEC/templates/tagger.html.sh)
   </form>
 
+  $(. $_EXEC/templates/preferences.html.sh)
+
   <div class="panel footer" id="foot">
     <a class="panel tagger show" href="#tagger">Add Tags</a>
+    <a class="panel tagger show" href="#preferences">Preferences</a>
 
     <div class="pagination_nav">
       <label>Page:</label>
diff --git a/templates/preferences.html.sh b/templates/preferences.html.sh
new file mode 100755 (executable)
index 0000000..bf87ae3
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright 2015 Paul Hänsch
+#
+# This file is part of Serve0
+# 
+# Serve0 is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# Serve0 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with Serve0  If not, see <http://www.gnu.org/licenses/>. 
+
+cat <<EOF
+  <form class="panel footer" id="preferences"
+   action="?action=preferences" method="post" accept-charset="UTF-8">
+    <a class="panel hide" href="#foot">Hide</a>
+
+    <input type="checkbox" name="fakemp4" value="yes" $([ "${_COOKIE[fakemp4]}" = yes ] && printf 'checked') id="ck_fakemp4">
+    <label for="ck_fakemp4">Fake .mp4 file ending, even if file is of different type</label>
+
+    <h2>Watch videos:</h2>
+    <input type="radio" name="watch" value="240p"     $([ "${_COOKIE[watch]}" = 240p     ] && printf 'checked') id="rd_w240p">
+    <label for="rd_w240p">as Download in 240p</label><br>
+    <input type="radio" name="watch" value="480p"     $([ "${_COOKIE[watch]}" = 480p     ] && printf 'checked') id="rd_w480p">
+    <label for="rd_w480p">as Download in 480p</label><br>
+    <input type="radio" name="watch" value="download" $([ "${_COOKIE[watch]}" = download ] && printf 'checked') id="rd_wdown">
+    <label for="rd_wdown">as Download (original)</label><br>
+    <input type="radio" name="watch" value="raspi"    $([ "${_COOKIE[watch]}" = raspi    ] && printf 'checked') id="rd_wrasp">
+    <label for="rd_wrasp">on RaspBerry</label><br>
+    <input type="radio" name="watch" value="player"   $([ "${_COOKIE[watch]}" = player   ] && printf 'checked') id="rd_wplay">
+    <label for="rd_wplay">in embedded player</label><br>
+
+    <input type="submit" value="Set Cookie!">
+  </form>
+EOF
+
+# vi:set filetype=html: