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) { 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'), var Item = modulejs.require('model/item'),
item = Item.get(absHref); item = Item.get(absHref);
@ -83,7 +83,7 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
var found = {}; 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); var e = Item.get(jsonItem.absHref, jsonItem.time, jsonItem.size, jsonItem.status, jsonItem.content);
found[e.absHref] = true; 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); server.request({action: 'delete', hrefs: hrefsStr}, handleResponse);
}, },
onSelection = function (entries) { onSelection = function (items) {
selectedHrefsStr = ''; selectedHrefsStr = '';
if (entries.length) { if (items.length) {
selectedHrefsStr = _.map(entries, function (item) { selectedHrefsStr = _.map(items, function (item) {
return item.absHref; return item.absHref;
}).join(':'); }).join(':');

View file

@ -56,11 +56,11 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
}, handleResponse); }, handleResponse);
}, },
onSelection = function (entries) { onSelection = function (items) {
selectedHrefsStr = ''; selectedHrefsStr = '';
if (entries.length) { if (items.length) {
selectedHrefsStr = _.map(entries, function (item) { selectedHrefsStr = _.map(items, function (item) {
return item.absHref; return item.absHref;
}).join(':'); }).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); $(window).on('keydown', onKeydown);
$('#pv-img-overlay').stop(true, true).fadeIn(200); $('#pv-img-overlay').stop(true, true).fadeIn(200);
currentEntries = entries; currentEntries = items;
onIndexChange(idx); 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); $(window).on('keydown', onKeydown);
$('#pv-txt-overlay').stop(true, true).fadeIn(200); $('#pv-txt-overlay').stop(true, true).fadeIn(200);
currentEntries = entries; currentEntries = items;
onIndexChange(idx); onIndexChange(idx);
}, },

View file

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

View file

@ -96,10 +96,10 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
if (self.isContentFetched) { if (self.isContentFetched) {
callback(self); callback(self);
} else { } 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) { if (response.items) {
_.each(response.entries, function (item) { _.each(response.items, function (item) {
getItem(item.absHref, item.time, item.size, item.status, item.content); 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 - interval: number, update interval in milliseconds, at least 1000
*/ */
"autorefresh": { "autorefresh": {
"enabled": false, "enabled": true,
"interval": 5000 "interval": 5000
}, },

View file

@ -62,11 +62,11 @@ class Api {
$response["custom"] = $this->app->get_customizations($abs_href); $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; $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)) { if (count($_REQUEST)) {

View file

@ -152,19 +152,19 @@ class App {
public function get_generic_json() { 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(); $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 // add content of subfolders
if ($what >= 2 && $folder !== null) { if ($what >= 2 && $folder !== null) {
foreach ($folder->get_content($cache) as $entry) { foreach ($folder->get_content($cache) as $item) {
$entry->get_content($cache); $item->get_content($cache);
} }
$folder = $folder->get_parent($cache); $folder = $folder->get_parent($cache);
} }
@ -175,10 +175,10 @@ class App {
$folder = $folder->get_parent($cache); $folder = $folder->get_parent($cache);
} }
uasort($cache, array("Entry", "cmp")); uasort($cache, array("Item", "cmp"));
$result = array(); $result = array();
foreach ($cache as $p => $entry) { foreach ($cache as $p => $item) {
$result[] = $entry->to_json_object(); $result[] = $item->to_json_object();
} }
return $result; return $result;
@ -190,21 +190,21 @@ class App {
date_default_timezone_set("UTC"); date_default_timezone_set("UTC");
$cache = array(); $cache = array();
$folder = Entry::get($this, $this->abs_path, $cache); $folder = Item::get($this, $this->abs_path, $cache);
$entries = $folder->get_content($cache); $items = $folder->get_content($cache);
uasort($entries, array("Entry", "cmp")); uasort($items, array("Item", "cmp"));
$html = "<table>"; $html = "<table>";
$html .= "<tr><th></th><th><span>Name</span></th><th><span>Last modified</span></th><th><span>Size</span></th></tr>"; $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)) { 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>"; $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 .= "<tr>";
$html .= "<td><img src=\"" . $this->app_abs_href . "client/icons/16x16/" . ($entry->is_folder ? "folder" : "default") . ".png\"/></td>"; $html .= "<td><img src=\"" . $this->app_abs_href . "client/icons/16x16/" . ($item->is_folder ? "folder" : "default") . ".png\"/></td>";
$html .= "<td><a href=\"" . $entry->abs_href . "\">" . basename($entry->abs_path) . "</a></td>"; $html .= "<td><a href=\"" . $item->abs_href . "\">" . basename($item->abs_path) . "</a></td>";
$html .= "<td>" . date("Y-m-d H:i", $entry->date) . "</td>"; $html .= "<td>" . date("Y-m-d H:i", $item->date) . "</td>";
$html .= "<td>" . ($entry->size !== null ? intval($entry->size / 1000) . " KB" : "" ) . "</td>"; $html .= "<td>" . ($item->size !== null ? intval($item->size / 1000) . " KB" : "" ) . "</td>";
$html .= "</tr>"; $html .= "</tr>";
} }
$html .= "</table>"; $html .= "</table>";

View file

@ -1,19 +1,19 @@
<?php <?php
class Entry { class Item {
private static $FOLDER_SIZE_CMD = "du -sb \"[DIR]\""; 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; return -1;
} }
if (!$entry1->is_folder && $entry2->is_folder) { if (!$item1->is_folder && $item2->is_folder) {
return 1; 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) { public static function get($app, $abs_path, &$cache) {
@ -27,12 +27,12 @@ class Entry {
return $cache[$abs_path]; return $cache[$abs_path];
} }
$entry = new Entry($app, $abs_path); $item = new Item($app, $abs_path);
if (is_array($cache)) { 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; $this->size = null;
$options = $app->get_options(); $options = $app->get_options();
if ($options["foldersize"]["enabled"]) { 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); $this->size = intval(preg_replace("/\s.*$/", "", `$cmd`), 10);
} }
} else { } else {
@ -89,7 +89,7 @@ class Entry {
$parent_abs_path = normalize_path(dirname($this->abs_path)); $parent_abs_path = normalize_path(dirname($this->abs_path));
if (starts_with($parent_abs_path, $this->app->get_root_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; return null;
} }
@ -105,8 +105,8 @@ class Entry {
$files = $this->app->read_dir($this->abs_path); $files = $this->app->read_dir($this->abs_path);
foreach ($files as $file) { foreach ($files as $file) {
$entry = Entry::get($this->app, $this->abs_path . "/" . $file, $cache); $item = Item::get($this->app, $this->abs_path . "/" . $file, $cache);
$content[$entry->abs_path] = $entry; $content[$item->abs_path] = $item;
} }
$this->is_content_fetched = true; $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/util.php");
normalized_require_once("/server/php/inc/App.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); $app = new App(APP_ABS_PATH, APP_ABS_HREF, ABS_HREF);
@ -33,8 +33,12 @@ if (array_key_exists("action", $_REQUEST)) {
} else { } else {
header("Content-type: text/html");
$HREF = $app->get_app_abs_href(); $HREF = $app->get_app_abs_href();
$FALLBACK = $app->get_no_js_fallback(); $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 href = "<?php global $HREF; echo $HREF; ?>"
- var fallback = "<?php echo $FALLBACK; ?>" - var fallback = "<?php global $FALLBACK; echo $FALLBACK; ?>"
doctype 5 doctype 5
//if lt IE 9 //if lt IE 9

View file

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