More semantic changes.

This commit is contained in:
Lars Jung 2012-10-27 04:17:28 +02:00
parent 1dea89befb
commit 32d7aa74e5
14 changed files with 57 additions and 53 deletions

View File

@ -74,7 +74,7 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
load = function (callback) {
modulejs.require('core/server').request({action: 'get', entries: true, entriesHref: absHref, entriesWhat: 1}, function (json) {
modulejs.require('core/server').request({action: 'get', items: true, itemsHref: absHref, itemsWhat: 1}, function (json) {
var Item = modulejs.require('model/item'),
item = Item.get(absHref);
@ -83,7 +83,7 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
var found = {};
_.each(json.entries, function (jsonItem) {
_.each(json.items, function (jsonItem) {
var e = Item.get(jsonItem.absHref, jsonItem.time, jsonItem.size, jsonItem.status, jsonItem.content);
found[e.absHref] = true;

View File

@ -41,11 +41,11 @@ modulejs.define('ext/delete', ['_', '$', 'core/settings', 'core/event', 'core/re
server.request({action: 'delete', hrefs: hrefsStr}, handleResponse);
},
onSelection = function (entries) {
onSelection = function (items) {
selectedHrefsStr = '';
if (entries.length) {
selectedHrefsStr = _.map(entries, function (item) {
if (items.length) {
selectedHrefsStr = _.map(items, function (item) {
return item.absHref;
}).join(':');

View File

@ -56,11 +56,11 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
}, handleResponse);
},
onSelection = function (entries) {
onSelection = function (items) {
selectedHrefsStr = '';
if (entries.length) {
selectedHrefsStr = _.map(entries, function (item) {
if (items.length) {
selectedHrefsStr = _.map(items, function (item) {
return item.absHref;
}).join(':');

View File

@ -150,12 +150,12 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
});
},
onEnter = function (entries, idx) {
onEnter = function (items, idx) {
$(window).on('keydown', onKeydown);
$('#pv-img-overlay').stop(true, true).fadeIn(200);
currentEntries = entries;
currentEntries = items;
onIndexChange(idx);
},

View File

@ -211,12 +211,12 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
});
},
onEnter = function (entries, idx) {
onEnter = function (items, idx) {
$(window).on('keydown', onKeydown);
$('#pv-txt-overlay').stop(true, true).fadeIn(200);
currentEntries = entries;
currentEntries = items;
onIndexChange(idx);
},

View File

@ -13,12 +13,12 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], functio
publish = function () {
var entries = _.map($('#items .item.selected'), function (itemElement) {
var items = _.map($('#items .item.selected'), function (itemElement) {
return $(itemElement).data('item');
});
event.pub('selection', entries);
event.pub('selection', items);
},
selectionUpdate = function (event) {

View File

@ -96,10 +96,10 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
if (self.isContentFetched) {
callback(self);
} else {
server.request({action: 'get', entries: true, entriesHref: self.absHref, entriesWhat: 1}, function (response) {
server.request({action: 'get', items: true, itemsHref: self.absHref, itemsWhat: 1}, function (response) {
if (response.entries) {
_.each(response.entries, function (item) {
if (response.items) {
_.each(response.items, function (item) {
getItem(item.absHref, item.time, item.size, item.status, item.content);
});
}

View File

@ -55,7 +55,7 @@ Options
- interval: number, update interval in milliseconds, at least 1000
*/
"autorefresh": {
"enabled": false,
"enabled": true,
"interval": 5000
},

View File

@ -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)) {

View File

@ -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>";

View File

@ -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;

View File

@ -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");
}
?>

View File

@ -1,7 +1,6 @@
|<?php require_once(str_replace("\\", "/", dirname(__FILE__)) . "/inc/init.php"); ?>
- var href = "<?php echo $HREF; ?>"
- var fallback = "<?php echo $FALLBACK; ?>"
- var href = "<?php global $HREF; echo $HREF; ?>"
- var fallback = "<?php global $FALLBACK; echo $FALLBACK; ?>"
doctype 5
//if lt IE 9

View File

@ -0,0 +1 @@
<?php require_once(str_replace("\\", "/", dirname(__FILE__)) . "/inc/init.php"); ?>