[37504] users/rhwood

rhwood at macports.org rhwood at macports.org
Tue Jun 10 03:48:39 PDT 2008


Revision: 37504
          http://trac.macosforge.org/projects/macports/changeset/37504
Author:   rhwood at macports.org
Date:     2008-06-10 03:48:38 -0700 (Tue, 10 Jun 2008)

Log Message:
-----------
Branch trunk/www for development

Modified Paths:
--------------
    users/rhwood/macports-www/includes/common.inc
    users/rhwood/macports-www/includes/header.inc
    users/rhwood/macports-www/macports.css

Added Paths:
-----------
    users/rhwood/macports-www/
    users/rhwood/macports-www/img/rss.png
    users/rhwood/macports-www/img/spinner_small.gif
    users/rhwood/macports-www/includes/portindex.php
    users/rhwood/macports-www/includes/rss.php
    users/rhwood/macports-www/includes/search.php
    users/rhwood/macports-www/port.php

Copied: users/rhwood/macports-www (from rev 37499, trunk/www)

Added: users/rhwood/macports-www/img/rss.png
===================================================================
(Binary files differ)


Property changes on: users/rhwood/macports-www/img/rss.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: users/rhwood/macports-www/img/spinner_small.gif
===================================================================
(Binary files differ)


Property changes on: users/rhwood/macports-www/img/spinner_small.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Modified: users/rhwood/macports-www/includes/common.inc
===================================================================
--- trunk/www/includes/common.inc	2008-06-10 07:42:09 UTC (rev 37499)
+++ users/rhwood/macports-www/includes/common.inc	2008-06-10 10:48:38 UTC (rev 37504)
@@ -77,6 +77,7 @@
                     'num_categories' => 'many'
                 );
                 break;
+            case "port.php":
             case "ports.php":
                 print "
                     <div id='content'>

Modified: users/rhwood/macports-www/includes/header.inc
===================================================================
--- trunk/www/includes/header.inc	2008-06-10 07:42:09 UTC (rev 37499)
+++ users/rhwood/macports-www/includes/header.inc	2008-06-10 10:48:38 UTC (rev 37504)
@@ -23,6 +23,7 @@
         <meta name="verify-v1" content="/aylCprlQpTgk6J7bm51erICmpcEK5kcXH7FMFr0WsI=" />
         <meta name="robots" content="all" />
         <link rel="stylesheet" type="text/css" href="macports.css" />
+	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"></script>
         <script type="text/javascript" src="mootools.v1.11.js"></script>
         <script type="text/javascript" src="language.js"></script>
     </head>

