Add scripts to create myops-getqueryview:
[myops.git] / web / view / index.php
diff --git a/web/view/index.php b/web/view/index.php
new file mode 100644 (file)
index 0000000..8d47793
--- /dev/null
@@ -0,0 +1,75 @@
+<html>
+<title>MyOps-View</title>
+<head>
+<!-- Every 5 minutes -->
+<meta http-equiv="refresh" content="600">
+</head>
+<body style="width: 1340px;">
+<?php
+
+$f_list = file("urllist.txt");
+
+$opts = array( 'hideLegend' => 'False', 
+                          'width' => '900', 
+                          'height' => '500' );
+                               
+print "Page rendered at <b>" . date("Y-m-d H:i:s e") . "</b>.  Refreshes every 10 minutes.";
+$url = "http://" . $_SERVER['SERVER_NAME'] . ":5984/myops/_design/myops/index.html";
+print "<br><a href='$url'>Raw MyOps-Query</a>";
+
+$tag = NULL;
+$show_all_default = True;
+$tagcount = 0;
+$tag_matches = False;
+$t = "";
+if ( isset($_REQUEST['tag']) )
+{
+    $tag = $_REQUEST['tag'];
+       $show_all_default = False;
+}
+
+# there are three cases
+# show thumbnails of everything
+# show thumbnails of just one tag
+# show large version of a thumbnail
+
+foreach ( $f_list as $url )
+{
+       $url = trim($url);
+       #print_r($show_all_default); print("sad<br>\n");
+       #print_r($tag); print(": tag<br>\n");
+       #print_r(isset($tag)); print(": tag<br>\n");
+       #print_r($tagcount); print(": tagcount<br>\n");
+       #print_r($tag_matches); print(": tag_matches<br>\n");
+       #print_r(preg_match("/#/", $url) > 0); print(": preg_match(#)<br>\n");
+       #print_r(strcmp(substr($url,1), $tag)); print(": strcmp: " . substr($url, 1) . "--" . $tag . "<BR>\n");
+       if ( $show_all_default || isset($tag) )
+       {
+               if ( preg_match("/#/", $url) > 0 )
+               {
+                       if ( strcmp(substr($url,1), $tag) == 0 )
+                       {
+                               $tag_matches = True;
+                       } else {
+                               $tag_matches = False;
+                       }
+                       if ( $tag_matches || $show_all_default ) {
+                               if ( $tagcount >= 4  && $t != "") {
+                               print "<a href='" . $_SERVER['PHP_SELF'] . "?tag=$t'>" . ($tagcount-4) ." more graphs...</a>\n";
+                               }
+                               $t = substr($url, 1);
+                           print "<br><hr><h3><a href='" . $_SERVER['PHP_SELF'] . "?tag=$t'>$t</a></h3>\n";
+                               $tagcount = 0;
+                       }
+               } else {
+                       if ( ( ( $tagcount < 4 && $show_all_default ) || $tag_matches )  && preg_match("/http/", $url) > 0 ) {
+                               print "<a href='$url&" . http_build_query($opts) . "'><img src='$url' /></a>\n";
+                       } 
+                       $tagcount += 1;
+               }
+       }
+}
+
+?>
+</body>
+</html>