From 7e0420073b96b0a3998829a75a70f16a94131749 Mon Sep 17 00:00:00 2001 From: Lars Jung <lrsjng@gmail.com> Date: Sun, 1 Jun 2014 03:48:53 +0200 Subject: [PATCH] Add theme support. --- CHANGELOG.md | 6 +- src/_h5ai/client/js/inc/core/resource.js | 5 +- src/_h5ai/client/js/scripts.js | 2 +- .../evolvere/icons/{default.svg => file.svg} | 0 .../client/themes/faenza/icons/blank.png | Bin 119 -> 0 bytes .../faenza/icons/{default.png => file.png} | Bin .../fallback/icons}/file.png | Bin .../client/themes/fallback/icons/file.svg | 75 +++++++++++++++++ .../fallback/icons}/folder-page.png | Bin .../themes/fallback/icons/folder-page.svg | 75 +++++++++++++++++ .../fallback/icons/folder-parent-0.png} | Bin .../themes/fallback/icons/folder-parent-0.svg | 77 ++++++++++++++++++ .../themes/fallback/icons/folder-parent.png | Bin 0 -> 784 bytes .../themes/fallback/icons/folder-parent.svg | 77 ++++++++++++++++++ .../fallback/icons}/folder.png | Bin .../client/themes/fallback/icons/folder.svg | 75 +++++++++++++++++ src/_h5ai/conf/options.json | 4 +- src/_h5ai/conf/types.json | 3 +- src/_h5ai/server/php/inc/class-api.php | 6 ++ src/_h5ai/server/php/inc/class-app.php | 37 ++++++++- 20 files changed, 430 insertions(+), 12 deletions(-) rename src/_h5ai/client/themes/evolvere/icons/{default.svg => file.svg} (100%) delete mode 100644 src/_h5ai/client/themes/faenza/icons/blank.png rename src/_h5ai/client/themes/faenza/icons/{default.png => file.png} (100%) rename src/_h5ai/client/{images/fallback => themes/fallback/icons}/file.png (100%) create mode 100644 src/_h5ai/client/themes/fallback/icons/file.svg rename src/_h5ai/client/{images/fallback => themes/fallback/icons}/folder-page.png (100%) create mode 100644 src/_h5ai/client/themes/fallback/icons/folder-page.svg rename src/_h5ai/client/{images/fallback/parent.png => themes/fallback/icons/folder-parent-0.png} (100%) create mode 100644 src/_h5ai/client/themes/fallback/icons/folder-parent-0.svg create mode 100644 src/_h5ai/client/themes/fallback/icons/folder-parent.png create mode 100644 src/_h5ai/client/themes/fallback/icons/folder-parent.svg rename src/_h5ai/client/{images/fallback => themes/fallback/icons}/folder.png (100%) create mode 100644 src/_h5ai/client/themes/fallback/icons/folder.svg 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 3418e3e242cfd92f3a7cbd47cad9ca410dd863b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeK3?y%aJ*@^(Ea{HEjtmSN`?>!lvI6<c0X`wF zKzezV?JXe1SQ6wH%;50sMjDVK<muuVVsSb-L4tL0f=Ex(Lrw;k2MmmtzP~F0$})Jm L`njxgN@xNA7*rm6 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg7384" + height="96" + width="96" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="file.svg" + inkscape:export-filename="/home/lars/env/workspace/h5ai/local/file.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1877" + inkscape:window-height="1056" + id="namedview8" + showgrid="true" + inkscape:zoom="7.375" + inkscape:cx="23.67136" + inkscape:cy="43.419032" + inkscape:window-x="43" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg7384" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3002" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="6px" + spacingy="6px" /> + </sodipodi:namedview> + <metadata + id="metadata90"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Gnome Symbolic Icon Theme</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <path + style="fill:#555555;fill-opacity:1;stroke:none" + d="M 12,6 12,90 84,90 84,24 66,6 z m 6,6 45.559322,0 L 78,26.576271 78,84 18,84 z" + id="rect2984" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccccc" /> +</svg> 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg7384" + height="96" + width="96" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="folder-page.svg" + inkscape:export-filename="/home/lars/env/workspace/h5ai/src/_h5ai/client/images/fallback/folder-page.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1877" + inkscape:window-height="1056" + id="namedview8" + showgrid="true" + inkscape:zoom="7.375" + inkscape:cx="37.319242" + inkscape:cy="44.02228" + inkscape:window-x="43" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg7384" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3001" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="6px" + spacingy="6px" /> + </sodipodi:namedview> + <metadata + id="metadata90"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Gnome Symbolic Icon Theme</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <path + style="fill:#555555" + d="m 0,18 0,72 96,0 0,-72 -30,0 -12,-12.0000002 -42,0 z m 12,12 54,0 18,18 0,36 -72,0 z m 66,54 0,-30 -18,0 0,-18 -42,0 0,48" + id="rect3845" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccccccccccccc" /> +</svg> 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg7384" + height="96" + width="96" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="folder-parent.svg" + inkscape:export-filename="/home/lars/folder-16.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1877" + inkscape:window-height="1056" + id="namedview8" + showgrid="true" + inkscape:zoom="7.375" + inkscape:cx="49.162692" + inkscape:cy="47.182237" + inkscape:window-x="43" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg7384" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3002" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="6px" + spacingy="6px" /> + </sodipodi:namedview> + <metadata + id="metadata90"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Gnome Symbolic Icon Theme</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <path + style="fill:#555555" + d="M 12,5.9999998 0,18 0,90 96,90 96,18 66,18 54,5.9999998 z M 48,30 72,54 66,60 54,54 54,72 42,72 42,54 30,60 24,54 z" + id="rect3845" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccccccccccc" + inkscape:export-xdpi="270" + inkscape:export-ydpi="270" /> +</svg> 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 0000000000000000000000000000000000000000..2298b5179d5e6a4e320f97f6d8ac1f4b11a298dd GIT binary patch literal 784 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoEX7WqAsj$Z!;#Vf<Z~8yL>2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4<ivthz5Jr|+3#$mfQsZnib66= za#9)G^YU|36@n{slk#&ilNCIZ^Yau!GE#F>`<7^~W?*1S@^o<wshIQjj&I%}1A(K3 zyVV!BGsw4pu_)AIRG*zU!*|Ixk@G*!wtT<8QDM_P|A)>VA%dDb*V%tDyq9A<Ajlv? zBoUL<aP8KmsOSsNB{X#%vU3F|uI`92R$jt#;p5lBw3ZTv-ygTG;aJH~Cl!CXV*=ZQ z^&hw9aA-2jlZ`*!A|Ur*|KsdP0Vn1?R{N$gD(W0~@gu6FWdcLk<LrrohZrOJ*SorM zus$%|Cnl)K)A0RAlu3&K!{%exl@t#!rU4}#8<-XVc?t&@E<Dc8VBv6>^3hb~P)S3^ z<7|zVl?;K$uM2QoW?0m}{;b;!rU|JvxoS<;4%<F%jpSIz5PAH1n!*mo6#4kiZUu}M zr+&;*Z?Zga@!0h}0zQm=R{NecCa@KJ`DmKWBHU0e8Nb;@f~{ivM^kN<AN)r9OT;Ih zzu0ZFuF%|~-}^Ab>s@+VujzLmw%OHvBK`f}ExEUIza-t>cDL%idUi+D>+8GLoqkd3 z^NvB8<?_Stkxmi4@m&wSFEBK{{_xvPQRle+(I2)C=5qwM-~Z0l^7Y43i#?q7jSRAN z_csg3J)ZvPi{=aVmVm?WfAb#7{uAW2a$bGxpC5e%LKB}}y{JF^^aaN1_g|+zpL_m! z@Y>RqTkq{TrhioOfRf08HA?k@)!iHneGCuq6NmoG6?~~+Z%}5iU?Q6M&8EKb>!W#V SBJKbaCWEJ|pUXO@geCwTggD#) literal 0 HcmV?d00001 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg7384" + height="96" + width="96" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="folder-parent.svg" + inkscape:export-filename="/home/lars/env/workspace/h5ai/src/_h5ai/client/themes/fallback/icons/folder-parent-1.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1877" + inkscape:window-height="1056" + id="namedview8" + showgrid="true" + inkscape:zoom="7.375" + inkscape:cx="33.027099" + inkscape:cy="47.182237" + inkscape:window-x="43" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg7384" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3002" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="6px" + spacingy="6px" /> + </sodipodi:namedview> + <metadata + id="metadata90"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Gnome Symbolic Icon Theme</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <path + style="fill:#555555" + d="M 48,20 80,51.999999 72,60 56,51.999999 56,76 l -15.999999,0 0,-24.000001 L 24,60 16,51.999999 z" + id="rect3845" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccc" + inkscape:export-xdpi="270" + inkscape:export-ydpi="270" /> +</svg> 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg7384" + height="96" + width="96" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="folder.svg.2014_05_17_14_45_14.0.svg" + inkscape:export-filename="/home/lars/env/workspace/web/h5ai/src/_h5ai/client/icons/scalable/folder.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1877" + inkscape:window-height="1056" + id="namedview8" + showgrid="true" + inkscape:zoom="7.375" + inkscape:cx="31.901036" + inkscape:cy="43.419032" + inkscape:window-x="43" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg7384" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3002" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="6px" + spacingy="6px" /> + </sodipodi:namedview> + <metadata + id="metadata90"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Gnome Symbolic Icon Theme</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <path + style="fill:#555555" + d="m 0,18 0,72 96,0 0,-72 -30,0 -12,-12.0000002 -42,0 z" + id="rect3845" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccc" /> +</svg> 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 .= "<tr>"; - $html .= "<td class='fb-i'><img src='" . APP_HREF . "client/images/fallback/parent.png' alt='folder-parent'/></td>"; + $html .= "<td class='fb-i'><img src='" . APP_HREF . "client/themes/fallback/icons/folder-parent.png' alt='folder-parent'/></td>"; $html .= "<td class='fb-n'><a href='..'>Parent Directory</a></td>"; $html .= "<td class='fb-d'></td>"; $html .= "<td class='fb-s'></td>"; @@ -190,7 +223,7 @@ class App { $type = $item->is_folder ? "folder" : "file"; $html .= "<tr>"; - $html .= "<td class='fb-i'><img src='" . APP_HREF . "client/images/fallback/" . $type . ".png' alt='" . $type . "'/></td>"; + $html .= "<td class='fb-i'><img src='" . APP_HREF . "client/themes/fallback/icons/" . $type . ".png' alt='" . $type . "'/></td>"; $html .= "<td class='fb-n'><a href='" . $item->url . "'>" . basename($item->path) . "</a></td>"; $html .= "<td class='fb-d'>" . date("Y-m-d H:i", $item->date) . "</td>"; $html .= "<td class='fb-s'>" . ($item->size !== null ? intval($item->size / 1000) . " KB" : "" ) . "</td>";