svn: /pear2/sandbox/pear2.php.net/trunk/www/ css/file-browser.css templates/pear2/html/ReleaseFileBrowser.tpl.php

[email protected] (Michael Gauthier)
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
gauthierm                                Mon, 12 Jul 2010 22:18:45 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=301221

Log:
More work on the file browser.

Changed paths:
    U   pear2/sandbox/pear2.php.net/trunk/www/css/file-browser.css
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/ReleaseFileBrowser.tpl.php

Modified: pear2/sandbox/pear2.php.net/trunk/www/css/file-browser.css
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/css/file-browser.css	2010-07-12 21:42:02 UTC (rev 301220)
+++ pear2/sandbox/pear2.php.net/trunk/www/css/file-browser.css	2010-07-12 22:18:45 UTC (rev 301221)
@@ -1,6 +1,33 @@
+/**
+ * File Browser Styles
+ *
+ * @package   PEAR2Web
+ * @copyright 2010 PEAR Group
+ * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @author    Michael Gauthier <[email protected]>
+ */
+/* {{{ Package and file title */
+
+.file-title {
+	margin-top: 0;
+}
+
+.file-title .pearbox-header {
+	padding: 4px;
+}
+
+.file-title h2 span {
+	font-size: 12px;
+	display: block;
+}
+
+/* }}} */
+/* {{{ File tree */
+
 .file-list {
-	width: 250px;
-	float: left;
+	font-size: 12px;
+	width: 230px;
+	float: right;
 	margin-top: 0;
 }

@@ -8,15 +35,21 @@
 	margin-left: 0.5em;
 }

+/* }}} */
+/* {{{ File content */
+
 .file-content {
 	font-family: "Consolas", "Monaco", "DejaVu Sans Mono", "Lucida Console", monospace;
 	font-size: 12px;
-	margin: 0 0 0 280px;
-	width: 620px;
+	margin: 0 280px 0 0;
+	width: 630px;
+	position: relative;
+	padding-left: 10px;
 }
+
 .file-content .file-line-numbers {
 	float: left;
-	color: #888;
+	color: #aaa;
 	margin-bottom: 4em;
 }

@@ -27,14 +60,26 @@

 .file-content pre {
 	overflow-x: auto;
+	background: #fafafa;
 }

 .file-content pre code {
 	line-height: 1.231;
 	font-family: "Consolas", "Monaco", "DejaVu Sans Mono", "Lucida Console", monospace;
+	background: #fafafa;
 }

 .file-content .file-end {
 	margin-top: 1em;
-	color: #888;
+	color: #aaa;
 }
+/* }}} */
+/* {{{ File info */
+
+.file-info {
+	font-size: 17px;
+	padding-left: 10px;
+	margin: 0 0 0.25em;
+}
+
+/* }}} */

Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/ReleaseFileBrowser.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/ReleaseFileBrowser.tpl.php	2010-07-12 21:42:02 UTC (rev 301220)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/ReleaseFileBrowser.tpl.php	2010-07-12 22:18:45 UTC (rev 301221)
@@ -1,30 +1,51 @@
 <?php

+if (isset($context->options['packageVersion'])) {
+    $releaseRoot = $context->package->name . '-'
+        . $context->package->version['release'];
+} else {
+    $releaseRoot = $context->package->name;
+}
+
+$releaseURL = PEAR2\SimpleChannelFrontend\Main::getURL()
+    . $releaseRoot;
+
 // Set the page title
 $parent->context->page_title = 'File Content - '
     . PEAR2\SimpleChannelFrontend\Main::$title;

 ?>
-<h2>File</h2>
+<div class="file-title pearbox">
+    <div class="pearbox-header">
+        <h2>
+            <a href="<?php echo $releaseURL; ?>"><?php echo $releaseRoot; ?></a> ›
+            <?php if (isset($context->options['file'])) { ?>
+                <span><?php echo $context->options['file']; ?></span>
+            <?php } ?>
+        </h2>
+    </div>
+</div>
+
 <div class="file-list pearbox">
-<div class="pearbox-header">
-<h3>Files</h3>
-</div>
 <div class="pearbox-content">
 <?php

-if (isset($context->options['packageVersion'])) {
-    $releaseRoot = $context->package->name . '-'
-        . $context->package->version['release'];
-} else {
-    $releaseRoot = $context->package->name;
-}
-
 $releaseFile = $context->package->name . '-'
     . $context->package->version['release'] . '.tgz';

-$traverseFiles = function(\RecursiveIterator $node) use (&$traverseFiles, $context, $releaseFile, $releaseRoot)
-{
+$fileCount      = 0;
+$directoryCount = 0;
+
+$traverseFiles = function(
+    \RecursiveIterator $node
+) use (
+    &$traverseFiles,
+    $context,
+    $releaseFile,
+    $releaseRoot,
+    &$fileCount,
+    &$directoryCount
+) {
     echo '<ul>';
     foreach ($node as $file) {
         echo '<li>';
@@ -32,10 +53,12 @@
         $filename = basename($file);

         if ($node->hasChildren()) {
-            echo $filename;
-            echo '/';
+            $directoryCount++;
+            echo $filename . '/';
             $traverseFiles($node->getChildren());
         } else {
+            $fileCount++;
+
             $filePath = substr(
                 $file,
                 strpos($file, $releaseFile) + strlen($releaseFile) + 1
@@ -60,10 +83,10 @@
 ?>
 </div>
 </div>
-<div class="file-content">
 <?php

 if (isset($context->file)) {
+    echo' <div class="file-content">';
     echo '<div class="file-line-numbers">';
     $count = 0;
     foreach ($context->file as $line) {
@@ -73,9 +96,7 @@
         echo '<div class=' . $class . '>' . $count . '</div>';
     }
     echo '</div>';
-}

-if (isset($context->file)) {
     echo '<pre class="file-lines">';
     echo '<code>';
     $count = 0;
@@ -91,11 +112,19 @@
     }
     echo '</code>';
     echo '</pre>';
+
+    echo '<div class="file-end">EOF</div>';
+    echo '<script>hljs.initHighlightingOnLoad();</script>';
+    echo '</div>';
+} else {
+    echo '<div class="file-info">';
+    printf(
+        '<strong>%s</strong> files in <strong>%s</strong> directories. ',
+        $fileCount,
+        $directoryCount
+    );
+    echo 'Select a file to view its contents.';
+    echo '</div>';
 }
+
 ?>
-
-<div class="file-end">EOF</div>
-
-<script>hljs.initHighlightingOnLoad();</script>
-
-</div>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.