Added: users/rhwood/macports-www/includes/portindex.php
===================================================================
--- users/rhwood/macports-www/includes/portindex.php	                        (rev 0)
+++ users/rhwood/macports-www/includes/portindex.php	2008-06-10 10:48:38 UTC (rev 37504)
@@ -0,0 +1,126 @@
+<?php
+    /* -*- coding: utf-8; mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=php:et:sw=4:ts=4:sts=4 */
+    /* Web client to the PortIndex2MySQL script located in MacPorts base/portmgr/jobs svn directory. */
+    /* $Id: ports.php 35225 2008-03-21 06:31:53Z eridius at macports.org $ */
+    /* Copyright (c) 2004-2008, The MacPorts Project. */
+
+/*
+	returns the time the database was last updated from the portindex
+	takes a parameter to return the date ('date'), the time ('time'), or the unix timestamp ('unix')
+	
+	This function uses a global variable to store the last update time so that we don't have to repeatedly
+	make sql calls to get it during a single session
+ */
+function lastUpdate($type) {
+	global $lastUpdateTimeStamp;
+	global $portsdb_name;
+	if (!$lastUpdateTimeStamp['unix']) {
+		$query = "SELECT UNIX_TIMESTAMP(activity_time) FROM $portsdb_name.log ORDER BY UNIX_TIMESTAMP(activity_time) DESC";
+		$result = mysql_query($query);
+		if ($result && $row = mysql_fetch_row($result)) {
+			$lastUpdateTimeStamp['date'] = date('Y-m-d', $row[0]);
+			$lastUpdateTimeStamp['time'] = date('H:i:s e', $row[0]);
+			$lastUpdateTimeStamp['unix'] = $row[0];
+		} else {
+			return '(unknown)';
+		}
+	}
+	return $lastUpdateTimeStamp[$type];
+}
+
+/*
+	prints a brief block of information on a port, given the data returned from an SQL query against the port
+ */
+function portInfo($port, $printName = true) {
+    /* Port name and Portfile URL */
+    if ($printName) {
+	    print "<dt><b><a href=\"$_SERVER[PHP_SELF]?port={$port['name']}\">" . htmlspecialchars($port['name'])
+    		. '</a></b> ' . htmlspecialchars($port['version']) . '</dt>';
+    } else {
+    	print "<i>Version:</i> ". htmlspecialchars($port['version']) . "<br />";
+    } 
+    
+    print '<dd>';
+    /* Port short description */
+    print htmlspecialchars($port['description']) . '<br />';
+    
+    /* Maintainers */
+    printRepeatingPortInfo('maintainer', 'maintainers', $port['name'], null, 'obfuscate_email', true);
+
+    /* Categories */
+    printRepeatingPortInfo('category', 'categories', $port['name'], null, null, true);
+
+    /* Platforms */
+    printRepeatingPortInfo('platform', 'platforms', $port['name']);
+
+    /* Dependencies */
+    printRepeatingPortInfo('library', 'dependencies', $port['name'], 'cleanLibraryName');
+
+    /* Variants */
+    printRepeatingPortInfo('variant', 'variants', $port['name']);
+
+    print '<br /><br /></dd>';
+}
+
+function printRepeatingPortInfo($select, $from, $port, $parser = null, $formatter = null, $highlightFirstItem = false) {
+	global $portsdb_name;
+	$port = mysql_real_escape_string($port);
+	$result = mysql_query("SELECT $select FROM $portsdb_name.$from WHERE portfile='$port' ORDER BY $select");
+	if ($result && mysql_num_rows($result) > 0) {
+		print '<br /><i>' . ucfirst($from) . ':</i>';
+		while ($row = mysql_fetch_row($result)) {
+			print " ";
+			if ($parser) {
+				$out = call_user_func($parser, $row[0]);
+			} else {
+				$out = $row[0];
+			}
+			if ($formatter) {
+				$outText = call_user_func($formatter, $out);
+			} else {
+				$outText = $out;
+			}
+			if ($highlightFirstItem) {
+				$outText = "<b>$outText</b>";
+				$highlightFirstItem = false;
+			}
+			print "<a href=\"$_SERVER[PHP_SELF]?by=$select&amp;substr=$out\">$outText</a>";
+        }
+	}
+}
+
+function cleanLibraryName($name) {
+	return eregi_replace('^([^:]*:[^:]*:|[^:]*:)', '', $name);
+}
+
+function queryForPort($name) {
+	global $portsdb_name;
+	$result = mysql_query("SELECT DISTINCT name, path, version, description FROM $portsdb_name.portfiles AS p WHERE p.name = \"" . mysql_real_escape_string($name) . "\" ORDER BY name");
+	if ($result) {
+		list($name, $path, $version, $description) = mysql_fetch_row($result);
+		return array("name" => $name, "path" => $path, "version" => $version, "description" => $description);
+	}
+}
+
+function portTickets($feed, $max) {
+	$tickets = parseRSS($feed, $max);
+	$output = "<dl>";
+	foreach ($tickets as $ticket) {
+		$output .= "<dt><a href=\"${ticket['link']}\">${ticket['title']}</a></dt>";
+	}
+	$output .= "</dl>";
+	return $output;
+}
+
+function portRevisions($feed, $max) {
+	$changesets = parseRSS($feed, $max);
+	$output = "<dl>";
+	foreach ($changesets as $changeset) {
+		$output .= "<dt><a href=\"${changeset['link']}\">${changeset['title']}</a> on ${changeset['pubDate']}</dt>";
+		$output .= "<dl>${changeset['description']}</dl>";
+	}
+	$output .= "</dl>";
+	return $output;	
+}
+
+?>
\ No newline at end of file

