]> git.plutz.net Git - busy/blobdiff - pages/Home.sh
porting busy to confetti framework
[busy] / pages / Home.sh
diff --git a/pages/Home.sh b/pages/Home.sh
new file mode 100755 (executable)
index 0000000..eea4316
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/zsh
+
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Busy
+# 
+# Busy 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.
+# 
+# Busy 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 Busy. If not, see <http://www.gnu.org/licenses/>. 
+
+
+searchresults() {
+  search="$(echo "$_GET[\"s\"]" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g')"
+
+  if [ -n "$search" ]; then
+    echo "<h1>News search results for: $search</h1>"
+    for each in $(grep -ile "$search" Home/<0000000000-9999999999>_<000-999>.news); do
+      id=$(sed -r 's:^.*/::;s:.news$::' <<<$each)
+      echo "<div class='search'><a href='#news_$id'><h2>$(date -d @$(cut -d_ -f1 <<<"$id"))</h2></a>"
+      grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
+      echo '</div>'
+    done
+    echo '<hr>'
+  fi
+}
+
+sponsored() {
+  btcAdAddress="$(sed -rn 's:^btcAdAddress=(.+):\1:p' project.meta)"
+  btcAdContent="$(sed -rn 's:^btcAdContent=([1-4]):\1:p' project.meta)"
+  grep -q 'advertise=btcAd' project.meta && cat <<EOF
+  <h1>Sponsored Links:</h1>
+  <iframe src="http://bitcoinadvertisers.com/a.php?p=${btcAdAddress}&a=${btcAdContent}&bg=FFFFFF&link=3366FF&text=414141"
+          scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>
+  <iframe src="http://bitcoinadvertisers.com/a.php?p=${btcAdAddress}&a=${btcAdContent}&bg=FFFFFF&link=3366FF&text=414141"
+          scrolling="no" style="width:120px;height:300px;border:1px solid #f2f2f2;"></iframe>
+EOF
+}
+
+case "$1" in
+  title)
+    echo "Home"
+  ;;
+  css)
+    cat ${_EXEC}/templates/Home.css
+  ;;
+  body)
+    #. ${_EXEC}/templates/text_home.sh
+    . ${_EXEC}/templates/Home.page
+  ;;
+esac
+