Lots of little changes, basic structure now looking pretty good
authorpaulr <me@pjr.cc>
Sun, 24 Jul 2011 16:17:34 +0000 (02:17 +1000)
committerpaulr <me@pjr.cc>
Sun, 24 Jul 2011 16:17:34 +0000 (02:17 +1000)
libglcas/web.php
plugins/admin.php
plugins/repo.php
plugins/webbase.php
www/css/normal.css [new file with mode: 0644]
www/index.php
www/js/base.js [new file with mode: 0644]

index 6c3723b..a8d013a 100644 (file)
@@ -29,21 +29,72 @@ class GLCASWeb {
        
 }
 
+function GLCASMenuBuilder()
+{
+       global $BASE_URL;
+       ?>
+<a href="<?php echo $BASE_URL ?>">Home</a>
+<a href="<?php echo $BASE_URL."/admin/"?>">Admin</a>
+       <?php
+}
+
+function GLCASMessageBuilder()
+{
+       echo "<i>Messages not implemented yet</i>";
+}
+
 function GLCASpageBuilder($bodyClass, $bodyFunction, $title="GLCAS")
 {
-       global $WEB_ROOT_FS;
+       global $WEB_ROOT_FS, $BASE_URL;
        
        // TODO: load css
-       // TODO: load js
        // header
-       echo "<html><title>$title</title><body>";
+       echo "<html><head><title>$title</title>";
+       
+       // load css
+       if(file_exists("$WEB_ROOT_FS/css")) {
+               $dh = opendir("$WEB_ROOT_FS/css");
+               if($dh) {
+                       while(($file = readdir($dh))!==false) {
+                               $mt = preg_match("/.*.css$/", $file);
+                               if($mt > 0) {
+                                       error_log("loading css $file");
+                                       echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$BASE_URL/css/$file\">";
+                                       //echo "required $basedir/$file\n";
+                               }
+                       }
+               }               
+       }
+
+       // load js
+       if(file_exists("$WEB_ROOT_FS/js")) {
+               $dh = opendir("$WEB_ROOT_FS/js");
+               if($dh) {
+                       while(($file = readdir($dh))!==false) {
+                               $mt = preg_match("/.*.js$/", $file);
+                               if($mt > 0) {
+                                       error_log("loading js $file");
+                                       echo "<script type=\"text/javascript\" src=\"$BASE_URL/css/$file\"></script>";
+                                       //echo "required $basedir/$file\n";
+                               }
+                       }
+               }               
+       }
+       
+       
+       // start body
+       echo "</head><body>";
        
        // page top
        echo "<h1>GLCAS</h1><br>";
-       echo "<table><tr><td>messages go here<td></tr><tr><td>";
+       echo "<table><tr><td>";
+       GLCASMessageBuilder();
+       echo "<td></tr><tr><td>";
        
        // menu, then body
-       echo "<table><tr><td>Menu goes here</td></tr><tr><td>";
+       echo "<table><tr><td>";
+       GLCASMenuBuilder();
+       echo "</td></tr><tr><td>";
        // body
        $url = "/";
        if(isset($_REQUEST["q"])) {
index 4e24665..8b6c2a9 100644 (file)
@@ -15,9 +15,82 @@ class GLCASAdmin {
        
        function go($url)
        {
-               echo "admin page";
+               error_log("repo:go called");
+               
+               if(isset($_REQUEST["action"])) {
+                       switch($_REQUEST["action"]) {
+                               case "addrepo":
+                                       GLCASpageBuilder($this,"doAddRepo");
+                                       return;
+                                       break;
+                               case "scanrepo":
+                                       break;
+                       }
+               }
+               GLCASpageBuilder($this, "body");
+       }
+       
+       function body($url)
+       {
+               // for the main admin body, we hae the following components
+               
+               // 1. list of currently available repos and stuff
+               
+               // 2. way to add a repo direct
+               
+               // 3. way to scan for a repo given a url
+               
+               // so first, lets do the main body
+               $this->mainBody($url);
+       }
+       
+       function doAddRepo($url)
+       {
+               $myRep = new GLCASRepo($this->config);
+               
+               $glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"]);
+               
+               echo "<pre>$glt</pre>";
        }
        
+       function mainBody($url)
+       {
+               // first, list available repos
+               echo "<h3>Repositories</h3><br><table>";
+               echo "<tr><th>Name</th><th>Type</th><th>Version</th><th>Browse</th><th>Control</th></tr>";
+               echo "</table><br><hr>";
+               
+               // wrap all this in a table
+               echo "<table><tr><td valign=\"top\">";
+               // now, add a repo
+               echo "<h3>Add A Repo</h3>";
+               echo "<form method=\"post\" action=\"?action=addrepo\">";
+               echo "Type <select name=\"repotype\">";
+                       echo "<option value=\"yumbase\">YUM (Base URL)</option>";
+                       echo "<option value=\"yummirrorlist\">YUM (Mirror List)</option>";
+                       echo "<option value=\"apt\">APT</option>";
+                       echo "</select><br>";
+               echo "URL <input type=\"text\" name=\"repourl\"><br>";
+               echo "<input type=\"submit\" name=\"Add\" value=\"Add\"><br>";
+               echo "</form><hr>";
+               
+               echo "</td><td valign=\"top\">";
+               
+               // now scan for a repo
+               echo "<h3>Scan For Repos</h3>";
+               echo "<form method=\"post\" action=\"?action=scanrepo\">";
+               echo "Hint <select name=\"repohint\">";
+                       echo "<option value=\"fedora\">Fedora</option>";
+                       echo "<option value=\"centos\">Centos</option>";
+                       echo "<option value=\"ubuntu\">Ubuntu</option>";
+                       echo "</select><br>";
+               echo "URL <input type=\"text\" name=\"repourl\"><br>";
+               echo "<input type=\"submit\" name=\"Scan\" value=\"Scan\"><br>";
+               echo "</form>";
+               
+               echo "</td></tr></table>";
+       }
+
        private $config;
 }
 
index 804a5ce..c85ff12 100644 (file)
@@ -9,7 +9,26 @@ class GLCASRepo {
        
        function go($url)
        {
-               echo "i am the repo man, i repo the repo";
+               error_log("repo:go called");
+               GLCASpageBuilder($this, "body");
+       }
+       
+       function body($url)
+       {
+               echo "for the repo, i am the repo $url";
+       }
+       
+       function getRepoDetailsYum($url)
+       {
+               $actionurl = $url."/repodata/repomd.xml";
+               
+               error_log("Getting for action of $actionurl");
+               
+               $ld = file_get_contents($actionurl);
+               
+               if(!$ld) return false;
+               
+               return $ld;
        }
        
        private $config;
index 13dbcc3..6fa5943 100644 (file)
@@ -19,7 +19,7 @@ class GLCASWebBase {
        
        function body($url)
        {
-               echo "i am disturbing";
+               echo "i am disturbing, $url";
        }
        
        private $config;
diff --git a/www/css/normal.css b/www/css/normal.css
new file mode 100644 (file)
index 0000000..460827d
--- /dev/null
@@ -0,0 +1,129 @@
+head {
+  color: #333333;
+}
+body {
+  color: #333333;
+}
+table { border-width: 0px;
+       empty-cells: hide;
+}
+table.formsection, table.sortable, table.ui_table, table.loginform {
+  border-collapse: collapse;
+  border: 1px solid #FFFFFF;
+  width: 100%;
+}
+img, a img { border:0; }
+tr.row0 {background-color:#e8e8ea;}
+tr.row1 {background-color:#f8f8fa;}
+table.formsection thead, table.sortable thead, table.ui_table thead, table.loginform thead {
+background-color:#427ad1;
+border:0px;
+color:#ffffff;
+border: 2px solid #b3b6b0;
+}
+table.formsection tbody, table.sortable tbody, table.ui_table tbody, table.loginform tbody {
+background-color:#EFEFEF;
+}
+tr.maintitle {
+  color: #ffffff;
+  background-color: #427ad1;
+}
+td.maintitle {
+  color: #ffffff;
+  background-color: #427ad1;
+}
+tr.maintitle a, tr.maintitle a:visited {
+  color: #ffffff;
+}
+td.maintitle a, td.maintitle a:visited {
+  color: #ffffff;
+}
+tr.maintitle a:hover {
+  color: #EFEFEF;
+}
+td.maintitle a:hover {
+  color: #EFEFEF;
+}
+a:link { color: #333399;
+  text-decoration: none;
+}
+a:hover, a:visited:hover { color: #6666EE;
+  text-decoration: none;
+}
+a:visited { color: #333399;
+  text-decoration: none;
+}
+body, p, td, br, center { font-size: 10pt;
+  font-family: sans-serif;
+}
+title { color: #333333;
+  font-family: sans-serif;
+}
+h1 { color: #333333;
+  font-size: 150%;
+  font-family: sans-serif;
+}
+h2 { color: #333333;
+  font-size: 130%;
+  font-family: sans-serif;
+}
+h3 { color: #333333;
+  font-size: 125%;
+  font-family: sans-serif;
+}   
+h4 { color: #333333;
+  font-size: 120%;
+  font-family: sans-serif;
+} 
+th { font-size: small; }
+pre { font-size: 8pt; }
+#main { border-style: solid;
+  border:1px solid #FFFFFF;
+  margin:0;
+  padding:0;
+}
+tr.mainsel { background-color: #ddffbb; }
+tr.mainhigh { background-color: #ffffbb; }
+tr.mainhighsel { background-color: #bbffcc; }
+.itemhidden { display: none; }
+.itemshown { display:block; }
+.barchart { padding: 1px;
+  border: 1px solid #b3b6b0;
+  position:relative;
+}
+.ui_post_header{ font-size: 120%;
+ text-align: center;
+ padding: 4px;
+}
+hr { border: 0;
+  width: 90%;
+  height: 1px;
+  color: #D9D9D9;
+  background-color: #D9D9D9;
+}
+table.wrapper {
+  background-color:#D9D9D9;
+       border:0;
+  padding:0;
+  margin:0;
+  border-collapse:collapse;
+}
+div.wrapper {
+  border:1px solid #D9D9D9;
+  background-color:#F5F5F5;
+  padding:0;
+  margin:0;
+}
+.shrinkwrapper {
+  background-color:#D9D9D9;
+  border:0;
+  padding:0;
+       margin:0;
+  border-collapse:collapse;
+}
+.tabSelected {
+       background-color:#D9D9D9;
+}
+.tabUnselected {
+  background-color:#dadaf8;
+}
\ No newline at end of file
index 4657e52..e6e6f95 100644 (file)
@@ -1,8 +1,9 @@
 <?php
 
 $WEB_ROOT_FS = realpath(dirname(__FILE__));
+$BASE_URL = dirname($_SERVER["PHP_SELF"]);
 
-global $WEB_ROOT_FS, $URL_HANDLERS;
+global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
 
 // add libglcas as if it were a path in ../libglcas
 if(file_exists("../libglcas")) {
@@ -42,9 +43,14 @@ $glconfig = new GLCASConfig();
 $glconfig->loadConfig($configpath);
 $webResponder = new GLCASWeb($glconfig);
 $webResponder->go($URL_HANDLERS);
-/*
 
+
+/*
 echo "<pre>";
+echo "BASEURL: $BASE_URL\n";
+echo "CUSTOM\n";
+print_r($_SERVER);
+
 $vars = get_defined_vars();
 foreach($vars as $var => $vkey) {
        echo "VAR $var is:\n";
diff --git a/www/js/base.js b/www/js/base.js
new file mode 100644 (file)
index 0000000..58fd4b1
--- /dev/null
@@ -0,0 +1 @@
+// none
\ No newline at end of file