mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-05 17:24:20 -04:00
More semantic changes.
This commit is contained in:
parent
1dea89befb
commit
32d7aa74e5
14 changed files with 57 additions and 53 deletions
|
@ -62,11 +62,11 @@ class Api {
|
|||
$response["custom"] = $this->app->get_customizations($abs_href);
|
||||
}
|
||||
|
||||
if (array_key_exists("entries", $_REQUEST)) {
|
||||
if (array_key_exists("items", $_REQUEST)) {
|
||||
|
||||
list($abs_href, $what) = use_optional_request_params("entriesHref", "entriesWhat", "entries");
|
||||
list($abs_href, $what) = use_optional_request_params("itemsHref", "itemsWhat", "items");
|
||||
$what = is_numeric($what) ? intval($what, 10) : 1;
|
||||
$response["entries"] = $this->app->get_entries($abs_href, $what);
|
||||
$response["items"] = $this->app->get_items($abs_href, $what);
|
||||
}
|
||||
|
||||
if (count($_REQUEST)) {
|
||||
|
|
|
@ -152,19 +152,19 @@ class App {
|
|||
|
||||
public function get_generic_json() {
|
||||
|
||||
return json_encode(array("entries" => $this->get_entries($this->abs_href, 1))) . "\n";
|
||||
return json_encode(array("items" => $this->get_items($this->abs_href, 1))) . "\n";
|
||||
}
|
||||
|
||||
|
||||
public function get_entries($abs_href, $what) {
|
||||
public function get_items($abs_href, $what) {
|
||||
|
||||
$cache = array();
|
||||
$folder = Entry::get($this, $this->get_abs_path($abs_href), $cache);
|
||||
$folder = Item::get($this, $this->get_abs_path($abs_href), $cache);
|
||||
|
||||
// add content of subfolders
|
||||
if ($what >= 2 && $folder !== null) {
|
||||
foreach ($folder->get_content($cache) as $entry) {
|
||||
$entry->get_content($cache);
|
||||
foreach ($folder->get_content($cache) as $item) {
|
||||
$item->get_content($cache);
|
||||
}
|
||||
$folder = $folder->get_parent($cache);
|
||||
}
|
||||
|
@ -175,10 +175,10 @@ class App {
|
|||
$folder = $folder->get_parent($cache);
|
||||
}
|
||||
|
||||
uasort($cache, array("Entry", "cmp"));
|
||||
uasort($cache, array("Item", "cmp"));
|
||||
$result = array();
|
||||
foreach ($cache as $p => $entry) {
|
||||
$result[] = $entry->to_json_object();
|
||||
foreach ($cache as $p => $item) {
|
||||
$result[] = $item->to_json_object();
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -190,21 +190,21 @@ class App {
|
|||
date_default_timezone_set("UTC");
|
||||
|
||||
$cache = array();
|
||||
$folder = Entry::get($this, $this->abs_path, $cache);
|
||||
$entries = $folder->get_content($cache);
|
||||
uasort($entries, array("Entry", "cmp"));
|
||||
$folder = Item::get($this, $this->abs_path, $cache);
|
||||
$items = $folder->get_content($cache);
|
||||
uasort($items, array("Item", "cmp"));
|
||||
|
||||
$html = "<table>";
|
||||
$html .= "<tr><th></th><th><span>Name</span></th><th><span>Last modified</span></th><th><span>Size</span></th></tr>";
|
||||
if ($folder->get_parent($cache)) {
|
||||
$html .= "<tr><td><img src=\"" . $this->app_abs_href . "client/icons/16x16/folder-parent.png\"/></td><td><a href=\"..\">Parent Directory</a></td><td></td><td></td></tr>";
|
||||
}
|
||||
foreach ($entries as $entry) {
|
||||
foreach ($items as $item) {
|
||||
$html .= "<tr>";
|
||||
$html .= "<td><img src=\"" . $this->app_abs_href . "client/icons/16x16/" . ($entry->is_folder ? "folder" : "default") . ".png\"/></td>";
|
||||
$html .= "<td><a href=\"" . $entry->abs_href . "\">" . basename($entry->abs_path) . "</a></td>";
|
||||
$html .= "<td>" . date("Y-m-d H:i", $entry->date) . "</td>";
|
||||
$html .= "<td>" . ($entry->size !== null ? intval($entry->size / 1000) . " KB" : "" ) . "</td>";
|
||||
$html .= "<td><img src=\"" . $this->app_abs_href . "client/icons/16x16/" . ($item->is_folder ? "folder" : "default") . ".png\"/></td>";
|
||||
$html .= "<td><a href=\"" . $item->abs_href . "\">" . basename($item->abs_path) . "</a></td>";
|
||||
$html .= "<td>" . date("Y-m-d H:i", $item->date) . "</td>";
|
||||
$html .= "<td>" . ($item->size !== null ? intval($item->size / 1000) . " KB" : "" ) . "</td>";
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</table>";
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?php
|
||||
|
||||
class Entry {
|
||||
class Item {
|
||||
|
||||
private static $FOLDER_SIZE_CMD = "du -sb \"[DIR]\"";
|
||||
|
||||
public static function cmp($entry1, $entry2) {
|
||||
public static function cmp($item1, $item2) {
|
||||
|
||||
if ($entry1->is_folder && !$entry2->is_folder) {
|
||||
if ($item1->is_folder && !$item2->is_folder) {
|
||||
return -1;
|
||||
}
|
||||
if (!$entry1->is_folder && $entry2->is_folder) {
|
||||
if (!$item1->is_folder && $item2->is_folder) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return strcasecmp($entry1->abs_path, $entry2->abs_path);
|
||||
return strcasecmp($item1->abs_path, $item2->abs_path);
|
||||
}
|
||||
|
||||
public static function get($app, $abs_path, &$cache) {
|
||||
|
@ -27,12 +27,12 @@ class Entry {
|
|||
return $cache[$abs_path];
|
||||
}
|
||||
|
||||
$entry = new Entry($app, $abs_path);
|
||||
$item = new Item($app, $abs_path);
|
||||
|
||||
if (is_array($cache)) {
|
||||
$cache[$abs_path] = $entry;
|
||||
$cache[$abs_path] = $item;
|
||||
}
|
||||
return $entry;
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Entry {
|
|||
$this->size = null;
|
||||
$options = $app->get_options();
|
||||
if ($options["foldersize"]["enabled"]) {
|
||||
$cmd = str_replace("[DIR]", $this->abs_path, Entry::$FOLDER_SIZE_CMD);
|
||||
$cmd = str_replace("[DIR]", $this->abs_path, Item::$FOLDER_SIZE_CMD);
|
||||
$this->size = intval(preg_replace("/\s.*$/", "", `$cmd`), 10);
|
||||
}
|
||||
} else {
|
||||
|
@ -89,7 +89,7 @@ class Entry {
|
|||
|
||||
$parent_abs_path = normalize_path(dirname($this->abs_path));
|
||||
if (starts_with($parent_abs_path, $this->app->get_root_abs_path())) {
|
||||
return Entry::get($this->app, $parent_abs_path, $cache);
|
||||
return Item::get($this->app, $parent_abs_path, $cache);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ class Entry {
|
|||
|
||||
$files = $this->app->read_dir($this->abs_path);
|
||||
foreach ($files as $file) {
|
||||
$entry = Entry::get($this->app, $this->abs_path . "/" . $file, $cache);
|
||||
$content[$entry->abs_path] = $entry;
|
||||
$item = Item::get($this->app, $this->abs_path . "/" . $file, $cache);
|
||||
$content[$item->abs_path] = $item;
|
||||
}
|
||||
|
||||
$this->is_content_fetched = true;
|
|
@ -17,7 +17,7 @@ function normalized_require_once($lib) {
|
|||
|
||||
normalized_require_once("/server/php/inc/util.php");
|
||||
normalized_require_once("/server/php/inc/App.php");
|
||||
normalized_require_once("/server/php/inc/Entry.php");
|
||||
normalized_require_once("/server/php/inc/Item.php");
|
||||
|
||||
$app = new App(APP_ABS_PATH, APP_ABS_HREF, ABS_HREF);
|
||||
|
||||
|
@ -33,8 +33,12 @@ if (array_key_exists("action", $_REQUEST)) {
|
|||
|
||||
} else {
|
||||
|
||||
header("Content-type: text/html");
|
||||
|
||||
$HREF = $app->get_app_abs_href();
|
||||
$FALLBACK = $app->get_no_js_fallback();
|
||||
|
||||
normalized_require_once("/server/php/inc/page.php");
|
||||
}
|
||||
|
||||
?>
|
42
src/_h5ai/server/php/inc/page.php.jade
Normal file
42
src/_h5ai/server/php/inc/page.php.jade
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
- var href = "<?php global $HREF; echo $HREF; ?>"
|
||||
- var fallback = "<?php global $FALLBACK; echo $FALLBACK; ?>"
|
||||
|
||||
doctype 5
|
||||
//if lt IE 9
|
||||
<html class="no-js oldie" lang="en">
|
||||
//[if gt IE 8]><!
|
||||
html.no-js( lang="en" )
|
||||
//<![endif]
|
||||
|
||||
head
|
||||
meta( charset="utf-8" )
|
||||
meta( http-equiv="X-UA-Compatible", content="IE=edge,chrome=1" )
|
||||
title index · styled with {{pkg.name}} {{pkg.version}} ({{pkg.url}})
|
||||
meta( name="description", content="index styled with {{pkg.name}} {{pkg.version}} ({{pkg.url}})" )
|
||||
meta( name="viewport", content="width=device-width" )
|
||||
link( rel="shortcut icon", href!="#{href}client/images/app-16x16.ico" )
|
||||
link( rel="apple-touch-icon", type="image/png", href!="#{href}client/images/app-48x48.png" )
|
||||
link( rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic|Ubuntu:400,700,400italic,700italic" )
|
||||
link( rel="stylesheet", href!="#{href}client/css/styles.css" )
|
||||
script( src!="#{href}client/js/scripts.js" )
|
||||
|
||||
body
|
||||
|
||||
div#topbar.clearfix
|
||||
ul#navbar
|
||||
|
||||
div#bottombar.clearfix
|
||||
span.left
|
||||
a#h5ai-reference( href="{{pkg.url}}", title="{{pkg.name}} · {{pkg.description}}" )
|
||||
| {{pkg.name}} {{pkg.version}}
|
||||
span.hideOnJs.noJsMsg
|
||||
| ⚡ JavaScript is disabled! ⚡
|
||||
span.oldBrowser
|
||||
| ⚡ Some features disabled! Works best in
|
||||
a( href="http://browsehappy.com" ) modern browsers
|
||||
| . ⚡
|
||||
span.right
|
||||
span.center
|
||||
|
||||
div#no-js-fallback.hideOnJs !{fallback}
|
Loading…
Add table
Add a link
Reference in a new issue