index : website | |
Archlinux32 website - obsolete | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-04-12 10:28:31 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-04-12 10:28:31 +0200 |
commit | 5036d7a7172055a24ae9fa493e37998b725966eb (patch) | |
tree | 82956ba699664612f283109c104ae4533c5fc080 /buildmaster/todos.php | |
parent | 4b2dcc3b53fafcab1f1912990fd5468795108a18 (diff) |
-rw-r--r-- | buildmaster/todos.php | 95 |
diff --git a/buildmaster/todos.php b/buildmaster/todos.php new file mode 100644 index 0000000..99e991c --- /dev/null +++ b/buildmaster/todos.php @@ -0,0 +1,95 @@ +<?php + +$mysql = new mysqli("localhost", "webserver", "empty", "buildmaster"); +if ($mysql->connect_error) { + die("Connection failed: " . $mysql->connect_error); +} + +$result = $mysql -> query( + "SELECT DISTINCT " . + "`todos`.`id`," . + "`todos`.`file`," . + "`todos`.`line`," . + "`todos`.`description` " . + "FROM `todos`;" +); + +if (isset($_GET["graph"])) { + + if ($result -> num_rows > 0) { + + while ($row = $result->fetch_assoc()) + $knot_rows[$row["id"]] = + $row["file"]. " (line ".$row["line"]."):\\n".str_replace("\"","\\\"",$row["description"]); + + unset($knots); + foreach ($knot_rows as $knot) + $knots=$knots . "\"" . $knot . "\";\n"; + + } + + $result = $mysql -> query( + "SELECT DISTINCT " . + "`todo_links`.`dependent`," . + "`todo_links`.`depending_on` " . + "FROM `todo_links`;" + ); + + if ($result -> num_rows > 0) { + $count = 0; + while ($row = $result->fetch_assoc()) { + $link_rows[$count]["dependent"] = + $knot_rows[$row["dependent"]]; + $link_rows[$count]["depending_on"] = + $knot_rows[$row["depending_on"]]; + $count++; + } + + unset($edges); + foreach ($link_rows as $link) + $edges=$edges . "\"" . $link["depending_on"] . "\" -> \"" . $link["dependent"] . "\";\n"; + } + + $knots = str_replace("\$","\\\$",$knots); + $edges = str_replace("\$","\\\$",$edges); + + header ("Content-type: image/png"); + passthru( + "dot -Tpng -o/dev/stdout /dev/stdin <<EOF\n" . + "digraph dependencies {\n" . + "rankdir=LR;\n" . + "fontname=dejavu;\n" . + $knots . + $edges . + "}\n" . + "EOF\n" + ); + +} else { // isset($_GET["graph"]) + + if ($result -> num_rows > 0) { + + print "<html>\n"; + print "<head>\n"; + print "<title>Todos in the build scripts</title>\n"; + print "</head>\n"; + print "<body>\n"; + + while ($row = $result->fetch_assoc()) { + print "<a href=\"#TODO" . $row["id"] . "\">TODO #" . $row["id"] . "</a>"; + print " - "; + print "<a href=\"https://github.com/archlinux32/builder/blob/master/" . $row["file"] . "#L" . $row["line"] . "\">" . $row["file"] . "(line " . $row["line"] . ")</a>"; + print ":<br>\n"; + print str_replace("\\n","<br>\n",$row["description"]); + print "<br>\n"; + print "<br>\n"; + } + + print "</body>\n"; + print "</html>\n"; + + } + +} + +?> |