Added: users/rhwood/macports-www/includes/rss.php
===================================================================
--- users/rhwood/macports-www/includes/rss.php	                        (rev 0)
+++ users/rhwood/macports-www/includes/rss.php	2008-06-10 10:48:38 UTC (rev 37504)
@@ -0,0 +1,26 @@
+<?php
+
+/*
+	Returns an array of RSS feed items for running through a formatter
+ */
+function parseRSS($url, $max) {
+	$feed = new DOMDocument();
+	$feed->load($url);
+	$items = array();
+	$count = 1;
+	foreach ($feed->getElementsByTagName('item') as $node) {
+		if ($count < $max) {
+			$item['link'] = $node->getElementsByTagName('link')->item(0)->nodeValue;
+			$item['title'] = $node->getElementsByTagName('title')->item(0)->nodeValue;
+			$item['description'] = $node->getElementsByTagName('description')->item(0)->nodeValue;
+			$item['pubDate'] = $node->getElementsByTagName('pubDate')->item(0)->nodeValue;
+			$items[$count - 1] = $item;
+			$count++;
+		} else {
+			break;
+		}
+	}
+	return $items;
+}
+
+?>
\ No newline at end of file

Added: users/rhwood/macports-www/includes/search.php
===================================================================
--- users/rhwood/macports-www/includes/search.php	                        (rev 0)
+++ users/rhwood/macports-www/includes/search.php	2008-06-10 10:48:38 UTC (rev 37504)
@@ -0,0 +1,26 @@
+<?php
+    /* -*- coding: utf-8; mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=php:et:sw=4:ts=4:sts=4 */
+    /* The ports search bar as portable code */
+    /* $Id: ports.php 35225 2008-03-21 06:31:53Z eridius at macports.org $ */
+    /* Copyright (c) 2004, OpenDarwin. */
+    /* Copyright (c) 2004-2008, The MacPorts Project. */
+    
+    $MPWEB = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['SCRIPT_NAME']);
+    include_once("$MPWEB/includes/common.inc");
+    
+    $by = isset($_GET['by']) ? $_GET['by'] : '';
+?>
+
+<form action="<?php print dirname($_SERVER['PHP_SELF']); ?>/ports.php" method="get">
+    <label>Search by:</label>
+    <select name="by">
+        <option value="name"<?php if ($by == 'name') { print ' selected="selected"'; } ?>>Software Title</option>
+        <option value="category"<?php if ($by == 'category') { print ' selected="selected"'; } ?>>Category</option>
+        <option value="maintainer"<?php if ($by == 'maintainer') { print ' selected="selected"'; } ?>>Maintainer</option>
+<!--        <option value="library"<?php if ($by == 'dependency') { print ' selected="selected"'; } ?>>Dependency</option> -->
+        <option value="variant"<?php if ($by == 'variant') { print ' selected="selected"'; } ?>>Variant</option>
+        <option value="platform"<?php if ($by == 'platform') { print ' selected="selected"'; } ?>>Platform</option>
+    </select>
+    <input type="text" name="substr" size="20" />
+    <input type="submit" value="Search" />
+</form>

Modified: users/rhwood/macports-www/macports.css
===================================================================
--- trunk/www/macports.css	2008-06-10 07:42:09 UTC (rev 37499)
+++ users/rhwood/macports-www/macports.css	2008-06-10 10:48:38 UTC (rev 37504)
@@ -224,3 +224,29 @@
     height: 31px;
     width: 88px;
 }
+
+.feedInnerWrapper {
+	border: #8695B3 solid 2px;
+}
+
+.feedHeader {
+}
+
+.feedHeader a {
+	color: white;
+}
+
+.feed {
+}
+
+.feed dl {
+	margin: 0;
+	padding: 0;
+	padding-left: 2.5em;
+	text-indent: -2.5em;
+}
+
+.feedFooter {
+    background: #8695B3;
+    text-align: right;
+}
\ No newline at end of file

