diff --git a/CHANGELOG.md b/CHANGELOG.md index 9304a9f5..c895be4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,9 @@ * adds initial theme support * adds icons from [Evolvere Icon Theme](http://franksouza183.deviantart.com/art/Evolvere-Icon-theme-440718295) * adds PHP variant to calc folder sizes -* adds scroll position reset on location change (issue #279) +* adds scroll position reset on location change (issue [#279](https://github.com/lrsjng/h5ai/issues/279)) * adds "hide if 403" option -* fixes QR code URI origin (issue #287) +* fixes QR code URI origin (issue [#287](https://github.com/lrsjng/h5ai/issues/287)) * adds Google UA support * extends selectable icon sizes (adds 128px, 192px, 256px, 384px) * updates H5BP to 4.3.0 @@ -25,7 +25,7 @@ ## v0.24.1 - *2014-04-09* -* security fixes! (issues #268, #269) +* security fixes! (issues [#268](https://github.com/lrsjng/h5ai/issues/268), [#269](https://github.com/lrsjng/h5ai/issues/269)) * language updates (`fi`, `fr`, `hi`, `it`, `zh-tw`) * fixes WinOS command detection diff --git a/src/_h5ai/client/js/inc/core/resource.js b/src/_h5ai/client/js/inc/core/resource.js index 90b5c35f..562f9c88 100644 --- a/src/_h5ai/client/js/inc/core/resource.js +++ b/src/_h5ai/client/js/inc/core/resource.js @@ -1,5 +1,5 @@ -modulejs.define('core/resource', ['core/settings'], function (settings) { +modulejs.define('core/resource', ['config', 'core/settings'], function (config, settings) { var image = function (id) { @@ -8,8 +8,7 @@ modulejs.define('core/resource', ['core/settings'], function (settings) { icon = function (id) { - return settings.appHref + 'client/themes/faenza/icons/' + id + '.png'; - // return settings.appHref + 'client/themes/evolvere/icons/' + id + '.svg'; + return settings.appHref + 'client/themes/' + config.theme[id]; }; return { diff --git a/src/_h5ai/client/js/scripts.js b/src/_h5ai/client/js/scripts.js index 24fa44dd..0250cdbf 100644 --- a/src/_h5ai/client/js/scripts.js +++ b/src/_h5ai/client/js/scripts.js @@ -46,7 +46,7 @@ $.ajax({ url: url, - data: {action: 'get', setup: true, options: true, types: true, langs: true}, + data: {action: 'get', setup: true, options: true, types: true, theme: true, langs: true}, type: 'POST', dataType: 'json', success: function (config) { diff --git a/src/_h5ai/client/themes/evolvere/icons/default.svg b/src/_h5ai/client/themes/evolvere/icons/file.svg similarity index 100% rename from src/_h5ai/client/themes/evolvere/icons/default.svg rename to src/_h5ai/client/themes/evolvere/icons/file.svg diff --git a/src/_h5ai/client/themes/faenza/icons/blank.png b/src/_h5ai/client/themes/faenza/icons/blank.png deleted file mode 100644 index 3418e3e2..00000000 Binary files a/src/_h5ai/client/themes/faenza/icons/blank.png and /dev/null differ diff --git a/src/_h5ai/client/themes/faenza/icons/default.png b/src/_h5ai/client/themes/faenza/icons/file.png similarity index 100% rename from src/_h5ai/client/themes/faenza/icons/default.png rename to src/_h5ai/client/themes/faenza/icons/file.png diff --git a/src/_h5ai/client/images/fallback/file.png b/src/_h5ai/client/themes/fallback/icons/file.png similarity index 100% rename from src/_h5ai/client/images/fallback/file.png rename to src/_h5ai/client/themes/fallback/icons/file.png diff --git a/src/_h5ai/client/themes/fallback/icons/file.svg b/src/_h5ai/client/themes/fallback/icons/file.svg new file mode 100644 index 00000000..48ea7c04 --- /dev/null +++ b/src/_h5ai/client/themes/fallback/icons/file.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + diff --git a/src/_h5ai/client/images/fallback/folder-page.png b/src/_h5ai/client/themes/fallback/icons/folder-page.png similarity index 100% rename from src/_h5ai/client/images/fallback/folder-page.png rename to src/_h5ai/client/themes/fallback/icons/folder-page.png diff --git a/src/_h5ai/client/themes/fallback/icons/folder-page.svg b/src/_h5ai/client/themes/fallback/icons/folder-page.svg new file mode 100644 index 00000000..7f2e4a06 --- /dev/null +++ b/src/_h5ai/client/themes/fallback/icons/folder-page.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + diff --git a/src/_h5ai/client/images/fallback/parent.png b/src/_h5ai/client/themes/fallback/icons/folder-parent-0.png similarity index 100% rename from src/_h5ai/client/images/fallback/parent.png rename to src/_h5ai/client/themes/fallback/icons/folder-parent-0.png diff --git a/src/_h5ai/client/themes/fallback/icons/folder-parent-0.svg b/src/_h5ai/client/themes/fallback/icons/folder-parent-0.svg new file mode 100644 index 00000000..bbccccd0 --- /dev/null +++ b/src/_h5ai/client/themes/fallback/icons/folder-parent-0.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + diff --git a/src/_h5ai/client/themes/fallback/icons/folder-parent.png b/src/_h5ai/client/themes/fallback/icons/folder-parent.png new file mode 100644 index 00000000..2298b517 Binary files /dev/null and b/src/_h5ai/client/themes/fallback/icons/folder-parent.png differ diff --git a/src/_h5ai/client/themes/fallback/icons/folder-parent.svg b/src/_h5ai/client/themes/fallback/icons/folder-parent.svg new file mode 100644 index 00000000..7ef538dc --- /dev/null +++ b/src/_h5ai/client/themes/fallback/icons/folder-parent.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + diff --git a/src/_h5ai/client/images/fallback/folder.png b/src/_h5ai/client/themes/fallback/icons/folder.png similarity index 100% rename from src/_h5ai/client/images/fallback/folder.png rename to src/_h5ai/client/themes/fallback/icons/folder.png diff --git a/src/_h5ai/client/themes/fallback/icons/folder.svg b/src/_h5ai/client/themes/fallback/icons/folder.svg new file mode 100644 index 00000000..243e2ba0 --- /dev/null +++ b/src/_h5ai/client/themes/fallback/icons/folder.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + diff --git a/src/_h5ai/conf/options.json b/src/_h5ai/conf/options.json index 52e2ea5e..751bdc36 100644 --- a/src/_h5ai/conf/options.json +++ b/src/_h5ai/conf/options.json @@ -42,6 +42,7 @@ Options - smartBrowsing: use History API if available (no need to reload the whole page) - extInNewWindow: open non-h5ai links in new window/tab - hideIf403: hide files and folders that are not readable by the server + - theme: name of one of the folders in "_h5ai/client/themes", defaults to "fallback" */ "view": { "modes": ["details", "grid", "icons"], @@ -54,7 +55,8 @@ Options "ignore": ["^\\.", "^_{{pkg.name}}"], "smartBrowsing": true, "extInNewWindow": false, - "hideIf403": true + "hideIf403": true, + "theme": "fallback" }, diff --git a/src/_h5ai/conf/types.json b/src/_h5ai/conf/types.json index 3fa61997..ccde74f3 100644 --- a/src/_h5ai/conf/types.json +++ b/src/_h5ai/conf/types.json @@ -10,7 +10,6 @@ File types mapped to file extensions "audio": [".aif", ".aiff", ".flac", ".m4a", ".mid", ".mp3", ".mpa", ".ra", ".ogg", ".wav", ".wma"], "authors": ["authors"], "bin": [".class", ".o", ".so"], - "blank": [], "bmp": [".bmp"], "c": [".c"], "calc": [".ods", ".ots", ".xlr", ".xls", ".xlsx"], @@ -19,12 +18,12 @@ File types mapped to file extensions "cpp": [".cpp"], "css": [".css", ".less"], "deb": [".deb"], - "default": [], "diff": [".diff", ".patch"], "doc": [".doc", ".docx", ".odm", ".odt", ".ott"], "draw": [".drw"], "eps": [".eps"], "exe": [".bat", ".cmd", ".exe"], + "file": [], "folder": [], "folder-page": [], "folder-parent": [], diff --git a/src/_h5ai/server/php/inc/class-api.php b/src/_h5ai/server/php/inc/class-api.php index 0a55da6b..2313851f 100644 --- a/src/_h5ai/server/php/inc/class-api.php +++ b/src/_h5ai/server/php/inc/class-api.php @@ -46,6 +46,12 @@ class Api { $response["types"] = $this->app->get_types(); } + if (has_request_param("theme")) { + + use_request_param("theme"); + $response["theme"] = $this->app->get_theme(); + } + if (has_request_param("langs")) { use_request_param("langs"); diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index 0b208153..a67dbef4 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -3,6 +3,7 @@ class App { private static $RE_DELIMITER = "|"; + private static $ICON_EXTS = array("svg", "png", "jpg"); private $options; @@ -34,6 +35,38 @@ class App { } + public function get_icon($theme, $type, $fallback = null) { + + foreach (App::$ICON_EXTS as $ext) { + $icon = "${theme}/icons/${type}.${ext}"; + if (is_file(APP_PATH . "/client/themes/${icon}")) { + return $icon; + } + } + + return $fallback; + } + + + public function get_theme() { + + $theme = $this->options["view"]["theme"]; + $types = $this->get_types(); + + $icons = array(); + foreach (array("file", "folder", "folder-page", "folder-parent") as $type) { + $icons[$type] = $this->get_icon($theme, $type, "default/icons/${type}.svg"); + } + foreach ($types as $type => $exts) { + if (!array_key_exists($type, $icons)) { + $icons[$type] = $this->get_icon($theme, $type, $icons["file"]); + } + } + + return $icons; + } + + public function to_url($path, $trailing_slash = true) { $rel_path = substr($path, strlen(ROOT_PATH)); @@ -179,7 +212,7 @@ class App { if ($folder->get_parent($cache)) { $html .= ""; - $html .= "folder-parent"; + $html .= "folder-parent"; $html .= "Parent Directory"; $html .= ""; $html .= ""; @@ -190,7 +223,7 @@ class App { $type = $item->is_folder ? "folder" : "file"; $html .= ""; - $html .= "" . $type . ""; + $html .= "" . $type . ""; $html .= "" . basename($item->path) . ""; $html .= "" . date("Y-m-d H:i", $item->date) . ""; $html .= "" . ($item->size !== null ? intval($item->size / 1000) . " KB" : "" ) . "";