Added: users/rhwood/macports-www/port.php
===================================================================
--- users/rhwood/macports-www/port.php	                        (rev 0)
+++ users/rhwood/macports-www/port.php	2008-06-10 10:48:38 UTC (rev 37504)
@@ -0,0 +1,86 @@
+<?php
+    /* -*- coding: utf-8; mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=php:et:sw=4:ts=4:sts=4 */
+    /* Web client to the PortIndex2MySQL script located in MacPorts base/portmgr/jobs svn directory. */
+    /* $Id: ports.php 35225 2008-03-21 06:31:53Z eridius at macports.org $ */
+    /* Copyright (c) 2004-2008, The MacPorts Project. */
+
+	/* if port has not been passed, have ports.php do all the processing and exit */
+	if (isset($_GET['port'])) {
+		$port = $_GET['port'];
+	/* use the language that ports.php uses to refer to a single port */
+	/* this should throw an http permanent redirect instead */
+	} else if (isset($_GET['by']) && $_GET['by'] == 'library') {
+		$port = $_GET['substr'];
+	} else {
+		include_once('ports.php');
+		exit;
+	}
+	
+	session_start();
+    
+    $MPWEB = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['SCRIPT_NAME']);
+    include_once("$MPWEB/includes/common.inc");
+    $portsdb_info = portsdb_connect($portsdb_host, $portsdb_user, $portsdb_passwd);
+    include_once("$MPWEB/includes/portindex.php");
+  
+    $port = queryForPort($port);
+
+	$tickets = "{$trac_url}query?status=new&amp;status=assigned&amp;status=reopened&amp;summary=%7E{$port['name']}&amp;order=priority";
+	$history = "{$trac_url}log/trunk/dports/{$port['path']}/Portfile?mode=stop_on_copy";
+	$ticketsRSS = "{$tickets}&amp;format=rss";
+	$historyRSS = "{$history}&amp;format=rss";
+
+	if (isset($_GET['trac'])) {
+		include_once("$MPWEB/includes/rss.php");
+		if ($_GET['trac'] == 'tickets') {
+			print portTickets($ticketsRSS, 10);
+		} else {
+			print portRevisions($historyRSS, 10);
+		}
+		exit;
+	}
+
+    print_header("The MacPorts Project -- {$port['name']}", 'utf-8');
+
+?>
+
+<?php /*
+This is a simple javascript that sets a global variable for use in other javascripts
+I do this so that HTML/javascript code later is not strings in php print statements
+*/ ?>
+<script type="text/javascript">
+<?php print "var MPportName = '{$port['name']}';\n" ?>
+</script>
+
+<div id="content">
+
+    <h2 class="hdr">Port <?php print($port['name']); ?></h2>
+
+	<?php portInfo($port, false); ?>
+	
+	<p>Last updated on <?php print lastUpdate('date') . " at " . lastUpdate('time') . "."; ?></p>
+	
+    <div id="tracHistoryWrapper" style="float:right; width:50%" class="feedOuterWrapper"><div class="feedInnerWrapper" style="margin-left: 5px">
+    	<h3 class="feedHeader"><?php print "<a href=\"{$historyRSS}\">"; ?><img style="float: right; border: none;" src="img/rss.png" />Revision History</a></h3>
+    	<div id="tracHistory" class="feed"><img src="img/spinner_small.gif" /></div>
+    	<div class="feedFooter"><?php print "<a href=\"{$history}\">"; ?>More...</a></div>
+    </div></div>
+    <div id="tracTicketsWrapper" style="width:50%" class="feedOuterWrapper"><div class="feedInnerWrapper" style="margin-right: 5px">
+    	<h3 class="feedHeader"><?php print "<a href=\"{$ticketsRSS}\">"; ?><img style="float: right; border: none;" src="img/rss.png" />Tickets</a></h3>
+    	<div id="tracTickets" class="feed"><img src="img/spinner_small.gif" /></div>
+    	<div class="feedFooter"><?php print "<a href=\"{$tickets}\">"; ?>More...</a></div>
+    </div></div>
+
+	<script type="text/javascript">
+		Event.observe(window, 'load', function() {
+			new Ajax.Updater('tracHistory', window.location.pathname, { method: 'get', parameters: { port: MPportName, trac: 'history' } });
+			new Ajax.Updater('tracTickets', window.location.pathname, { method: 'get', parameters: { port: MPportName, trac: 'tickets' } });
+		});
+	</script>
+
+</div>
+
+<?php
+    print_footer();
+    mysql_close($portsdb_info['connection_handler']);
+?>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080610/da6647ce/attachment-0001.htm 


More information about the macports-changes mailing list