1
0
mirror of https://github.com/lrsjng/h5ai.git synced 2025-09-03 19:02:33 +02:00

Compare commits

..

8 Commits

Author SHA1 Message Date
Lars Jung
a8f62f187c Added it translation. Switched to wepp. 2011-09-18 19:49:26 +02:00
Lars Jung
8e21a3c038 Fixed security issues. 2011-09-06 20:57:49 +02:00
Lars Jung
df30c67ade Added selection and zipped download. 2011-09-04 21:18:55 +02:00
Lars Jung
2d3b0eed4f Added selection and zipped download. 2011-09-04 21:18:19 +02:00
Lars Jung
a371ee2afd Minor additions. 2011-09-01 14:27:58 +02:00
Lars Jung
480c4aab79 Added thumbs and slide option. 2011-08-16 21:03:09 +02:00
Lars Jung
745bff09cb Changes in /h5ai/.htaccess 2011-08-12 19:04:14 +02:00
Lars Jung
7d6ced78da Fixes on PHP interpretation and tree display. 2011-08-12 15:58:03 +02:00
49 changed files with 4445 additions and 2999 deletions

View File

@@ -9,6 +9,53 @@ It uses the [Faenza icon set](http://tiheum.deviantart.com/art/Faenza-Icons-1733
## Changelog ## Changelog
### v0.15.2 · *2011-09-18*
* added it translation by [Salvo Gentile](http://github.com/SalvoGentile) and [Marco Patriarca](http://github.com/Fexys)
* switched build process from scripp to wepp
### v0.15.1 · *2011-09-06*
* fixed security issues with the zipped download feature
* made zipped download optional (but enabled by default)
### v0.15 · *2011-09-04*
* added zipped download for selected files
* cleaned and refactored
### v0.14.1 · *2011-09-01*
* display meta information in bottom bar (icon view)
* added zh-cn translation by [Dongsheng Cai](http://github.com/dongsheng)
* added pl translation by Radosław Zając
* added ru translation by Богдан Илюхин
### v0.14 · *2011-08-16*
* added image thumbnails for PHP version
* new option `slideTree` to turn off auto slide in
### v0.13.2 · *2011-08-12*
* changes in `/h5ai/.htaccess` ... PHP configuration ...
### v0.13.1 · *2011-08-12*
* ~~hopefully fixed that PHP doesn't get interpreted~~ :/
* fixed initial tree display
* added sort order option
* added/fixed some translations
* added lv translation by Sandis Veinbergs
### v0.13 · *2011-08-06* ### v0.13 · *2011-08-06*
* added PHP implementation! (should work with PHP 5.2+) * added PHP implementation! (should work with PHP 5.2+)

View File

@@ -1,20 +1,20 @@
custom = true custom = true
# project # project
project.name = h5ai project.name = h5ai
project.version = 0.13 project.version = 0.15.2
# src # src
src.dir = src src.dir = src
# build # build
build.dir = build build.dir = build
release.dir = release release.dir = release
# libs # tools
lib.scripp.jar = tools/scripp.jar wepp = tools/wepp

114
build.xml
View File

@@ -1,81 +1,57 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project <project
name="h5ai" name="h5ai"
basedir="." basedir="."
default="release" default="release"
xmlns:scripp="antlib:de.larsjung.scripp.ant"
> >
<target name="init">
<property file="build.properties" />
<tstamp>
<format property="build.stamp" pattern="yyyy-MM-dd-HHmmss" />
</tstamp>
<property name="build.label" value="${project.name} ${project.version} b${build.stamp}" />
<echo>Build: ${build.label}</echo>
<taskdef
resource="de/larsjung/scripp/ant/antlib.xml"
uri="antlib:de.larsjung.scripp.ant"
classpath="${lib.scripp.jar}"
/>
</target>
<import file="tools/wepp.ant.xml" />
<target name="clean" depends="init"> <target name="init">
<delete dir="${build.dir}" /> <property file="build.properties" />
<delete dir="${release.dir}" /> <tstamp>
</target> <format property="build.stamp" pattern="yyyy-MM-dd-HHmmss" />
</tstamp>
<property name="build.label" value="${project.name} ${project.version} b${build.stamp}" />
<echo>Build: ${build.label}</echo>
</target>
<target name="clean" depends="init">
<delete dir="${build.dir}" />
<delete dir="${release.dir}" />
</target>
<target name="build-prepare" depends="clean"> <target name="build-prepare" depends="clean">
<mkdir dir="${build.dir}" /> <mkdir dir="${build.dir}" />
<copy todir="${build.dir}"> <copy todir="${build.dir}">
<fileset dir="${src.dir}" /> <fileset dir="${src.dir}" />
<fileset file="LICENSE.txt" /> <fileset file="LICENSE.txt" />
<fileset file="README.md" /> <fileset file="README.md" />
</copy> </copy>
<replace dir="${build.dir}"> <replace dir="${build.dir}">
<replacefilter token="%BUILD%" value="${build.label}" /> <replacefilter token="%BUILD%" value="${build.label}" />
<replacefilter token="%BUILD_NAME%" value="${project.name}" /> <replacefilter token="%BUILD_NAME%" value="${project.name}" />
<replacefilter token="%BUILD_VERSION%" value="${project.version}" /> <replacefilter token="%BUILD_VERSION%" value="${project.version}" />
<replacefilter token="%BUILD_STAMP%" value="${build.stamp}" /> <replacefilter token="%BUILD_STAMP%" value="${build.stamp}" />
</replace> </replace>
</target> </target>
<target name="build" depends="build-prepare">
<target name="build" depends="build-prepare"> <wepp.dir dir="${build.dir}/h5ai/css" />
<scripp.dir dir="${build.dir}/h5ai/css" /> <wepp.dir dir="${build.dir}/h5ai/js" />
<scripp.dir dir="${build.dir}/h5ai/js" /> </target>
</target>
<target name="build-uncompressed" depends="build-prepare">
<wepp.dir dir="${build.dir}/h5ai/css" args="--nc" />
<wepp.dir dir="${build.dir}/h5ai/js" args="--nc" />
</target>
<target name="build-uncompressed" depends="build-prepare"> <target name="release" depends="build">
<scripp.dir dir="${build.dir}/h5ai/css" compress="false" /> <mkdir dir="${release.dir}" />
<scripp.dir dir="${build.dir}/h5ai/js" compress="false" /> <zip destfile="${release.dir}/${project.name}-${project.version}.zip" basedir="${build.dir}" />
</target> <tar destfile="${release.dir}/${project.name}-${project.version}.tar" basedir="${build.dir}"/>
<gzip destfile="${release.dir}/${project.name}-${project.version}.tar.gz" src="${release.dir}/${project.name}-${project.version}.tar"/>
<delete file="${release.dir}/${project.name}-${project.version}.tar" />
</target>
<target name="release" depends="build">
<mkdir dir="${release.dir}" />
<zip destfile="${release.dir}/${project.name}-${project.version}.zip" basedir="${build.dir}" />
<tar destfile="${release.dir}/${project.name}-${project.version}.tar" basedir="${build.dir}"/>
<gzip destfile="${release.dir}/${project.name}-${project.version}.tar.gz" src="${release.dir}/${project.name}-${project.version}.tar"/>
<delete file="${release.dir}/${project.name}-${project.version}.tar" />
</target>
<macrodef name="scripp.dir">
<attribute name="dir" />
<attribute name="compress" default="true" />
<sequential>
<scripp:process compress="@{compress}">
<fileset dir="@{dir}" includes="**/*.less,**/*.css,**/*.js" excludes="inc/**/*,**/*.min.css,**/*.min.js" />
<globmapper from="*.less" to="*.css" />
<globmapper from="*.css" to="*.css" />
<globmapper from="*.js" to="*.js" />
</scripp:process>
<delete dir="@{dir}/inc">
<fileset dir="@{dir}" includes="**/*.less" />
</delete>
</sequential>
</macrodef>
</project> </project>

Binary file not shown.

BIN
release/h5ai-0.15.2.tar.gz Normal file

Binary file not shown.

View File

@@ -1,16 +1,35 @@
AddType text/html .php AddType text/html .php
###########################################
# if php doesn't get interpreted try to
# uncomment one of the following lines
###########################################
#AddHandler application/x-httpd-php .php
#AddHandler application/x-httpd-php5 .php
#AddHandler application/x-httpd-php52 .php
#AddHandler application/x-httpd-php53 .php
#AddHandler php-script .php
#AddHandler php5-script .php
#AddHandler php52-script .php
#AddHandler php53-script .php
# cache images, css and js for 52 weeks # cache images, css and js for 52 weeks
<IfModule headers_module> <IfModule headers_module>
<FilesMatch "\.png$"> <FilesMatch "\.png$">
Header set Cache-Control "max-age=31449600, public" Header set Cache-Control "max-age=31449600, public"
</FilesMatch> </FilesMatch>
<FilesMatch "\.css$"> <FilesMatch "\.css$">
Header set Cache-Control "max-age=31449600, public" Header set Cache-Control "max-age=31449600, public"
</FilesMatch> </FilesMatch>
<FilesMatch "\.js$"> <FilesMatch "\.js$">
Header set Cache-Control "max-age=31449600, public" Header set Cache-Control "max-age=31449600, public"
</FilesMatch> </FilesMatch>
<FilesMatch "thumb-.*\.jpg$">
Header set Cache-Control "max-age=31449600, public"
</FilesMatch>
</IfModule> </IfModule>

View File

@@ -1,219 +1,265 @@
#extended.details-view { #extended.details-view {
display: none; display: none;
ul { ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
li { li {
position: relative; position: relative;
white-space: nowrap; white-space: nowrap;
clear: both; clear: both;
&.header { &.header {
a, a:active, a:visited { a, a:active, a:visited {
padding-bottom: 18px; padding-bottom: 18px;
color: #555; color: #555;
text-decoration: none; text-decoration: none;
opacity: 0.4; opacity: 0.4;
cursor: pointer; cursor: pointer;
.transition( all 0.2s ease-in-out ); .transition(all 0.2s ease-in-out);
&:hover {
color: #555;
opacity: 0.9;
}
img {
width: 12px;
height: 12px;
padding: 0 8px;
}
}
}
&.entry {
border-bottom: 1px solid #ddd;
a, a:active, a:visited { &:hover {
display: block; color: #555;
color: #555; opacity: 0.9;
text-decoration: none; }
cursor: pointer; img {
width: 12px;
&:hover, &.hover { height: 12px;
background-color: #f6f6f6; padding: 0 8px;
color: #e80; }
} }
} }
&.error { &.entry {
a, a:active, a:visited {
color: #aaa;
.label {
.hint {
margin-left: 12px;
font-size: 0.9em;
color: #c55;
}
}
&:hover, &.hover {
opacity: 1;
background-color: #f6f6f6;
color: #e80;
}
}
}
&.folder-parent {
.date, .size {
display: none;
}
}
&.folder {
.size {
display: none;
}
}
}
.icon, .label, .date, .size {
padding: 6px;
}
.icon {
display: inline-block;
position: absolute;
left: 0;
top: 2px;
width: 16px;
img { a, a:active, a:visited {
width: 16px; display: block;
height: 16px; color: #555;
} text-decoration: none;
} cursor: pointer;
.icon.big { border-bottom: 1px solid #ddd;
display: none;
} &:hover, &.hover {
.label { background-color: #f6f6f6;
display: block; color: #e80;
margin: 0 270px 0 24px; }
overflow: hidden; &.selected {
white-space: nowrap; border-color: rgba(240,100,0,0.2);
text-align: left; background-color: rgba(240,100,0,0.2);
} }
.date { }
position: absolute; &.error {
right: 100px; a, a:active, a:visited {
top: 0; color: #aaa;
text-align: right;
width: 160px; .label {
white-space: nowrap; .hint {
} margin-left: 12px;
.size { font-size: 0.9em;
position: absolute; color: #c55;
right: 0; }
top: 0; }
text-align: right; &:hover, &.hover {
width: 80px; opacity: 1;
white-space: nowrap; background-color: #f6f6f6;
} color: #e80;
} }
} }
.empty { }
text-align: center; &.folder-parent {
margin: 50px 0; .date, .size {
color: #ddd; display: none;
font-size: 5em; }
font-weight: bold; }
} &.folder {
.size {
display: none;
}
}
}
.icon, .label, .date, .size {
padding: 6px;
}
.icon {
display: inline-block;
position: absolute;
left: 0;
top: 2px;
width: 16px;
img {
width: 16px;
height: 16px;
}
}
.icon.big {
display: none;
}
.label {
display: block;
margin: 0 270px 0 24px;
overflow: hidden;
white-space: nowrap;
text-align: left;
}
.date {
position: absolute;
right: 100px;
top: 0;
text-align: right;
width: 160px;
white-space: nowrap;
}
.size {
position: absolute;
right: 0;
top: 0;
text-align: right;
width: 80px;
white-space: nowrap;
}
&.entry.thumb .icon.small {
overflow: hidden;
padding: 5px;
img {
background-color: #eee;
width: 16px;
height: 16px;
border: 1px solid #ddd;
overflow: hidden;
}
}
}
}
.empty {
text-align: center;
margin: 50px 0;
color: #ddd;
font-size: 5em;
font-weight: bold;
}
}
#selection-rect {
display: none;
position: absolute;
left: 0;
top: 0;
z-index: 2;
border: 1px dashed rgba(240,100,0,0.5);
background-color: rgba(240,100,0,0.2);
} }
#extended.icons-view { #extended.icons-view {
display: none; display: none;
padding: 3px; padding: 3px;
border: 1px solid #eee; border: 1px solid #eee;
border-radius: 15px; border-radius: 15px;
ul { ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
li { li {
&.header { &.header {
display: none; display: none;
} }
&.entry { &.entry {
float: left; float: left;
a, a:active, a:visited { a, a:active, a:visited {
display: block; display: block;
margin: 8px; margin: 8px;
padding: 8px; padding: 8px;
width: 100px; width: 100px;
height: 120px; height: 120px;
float: left; float: left;
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
overflow: hidden; overflow: hidden;
border-radius: 5px; border-radius: 5px;
color: #555; color: #555;
cursor: pointer; cursor: pointer;
border: 2px solid rgba(0,0,0,0); border: 2px solid rgba(0,0,0,0);
&:hover, &.hover {
color: #e80;
border-color: #eee;
background-color: #f6f6f6;
}
.icon {
display: block;
img { &:hover, &.hover {
width: 48px; color: #e80;
height: 48px; border-color: #eee;
margin-bottom: 8px; background-color: #f6f6f6;
} }
} &.selected {
.icon.small { border-color: rgba(240,100,0,0.2);
display: none; background-color: rgba(240,100,0,0.2);
} }
.label { .icon {
display: block; display: block;
word-wrap: break-word;
} img {
.date, .size { min-width: 48px;
display: none; min-height: 48px;
} margin-bottom: 8px;
} }
&.error { }
a, a:active, a:visited { .icon.small {
color: #aaa; display: none;
text-decoration: none; }
.label {
.label { display: block;
.hint { word-wrap: break-word;
padding: 0 6px; }
font-size: 0.9em; .date, .size {
color: #c55; display: none;
} }
} }
&:hover, &.hover { &.error {
color: #e80; a, a:active, a:visited {
border-color: #eee; color: #aaa;
background-color: #f6f6f6; text-decoration: none;
}
} .label {
} .hint {
} padding: 0 6px;
} font-size: 0.9em;
} color: #c55;
.empty { }
padding: 16px; }
height: 120px; &:hover, &.hover {
text-align: center; color: #e80;
color: #ddd; border-color: #eee;
font-size: 5em; background-color: #f6f6f6;
font-weight: bold; }
} }
}
}
&.entry.thumb .icon.big {
width: 100px;
height: 58px;
overflow: hidden;
img {
background-color: #eee;
min-width: 46px;
min-height: 46px;
min-width: 12px;
min-height: 12px;
border: 1px solid #ddd;
overflow: hidden;
}
}
}
}
.empty {
padding: 16px;
height: 120px;
text-align: center;
color: #ddd;
font-size: 5em;
font-weight: bold;
}
} }

View File

@@ -53,8 +53,8 @@ sup { top: -0.5em; }
sub { bottom: -0.25em; } sub { bottom: -0.25em; }
pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; padding: 15px; } pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; padding: 15px; }
textarea { overflow: auto; } textarea { overflow: auto; }
.ie6 legend, .ie7 legend { margin-left: -7px; } .ie6 legend, .ie7 legend { margin-left: -7px; }
input[type="radio"] { vertical-align: text-bottom; } input[type="radio"] { vertical-align: text-bottom; }
input[type="checkbox"] { vertical-align: bottom; } input[type="checkbox"] { vertical-align: bottom; }
.ie7 input[type="checkbox"] { vertical-align: baseline; } .ie7 input[type="checkbox"] { vertical-align: baseline; }
@@ -81,7 +81,7 @@ a:hover { color: #036; }
/** /**
* Primary styles * Primary styles
* *
* Author: * Author:
*/ */
@@ -117,20 +117,20 @@ a:hover { color: #036; }
} }
@media screen and (max-device-width: 480px) { @media screen and (max-device-width: 480px) {
/* html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; } */ /* html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; } */
} }
@media print { @media print {
* { background: transparent !important; color: black !important; text-shadow: none !important; filter:none !important; * { background: transparent !important; color: black !important; text-shadow: none !important; filter:none !important;
-ms-filter: none !important; } -ms-filter: none !important; }
a, a:visited { color: #444 !important; text-decoration: underline; } a, a:visited { color: #444 !important; text-decoration: underline; }
a[href]:after { content: " (" attr(href) ")"; } a[href]:after { content: " (" attr(href) ")"; }
abbr[title]:after { content: " (" attr(title) ")"; } abbr[title]:after { content: " (" attr(title) ")"; }
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
thead { display: table-header-group; } thead { display: table-header-group; }
tr, img { page-break-inside: avoid; } tr, img { page-break-inside: avoid; }
@page { margin: 0.5cm; } @page { margin: 0.5cm; }
p, h2, h3 { orphans: 3; widows: 3; } p, h2, h3 { orphans: 3; widows: 3; }

View File

@@ -4,108 +4,113 @@
html.js { html.js {
.hideOnJs { .hideOnJs {
display: none; display: none;
} }
} }
html.no-js { html.no-js {
.hideOnNoJs { .hideOnNoJs {
display: none; display: none;
} }
} }
body { body {
font-family: Ubuntu, sans-serif; font-family: Ubuntu, sans-serif;
font-size: 16px; font-size: 16px;
color: #555; color: #555;
margin: 80px 30px; margin: 80px 30px;
} }
body > nav { body > nav {
position: fixed; position: fixed;
z-index: 1; z-index: 1;
width: 100%; width: 100%;
left: 0; left: 0;
top: 0; top: 0;
font-size: 0.85em; font-size: 0.85em;
background-color: rgb(241,241,241); background-color: rgb(241,241,241);
border-bottom: 2px solid rgb(210,210,210); border-bottom: 2px solid rgb(210,210,210);
span.jsDisabledFallback { span.jsDisabledFallback {
display: block; display: block;
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
padding: 0 10px; padding: 0 10px;
color: #999; color: #999;
} }
a, a:active, a:visited { a, a:active, a:visited {
color: #555; color: #555;
cursor: pointer; cursor: pointer;
text-decoration: none; text-decoration: none;
opacity: 0.7; opacity: 0.7;
.transition( all 0.2s ease-in-out ); .transition(all 0.2s ease-in-out);
display: block;
height: 30px;
line-height: 30px;
padding: 0 10px;
&:hover, &.hover { display: block;
color: #e80; height: 30px;
background-color: rgba(255,255,255,0.5); line-height: 30px;
opacity: 1.0; padding: 0 10px;
}
} &:hover, &.hover {
.current a { color: #e80;
background-color: rgba(255,255,255,0.5); background-color: rgba(255,255,255,0.5);
opacity: 1.0; opacity: 1.0;
} }
img { }
width: 16px; .current a {
height: 16px; background-color: rgba(255,255,255,0.5);
vertical-align: bottom; opacity: 1.0;
padding: 0 6px 6px 0; }
} img {
.crumb { width: 16px;
float: left; height: 16px;
border-right: 1px solid rgb(231,231,231); vertical-align: bottom;
.hint { padding: 0 6px 6px 0;
margin-left: 8px; }
font-style: italic; .crumb {
color: #999; float: left;
} border-right: 1px solid rgb(231,231,231);
img.hint { .hint {
width: 10px; margin-left: 8px;
height: 10px; font-style: italic;
vertical-align: baseline; color: #999;
padding: 0px; }
} img.hint {
} width: 10px;
.view { height: 10px;
float: right; vertical-align: baseline;
border-left: 1px solid rgb(231,231,231); padding: 0px;
} }
}
.view {
float: right;
border-left: 1px solid rgb(231,231,231);
}
#download {
display: none;
float: right;
border-left: 1px solid rgb(231,231,231);
}
} }
#content { #content {
max-width: 960px; max-width: 960px;
margin: 0 auto; margin: 0 auto;
> header { > header {
display: none; display: none;
padding-bottom: 10px; padding-bottom: 10px;
margin-bottom: 80px; margin-bottom: 80px;
border-bottom: 2px dashed #ddd; border-bottom: 2px dashed #ddd;
} }
> footer { > footer {
display: none; display: none;
padding-top: 10px; padding-top: 10px;
margin-top: 80px; margin-top: 80px;
border-top: 2px dashed #ddd; border-top: 2px dashed #ddd;
} }
} }
@@ -115,80 +120,91 @@ body > nav {
body > footer { body > footer {
position: fixed; position: fixed;
z-index: 1; z-index: 1;
width: 100%; width: 100%;
left: 0; left: 0;
bottom: 0; bottom: 0;
padding: 6px 0 8px 0; padding: 6px 0 8px 0;
background-color: rgb(241,241,241); background-color: rgb(241,241,241);
border-top: 2px solid rgb(210,210,210); border-top: 2px solid rgb(210,210,210);
color: #999;
font-size: 0.85em;
text-align: center;
a, a:active, a:visited { color: #999;
color: #555; font-size: 0.85em;
text-decoration: none; text-align: center;
.transition( all 0.2s ease-in-out );
opacity: 0.7; a, a:active, a:visited {
color: #555;
&:hover { text-decoration: none;
color: #e80; .transition(all 0.2s ease-in-out);
opacity: 1; opacity: 0.7;
}
} &:hover {
.left { color: #e80;
display: block; opacity: 1;
padding: 0 8px; }
float: left }
} .left {
.center { display: block;
display: block; padding: 0 8px;
margin: 0 300px; float: left
} }
.right { .center {
display: block; display: block;
padding: 0 8px; margin: 0 300px;
float: right }
} .right {
#langSelector { display: block;
position: relative; padding: 0 8px;
cursor: pointer; float: right
}
.langOptions { .status {
position: absolute; .sep {
z-index: 2; display: inline-block;
display: none; padding: 0 6px;
right: 0; }
top: 0; &.default {
background-color: rgb(241,241,241); }
border: 1px solid rgb(210,210,210); &.dynamic {
display: none;
ul { }
margin: 0; }
padding: 0; #langSelector {
list-style: none; position: relative;
text-align: left; cursor: pointer;
li { .langOptions {
padding: 8px 24px 10px 24px; position: absolute;
white-space: nowrap; z-index: 2;
border-top: 1px solid rgb(231,231,231); display: none;
.transition( all 0.2s ease-in-out ); right: 0;
top: 0;
&.current { background-color: rgb(241,241,241);
color: #333; border: 1px solid rgb(210,210,210);
background-color: rgba(255,255,255,0.8);
} ul {
&:hover { margin: 0;
color: #e80; padding: 0;
background-color: rgba(255,255,255,0.8); list-style: none;
} text-align: left;
}
} li {
} padding: 8px 24px 10px 24px;
} white-space: nowrap;
border-top: 1px solid rgb(231,231,231);
.transition(all 0.2s ease-in-out);
&.current {
color: #333;
background-color: rgba(255,255,255,0.8);
}
&:hover {
color: #e80;
background-color: rgba(255,255,255,0.8);
}
}
}
}
}
} }

View File

@@ -1,38 +1,38 @@
.border-radius ( @radius ) { .border-radius (@radius) {
-moz-border-radius: @radius; -moz-border-radius: @radius;
-webkit-border-radius: @radius; -webkit-border-radius: @radius;
border-radius: @radius; border-radius: @radius;
} }
.box-shadow ( @shadow ) { .box-shadow (@shadow) {
-moz-box-shadow: @shadow; -moz-box-shadow: @shadow;
-webkit-box-shadow: @shadow; -webkit-box-shadow: @shadow;
box-shadow: @shadow; box-shadow: @shadow;
} }
.transition ( @transition ) { .transition (@transition) {
-moz-transition: @transition; -moz-transition: @transition;
-ms-transition: @transition; -ms-transition: @transition;
-o-transition: @transition; -o-transition: @transition;
-webkit-transition: @transition; -webkit-transition: @transition;
transition: @transition; transition: @transition;
} }
.transform ( @transform ) { .transform (@transform) {
-moz-transform: @transform; -moz-transform: @transform;
-o-transform: @transform; -o-transform: @transform;
-webkit-transform: @transform; -webkit-transform: @transform;
transform: @transform; transform: @transform;
} }
.background-size ( @size ) { .background-size (@size) {
-moz-background-size: @size; -moz-background-size: @size;
-webkit-background-size: @size; -webkit-background-size: @size;
background-size: @size; background-size: @size;
} }

View File

@@ -1,68 +1,68 @@
#table { #table {
table { table {
display: block; display: block;
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
th, td { th, td {
padding: 3px 6px; padding: 3px 6px;
text-align: left; text-align: left;
border: none; border: none;
} }
th { th {
padding-bottom: 18px; padding-bottom: 18px;
opacity: 0.4; opacity: 0.4;
.transition( all 0.2s ease-in-out ); .transition(all 0.2s ease-in-out);
&:hover, &:hover a { &:hover, &:hover a {
color: #555; color: #555;
cursor: pointer; cursor: pointer;
opacity: 0.9; opacity: 0.9;
} }
a, a:visited { a, a:visited {
color: #555; color: #555;
font-weight: normal; font-weight: normal;
img { img {
width: 12px; width: 12px;
height: 12px; height: 12px;
padding: 0 8px; padding: 0 8px;
} }
} }
} }
td { td {
border: 1px solid #ddd; border: 1px solid #ddd;
border-left: none; border-left: none;
border-right: none; border-right: none;
} }
td:nth-child(1), th:nth-child(1) { td:nth-child(1), th:nth-child(1) {
text-align: center; text-align: center;
width: 16px; width: 16px;
img { img {
width: 16px; width: 16px;
height: 16px; height: 16px;
padding-top: 2px; padding-top: 2px;
} }
} }
td:nth-child(2), th:nth-child(2) { td:nth-child(2), th:nth-child(2) {
width: 682px; width: 682px;
max-width: 682px; max-width: 682px;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
} }
td:nth-child(3), th:nth-child(3) { td:nth-child(3), th:nth-child(3) {
text-align: right; text-align: right;
width: 160px; width: 160px;
min-width: 160px; min-width: 160px;
white-space: nowrap; white-space: nowrap;
} }
td:nth-child(4), th:nth-child(4) { td:nth-child(4), th:nth-child(4) {
text-align: right; text-align: right;
width: 70px; width: 70px;
min-width: 70px; min-width: 70px;
white-space: nowrap; white-space: nowrap;
} }
} }
} }

View File

@@ -1,129 +1,129 @@
#tree { #tree {
display: none; display: none;
position: fixed; position: fixed;
left: 0; left: 0;
top: 82px; top: 82px;
z-index: 1; z-index: 1;
overflow: auto; overflow: auto;
font-size: 0.85em; font-size: 0.85em;
padding: 16px 16px 16px 16px; padding: 16px 16px 16px 16px;
background-color: rgb(241,241,241); background-color: rgb(241,241,241);
border: 2px solid rgb(210,210,210); border: 2px solid rgb(210,210,210);
border-left: none; border-left: none;
.border-radius ( 0 15px 15px 0 ); .border-radius (0 15px 15px 0);
> .scrollbar { > .scrollbar {
margin: 12px 12px 12px 0; margin: 12px 12px 12px 0;
width: 6px; width: 6px;
background-color: rgb(210,210,210); background-color: rgb(210,210,210);
.border-radius( 3px ); .border-radius(3px);
.drag {
background-color: rgb(180,180,180);
.border-radius( 3px );
}
&.dragOn .drag {
background-color: rgb(150,150,150);
}
}
.entry {
.blank, .indicator {
display: inline-block;
width: 16px;
height: 25px;
float: left;
}
.indicator {
opacity: 0.7;
.transition( all 0.2s ease-in-out );
cursor: pointer;
&:hover {
opacity: 1;
}
img {
position: relative;
left: 0;
top: 3px;
width: 12px;
height: 12px;
vertical-align: bottom;
.transition( all 0.2s ease-in-out );
}
&.open {
img {
.transform( rotate(90deg) );
}
}
&.unknown {
opacity: 0.3;
}
}
> a, > a:active, > a.visited {
margin-left: 16px;
padding: 4px 6px;
border: 1px solid rgba(0,0,0,0);
.border-radius( 5px );
display: block;
color: #555;
text-decoration: none;
opacity: 0.7;
&:hover, &.hover { .drag {
color: #e80; background-color: rgb(180,180,180);
background-color: rgba(255,255,255,0.5); .border-radius(3px);
opacity: 1; }
} &.dragOn .drag {
.label { background-color: rgb(150,150,150);
display: inline-block; }
} }
.icon {
display: inline-block; .entry {
width: 20px; .blank, .indicator {
img { display: inline-block;
width: 16px; width: 16px;
height: 16px; height: 25px;
vertical-align: bottom; float: left;
} }
} .indicator {
.hint { opacity: 0.7;
display: inline-block; .transition(all 0.2s ease-in-out);
margin-left: 12px; cursor: pointer;
font-size: 0.9em;
color: #ccc; &:hover {
img { opacity: 1;
width: 10px; }
height: 10px; img {
vertical-align: baseline; position: relative;
} left: 0;
} top: 3px;
} width: 12px;
&.file { height: 12px;
display: none; vertical-align: bottom;
} .transition(all 0.2s ease-in-out);
&.current { }
> a, > a:active, > a:visited { &.open {
border: 1px solid rgb(221,221,221); img {
background-color: rgba(255,255,255,0.5); .transform(rotate(90deg));
opacity: 1; }
} }
} &.unknown {
&.error { opacity: 0.3;
> a, > a:active, > a:visited { }
color: #999; }
&:hover, &.hover { > a, > a:active, > a.visited {
color: #e80; margin-left: 16px;
} padding: 4px 6px;
} border: 1px solid rgba(0,0,0,0);
.hint { .border-radius(5px);
color: #c55; display: block;
} color: #555;
} text-decoration: none;
.content { opacity: 0.7;
list-style: none;
margin-left: 20px; &:hover, &.hover {
} color: #e80;
} background-color: rgba(255,255,255,0.5);
opacity: 1;
}
.label {
display: inline-block;
}
.icon {
display: inline-block;
width: 20px;
img {
width: 16px;
height: 16px;
vertical-align: bottom;
}
}
.hint {
display: inline-block;
margin-left: 12px;
font-size: 0.9em;
color: #ccc;
img {
width: 10px;
height: 10px;
vertical-align: baseline;
}
}
}
&.file {
display: none;
}
&.current {
> a, > a:active, > a:visited {
border: 1px solid rgb(221,221,221);
background-color: rgba(255,255,255,0.5);
opacity: 1;
}
}
&.error {
> a, > a:active, > a:visited {
color: #999;
&:hover, &.hover {
color: #e80;
}
}
.hint {
color: #c55;
}
}
.content {
list-style: none;
margin-left: 20px;
}
}
} }

View File

@@ -3,13 +3,15 @@
#table { #table {
display: none; display: none;
} }
#tree, #content > header, #content > footer { #tree, #content > header, #content > footer {
display: block; display: block;
} }
html.no-js { html.no-js {
#extended.details-view, #extended.icons-view { #extended.details-view, #extended.icons-view {
display: block; display: block;
} }
} }

View File

@@ -1,30 +1,34 @@
<!-- generated code ends here --> <!-- generated code ends here -->
</section> </section>
<section id="extended"></section> <section id="extended" class="clearfix"></section>
<footer></footer> <footer></footer>
</section> </section>
<section id="tree"></section> <section id="tree"></section>
<footer class="clearfix"> <footer class="clearfix">
<span class="left"> <span class="left">
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai project page">h5ai %BUILD_VERSION% (js)</a> <a href="http://larsjung.de/h5ai" target="_blank" title="h5ai project page">h5ai %BUILD_VERSION% (js)</a>
</span> </span>
<span class="right"> <span class="right">
<span class="hideOnJs">JavaScript is disabled!</span> <span class="hideOnJs">JavaScript is disabled!</span>
<span id="langSelector"> <span id="langSelector">
<span class="lang">en</span> - <span class="l10n-lang">english</span> <span class="lang">en</span> - <span class="l10n-lang">english</span>
<span class="langOptions"></span> <span class="langOptions"></span>
</span> </span>
</span> </span>
<span class="center"> <span class="center">
<span class="hideOnNoJs"> <span class="hideOnNoJs">
<span class="folderCount"></span> <span class="l10n-folders">folders</span> <span class="status default">
· <span class="folderCount"></span> <span class="l10n-folders">folders</span>
<span class="fileCount"></span> <span class="l10n-files">files</span> <span class='sep'>·</span>
</span> <span class="fileCount"></span> <span class="l10n-files">files</span>
</span> </span>
</footer> <span class="status dynamic">
<script src="/h5ai/js/lib/jquery.min.js"></script> </span>
<script src="/h5ai/options.js"></script> </span>
<script src="/h5ai/js/main-js.js"></script> </span>
</footer>
<script src="/h5ai/js/lib/jquery.min.js"></script>
<script src="/h5ai/options.js"></script>
<script src="/h5ai/js/main-js.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,4 +1,4 @@
<!-- generated code ends here --> <!-- generated code ends here -->
</section> </section>
</body> </body>
</html> </html>

View File

@@ -1,34 +1,38 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="no-js"> <html class="no-js">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Directory index · styled with h5ai</title> <title>Directory index · styled with h5ai</title>
<meta name="h5ai-version" content="h5ai %BUILD_VERSION% (js)"> <meta name="h5ai-version" content="h5ai %BUILD_VERSION% (js)">
<meta name="description" content="Directory index styled with h5ai (http://larsjung.de/h5ai)"> <meta name="description" content="Directory index styled with h5ai (http://larsjung.de/h5ai)">
<meta name="keywords" content="directory, index, autoindex, h5ai"> <meta name="keywords" content="directory, index, autoindex, h5ai">
<link rel="shortcut icon" type="image/png" href="/h5ai/images/h5ai-16x16.png"> <link rel="shortcut icon" type="image/png" href="/h5ai/images/h5ai-16x16.png">
<link rel="apple-touch-icon" type="image/png" href="/h5ai/images/h5ai-48x48.png"> <link rel="apple-touch-icon" type="image/png" href="/h5ai/images/h5ai-48x48.png">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold">
<link rel="stylesheet" type="text/css" href="/h5ai/css/main-js.css"> <link rel="stylesheet" type="text/css" href="/h5ai/css/main-js.css">
<script src="/h5ai/js/lib/modernizr.min.js"></script> <script src="/h5ai/js/lib/modernizr.min.js"></script>
</head> </head>
<body> <body>
<nav class="clearfix"> <div id="selection-rect"></div>
<ul> <nav class="clearfix">
<li id="viewicons" class="view hideOnNoJs"> <ul>
<a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-icons">icons</span></a> <li id="viewicons" class="view hideOnNoJs">
</li> <a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-icons">icons</span></a>
<li id="viewdetails" class="view hideOnNoJs" > </li>
<a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-details">details</span></a> <li id="viewdetails" class="view hideOnNoJs" >
</li> <a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-details">details</span></a>
</ul> </li>
</nav> <li id="download" class="hideOnNoJs">
<section id="content"> <a href="#"><img src="/h5ai/images/download.png" alt="download" /><span class="l10n-download">download</span></a>
<header></header> </li>
<section id="table" class="hideOnJs"> </ul>
<!-- </nav>
The following code was generated by apache's autoindex module. It is not valid HTML 5 for the <section id="content">
reason, that 'align' and 'valign' attributes on the td element are obsolete. Both of them are <header></header>
removed via javascript. The actual page should render as perfect HTML 5, even if the produced <section id="table" class="hideOnJs">
source is not valid HTML 5. <!--
--> The following code was generated by apache's autoindex module. It is not valid HTML 5 for the
reason, that 'align' and 'valign' attributes on the td element are obsolete. Both of them are
removed via javascript. The actual page should render as perfect HTML 5, even if the produced
source is not valid HTML 5.
-->

View File

@@ -2,54 +2,62 @@
<html class="no-js"> <html class="no-js">
<?php include "php/main.php"; ?> <?php include "php/main.php"; ?>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $h5ai->getTitle(); ?></title> <title><?php echo $h5ai->getTitle(); ?></title>
<meta name="h5ai-version" content="h5ai %BUILD_VERSION% (php)"> <meta name="h5ai-version" content="h5ai %BUILD_VERSION% (php)">
<meta name="description" content="Directory index styled with h5ai (http://larsjung.de/h5ai)"> <meta name="description" content="Directory index styled with h5ai (http://larsjung.de/h5ai)">
<meta name="keywords" content="directory, index, autoindex, h5ai"> <meta name="keywords" content="directory, index, autoindex, h5ai">
<link rel="shortcut icon" type="image/png" href="/h5ai/images/h5ai-16x16.png"> <link rel="shortcut icon" type="image/png" href="/h5ai/images/h5ai-16x16.png">
<link rel="apple-touch-icon" type="image/png" href="/h5ai/images/h5ai-48x48.png"> <link rel="apple-touch-icon" type="image/png" href="/h5ai/images/h5ai-48x48.png">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold">
<link rel="stylesheet" type="text/css" href="/h5ai/css/main-php.css"> <link rel="stylesheet" type="text/css" href="/h5ai/css/main-php.css">
<script src="/h5ai/js/lib/modernizr.min.js"></script> <script src="/h5ai/js/lib/modernizr.min.js"></script>
</head> </head>
<body> <body>
<nav class="clearfix"> <div id="selection-rect"></div>
<ul> <nav class="clearfix">
<?php echo $crumb->toHtml(); ?> <ul>
<li id="viewicons" class="view hideOnNoJs"> <?php echo $crumb->toHtml(); ?>
<a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-icons">icons</span></a> <li id="viewicons" class="view hideOnNoJs">
</li> <a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-icons">icons</span></a>
<li id="viewdetails" class="view hideOnNoJs" > </li>
<a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-details">details</span></a> <li id="viewdetails" class="view hideOnNoJs" >
</li> <a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-details">details</span></a>
</ul> </li>
</nav> <li id="download" class="hideOnNoJs">
<?php echo $tree->toHtml(); ?> <a href="#"><img src="/h5ai/images/download.png" alt="download" /><span class="l10n-download">download</span></a>
<section id="content"> </li>
<?php echo $customize->getHeader(); ?> </ul>
<?php echo $extended->toHtml(); ?> </nav>
<?php echo $customize->getFooter(); ?> <?php echo $tree->toHtml(); ?>
</section> <section id="content">
<footer class="clearfix"> <?php echo $customize->getHeader(); ?>
<span class="left"> <?php echo $extended->toHtml(); ?>
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai project page">h5ai %BUILD_VERSION% (php)</a> <?php echo $customize->getFooter(); ?>
</span> </section>
<span class="right"> <footer class="clearfix">
<span class="hideOnJs">JavaScript is disabled!</span> <span class="left">
<span id="langSelector"> <a href="http://larsjung.de/h5ai" target="_blank" title="h5ai project page">h5ai %BUILD_VERSION% (php)</a>
<span class="lang">en</span> - <span class="l10n-lang">english</span> </span>
<span class="langOptions"></span> <span class="right">
</span> <span class="hideOnJs">JavaScript is disabled!</span>
</span> <span id="langSelector">
<span class="center"> <span class="lang">en</span> - <span class="l10n-lang">english</span>
<?php echo $extended->getFolderCount(); ?> <span class="l10n-folders">folders</span> <span class="langOptions"></span>
· </span>
<?php echo $extended->getFileCount(); ?> <span class="l10n-files">files</span> </span>
</span> <span class="center">
</footer> <span class="status default">
<script src="/h5ai/js/lib/jquery.min.js"></script> <?php echo $extended->getFolderCount(); ?> <span class="l10n-folders">folders</span>
<script src="/h5ai/options.js"></script> <span class='sep'>·</span>
<script src="/h5ai/js/main-php.js"></script> <?php echo $extended->getFileCount(); ?> <span class="l10n-files">files</span>
<section id="table"> </span>
<!-- the following code was generated by apache's autoindex module and gets ignored --> <span class="status dynamic">
</span>
</span>
</footer>
<script src="/h5ai/js/lib/jquery.min.js"></script>
<script src="/h5ai/options.js"></script>
<script src="/h5ai/js/main-php.js"></script>
<section id="table">
<!-- the following code was generated by apache's autoindex module and gets ignored -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

View File

@@ -1,155 +1,119 @@
var Extended = function ( pathCache ) { var Extended = function (pathCache, h5ai) {
"use strict";
/*global $*/
var settings = {
customHeader: "h5ai.header.html",
customFooter: "h5ai.footer.html"
},
initTitle = function () {
/******************************* document.title = document.domain + document.location.pathname;
* config try {
*******************************/ document.title = decodeURI(document.title);
} catch (err) {}
},
initBreadcrumb = function () {
this.config = { var idx, part,
defaultSortOrder: "C=N;O=A", $ul = $("body > nav ul"),
customHeader: "h5ai.header.html", pathname = "/",
customFooter: "h5ai.footer.html" path = pathCache.getPath(pathname),
}; pathnameParts = document.location.pathname.split("/");
$ul.append(path.updateCrumbHtml());
/******************************* for (idx in pathnameParts) {
* init part = pathnameParts[idx];
*******************************/ if (part !== "") {
pathname += part + "/";
$ul.append(pathCache.getPath(pathname).updateCrumbHtml());
}
}
},
initExtendedView = function () {
this.init = function () { var $ths = $("#table th"),
$label = $ths.eq(1).find("a"),
$date = $ths.eq(2).find("a"),
$size = $ths.eq(3).find("a"),
sortquery = document.location.search,
order = {
column: (sortquery.indexOf("C=N") >= 0) ? "name" : (sortquery.indexOf("C=M") >= 0) ? "date" : (sortquery.indexOf("C=S") >= 0) ? "size" : h5ai.settings.sortorder.column,
ascending: (sortquery.indexOf("O=A") >= 0) ? true : (sortquery.indexOf("O=D") >= 0) ? false : h5ai.settings.sortorder.ascending
},
$icon, $ul, $li;
try { $ul = $("<ul/>");
document.title = decodeURI( document.domain + document.location.pathname ); $li = $("<li class='header' />")
} catch ( err ) { .appendTo($ul)
document.title = document.domain + document.location.pathname; .append($("<a class='icon'></a>"))
}; .append($("<a class='label' href='" + $label.attr("href") + "'><span class='l10n-name'>" + $label.text() + "</span></a>"))
.append($("<a class='date' href='" + $date.attr("href") + "'><span class='l10n-lastModified'>" + $date.text() + "</span></a>"))
.append($("<a class='size' href='" + $size.attr("href") + "'><span class='l10n-size'>" + $size.text() + "</span></a>"));
this.initBreadcrumb(); // header sort icons
this.initExtendedView(); if (order.ascending) {
this.customize(); $icon = $("<img src='/h5ai/images/ascending.png' class='sort' alt='ascending' />");
this.initCounts(); } else {
}; $icon = $("<img src='/h5ai/images/descending.png' class='sort' alt='descending' />");
}
if (order.column === "date") {
$li.find("a.date").prepend($icon);
} else if (order.column === "size") {
$li.find("a.size").prepend($icon);
} else {
$li.find("a.label").append($icon);
}
// entries
$("#table td").closest("tr").each(function () {
var path = pathCache.getPath(document.location.pathname, this);
$ul.append(path.updateExtendedHtml());
});
$("#extended").append($ul);
/******************************* // empty
* breadcrumb if ($ul.children(".entry:not(.parentfolder)").size() === 0) {
*******************************/ $("#extended").append($("<div class='empty l10n-empty'>empty</div>"));
}
},
customize = function () {
this.initBreadcrumb = function () { $.ajax({
url: settings.customHeader,
dataType: "html",
success: function (data) {
$("#content > header").append($(data)).show();
}
});
var $ul = $( "body > nav ul" ); $.ajax({
url: settings.customFooter,
dataType: "html",
success: function (data) {
$("#content > footer").prepend($(data)).show();
}
});
},
initCounts = function () {
var pathname = "/"; $(".folderCount").text($("#extended .entry.folder:not(.parentfolder)").size());
var path = pathCache.getPathForFolder( pathname ); $(".fileCount").text($("#extended .entry.file").size());
$ul.append( path.updateCrumbHtml() ); },
init = function () {
var pathnameParts = document.location.pathname.split( "/" ); initTitle();
for ( idx in pathnameParts ) { initBreadcrumb();
var part = pathnameParts[idx]; initExtendedView();
if ( part !== "" ) { customize();
pathname += part + "/"; initCounts();
var path = pathCache.getPathForFolder( pathname ); },
$ul.append( path.updateCrumbHtml() ); extended = {
}; init: init
}; };
};
return extended;
/*******************************
* extended view
*******************************/
this.initExtendedView = function () {
var $ul = $( "<ul/>" );
// headers
var $ths = $( "#table th" );
var $label = $ths.eq( 1 ).find( "a" );
var $date = $ths.eq( 2 ).find( "a" );
var $size = $ths.eq( 3 ).find( "a" );
var $li = $( "<li class='header' />" ).appendTo( $ul );
$( "<a class='icon'></a>" ).appendTo( $li );
$( "<a class='label' href='" + $label.attr( "href" ) + "'><span class='l10n-name'>" + $label.text() + "</span></a>" ).appendTo( $li );
$( "<a class='date' href='" + $date.attr( "href" ) + "'><span class='l10n-lastModified'>" + $date.text() + "</span></a>" ).appendTo( $li );
$( "<a class='size' href='" + $size.attr( "href" ) + "'><span class='l10n-size'>" + $size.text() + "</span></a>" ).appendTo( $li );
// header sort icons
var order = document.location.search;
if ( order === "" ) {
order = this.config.defaultSortOrder;
};
var $icon;
if ( order.indexOf( "O=A" ) >= 0 ) {
$icon = $( "<img src='/h5ai/images/ascending.png' class='sort' alt='ascending' />" );
} else {
$icon = $( "<img src='/h5ai/images/descending.png' class='sort' alt='descending' />" );
};
if ( order.indexOf( "C=N" ) >= 0 ) {
$li.find( "a.label" ).append( $icon );
} else if ( order.indexOf( "C=M" ) >= 0 ) {
$li.find( "a.date" ).prepend( $icon );
} else if ( order.indexOf( "C=S" ) >= 0 ) {
$li.find( "a.size" ).prepend( $icon );
};
$.timer.log( "start entries" );
// entries
$( "#table td" ).closest( "tr" ).each( function () {
var path = pathCache.getPathForTableRow( document.location.pathname, this );
$ul.append( path.updateExtendedHtml() );
} );
$.timer.log( "end entries" );
$( "#extended" ).append( $ul );
$.log( document.location.pathname, "folders:", $( "#extended .folder" ).size() , "files:", $( "#extended .file" ).size() );
// empty
if ( $ul.children( ".entry:not(.parentfolder)" ).size() === 0 ) {
$( "#extended" ).append( $( "<div class='empty l10n-empty'>empty</div>" ) );
};
// in case of floats
$( "#extended" ).addClass( "clearfix" );
};
/*******************************
* customize
*******************************/
this.customize = function () {
$.ajax( {
url: this.config.customHeader,
dataType: "html",
success: function ( data ) {
$( "#content > header" ).append( $( data ) ).show();
}
} );
$.ajax( {
url: this.config.customFooter,
dataType: "html",
success: function ( data ) {
$( "#content > footer" ).prepend( $( data ) ).show();
}
} );
};
/*******************************
* init counts
*******************************/
this.initCounts = function () {
$( ".folderCount" ).text( $( "#extended .entry.folder:not(.parentfolder)" ).size() );
$( ".fileCount" ).text( $( "#extended .entry.file" ).size() );
};
}; };

View File

@@ -1,344 +1,395 @@
var H5ai = function ( options, langs ) { var H5ai = function (options, langs) {
"use strict";
/*global $, window, localStorage*/
/*******************************
* config var defaults = {
*******************************/ store: {
viewmode: "h5ai.viewmode",
var defaults = { lang: "h5ai.lang"
store: { },
viewmode: "h5ai.viewmode", callbacks: {
lang: "h5ai.lang" pathClick: []
}, },
callbacks: {
pathClick: [] viewmodes: ["details", "icons"],
}, sortorder: {
column: "name",
viewmodes: [ "details", "icons" ], ascending: true
showTree: true, },
folderStatus: { showTree: true,
}, slideTree: true,
lang: null, folderStatus: {},
useBrowserLang: true, lang: null,
setParentFolderLabels: true, useBrowserLang: true,
linkHoverStates: true setParentFolderLabels: true,
}; linkHoverStates: true,
this.config = $.extend( {}, defaults, options );
dateFormat: "Y-m-d H:i",
ignore: ["h5ai", "h5ai.header.html", "h5ai.footer.html"],
ignoreRE: ["/^\\./"],
/******************************* showThumbs: true,
* public api
*******************************/ zippedDownload: true
},
this.pathClick = function ( fn ) { settings = $.extend({}, defaults, options),
pathClick = function (fn) {
if ( $.isFunction( fn ) ) {
this.config.callbacks.pathClick.push( fn ); if ($.isFunction(fn)) {
}; settings.callbacks.pathClick.push(fn);
return this; }
}; },
triggerPathClick = function (path, context) {
var i, l, a = settings.callbacks.pathClick;
/*******************************
* init for (i = 0, l = a.length; i < l; i++) {
*******************************/ a[i].call(window, path, context);
}
this.init = function () { },
getViewmode = function () {
this.applyViewmode();
this.initTopSpace(); var viewmode = localStorage.getItem(settings.store.viewmode);
this.initViews();
this.initTree(); return $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0];
this.linkHoverStates(); },
this.initLangSelector( langs ); applyViewmode = function (viewmode) {
this.localize( langs, this.config.lang, this.config.useBrowserLang );
this.initIndicators(); if (viewmode) {
}; localStorage.setItem(settings.store.viewmode, viewmode);
}
viewmode = getViewmode();
/******************************* $("#viewdetails,#viewicons").hide().removeClass("current");
* callback triggers
*******************************/ if (settings.viewmodes.length > 1) {
if ($.inArray("details", settings.viewmodes) >= 0) {
this.triggerPathClick = function ( path, context ) { $("#viewdetails").show();
}
for ( idx in this.config.callbacks.pathClick ) { if ($.inArray("icons", settings.viewmodes) >= 0) {
this.config.callbacks.pathClick[idx].call( window, path, context ); $("#viewicons").show();
}; }
}; }
if (viewmode === "details") {
$("#viewdetails").closest("li").addClass("current");
/******************************* $("#extended").addClass("details-view").removeClass("icons-view").show();
* local stored viewmode } else if (viewmode === "icons") {
*******************************/ $("#viewicons").closest("li").addClass("current");
$("#extended").removeClass("details-view").addClass("icons-view").show();
this.getViewmode = function () { } else {
$("#extended").hide();
var viewmode = localStorage.getItem( this.config.store.viewmode ); }
return $.inArray( viewmode, this.config.viewmodes ) >= 0 ? viewmode : this.config.viewmodes[0]; },
}; initTopSpace = function () {
var adjustTopSpace = function () {
this.applyViewmode = function ( viewmode ) {
var winHeight = $(window).height(),
if ( viewmode !== undefined ) { navHeight = $("body > nav").outerHeight(),
localStorage.setItem( this.config.store.viewmode, viewmode ); footerHeight = $("body > footer").outerHeight(),
}; contentSpacing = 50,
viewmode = this.getViewmode(); treeSpacing = 50;
$( "#viewdetails,#viewicons" ).hide().removeClass( "current" ); $("body").css({
"margin-top": navHeight + contentSpacing,
if ( this.config.viewmodes.length > 1 ) { "margin-bottom": footerHeight + contentSpacing
if ( $.inArray( "details", this.config.viewmodes ) >= 0 ) { });
$( "#viewdetails" ).show();
}; $("#tree").css({
if ( $.inArray( "icons", this.config.viewmodes ) >= 0 ) { top: navHeight + treeSpacing,
$( "#viewicons" ).show(); height: winHeight - navHeight - footerHeight - 36 - 2 * treeSpacing
}; });
};
try {
if ( viewmode === "details" ) { $("#tree").get(0).updateScrollbar();
$( "#viewdetails" ).closest( "li" ).addClass( "current" ); } catch (err) {}
$( "#extended" ).addClass( "details-view" ).removeClass( "icons-view" ).show(); };
} else if ( viewmode === "icons" ) {
$( "#viewicons" ).closest( "li" ).addClass( "current" ); $(window).resize(function () {
$( "#extended" ).removeClass( "details-view" ).addClass( "icons-view" ).show(); adjustTopSpace();
} else { });
$( "#extended" ).hide(); adjustTopSpace();
}; },
}; initViews = function () {
$("#table").remove();
/******************************* $("#viewdetails").closest("li")
* top space, depending on nav height .click(function () { applyViewmode("details"); });
*******************************/ $("#viewicons").closest("li")
.click(function () { applyViewmode("icons"); });
this.initTopSpace = function () {
// status update
function adjustTopSpace() { $("#extended .entry a").hover(
function () {
var winHeight = $( window ).height(); if ($("#extended").hasClass("icons-view")) {
var navHeight = $( "body > nav" ).outerHeight(); var $this = $(this);
var footerHeight = $( "body > footer" ).outerHeight(); $(".status.default").hide();
var contentSpacing = 50; $(".status.dynamic")
var treeSpacing = 50; .empty()
.append($this.find(".label").clone())
$( "body" ) .append($("<span class='sep'>·</span>"))
.css( "margin-top", "" + ( navHeight + contentSpacing ) + "px" ) .append($this.find(".date").clone())
.css( "margin-bottom", "" + ( footerHeight + contentSpacing ) + "px" ); .show();
$( "#tree" ) if (!$this.closest(".entry").hasClass("folder")) {
.css( "top", "" + ( navHeight + treeSpacing ) + "px" ) $(".status.dynamic")
.css( "height", "" + ( winHeight - navHeight - footerHeight - 36 - 2 * treeSpacing ) + "px" ); .append($("<span class='sep'>·</span>"))
try { .append($this.find(".size").clone());
$( "#tree" ).get( 0 ).updateScrollbar(); }
} catch ( err ) {}; }
}; },
function () {
$( window ).resize( function () { $(".status.default").show();
adjustTopSpace(); $(".status.dynamic").empty().hide();
} ); }
adjustTopSpace(); );
}; },
shiftTree = function (forceVisible, dontAnimate) {
var $tree = $("#tree"),
/******************************* $extended = $("#extended");
* init views
*******************************/ if (settings.slideTree && $tree.outerWidth() < $extended.offset().left || forceVisible) {
if (dontAnimate) {
this.initViews = function () { $tree.stop().css({ left: 0 });
} else {
$( "#table" ).remove(); $tree.stop().animate({ left: 0 });
}
$( "#viewdetails" ).closest( "li" ) } else {
.click( $.proxy( function () { if (dontAnimate) {
this.applyViewmode( "details" ); $tree.stop().css({ left: 18 - $tree.outerWidth() });
}, this ) ); } else {
$( "#viewicons" ).closest( "li" ) $tree.stop().animate({ left: 18 - $tree.outerWidth() });
.click( $.proxy( function () { }
this.applyViewmode( "icons" ); }
}, this ) ); },
}; initTree = function () {
$("#tree").hover(
function () { shiftTree(true); },
/******************************* function () { shiftTree(); }
* init tree );
*******************************/ $(window).resize(function () { shiftTree(); });
shiftTree(false, true);
this.initTree = function () { },
linkHoverStates = function () {
var $tree = $( "#tree" );
var $extended = $( "#extended" ); if (settings.linkHoverStates) {
var shiftTree = function ( forceVisible, dontAnimate ) { $("a[href^='/']:not(.linkedHoverStates)").each(function () {
if ( $tree.outerWidth() < $extended.offset().left || forceVisible === true ) {
if ( dontAnimate === true ) { var $a = $(this).addClass("linkedHoverStates"),
$tree.stop().css( { left: 0 } ); href = $a.attr("href");
} else {
$tree.stop().animate( { left: 0 } ); $a.hover(
}; function () { $("a[href='" + href + "']").addClass("hover"); },
} else { function () { $("a[href='" + href + "']").removeClass("hover"); }
if ( dontAnimate === true ) { );
$tree.stop().css( { left: 18 - $tree.outerWidth() } ); });
} else { }
$tree.stop().animate( { left: 18 - $tree.outerWidth() } ); },
}; localize = function (langs, lang, useBrowserLang) {
};
}; var storedLang = localStorage.getItem(settings.store.lang),
browserLang, selected, key;
$tree.hover( function () { shiftTree( true ); }, function () { shiftTree(); } );
$( window ).resize( function() { if (langs[storedLang]) {
shiftTree(); lang = storedLang;
} ); } else if (useBrowserLang) {
browserLang = navigator.language;
shiftTree( false, true ); if (langs[browserLang]) {
}; lang = browserLang;
} else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
lang = browserLang.substr(0, 2);
}
/******************************* }
* link hover states
*******************************/ if (!langs[lang]) {
lang = "en";
this.linkHoverStates = function () { }
if ( !this.config.linkHoverStates ) { selected = langs[lang];
return; if (selected) {
}; for (key in selected) {
$(".l10n-" + key).text(selected[key]);
$( "a[href^='/']:not(.linkedHoverStates)" ).each( function () { }
$(".lang").text(lang);
var $a = $( this ).addClass( "linkedHoverStates" ); $(".langOption").removeClass("current");
var href = $a.attr( "href" ); $(".langOption." + lang).addClass("current");
$a.hover( }
function () { },
$( "a[href='" + href + "']" ).addClass( "hover" ); initLangSelector = function (langs) {
},
function () { var idx, lang,
$( "a[href='" + href + "']" ).removeClass( "hover" ); sortedLangsKeys = [],
} $ul;
);
} ); for (lang in langs) {
}; sortedLangsKeys.push(lang);
}
sortedLangsKeys.sort();
/******************************* $ul = $("<ul />");
* localization for (idx in sortedLangsKeys) {
*******************************/ (function (lang) {
$("<li class='langOption' />")
this.initLangSelector = function ( langs ) { .addClass(lang)
.text(lang + " - " + langs[lang].lang)
var sortedLangsKeys = []; .appendTo($ul)
for ( lang in langs ) { .click(function () {
sortedLangsKeys.push( lang ); localStorage.setItem(settings.store.lang, lang);
}; localize(langs, lang, false);
sortedLangsKeys.sort(); });
})(sortedLangsKeys[idx]);
var THIS = this; }
var $ul = $( "<ul />" ); $("#langSelector .langOptions").append($ul);
for ( idx in sortedLangsKeys ) { $("#langSelector").hover(
( function ( lang ) { function () {
$( "<li class='langOption' />" ) var $ele = $(".langOptions");
.addClass( lang ) $ele.css("top", "-" + $ele.outerHeight() + "px").stop(true, true).fadeIn();
.text( lang + " - " + langs[lang]["lang"] ) },
.appendTo( $ul ) function () {
.click( function () { $(".langOptions").stop(true, true).fadeOut();
localStorage.setItem( THIS.config.store.lang, lang ); }
THIS.localize( langs, lang, false ); );
} ); },
} )( sortedLangsKeys[idx] ); initIndicators = function () {
};
$( "#langSelector .langOptions" ) $("#tree .entry.folder:not(.initiatedIndicator)").each(function () {
.append( $ul );
$( "#langSelector" ).hover( var $entry = $(this).addClass("initiatedIndicator"),
function () { $indicator = $entry.find("> .indicator");
var $ele = $( ".langOptions" );
$ele.css( "top", "-" + $ele.outerHeight() + "px" ).stop( true, true ).fadeIn(); $indicator.click(function (event) {
},
function () { var $content;
$( ".langOptions" ).stop( true, true ).fadeOut();
} if ($indicator.hasClass("unknown")) {
); $.get("/h5ai/php/treecontent.php", { "href": $entry.find("> a").attr("href") }, function (html) {
}; $content = $(html);
$indicator.removeClass("unknown");
this.localize = function ( langs, lang, useBrowserLang ) { if ($content.find("> li").size() === 0) {
$indicator.replaceWith($("<span class='blank' />"));
if ( useBrowserLang === true ) { } else {
var browserLang = navigator.language; $indicator.addClass("open");
if ( langs[ browserLang ] !== undefined ) { $entry.find("> .content").replaceWith($content);
lang = browserLang; $("#tree").get(0).updateScrollbar();
} else if ( browserLang.length > 2 && langs[ browserLang.substr( 0, 2 ) ] !== undefined ) { initIndicators();
lang = browserLang.substr( 0, 2 ); }
}; });
}; } else if ($indicator.hasClass("open")) {
$indicator.removeClass("open");
if ( langs[ lang ] === undefined ) { $("#tree").get(0).updateScrollbar(true);
lang = "en"; $entry.find("> .content").slideUp(function () {
}; $("#tree").get(0).updateScrollbar();
});
var storedLang = localStorage.getItem( this.config.store.lang ); } else {
if ( langs[ storedLang ] !== undefined ) { $indicator.addClass("open");
lang = storedLang; $("#tree").get(0).updateScrollbar(true);
}; $entry.find("> .content").slideDown(function () {
$("#tree").get(0).updateScrollbar();
var selected = langs[ lang ]; });
for ( key in selected ) { }
$( ".l10n-" + key ).text( selected[key] ); });
}; });
$( ".lang" ).text( lang ); },
$( ".langOption" ).removeClass( "current" ); initZippedDownload = function () {
$( ".langOption." + lang ).addClass( "current" );
}; var x = 0,
y = 0,
$window = $(window),
selected = function (hrefs) {
/*******************************
* initiate tree indicators var query, idx;
*******************************/ for (idx in hrefs) {
query = query ? query + ":" + hrefs[idx] : hrefs[idx];
this.initIndicators = function () { }
query = "/h5ai/php/zipcontent.php?hrefs=" + query;
var THIS = this; $("#download").show().find("a").attr("href", query);
$( "#tree .entry.folder:not(.initiatedIndicator)" ).each( function () { },
selectionUpdate = function (event) {
var $entry = $( this ).addClass( "initiatedIndicator" );
var $indicator = $entry.find( "> .indicator" ); var l = Math.min(x, event.pageX),
$indicator.click( function( event ) { t = Math.min(y, event.pageY),
if ( $indicator.hasClass( "unknown" ) ) { w = Math.abs(x - event.pageX),
$.get( "/h5ai/php/treecontent.php", { "href": $entry.find( "> a" ).attr( "href" ) }, function ( html ) { h = Math.abs(y - event.pageY),
$content = $( html ); sel;
$indicator.removeClass( "unknown" );
if ( $content.find( "> li" ).size() === 0 ) { event.preventDefault();
$indicator.replaceWith( $( "<span class='blank' />" ) ); $("#selection-rect").css({left: l, top: t, width: w, height: h});
} else {
$indicator.addClass( "open" ); sel = $("#selection-rect").fracs("rect");
$entry.find( "> .content" ).replaceWith( $content ); $("#extended a").removeClass("selected").each(function () {
$( "#tree" ).get( 0 ).updateScrollbar();
THIS.initIndicators(); var $a = $(this),
}; rect = $a.fracs("rect"),
} ); inter = sel.intersection(rect);
} else if ( $indicator.hasClass( "open" ) ) { if (inter && !$a.closest(".entry").hasClass("folder-parent")) {
$indicator.removeClass( "open" ); $a.addClass("selected");
$( "#tree" ).get( 0 ).updateScrollbar( true ); }
$entry.find( "> .content" ).slideUp( function() { });
$( "#tree" ).get( 0 ).updateScrollbar(); },
} ); selectionEnd = function (event) {
} else {
$indicator.addClass( "open" ); event.preventDefault();
$( "#tree" ).get( 0 ).updateScrollbar( true ); $("#selection-rect").hide().css({left: 0, top: 0, width: 0, height: 0});
$entry.find( "> .content" ).slideDown( function() {
$( "#tree" ).get( 0 ).updateScrollbar(); $window.unbind("mousemove", selectionUpdate);
} );
}; var hrefs = [];
} ); $("#extended a.selected").each(function () {
} ); hrefs.push($(this).attr("href"));
}; });
if (hrefs.length > 0) {
selected(hrefs);
}
},
selectionStart = function (event) {
event.preventDefault();
x = event.pageX;
y = event.pageY;
$("#download").hide().find("a").attr("href", "#");
$("#extended a").removeClass("selected");
$("#selection-rect").show().css({left: x, top: y, width: 0, height: 0});
$window
.bind("mousemove", selectionUpdate)
.one("mouseup", selectionEnd);
},
noSelection = function (event) {
event.stopPropagation();
return false;
};
if (settings.zippedDownload) {
$("body>nav,body>footer,#tree,#extended a").bind("mousedown", noSelection);
$("#extended a").live("mousedown", noSelection);
$window.bind("mousedown", selectionStart);
}
},
init = function () {
applyViewmode();
initTopSpace();
initViews();
initTree();
linkHoverStates();
initLangSelector(langs);
localize(langs, settings.lang, settings.useBrowserLang);
initIndicators();
initZippedDownload();
},
h5ai = {
settings: settings,
shiftTree: shiftTree,
linkHoverStates: linkHoverStates,
pathClick: pathClick,
triggerPathClick: triggerPathClick,
init: init
};
return h5ai;
}; };

View File

@@ -0,0 +1,871 @@
/*
* jQuery.fracs 0.10
* http://larsjung.de/fracs
*
* provided under the terms of the MIT License
*/
/*
* ModPlug 0.4
* http://larsjung.de/modplug
*
* provided under the terms of the MIT License
*/
(function ($) {
"use strict";
/*globals jQuery */
/*jslint confusion: true */
var reference = "_mp_api";
$.ModPlug = $.ModPlug || {
plugin: function (namespace, options) {
if (!namespace || $[namespace] || $.fn[namespace]) {
// $.error("No namespace specified, or a plugin already exists on 'jQuery." + namespace + "'");
return !namespace ? 1 : ($[namespace] ? 2 : 3);
}
var defaults = {
statics: {},
methods: {},
defaultStatic: undefined,
defaultMethod: undefined
},
settings = $.extend({}, defaults, options),
staticPlug = function () {
var args, defaultMethod;
args = Array.prototype.slice.call(arguments);
defaultMethod = settings.defaultStatic instanceof Function ? settings.defaultStatic.apply(this, args) : settings.defaultStatic;
if (staticPlug[defaultMethod] instanceof Function) {
return staticPlug[defaultMethod].apply(this, args);
}
$.error("Static method defaulted to '" + defaultMethod + "' does not exist on 'jQuery." + namespace + "'");
},
methods = {},
methodPlug = function (method) {
var args, defaultMethod;
if (methods[method] instanceof Function) {
args = Array.prototype.slice.call(arguments, 1);
return methods[method].apply(this, args);
}
args = Array.prototype.slice.call(arguments);
defaultMethod = settings.defaultMethod instanceof Function ? settings.defaultMethod.apply(this, args) : settings.defaultMethod;
if (methods[defaultMethod] instanceof Function) {
return methods[defaultMethod].apply(this, args);
}
$.error("Method '" + method + "' defaulted to '" + defaultMethod + "' does not exist on 'jQuery." + namespace + "'");
},
api = {
addStatics: function (newStatics) {
$.extend(staticPlug, newStatics);
staticPlug[reference] = api;
return this;
},
addMethods: function (newMethods) {
$.extend(methods, newMethods);
return this;
}
};
api.addStatics(settings.statics).addMethods(settings.methods);
$[namespace] = staticPlug;
$.fn[namespace] = methodPlug;
return 0;
},
module: function (namespace, options) {
if (!$[namespace] || !$[namespace][reference]) {
// $.error("No ModPlug plugin exists on 'jQuery." + namespace + "'");
return !$[namespace] ? 1 : 2;
}
var defaults = {
statics: {},
methods: {}
},
settings = $.extend({}, defaults, options);
$[namespace][reference].addStatics(settings.statics).addMethods(settings.methods);
return 0;
}
};
}(jQuery));
/*
* jQuery.fracs - Core API
*/
(function ($) {
"use strict";
/*globals jQuery, HTMLElement */
/*jslint browser: true, vars: true */
var FracsData = function (htmlElementOrRect) {
var target = htmlElementOrRect,
callbacks = [],
prevFracs;
this.size = function () {
return callbacks.length;
};
this.bind = function (callback) {
if (callback instanceof Function && $.inArray(callback, callbacks) === -1) {
callbacks.push(callback);
}
};
this.unbind = function (callback) {
if (callback instanceof Function) {
var idx = $.inArray(callback, callbacks);
if (idx >= 0) {
callbacks.splice(idx, 1);
}
} else {
callbacks = [];
}
};
this.check = function () {
var rect = target instanceof HTMLElement ? $.fracs.rect(target) : target,
fracs = $.fracs.fracs(rect, $.fracs.viewport());
if (!prevFracs || !prevFracs.equals(fracs)) {
$.each(callbacks, function (idx, callback) {
callback.call(target, fracs, prevFracs);
});
prevFracs = fracs;
}
};
};
var Rect = function (left, top, width, height) {
var fracsData;
this.left = Math.round(left);
this.top = Math.round(top);
this.width = Math.round(width);
this.height = Math.round(height);
this.right = this.left + this.width;
this.bottom = this.top + this.height;
this.equals = function (that) {
return this.left === that.left && this.top === that.top && this.width === that.width && this.height === that.height;
};
this.area = function () {
return this.width * this.height;
};
this.intersection = function (rect) {
var left = Math.max(this.left, rect.left),
right = Math.min(this.right, rect.right),
top = Math.max(this.top, rect.top),
bottom = Math.min(this.bottom, rect.bottom),
width = right - left,
height = bottom - top;
return (width >= 0 && height >= 0) ? new Rect(left, top, width, height) : undefined;
};
this.envelope = function (rect) {
var left = Math.min(this.left, rect.left),
right = Math.max(this.right, rect.right),
top = Math.min(this.top, rect.top),
bottom = Math.max(this.bottom, rect.bottom),
width = right - left,
height = bottom - top;
return new Rect(left, top, width, height);
};
this.bind = function (callback) {
if (!fracsData) {
fracsData = new FracsData(this);
$(window).bind("scroll resize", fracsData.check);
}
fracsData.bind(callback);
};
this.unbind = function (callback) {
if (fracsData) {
fracsData.unbind(callback);
if (fracsData.size() === 0) {
$(window).unbind("scroll resize", fracsData.check);
fracsData = undefined;
}
}
};
this.check = function () {
if (fracsData) {
fracsData.check();
}
};
this.fracs = function () {
$.fracs.fracs(this);
};
};
var FracsResult = function (rectDocument, rectElement, rectViewport, visible, viewport, possible) {
/*jslint confusion: true */
if (!rectDocument || !rectElement || !rectViewport || !visible || !viewport || !possible) {
this.rects = undefined;
this.visible = 0;
this.viewport = 0;
this.possible = 0;
} else {
this.rects = {
document: rectDocument,
element: rectElement,
viewport: rectViewport
};
this.visible = visible;
this.viewport = viewport;
this.possible = possible;
}
this.equals = function (that) {
return this.fracsEqual(that) && this.rectsEqual(that);
};
this.fracsEqual = function (that) {
return this.visible === that.visible && this.viewport === that.viewport && this.possible === that.possible;
};
this.rectsEqual = function (that) {
if (!this.rects || !that.rects) {
return this.rects === that.rects;
}
return this.rects.document.equals(that.rects.document)
&& this.rects.element.equals(that.rects.element)
&& this.rects.viewport.equals(that.rects.viewport);
};
};
var ScrollState = function () {
var document = $.fracs.document(),
viewport = $.fracs.viewport(),
width = document.width - viewport.width,
height = document.height - viewport.height;
this.width = width <= 0 ? undefined : viewport.left / width;
this.height = height <= 0 ? undefined : viewport.top / height;
this.left = viewport.left;
this.top = viewport.top;
this.right = document.right - viewport.right;
this.bottom = document.bottom - viewport.bottom;
this.equals = function (that) {
return this.width === that.width && this.height === that.height
&& this.left === that.left && this.top === that.top
&& this.right === that.right && this.bottom === that.bottom;
};
};
var ScrollStateTracker = function () {
var prevState,
callbacks = [],
check = function () {
var state = new ScrollState();
if (!prevState || !prevState.equals(state)) {
$.each(callbacks, function (idx, callback) {
callback.call(window, state, prevState);
});
prevState = state;
}
};
$(window).bind("resize scroll load", check);
this.bind = function (callback) {
callbacks.push(callback);
};
};
// @beta
var FracsElement = function (htmlElement, fracs) {
this.element = htmlElement;
this.fracs = fracs;
this.update = function () {
var fracs = $.fracs.fracs(this.element),
changed = !this.fracs || !this.fracs.equals(fracs);
this.fracs = fracs;
return changed;
};
};
// @beta
var FracsGroup = function (htmlElements, property, callback) {
var THIS = this,
targets = [],
prevBest = null;
$.each(htmlElements, function (idx, element) {
if (element instanceof HTMLElement) {
targets.push(new FracsElement(element));
}
});
this.check = function () {
var best,
viewport = $.fracs.viewport();
$.each(targets, function (idx, target) {
target.update();
if (!best || target.fracs[property] > best.fracs[property]) {
best = target;
}
});
if (best && best.fracs[property] === 0) {
best = null;
}
if (prevBest !== best) {
callback.call(THIS, best, prevBest);
prevBest = best;
}
};
};
var $document = $(document),
$window = $(window),
$htmlBody = $("html,body"),
scrollStateTracker,
dataNs = "fracs",
statics = {
document: function () {
/*jslint confusion: true */
return new Rect(0, 0, $document.width(), $document.height());
},
viewport: function () {
/*jslint confusion: true */
return new Rect($window.scrollLeft(), $window.scrollTop(), $window.width(), $window.height());
},
rect: function (htmlElement) {
var $target = $(htmlElement),
offset = $target.offset();
if (!$target.is(":visible")) {
return new Rect(0, 0, 0, 0);
}
return new Rect(offset.left, offset.top, $target.outerWidth(), $target.outerHeight());
},
fracs: function (rect, viewport) {
var intersection, intersectionElementSpace, intersectionViewportSpace, intersectionArea, possibleArea;
rect = rect instanceof HTMLElement ? statics.rect(rect) : rect;
viewport = viewport || statics.viewport();
intersection = rect.intersection(viewport);
if (!intersection) {
return new FracsResult();
}
intersectionElementSpace = new Rect(intersection.left - rect.left, intersection.top - rect.top, intersection.width, intersection.height);
intersectionViewportSpace = new Rect(intersection.left - viewport.left, intersection.top - viewport.top, intersection.width, intersection.height);
intersectionArea = intersection.area();
possibleArea = Math.min(rect.width, viewport.width) * Math.min(rect.height, viewport.height);
return new FracsResult(
intersection,
intersectionElementSpace,
intersectionViewportSpace,
intersectionArea / rect.area(),
intersectionArea / viewport.area(),
intersectionArea / possibleArea
);
},
round: function (value, decs) {
if (isNaN(decs) || decs <= 0) {
return Math.round(value);
}
return Math.round(value * Math.pow(10, decs)) / Math.pow(10, decs);
},
scrollTo: function (left, top, duration) {
duration = isNaN(duration) ? 1000 : duration;
$htmlBody.stop(true).animate({ scrollLeft: left, scrollTop: top }, duration);
},
scroll: function (left, top, duration) {
duration = isNaN(duration) ? 1000 : duration;
$htmlBody.stop(true).animate({ scrollLeft: $window.scrollLeft() + left, scrollTop: $window.scrollTop() + top }, duration);
},
scrollState: function (callback) {
if (callback instanceof Function) {
scrollStateTracker = scrollStateTracker || new ScrollStateTracker();
scrollStateTracker.bind(callback);
} else {
return new ScrollState();
}
}
},
methods = {
bind: function (callback) {
return this.each(function () {
var $this = $(this),
data = $this.data(dataNs);
if (!data) {
data = new FracsData(this);
$this.data(dataNs, data);
$window.bind("scroll resize", data.check);
}
data.bind(callback);
});
},
unbind: function (callback) {
return this.each(function () {
var $this = $(this),
data = $this.data(dataNs);
if (data) {
data.unbind(callback);
if (data.size() === 0) {
$this.removeData(dataNs);
$window.unbind("scroll resize", data.check);
}
}
});
},
check: function () {
return this.each(function () {
var data = $(this).data(dataNs);
if (data) {
data.check();
}
});
},
fracs: function () {
return statics.fracs(statics.rect(this.get(0)), statics.viewport());
},
rect: function () {
return statics.rect(this.get(0));
},
max: function (property, callback) {
if (callback instanceof Function) {
var data = new FracsGroup(this, property, callback);
$window.bind("scroll resize", data.check);
data.check();
return this;
} else {
var obj, elements, maxValue;
if ($.inArray(property, [ "possible", "visible", "viewport" ]) >= 0) {
obj = "fracs";
} else if ($.inArray(property, [ "width", "height", "left", "right", "top", "bottom" ]) >= 0) {
obj = "rect";
} else {
return this;
}
this.each(function () {
var fracs = statics[obj](this);
if (!maxValue || fracs[property] > maxValue) {
elements = [ this ];
maxValue = fracs[property];
} else if (fracs[property] === maxValue) {
elements.push(this);
}
});
return $(elements);
}
},
min: function (property) {
var obj, elements, minValue;
if ($.inArray(property, [ "possible", "visible", "viewport" ]) >= 0) {
obj = "fracs";
} else if ($.inArray(property, [ "width", "height", "left", "right", "top", "bottom" ]) >= 0) {
obj = "rect";
} else {
return this;
}
this.each(function () {
var fracs = statics[obj](this);
if (!minValue || fracs[property] < minValue) {
elements = [ this ];
minValue = fracs[property];
} else if (fracs[property] === minValue) {
elements.push(this);
}
});
return $(elements);
},
envelope: function () {
var envelope, rect;
this.each(function () {
rect = statics.rect(this);
envelope = !envelope ? rect : envelope.envelope(rect);
});
return envelope;
},
scrollTo: function (paddingLeft, paddingTop, duration) {
var rect;
paddingLeft = paddingLeft || 0;
paddingTop = paddingTop || 0;
rect = statics.rect(this.get(0));
statics.scrollTo(rect.left - paddingLeft, rect.top - paddingTop, duration);
return this;
},
softLink: function (paddingLeft, paddingTop, duration) {
return this.filter("a[href^=#]").each(function () {
var $a = $(this),
href = $a.attr("href");
$a.click(function () {
$(href).fracs("scrollTo", paddingLeft, paddingTop, duration);
});
});
}
},
defaultStatic = function () {
return "fracs";
},
defaultMethod = function () {
if (arguments.length === 0) {
return "fracs";
} else if (arguments[0] instanceof Function) {
return "bind";
}
};
$.ModPlug.plugin("fracs", {
statics: statics,
methods: methods,
defaultStatic: defaultStatic,
defaultMethod: defaultMethod
});
}(jQuery));
/*
* jQuery.fracs - Outline API
*/
(function ($) {
"use strict";
/*globals jQuery */
/*jslint browser: true, vars: true */
var Outline = function (canvas, options) {
if (!(canvas instanceof HTMLElement && canvas.nodeName.toLowerCase() === "canvas")) {
return undefined;
}
var defaults = {
crop: false,
duration: 0,
focusWidth: 0.5,
focusHeight: 0.5,
autoFocus: true,
styles: [ {
selector: "header,footer,section,article",
fillStyle: "rgb(230,230,230)"
}, {
selector: "h1",
fillStyle: "rgb(240,140,060)"
}, {
selector: "h2",
fillStyle: "rgb(200,100,100)"
}, {
selector: "h3",
fillStyle: "rgb(100,200,100)"
}, {
selector: "h4",
fillStyle: "rgb(100,100,200)"
} ],
viewportStyle: {
fillStyle: "rgba(228,77,38,0.3)"
},
viewportDragStyle: {
fillStyle: "rgba(228,77,38,0.6)"
},
invertViewport: false
},
settings = $.extend({}, defaults, options),
$window = $(window),
$htmlBody = $("html,body"),
$canvas = $(canvas),
width = $canvas.attr("width"),
height = $canvas.attr("height"),
context = canvas.getContext("2d"),
docRect,
vpRect,
scale,
drag = false,
focusWidth,
focusHeight,
scroll = function (event) {
var r, x, y;
r = $canvas.fracs("rect");
x = event.pageX - r.left;
y = event.pageY - r.top;
$.fracs.scrollTo(x / scale - vpRect.width * focusWidth, y / scale - vpRect.height * focusHeight, settings.duration);
},
drawRect = function (context, rect, strokeWidth, strokeStyle, fillStyle, invert) {
if (strokeWidth !== undefined && scale) {
strokeWidth = strokeWidth > 0.2 / scale ? strokeWidth : 0.2 / scale;
}
if (strokeStyle || fillStyle) {
if (invert !== true) {
context.beginPath();
context.rect(rect.left, rect.top, rect.width, rect.height);
if (fillStyle) {
context.fillStyle = fillStyle;
context.fill();
}
if (strokeStyle) {
context.lineWidth = strokeWidth;
context.strokeStyle = strokeStyle;
context.stroke();
}
} else {
if (fillStyle) {
context.beginPath();
context.rect(0, 0, docRect.width, rect.top);
context.rect(0, rect.top, rect.left, rect.height);
context.rect(rect.right, rect.top, docRect.right - rect.right, rect.height);
context.rect(0, rect.bottom, docRect.width, docRect.bottom - rect.bottom);
context.fillStyle = fillStyle;
context.fill();
}
if (strokeStyle) {
context.beginPath();
context.rect(rect.left, rect.top, rect.width, rect.height);
context.lineWidth = strokeWidth;
context.strokeStyle = strokeStyle;
context.stroke();
}
}
}
},
drawElement = function (context, htmlElement, strokeWidth, strokeStyle, fillStyle) {
var $element = $(htmlElement),
rect = $element.fracs("rect");
if ($element.css("visibility") === "hidden") {
return;
}
strokeWidth = strokeWidth === "auto" ? $element.css("border-top-width") : strokeWidth;
strokeStyle = strokeStyle === "auto" ? $element.css("border-top-color") : strokeStyle;
fillStyle = fillStyle === "auto" ? $element.css("background-color") : fillStyle;
drawRect(context, rect, strokeWidth, strokeStyle, fillStyle);
},
drawViewport = function () {
var strokeWidth, strokeStyle, fillStyle;
if (drag && settings.viewportDragStyle) {
strokeWidth = settings.viewportDragStyle.storkeWidth;
strokeStyle = settings.viewportDragStyle.strokeStyle;
fillStyle = settings.viewportDragStyle.fillStyle;
} else {
strokeWidth = settings.viewportStyle.storkeWidth;
strokeStyle = settings.viewportStyle.strokeStyle;
fillStyle = settings.viewportStyle.fillStyle;
}
drawRect(context, vpRect, strokeWidth, strokeStyle, fillStyle, settings.invertViewport);
},
applyStyles = function (context) {
$.each(settings.styles, function (idx, style) {
$(style.selector).each(function () {
drawElement(context, this, style.strokeWidth, style.strokeStyle, style.fillStyle);
});
});
},
draw = function () {
/*jslint confusion: true */
var scaleX, scaleY;
docRect = $.fracs.document();
vpRect = $.fracs.viewport();
scaleX = width / docRect.width;
scaleY = height / docRect.height;
scale = scaleX < scaleY ? scaleX : scaleY;
if (settings.crop) {
$canvas.attr("width", docRect.width * scale).attr("height", docRect.height * scale);
}
context.clearRect(0, 0, $canvas.width(), $canvas.height());
context.scale(scale, scale);
applyStyles(context);
drawViewport();
context.scale(1 / scale, 1 / scale);
},
init = function () {
$canvas
.css("cursor", "pointer")
.mousedown(function (event) {
var r;
event.preventDefault();
drag = true;
if (settings.autoFocus) {
r = $canvas.fracs("rect");
focusWidth = (((event.pageX - r.left) / scale) - vpRect.left) / vpRect.width;
focusHeight = (((event.pageY - r.top) / scale) - vpRect.top) / vpRect.height;
}
if (!settings.autoFocus || focusWidth < 0 || focusWidth > 1 || focusHeight < 0 || focusHeight > 1) {
focusWidth = settings.focusWidth;
focusHeight = settings.focusHeight;
}
scroll(event);
$canvas.css("cursor", "crosshair").addClass("dragOn");
$htmlBody.css("cursor", "crosshair");
$window
.bind("mousemove", scroll)
.one("mouseup", function (event) {
event.preventDefault();
$canvas.css("cursor", "pointer").removeClass("dragOn");
$htmlBody.css("cursor", "auto");
$window.unbind("mousemove", scroll);
drag = false;
draw();
});
});
canvas.onselectstart = function () {
return false;
};
$window.bind("load resize scroll", draw);
draw();
};
init();
this.draw = draw;
};
var dataNs = "outline",
methods = {
outline: function (options) {
return this.each(function () {
var outline;
if (options === "redraw") {
outline = $(this).data(dataNs);
if (outline) {
outline.draw();
}
} else {
outline = new Outline(this, options);
if (outline) {
$(this).data(dataNs, outline);
}
}
});
}
};
$.ModPlug.module("fracs", {
methods: methods
});
}(jQuery));

View File

@@ -1,31 +0,0 @@
// v2.2
(function($){$.toJSON=function(o)
{if(typeof(JSON)=='object'&&JSON.stringify)
return JSON.stringify(o);var type=typeof(o);if(o===null)
return"null";if(type=="undefined")
return undefined;if(type=="number"||type=="boolean")
return o+"";if(type=="string")
return $.quoteString(o);if(type=='object')
{if(typeof o.toJSON=="function")
return $.toJSON(o.toJSON());if(o.constructor===Date)
{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array)
{var ret=[];for(var i=0;i<o.length;i++)
ret.push($.toJSON(o[i])||"null");return"["+ret.join(",")+"]";}
var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number")
name='"'+k+'"';else if(type=="string")
name=$.quoteString(k);else
continue;if(typeof o[k]=="function")
continue;var val=$.toJSON(o[k]);pairs.push(name+":"+val);}
return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);return eval("("+src+")");};$.secureEvalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
return eval("("+src+")");else
throw new SyntaxError("Error parsing JSON, source is not valid.");};$.quoteString=function(string)
{if(string.match(_escapeable))
{return'"'+string.replace(_escapeable,function(a)
{var c=_meta[a];if(typeof c==='string')return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};})(jQuery);

View File

@@ -1,133 +1,147 @@
( function ( $ ) { (function ($) {
var init = function ( htmlElement ) { var init = function (htmlElement) {
var $element = $( htmlElement ); var $element = $(htmlElement),
$scrollbar, $drag, $wrapper, $content, mouseOffsetY, updateId,
if ( $element.css( "position" ) === undefined || $element.css( "position" ) === "static" ) { update, scroll;
$element.css( "position", "relative" );
};
var $scrollbar = $( "<div class='scrollbar' />" ); if (!$element.css("position") || $element.css("position") === "static") {
var $drag = $( "<div class='drag' />" ).appendTo( $scrollbar ); $element.css("position", "relative");
$element }
.wrapInner( "<div class='wrapper'><div class='content' /></div>" )
.append( $scrollbar );
var $wrapper = $element.find( "> .wrapper" );
var $content = $wrapper.find( "> .content" );
var mouseOffsetY = 0;
var updateId = undefined;
var update = function ( repeat ) { $scrollbar = $("<div class='scrollbar' />");
if ( updateId !== undefined && !repeat ) { $drag = $("<div class='drag' />").appendTo($scrollbar);
clearInterval( updateId ); $element
updateId = undefined; .wrapInner("<div class='wrapper'><div class='content' /></div>")
} else if ( updateId === undefined && repeat ) { .append($scrollbar);
updateId = setInterval( function() { update( true ); }, 50 ); $wrapper = $element.find("> .wrapper");
}; $content = $wrapper.find("> .content");
mouseOffsetY = 0;
$wrapper.css( "height", $element.height() ); update = function (repeat) {
var visibleHeight = $element.height();
var contentHeight = $content.outerHeight();
var scrollTop = $wrapper.scrollTop();
var scrollTopFrac = scrollTop / contentHeight;
var visVertFrac = Math.min( visibleHeight / contentHeight, 1 );
if ( visVertFrac < 1 ) {
$scrollbar
.fadeIn( 50 )
.css( {
height: $element.innerHeight() + $scrollbar.height() - $scrollbar.outerHeight( true )
} );
$drag
.css( {
top: $scrollbar.height() * scrollTopFrac,
height: $scrollbar.height() * visVertFrac
} );
} else {
$scrollbar.fadeOut( 50 );
};
};
var scroll = function ( event ) {
var clickFrac = ( event.pageY - $scrollbar.offset().top - mouseOffsetY ) / $scrollbar.height();
$wrapper.scrollTop( $content.outerHeight() * clickFrac );
update();
};
$element var visibleHeight, contentHeight, scrollTop, scrollTopFrac, visVertFrac;
.mousewheel( function ( event, delta) {
$wrapper.scrollTop( $wrapper.scrollTop() - 50 * delta );
update();
event.stopPropagation();
event.preventDefault();
} )
.scroll( update );
$element.get( 0 ).updateScrollbar = update;
$wrapper
.css( {
"padding-right": $scrollbar.outerWidth( true ),
height: $element.height(),
overflow: "hidden"
} );
$scrollbar
.css( {
position: "absolute",
top: 0,
right: 0,
overflow: "hidden"
} )
.mousedown( function ( event ) {
mouseOffsetY = $drag.outerHeight() / 2;
scroll( event );
$scrollbar.addClass( "dragOn" );
$( window )
.bind( "mousemove", scroll )
.one( "mouseup", function ( event ) {
$scrollbar.removeClass( "dragOn" );
$( window ).unbind( "mousemove", scroll );
scroll( event );
event.stopPropagation();
} );
event.stopPropagation();
} )
.attr( "unselectable", "on" )
.css( "-moz-user-select", "none" )
.each( function () {
this.onselectstart = function () {
return false;
};
} );
$drag
.css( {
position: "absolute",
left: 0,
width: "100%"
} )
.mousedown( function ( event ) {
mouseOffsetY = event.pageY - $drag.offset().top;
scroll( event );
$scrollbar.addClass( "dragOn" );
$( window )
.bind( "mousemove", scroll )
.one( "mouseup", function ( event ) {
$scrollbar.removeClass( "dragOn" );
$( window ).unbind( "mousemove", scroll );
scroll( event );
event.stopPropagation();
} );
event.stopPropagation();
} );
update(); if (updateId && !repeat) {
}; clearInterval(updateId);
updateId = undefined;
} else if (!updateId && repeat) {
updateId = setInterval(function() { update(true); }, 50);
}
$wrapper.css("height", $element.height());
$.fn.scrollpanel = function () { visibleHeight = $element.height();
contentHeight = $content.outerHeight();
return this.each( function () { scrollTop = $wrapper.scrollTop();
scrollTopFrac = scrollTop / contentHeight;
visVertFrac = Math.min(visibleHeight / contentHeight, 1);
init( this ); if (visVertFrac < 1) {
} ); $scrollbar
}; .fadeIn(50)
.css({
height: $element.innerHeight() + $scrollbar.height() - $scrollbar.outerHeight(true)
});
$drag
.css({
top: $scrollbar.height() * scrollTopFrac,
height: $scrollbar.height() * visVertFrac
});
} else {
$scrollbar.fadeOut(50);
}
};
} )( jQuery ); scroll = function (event) {
var clickFrac = (event.pageY - $scrollbar.offset().top - mouseOffsetY) / $scrollbar.height();
$wrapper.scrollTop($content.outerHeight() * clickFrac);
update();
event.preventDefault();
};
$element
.mousewheel(function (event, delta) {
$wrapper.scrollTop($wrapper.scrollTop() - 50 * delta);
update();
event.stopPropagation();
event.preventDefault();
})
.scroll(update);
$element.get(0).updateScrollbar = update;
$wrapper
.css({
"padding-right": $scrollbar.outerWidth(true),
height: $element.height(),
overflow: "hidden"
});
$scrollbar
.css({
position: "absolute",
top: 0,
right: 0,
overflow: "hidden",
cursor: "pointer"
})
.mousedown(function (event) {
mouseOffsetY = $drag.outerHeight() / 2;
scroll(event);
$scrollbar.addClass("dragOn");
$(window)
.bind("mousemove", scroll)
.one("mouseup", function (event) {
$scrollbar.removeClass("dragOn");
$(window).unbind("mousemove", scroll);
scroll(event);
event.stopPropagation();
});
event.preventDefault();
})
.each(function () {
this.onselectstart = function () {
return false;
};
});
$drag
.css({
position: "absolute",
left: 0,
width: "100%"
})
.mousedown(function (event) {
mouseOffsetY = event.pageY - $drag.offset().top;
scroll(event);
$scrollbar.addClass("dragOn");
$(window)
.bind("mousemove", scroll)
.one("mouseup", function (event) {
$scrollbar.removeClass("dragOn");
$(window).unbind("mousemove", scroll);
scroll(event);
event.stopPropagation();
});
event.stopPropagation();
});
update();
};
$.fn.scrollpanel = function () {
return this.each(function () {
init(this);
});
};
})(jQuery);

View File

@@ -1,24 +1,29 @@
( function( $ ) { (function ($) {
"use strict";
/*global jQuery, window*/
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ // http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
// modified // modified
$.log = function () { $.log = function () {
$.log.history = $.log.history || []; $.log.history = $.log.history || [];
$.log.history.push( arguments ); $.log.history.push(arguments);
if ( window.console ) { if (window.console) {
window.console.log( Array.prototype.slice.call( arguments ) ); window.console.log(Array.prototype.slice.call(arguments));
}; }
}; };
var Timer = function () { $.timer = (function () {
this.start = new Date().getTime();; var start = $.now(),
this.last = this.start; last = start,
this.log = function ( label ) { timer = {
var now = new Date().getTime(); log: function (label) {
$.log( "timer", label, "+" + (now - this.last), "=" + (now - this.start) ); var now = $.now();
this.last = now; $.log("timer", label, "+" + (now - last), "=" + (now - start));
}; last = now;
}; }
$.timer = new Timer(); };
} )( jQuery ); return timer;
}());
})(jQuery);

View File

@@ -1,465 +1,404 @@
var pathnameSplitRegEx = /^(\/(.*\/)*)([^\/]+\/?)$/; var Path = function (pathCache, folder, tableRow) {
var pathEndsWithSlashRegEx = /\/$/; "use strict";
/*global $, h5ai, tree*/
var path,
checkedDecodeUri = function (uri) {
try { return decodeURI(uri); } catch (err) {}
return uri;
},
isEmpty = function () {
return path.content === undefined || $.isEmptyObject(path.content);
},
onClick = function (context) {
h5ai.triggerPathClick(path, context);
},
updateHtml = function () {
path.updateCrumbHtml();
path.updateExtendedHtml();
path.updateTreeHtml();
},
updateCrumbHtml = function () {
var $html, $a;
if (path.html.$crumb && path.html.$crumb.data("status") === path.status) {
return path.html.$crumb;
}
$html = $("<li class='crumb' />")
.data("path", path)
.addClass(path.isFolder ? "folder" : "file");
if (path.status) {
$html.data("status", path.status);
}
$a = $("<a><img src='/h5ai/images/crumb.png' alt='>' />" + path.label + "</a>")
.appendTo($html)
.attr("href", path.absHref)
.click(function() { onClick("crumb"); });
if (path.isDomain) {
$html.addClass("domain");
$a.find("img").attr("src", "/h5ai/images/home.png");
}
if (path.isCurrentFolder) {
$html.addClass("current");
}
if (!isNaN(path.status)) {
if (path.status === 200) {
$("<img class='hint' src='/h5ai/images/page.png' alt='not listable' />").appendTo($a);
} else {
$("<span class='hint'>(" + path.status + ")</span>").appendTo($a);
}
}
if (path.html.$crumb) {
path.html.$cpathreplaceWith($html);
}
path.html.$crumb = $html;
return $html;
},
updateExtendedHtml = function () {
var $html, $a, $label;
if (path.html.$extended && path.html.$extended.data("status") === path.status) {
return path.html.$extended;
}
$html = $("<li class='entry' />")
.data("path", path)
.addClass(path.isFolder ? "folder" : "file");
if (path.status) {
$html.data("status", path.status);
}
$label = $("<span class='label'>" + path.label + "</span>");
$a = $("<a />")
.attr("href", path.absHref)
.click(function() { onClick("extended"); })
.appendTo($html)
.append($("<span class='icon small'><img src='" + path.icon16 + "' alt='" + path.alt + "' /></span>"))
.append($("<span class='icon big'><img src='" + path.icon48 + "' alt='" + path.alt + "' /></span>"))
.append($label)
.append($("<span class='date'>" + path.date + "</span>"))
.append($("<span class='size'>" + path.size + "</span>"));
$a.hover(
function () {
if ($("#extended").hasClass("icons-view")) {
var $this = $(this);
$(".status.default").hide();
$(".status.dynamic")
.empty()
.append($this.find(".label").clone())
.append($("<span class='sep'>·</span>"))
.append($this.find(".date").clone())
.show();
if (!$this.closest(".entry").hasClass("folder")) {
$(".status.dynamic")
.append($("<span class='sep'>·</span>"))
.append($this.find(".size").clone());
}
}
},
function () {
$(".status.default").show();
$(".status.dynamic").empty().hide();
}
);
if (path.isParentFolder) {
if (!h5ai.settings.setParentFolderLabels) {
$label.addClass("l10n-parentDirectory");
}
$html.addClass("parentfolder");
}
if (!isNaN(path.status)) {
if (path.status === 200) {
$html.addClass("page");
$a.find(".icon.small img").attr("src", "/h5ai/icons/16x16/folder-page.png");
$a.find(".icon.big img").attr("src", "/h5ai/icons/48x48/folder-page.png");
} else {
$html.addClass("error");
$label.append($("<span class='hint'> " + path.status + " </span>"));
}
}
if (path.html.$extended) {
path.html.$extended.replaceWith($html);
}
path.html.$extended = $html;
return $html;
},
updateTreeHtml = function () {
var $html, $blank, $a, $indicator, $ul, idx;
$html = $("<div class='entry' />")
.data("path", path)
.addClass(path.isFolder ? "folder" : "file");
$blank = $("<span class='blank' />").appendTo($html);
$a = $("<a />")
.attr("href", path.absHref)
.click(function() { path.onClick("tree"); })
.appendTo($html)
.append($("<span class='icon'><img src='" + path.icon16 + "' /></span>"))
.append($("<span class='label'>" + path.label + "</span>"));
if (path.isFolder) {
// indicator
if (path.status === undefined || !path.isEmpty()) {
$indicator = $("<span class='indicator'><img src='/h5ai/images/tree.png' /></span>");
if (path.status === undefined) {
$indicator.addClass("unknown");
} else if (path.treeOpen) {
$indicator.addClass("open");
}
$indicator.click(function(event) {
if ($indicator.hasClass("unknown")) {
tree.fetchStatusAndContent(path.absHref, false, function (status, content) {
path.status = status;
path.content = content;
path.treeOpen = true;
$("#tree").get(0).updateScrollbar(true);
path.updateTreeHtml(function() {
$("#tree").get(0).updateScrollbar();
});
});
} else if ($indicator.hasClass("open")) {
path.treeOpen = false;
$indicator.removeClass("open");
$("#tree").get(0).updateScrollbar(true);
$html.find("> ul.content").slideUp(function() {
$("#tree").get(0).updateScrollbar();
});
} else {
path.treeOpen = true;
$indicator.addClass("open");
$("#tree").get(0).updateScrollbar(true);
$html.find("> ul.content").slideDown(function() {
$("#tree").get(0).updateScrollbar();
});
}
});
$html.addClass("initiatedIndicator");
$blank.replaceWith($indicator);
}
// is path the domain?
if (path.isDomain) {
$html.addClass("domain");
$a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-home.png");
}
// is path the current folder?
if (path.isCurrentFolder) {
$html.addClass("current");
$a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-open.png");
}
// does it have subfolders?
if (!path.isEmpty()) {
$ul = $("<ul class='content' />").appendTo($html);
for (idx in path.content) {
$("<li />").append(path.content[idx].updateTreeHtml()).appendTo($ul);
}
if (path.status === undefined || !path.treeOpen) {
$ul.hide();
}
}
// reflect folder status
if (!isNaN(path.status)) {
if (path.status === 200) {
$a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-page.png");
$a.append($("<span class='hint'><img src='/h5ai/images/page.png' /></span>"));
} else {
$html.addClass("error");
$a.append($("<span class='hint'>" + path.status + "</span>"));
}
}
}
if (path.html.$tree) {
path.html.$tree.replaceWith($html);
}
path.html.$tree = $html;
return $html;
},
init = function () {
var $tds, $img, $a, splits;
path = {
// parentFolder: undefined,
// label: undefined,
// date: undefined,
// size: undefined,
// href: undefined,
// absHref: undefined,
// alt: undefined,
// icon16: undefined,
// icon48: undefined,
// isFolder: undefined,
// isParentFolder: undefined,
// isCurrentFolder: undefined,
// isDomain: undefined,
status: undefined, // undefined, "h5ai" or HTTP response code
content: undefined, // associative array path.absHref -> path
html: {
$crumb: undefined,
$extended: undefined,
$tree: undefined
},
treeOpen: false,
isEmpty: isEmpty,
onClick: onClick,
updateHtml: updateHtml,
updateCrumbHtml: updateCrumbHtml,
updateExtendedHtml: updateExtendedHtml,
updateTreeHtml: updateTreeHtml
};
if (!pathCache.pathEndsWithSlash(folder)) {
folder += "/";
}
if (tableRow) {
$tds = $(tableRow).find("td");
$img = $tds.eq(0).find("img");
$a = $tds.eq(1).find("a");
path.parentFolder = folder;
path.label = $a.text();
path.date = $tds.eq(2).text();
path.size = $tds.eq(3).text();
path.href = $a.attr("href");
path.alt = $img.attr("alt");
path.icon16 = $img.attr("src");
} else {
splits = pathCache.splitPathname(folder);
path.parentFolder = splits[0];
path.label = checkedDecodeUri(splits[1]);
if (path.label === "/") {
path.label = checkedDecodeUri(document.domain) + "/";
}
path.date = "";
path.size = "";
path.href = splits[1];
path.alt = "[DIR]";
path.icon16 = "/h5ai/icons/16x16/folder.png";
}
if (pathCache.pathEndsWithSlash(path.label)) {
path.label = path.label.slice(0, -1);
}
path.icon48 = path.icon16.replace("16x16", "48x48");
path.isFolder = (path.alt === "[DIR]");
path.isParentFolder = (path.isFolder && path.label === "Parent Directory");
path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
path.isCurrentFolder = (path.absHref === document.location.pathname);
path.isDomain = (path.absHref === "/");
if (path.isParentFolder && h5ai.settings.setParentFolderLabels) {
if (path.isDomain) {
path.label = checkedDecodeUri(document.domain);
} else {
path.label = checkedDecodeUri(pathCache.splitPathname(pathCache.splitPathname(path.parentFolder)[0])[1].slice(0, -1));
}
}
};
init();
return path;
};
var PathCache = function () { var PathCache = function () {
"use strict";
/*global $*/
var pathCache,
cache = {},
rePathnameSplit = /^(\/(.*\/)*)([^\/]+\/?)$/,
rePathEndsWithSlash = /\/$/,
splitPathname = function (pathname) {
this.cache = {}; var match;
this.objectCache = {};
if (pathname === "/") {
return ["", "/"];
}
match = rePathnameSplit.exec(pathname);
return [match[1], match[3]];
},
pathEndsWithSlash = function (pathname) {
this.splitPathname = function ( pathname ) { return rePathEndsWithSlash.test(pathname);
},
if ( pathname === "/" ) { getAbsHref = function (folder, tableRow) {
return [ "", "/" ];
};
var match = pathnameSplitRegEx.exec( pathname );
return [ match[1], match[3] ];
};
this.loadCache = function () {
var json = localStorage.getItem( "h5ai.cache" ); var $a, isParentFolder, href;
var objs = $.evalJSON( json );
var objectCache = {};
for ( idx in objs ) {
var obj = objs[idx];
objectCache[obj.r] = obj;
};
return objectCache;
};
if (!pathEndsWithSlash(folder)) {
folder += "/";
}
if (!tableRow) {
return folder;
}
$a = $(tableRow).find("td").eq(1).find("a");
isParentFolder = ($a.text() === "Parent Directory");
href = $a.attr("href");
return isParentFolder ? undefined : folder + href;
},
getPath = function (folder, tableRow) {
this.storeCache = function () { var absHref = getAbsHref(folder, tableRow),
path = cache[absHref];
var objs = []; if (!path) {
for ( ref in this.objectCache ) { path = new Path(pathCache, folder, tableRow);
objs.push( this.objectCache[ref] ); if (!path.isParentFolder) {
}; cache[path.absHref] = path;
var json = $.toJSON( objs ); }
localStorage.setItem( "h5ai.cache", json ); }
};
return path;
};
this.pathToObject = function ( path ) { pathCache = {
splitPathname: splitPathname,
var object = { pathEndsWithSlash: pathEndsWithSlash,
r: path.absHref, getPath: getPath
s: path.status, };
c: [],
o: path.treeOpen
};
if ( path.content !== undefined ) {
for ( ref in path.content ) {
object.c.push( ref );
};
};
return object;
};
this.objectToPath = function ( obj ) {
var path = this.getPathForFolder( obj.r );
path.status = obj.s;
path.content = {};
path.treeOpen = obj.o;
for ( idx in obj.c ) {
var href = obj.c[idx];
path.content[href] = this.getPathForFolder( href );
};
return path;
};
this.getAbsHref = function ( folder, tableRow ) {
if ( ! pathEndsWithSlashRegEx.test( folder ) ) {
folder += "/";
};
if ( tableRow === undefined ) {
return folder;
};
var $a = $( tableRow ).find( "td" ).eq( 1 ).find( "a" );
var isParentFolder = ( $a.text() === "Parent Directory" );
var href = $a.attr( "href" );
return isParentFolder ? undefined : folder + href;
};
this.getPathForFolder = function ( folder ) {
var absHref = this.getAbsHref( folder );
var cachedPath = this.cache[absHref];
if ( cachedPath !== undefined ) {
return cachedPath;
};
var path = new Path( this, folder );
this.cache[path.absHref] = path;
var obj = this.objectCache[absHref];
if ( obj !== undefined ) {
path.status = obj.s;
path.content = {};
path.treeOpen = obj.o;
for ( idx in obj.c ) {
var href = obj.c[idx];
path.content[href] = this.getPathForFolder( href );
};
} else {
var obj = this.pathToObject( path );
this.objectCache[obj.r] = obj;
this.storeCache();
};
return path;
};
this.getPathForTableRow = function ( parentFolder, tableRow ) {
var absHref = this.getAbsHref( parentFolder, tableRow );
var cachedPath = this.cache[absHref];
if ( cachedPath !== undefined ) {
return cachedPath;
};
var path = new Path( this, parentFolder, tableRow );
if ( ! path.isParentFolder ) {
this.cache[path.absHref] = path;
var obj = this.objectCache[absHref];
if ( obj !== undefined ) {
path.status = obj.s;
path.content = {};
path.treeOpen = obj.o;
for ( idx in obj.c ) {
var href = obj.c[idx];
path.content[href] = this.getPathForFolder( href );
};
} else {
if ( path.isFolder && path.status !== undefined ) {
var obj = this.pathToObject( path );
this.objectCache[obj.r] = obj;
this.storeCache();
};
};
};
return path;
};
this.objectCache = this.loadCache();
}; return pathCache;
var Path = function ( pathCache, folder, tableRow ) {
this.checkedDecodeUri = function ( uri ) {
try {
return decodeURI( uri );
} catch ( err ) {
};
return uri;
}
if ( ! pathEndsWithSlashRegEx.test( folder ) ) {
folder += "/";
};
if ( tableRow !== undefined ) {
var $tds = $( tableRow ).find( "td" );
var $img = $tds.eq( 0 ).find( "img" );
var $a= $tds.eq( 1 ).find( "a" );
this.parentFolder = folder;
this.icon16 = $img.attr( "src" );
this.alt = $img.attr( "alt" );
this.label = $a.text();
this.href = $a.attr("href");
this.date = $tds.eq( 2 ).text();
this.size = $tds.eq( 3 ).text();
} else {
var splits = pathCache.splitPathname( folder );
this.parentFolder = splits[0];
this.href = splits[1];
this.label = this.checkedDecodeUri( splits[1] );
this.icon16 = "/h5ai/icons/16x16/folder.png";
this.alt = "[DIR]";
this.date = "";
this.size = "";
if ( this.label === "/" ) {
this.label = this.checkedDecodeUri( document.domain ) + "/";
};
};
if ( pathEndsWithSlashRegEx.test( this.label ) ) {
this.label = this.label.slice( 0, -1 );
};
this.icon48 = this.icon16.replace( "16x16", "48x48" );
this.isFolder = ( this.alt === "[DIR]" );
this.isParentFolder = ( this.isFolder && this.label === "Parent Directory" );
this.absHref = this.isParentFolder ? this.href : this.parentFolder + this.href;
this.isCurrentFolder = ( this.absHref === document.location.pathname );
this.isDomain = ( this.absHref === "/" );
if ( this.isParentFolder && h5ai.config.setParentFolderLabels ) {
if ( this.isDomain ) {
this.label = this.checkedDecodeUri( document.domain );
} else {
this.label = this.checkedDecodeUri( pathCache.splitPathname( pathCache.splitPathname( this.parentFolder )[0] )[1].slice( 0, -1 ) );
};
};
this.status = undefined; // undefined, "h5ai" or HTTP response code
this.content = undefined; // associative array path.absHref -> path
this.html = {
$crumb: undefined,
$extended: undefined,
$tree: undefined
};
this.treeOpen = false;
this.isEmpty = function() {
return this.content === undefined || $.isEmptyObject( this.content );
};
this.onClick = function ( context ) {
h5ai.triggerPathClick( this, context );
};
this.updateHtml = function () {
this.updateCrumbHtml();
this.updateExtendedHtml();
this.updateTreeHtml();
};
this.updateCrumbHtml = function () {
if ( this.html.$crumb !== undefined && this.html.$crumb.data( "status" ) === this.status ) {
return this.html.$crumb;
};
var $html = $( "<li class='crumb' />" ).data( "path", this );
if ( this.status !== undefined ) {
$html.data( "status", this.status );
};
try {
$html.addClass( this.isFolder ? "folder" : "file" );
var $a = $( "<a><img src='/h5ai/images/crumb.png' alt='>' />" + this.label + "</a>" );
$a.attr( "href", this.absHref );
$a.click( $.proxy( function() { this.onClick( "crumb" ); }, this ) );
$html.append( $a );
if ( this.isDomain ) {
$html.addClass( "domain" );
$a.find( "img" ).attr( "src", "/h5ai/images/home.png" );
};
if ( this.isCurrentFolder ) {
$html.addClass( "current" );
};
if ( !isNaN( this.status ) ) {
if ( this.status === 200 ) {
$( "<img class='hint' src='/h5ai/images/page.png' alt='not listable' />" ).appendTo( $a );
} else {
$( "<span class='hint'>(" + this.status + ")</span>" ).appendTo( $a );
};
};
} catch( err ) {
$( "<span class='fail'>failed</span>" ).appendTo( $html );
};
if ( this.html.$crumb !== undefined ) {
this.html.$crumb.replaceWith( $html );
};
this.html.$crumb = $html;
return $html;
};
this.updateExtendedHtml = function () {
if ( this.html.$extended !== undefined && this.html.$extended.data( "status" ) === this.status ) {
return this.html.$extended;
};
var $html = $( "<li class='entry' />" ).data( "path", this );
if ( this.status !== undefined ) {
$html.data( "status", this.status );
};
try {
$html.addClass( this.isFolder ? "folder" : "file" );
var $a = $( "<a />" ).appendTo( $html );
$a.attr( "href", this.absHref );
$a.click( $.proxy( function() { this.onClick( "extended" ); }, this ) );
$( "<span class='icon small'><img src='" + this.icon16 + "' alt='" + this.alt + "' /></span>" ).appendTo( $a );
$( "<span class='icon big'><img src='" + this.icon48 + "' alt='" + this.alt + "' /></span>" ).appendTo( $a );
var $label = $( "<span class='label'>" + this.label + "</span>" ).appendTo( $a );
$( "<span class='date'>" + this.date + "</span>" ).appendTo( $a );
$( "<span class='size'>" + this.size + "</span>" ).appendTo( $a );
if ( this.isParentFolder ) {
if ( !h5ai.config.setParentFolderLabels ) {
$label.addClass( "l10n-parentDirectory" );
};
$html.addClass( "parentfolder" );
};
if ( !isNaN( this.status ) ) {
if ( this.status === 200 ) {
$html.addClass( "page" );
$a.find( ".icon.small img" ).attr( "src", "/h5ai/icons/16x16/folder-page.png" );
$a.find( ".icon.big img" ).attr( "src", "/h5ai/icons/48x48/folder-page.png" );
} else {
$html.addClass( "error" );
$label.append( $( "<span class='hint'> " + this.status + " </span>" ) );
};
};
} catch( err ) {
$( "<span class='fail'>failed</span>" ).appendTo( $html );
};
if ( this.html.$extended !== undefined ) {
this.html.$extended.replaceWith( $html );
};
this.html.$extended = $html;
return $html;
};
this.updateTreeHtml = function () {
var $html = $( "<div class='entry' />" ).data( "path", this );
var $blank = $( "<span class='blank' />" ).appendTo( $html );
try {
$html.addClass( this.isFolder ? "folder" : "file" );
var $a = $( "<a />" )
.appendTo( $html )
.append( $( "<span class='icon'><img src='" + this.icon16 + "' /></span>" ) )
.append( $( "<span class='label'>" + this.label + "</span>" ) );
$a.attr( "href", this.absHref );
$a.click( $.proxy( function() { this.onClick( "tree" ); }, this ) );
if ( this.isFolder ) {
// indicator
if ( this.status === undefined || !this.isEmpty() ) {
var $indicator = $( "<span class='indicator'><img src='/h5ai/images/tree.png' /></span>" );
if ( this.status === undefined ) {
$indicator.addClass( "unknown" );
} else if ( this.treeOpen ) {
$indicator.addClass( "open" );
};
$indicator.click( $.proxy( function( event ) {
if ( $indicator.hasClass( "unknown" ) ) {
tree.fetchStatusAndContent( this.absHref, false, $.proxy( function ( status, content ) {
this.status = status;
this.content = content;
this.treeOpen = true;
pathCache.objectCache[this.absHref] = pathCache.pathToObject( this );
pathCache.storeCache();
$( "#tree" ).get( 0 ).updateScrollbar( true );
this.updateTreeHtml( function() {
$( "#tree" ).get( 0 ).updateScrollbar();
} );
}, this ) );
} else if ( $indicator.hasClass( "open" ) ) {
this.treeOpen = false;
pathCache.objectCache[this.absHref] = pathCache.pathToObject( this );
pathCache.storeCache();
$indicator.removeClass( "open" );
$( "#tree" ).get( 0 ).updateScrollbar( true );
$html.find( "> ul.content" ).slideUp( function() {
$( "#tree" ).get( 0 ).updateScrollbar();
} );
} else {
this.treeOpen = true;
pathCache.objectCache[this.absHref] = pathCache.pathToObject( this );
pathCache.storeCache();
$indicator.addClass( "open" );
$( "#tree" ).get( 0 ).updateScrollbar( true );
$html.find( "> ul.content" ).slideDown( function() {
$( "#tree" ).get( 0 ).updateScrollbar();
} );
};
}, this ) );
$html.addClass( "initiatedIndicator" );
$blank.replaceWith( $indicator );
};
// is this the domain?
if ( this.isDomain ) {
$html.addClass( "domain" );
$a.find( ".icon img" ).attr( "src", "/h5ai/icons/16x16/folder-home.png" );
};
// is this the current folder?
if ( this.isCurrentFolder ) {
$html.addClass( "current" );
$a.find( ".icon img" ).attr( "src", "/h5ai/icons/16x16/folder-open.png" );
};
// does it have subfolders?
if ( !this.isEmpty() ) {
var $ul = $( "<ul class='content' />" ).appendTo( $html );
for ( idx in this.content ) {
$( "<li />" ).append( this.content[idx].updateTreeHtml() ).appendTo( $ul );
};
if ( this.status === undefined || !this.treeOpen ) {
$ul.hide();
};
};
// reflect folder status
if ( !isNaN( this.status ) ) {
if ( this.status === 200 ) {
$a.find( ".icon img" ).attr( "src", "/h5ai/icons/16x16/folder-page.png" );
$a.append( $( "<span class='hint'><img src='/h5ai/images/page.png' /></span>" ) );
} else {
$html.addClass( "error" );
$a.append( $( "<span class='hint'>" + this.status + "</span>" ) );
};
};
};
} catch( err ) {
$( "<span class='fail'>failed</span>" ).appendTo( $html );
};
if ( this.html.$tree !== undefined ) {
this.html.$tree.replaceWith( $html );
};
this.html.$tree = $html;
return $html;
};
}; };

View File

@@ -1,148 +1,147 @@
var Tree = function ( pathCache, h5ai ) { var Tree = function (pathCache, h5ai) {
"use strict";
/*global $*/
var contentTypeRegEx = /^text\/html;h5ai=/,
pathnameStatusCache = {},
fetchStatus = function (pathname, callback) {
this.init = function () { if (h5ai.settings.folderStatus[pathname]) {
callback(h5ai.settings.folderStatus[pathname]);
return;
} else if (pathnameStatusCache[pathname]) {
callback(pathnameStatusCache[pathname]);
return;
}
if ( h5ai.config.showTree ) { $.ajax({
this.updatePaths(); url: pathname,
this.populateTree(); type: "HEAD",
}; complete: function (xhr) {
};
var status = xhr.status;
this.updatePath = function ( path ) { if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) {
status = "h5ai";
}
pathnameStatusCache[pathname] = status;
callback(status);
}
});
},
updatePath = function (path) {
if ( path.isFolder && !path.isParentFolder && path.status === undefined ) { if (path.isFolder && !path.isParentFolder && path.status === undefined) {
this.fetchStatus( path.absHref, function ( status ) { fetchStatus(path.absHref, function (status) {
if ( status !== "h5ai" ) {
path.status = status;
};
path.updateHtml();
h5ai.linkHoverStates();
} );
};
};
if (status !== "h5ai") {
path.status = status;
}
path.updateHtml();
h5ai.linkHoverStates();
});
}
},
updatePaths = function () {
this.updatePaths = function () { var ref;
for ( var ref in pathCache.cache ) { for (ref in pathCache.cache) {
this.updatePath( pathCache.cache[ref] ); updatePath(pathCache.cache[ref]);
}; }
}; },
fetchStatusAndContent = function (pathname, includeParent, callback) {
fetchStatus(pathname, function (status) {
this.populateTree = function () { if (status !== "h5ai") {
callback(status, {});
return;
}
this.fetchTree( document.location.pathname, function( path ) { $.ajax({
$( "#tree" ) url: pathname,
.append( path.updateTreeHtml() ) type: "GET",
.scrollpanel() dataType: "html",
.show(); error: function (xhr) {
h5ai.linkHoverStates();
pathCache.storeCache();
setTimeout( function () {
$( "#tree" ).get( 0 ).updateScrollbar();
}, 1 );
} );
};
callback(xhr.status, {}); // since it was checked before this should never happen
},
success: function (html, status, xhr) {
this.fetchTree = function ( pathname, callback, childPath ) { var content = {};
this.fetchPath( pathname, $.proxy( function ( path ) { if (!contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) {
callback(xhr.status, {}); // since it was checked before this should never happen
path.treeOpen = true; return;
}
if ( childPath !== undefined ) {
path.content[ childPath.absHref ] = childPath;
};
var parent = pathCache.splitPathname( pathname )[0]; $(html).find("#table td").closest("tr").each(function () {
if ( parent === "" ) {
callback( path );
} else {
this.fetchTree( parent, callback, path );
};
}, this ) );
};
var path = pathCache.getPath(pathname, this);
this.fetchPath = function ( pathname, callback ) { if (path.isFolder && (!path.isParentFolder || includeParent)) {
content[path.absHref] = path;
updatePath(path);
}
});
callback("h5ai", content);
}
});
});
},
fetchPath = function (pathname, callback) {
this.fetchStatusAndContent( pathname, false, function ( status, content ) { fetchStatusAndContent(pathname, false, function (status, content) {
var path = pathCache.getPathForFolder( pathname );
path.status = status;
path.content = content;
callback( path );
} );
};
var path = pathCache.getPath(pathname);
path.status = status;
path.content = content;
callback(path);
});
},
fetchTree = function (pathname, callback, childPath) {
var THIS = this; fetchPath(pathname, function (path) {
var contentTypeRegEx = /^text\/html;h5ai=/;
var pathnameStatusCache = {};
this.fetchStatusAndContent = function ( pathname, includeParent, callback ) { var parent = pathCache.splitPathname(pathname)[0];
this.fetchStatus( pathname, function ( status ) { path.treeOpen = true;
if (childPath) {
path.content[childPath.absHref] = childPath;
}
if (parent === "") {
callback(path);
} else {
fetchTree(parent, callback, path);
}
});
},
populateTree = function () {
if ( status !== "h5ai" ) { fetchTree(document.location.pathname, function (path) {
callback( status, {} ); $("#tree")
return; .append(path.updateTreeHtml())
}; .scrollpanel()
.show();
h5ai.shiftTree(false, true);
h5ai.linkHoverStates();
setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1);
});
},
init = function () {
$.ajax( { if (h5ai.settings.showTree) {
url: pathname, updatePaths();
type: "GET", populateTree();
dataType: "html", }
error: function ( xhr ) { },
callback( xhr.status, {} ); // since it was checked before this should never happen tree = {
}, fetchStatusAndContent: fetchStatusAndContent,
success: function ( html, status, xhr ) { init: init
if ( !contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) { };
callback( xhr.status, {} ); // since it was checked before this should never happen
return;
};
var content = {}; return tree;
$( html ).find( "#table td" ).closest( "tr" ).each( function () {
var path = pathCache.getPathForTableRow( pathname, this );
if ( path.isFolder && ( !path.isParentFolder || includeParent ) ) {
content[path.absHref] = path;
THIS.updatePath( path );
};
} );
callback( "h5ai", content );
}
} );
} );
};
this.fetchStatus = function ( pathname, callback ) {
if ( h5ai.config.folderStatus[ pathname ] !== undefined ) {
callback( h5ai.config.folderStatus[ pathname ] );
return;
} else if ( pathnameStatusCache[ pathname ] !== undefined ) {
callback( pathnameStatusCache[ pathname ] );
return;
};
$.ajax( {
url: pathname,
type: "HEAD",
complete: function ( xhr ) {
var status = xhr.status;
if ( status === 200 && contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
status = "h5ai";
};
pathnameStatusCache[ pathname ] = status;
callback( status );
}
} );
};
}; };

View File

@@ -1,44 +1,30 @@
( function( $ ) { (function($) {
"use strict";
/*global jQuery, h5aiOptions, h5aiLangs*/
// @include "inc/jquery.json.min.js" // @include "inc/jquery.mousewheel.min.js"
// @include "inc/jquery.mousewheel.min.js" // @include "inc/jquery.scrollpanel.js"
// @include "inc/jquery.scrollpanel.js" // @include "inc/jquery.utils.js"
// @include "inc/jquery.utils.js" // @include "inc/jquery.fracs.js"
// @include "inc/path.js" // @include "inc/path.js"
// @include "inc/extended.js" // @include "inc/h5ai.js"
// @include "inc/h5ai.js" // @include "inc/extended.js"
// @include "inc/tree.js" // @include "inc/tree.js"
var pathCache = new PathCache(),
h5ai = new H5ai(h5aiOptions, h5aiLangs),
extended = new Extended(pathCache, h5ai),
tree = new Tree(pathCache, h5ai);
/******************************* $.h5ai = {
* create click: $.proxy(h5ai.pathClick, h5ai)
*******************************/ };
$.timer.log( "start pathcache" ); $(function () {
var pathCache = new PathCache();
$.timer.log( "end pathcache" );
var extended = new Extended( pathCache );
var h5ai = new H5ai( h5aiOptions, h5aiLangs );
var tree = new Tree( pathCache, h5ai );
extended.init();
tree.init();
h5ai.init();
});
/******************************* })(jQuery);
* register public api
*******************************/
$.h5ai = {
click: $.proxy( h5ai.pathClick, h5ai )
};
/*******************************
* init after dom load
*******************************/
$( function() {
extended.init();
tree.init();
h5ai.init();
} );
} )( jQuery );

View File

@@ -1,36 +1,24 @@
( function( $ ) { (function($) {
"use strict";
/*global jQuery, h5aiOptions, h5aiLangs*/
// @include "inc/jquery.json.min.js" // @include "inc/jquery.mousewheel.min.js"
// @include "inc/jquery.mousewheel.min.js" // @include "inc/jquery.scrollpanel.js"
// @include "inc/jquery.scrollpanel.js" // @include "inc/jquery.utils.js"
// @include "inc/jquery.utils.js" // @include "inc/jquery.fracs.js"
// @include "inc/h5ai.js" // @include "inc/h5ai.js"
var h5ai = new H5ai(h5aiOptions, h5aiLangs);
/******************************* $.h5ai = {
* create click: $.proxy(h5ai.pathClick, h5ai)
*******************************/ };
var h5ai = new H5ai( h5aiOptions, h5aiLangs ); $(function () {
h5ai.init();
$("#tree").scrollpanel();
h5ai.shiftTree(false, true);
});
/******************************* })(jQuery);
* register public api
*******************************/
$.h5ai = {
click: $.proxy( h5ai.pathClick, h5ai )
};
/*******************************
* init after dom load
*******************************/
$( function() {
h5ai.init();
$( "#tree" ).scrollpanel();
} );
} )( jQuery );

View File

@@ -1,83 +1,109 @@
/* /*
* h5ai %BUILD_VERSION% * h5ai %BUILD_VERSION%
* Options and localization * Options and localization
*/ */
h5aiOptions = { h5aiOptions = {
/* /*
* An array of view modes the user may choose from. Currently there * An array of view modes the user may choose from. Currently there
* are two possible values: "details" and "icons". The first value * are two possible values: "details" and "icons". The first value
* indicates the default view mode. If only one value is given the * indicates the default view mode. If only one value is given the
* view mode is fixed and the selector buttons are hidden. * view mode is fixed and the selector buttons are hidden.
* The user selected view mode is also stored local in modern browsers * The user selected view mode is also stored local in modern browsers
* so that it will be persistent. * so that it will be persistent.
*/ */
"viewmodes": [ "details", "icons" ], "viewmodes": ["details", "icons"],
/* /*
* Show a folder tree, boolean. * Default sort order. Valid values for column are "name", "date" and
* Note that this tree might have side effects as it sends HEAD requests * "size".
* to the folders, and therefore will invoke index.php scripts. Use * If you are using the JavaScript version please make sure to change
* folderStatus below to avoid such requests. * IndexOrderDefault in js.htaccess as well.
* It might also affect performance significantly. */
*/ "sortorder": {
"showTree": true, "column": "name",
"ascending": true
},
/* /*
* Associative array of folders and their HTTP status codes to * Show a folder tree, boolean.
* avoid HEAD requests to that folders. The key (folder) must start * Note that this tree might have side effects as it sends HEAD requests
* and end with a slash (/). * to the folders, and therefore will invoke index.php scripts. Use
* For example: * folderStatus below to avoid such requests.
* "/some/folder/": 200 * It might also affect performance significantly.
* will always return HTTP status 200 (OK), which will be interpreted */
* as a non auto indexed folder, that means a folder containing an "showTree": true,
* appropriate default index file.
*/
"folderStatus": {
/*
* for example:
* "/some/folder/": 200
*/
},
/* /*
* Localization, for example "en", "de" etc. - see h5aiLangs below for * Slide tree bar into viewport if there is enough space, boolean.
* possible values. Adjust it to your needs. If lang is not found in */
* h5aiLangs it defaults to "en". "slideTree": true,
*/
"lang": null,
/* /*
* Try to use browser language, falls back to previous specified lang. * Associative array of folders and their HTTP status codes to
*/ * avoid HEAD requests to that folders. The key (folder) must start
"useBrowserLang": true, * and end with a slash (/).
* For example:
/* * "/some/folder/": 200
* Set parent folder labels to real folder names. * will always return HTTP status 200 (OK), which will be interpreted
*/ * as a non auto indexed folder, that means a folder containing an
"setParentFolderLabels": true, * appropriate default index file.
*/
/* "folderStatus": {},
* Link the hover effects between crumb, extended view and tree.
*/
"linkHoverStates": true,
/* /*
* Only used in PHP implementation. * Localization, for example "en", "de" etc. - see h5aiLangs below for
* Date format in PHP syntax, for example: "Y-m-d H:i:s" * possible values. Adjust it to your needs. If lang is not found in
* http://www.php.net/manual/en/function.date.php * h5aiLangs it defaults to "en".
*/ */
"dateFormat": "Y-m-d H:i", "lang": null,
/* /*
* Only used in PHP implementation. * Try to use browser language, falls back to previous specified lang.
* Files/folders that should never be listed. Specified */
* by the complete filename or by a regular expression. "useBrowserLang": true,
* http://www.php.net/manual/en/function.preg-match.php
*/ /*
"ignore": [ "h5ai", "h5ai.header.html", "h5ai.footer.html" ], * Set parent folder labels to real folder names.
"ignoreRE": [ "/^\\./" ] */
"setParentFolderLabels": true,
/*
* Link the hover effects between crumb, extended view and tree.
*/
"linkHoverStates": true,
/*
* Only used in PHP implementation.
* Date format in PHP syntax, for example: "Y-m-d H:i:s"
* http://www.php.net/manual/en/function.date.php
*/
"dateFormat": "Y-m-d H:i",
/*
* IMPORTANT: PHP implementation doesn't care about Apache's
* ignores, so you have to specify this here.
*
* Only used in PHP implementation.
* Files/folders that should never be listed. Specified
* by the complete filename or by a regular expression.
* http://www.php.net/manual/en/function.preg-match.php
*/
"ignore": ["h5ai", "h5ai.header.html", "h5ai.footer.html"],
"ignoreRE": ["/^\\./"],
/*
* Only used in PHP implementation.
* Show thumbnails in Icons view.
*/
"showThumbs": true,
/*
* Enable zipped download of selected entries. Requieres
* PHP on the server.
*/
"zippedDownload": true
}; };
@@ -87,146 +113,227 @@ h5aiOptions = {
*/ */
h5aiLangs = { h5aiLangs = {
"en": { "en": {
"lang": "english", "lang": "english",
"details": "details", "details": "details",
"icons": "icons", "icons": "icons",
"name": "Name", "name": "Name",
"lastModified": "Last modified", "lastModified": "Last modified",
"size": "Size", "size": "Size",
"parentDirectory": "Parent Directory", "parentDirectory": "Parent Directory",
"empty": "empty", "empty": "empty",
"folders": "folders", "folders": "folders",
"files": "files" "files": "files",
}, "download": "download"
},
"de": { "de": {
"lang": "deutsch", "lang": "deutsch",
"details": "Details", "details": "Details",
"icons": "Icons", "icons": "Icons",
"name": "Name", "name": "Name",
"lastModified": "Geändert", "lastModified": "Geändert",
"size": "Größe", "size": "Größe",
"parentDirectory": "Übergeordnetes Verzeichnis", "parentDirectory": "Übergeordnetes Verzeichnis",
"empty": "leer", "empty": "leer",
"folders": "Ordner", "folders": "Ordner",
"files": "Dateien" "files": "Dateien",
}, "download": "Download"
},
"fr": {
"lang": "française",
"details": "détails",
"icons": "icônes",
"name": "Nom",
"lastModified": "Dernière modification",
"size": "Taille",
"parentDirectory": "Dossier parent",
"empty": "vide",
"folders": "[?folders?]",
"files": "[?files?]"
},
"nl": { "fr": {
"lang": "nederlands", "lang": "français",
"details": "details", "details": "détails",
"icons": "iconen", "icons": "icônes",
"name": "Naam", "name": "Nom",
"lastModified": "Laatste wijziging", "lastModified": "Dernière modification",
"size": "Grootte", "size": "Taille",
"parentDirectory": "Bovenliggende map", "parentDirectory": "Dossier parent",
"empty": "lege", "empty": "vide",
"folders": "[?folders?]", "folders": "Répertoires",
"files": "[?files?]" "files": "Fichiers",
}, "download": "download"
},
"sv": { "nl": {
"lang": "svenska", "lang": "nederlands",
"details": "detaljerad", "details": "details",
"icons": "ikoner", "icons": "iconen",
"name": "Filnamn", "name": "Naam",
"lastModified": "Senast ändrad", "lastModified": "Laatste wijziging",
"size": "Filstorlek", "size": "Grootte",
"parentDirectory": "Till överordnad mapp", "parentDirectory": "Bovenliggende map",
"empty": "tom", "empty": "lege",
"folders": "[?folders?]", "folders": "folders",
"files": "[?files?]" "files": "files",
}, "download": "download"
},
"cs": { "sv": {
"lang": "[?lang?]", "lang": "svenska",
"details": "podrobnosti", "details": "detaljerad",
"icons": "ikony", "icons": "ikoner",
"name": "Název", "name": "Filnamn",
"lastModified": "Upraveno", "lastModified": "Senast ändrad",
"size": "Velikost", "size": "Filstorlek",
"parentDirectory": "Nadřazený adresář", "parentDirectory": "Till överordnad mapp",
"empty": "prázdný", "empty": "tom",
"folders": "[?folders?]", "folders": "folders",
"files": "[?files?]" "files": "files",
}, "download": "download"
},
"sk": { "cs": {
"lang": "[?lang?]", "lang": "čeština",
"details": "podrobnosti", "details": "podrobnosti",
"icons": "ikony", "icons": "ikony",
"name": "Názov", "name": "Název",
"lastModified": "Upravené", "lastModified": "Upraveno",
"size": "Velkosť", "size": "Velikost",
"parentDirectory": "Nadriadený priečinok", "parentDirectory": "Nadřazený adresář",
"empty": "prázdny", "empty": "prázdný",
"folders": "[?folders?]", "folders": "složek",
"files": "[?files?]" "files": "souborů",
}, "download": "download"
},
"es": { "sk": {
"lang": "español", "lang": "slovenčina",
"details": "Detalles", "details": "podrobnosti",
"icons": "Íconos", "icons": "ikony",
"name": "Nombre", "name": "Názov",
"lastModified": "Última modificación", "lastModified": "Upravené",
"size": "Tamaño", "size": "Velkosť",
"parentDirectory": "Directorio superior", "parentDirectory": "Nadriadený priečinok",
"empty": "vacío", "empty": "prázdny",
"folders": "[?folders?]", "folders": "priečinkov",
"files": "[?files?]" "files": "súborov",
}, "download": "download"
},
"tr": { "es": {
"lang": "türkçe", "lang": "español",
"details": "detaylar", "details": "Detalles",
"icons": "ikonlar", "icons": "Íconos",
"name": "İsim", "name": "Nombre",
"lastModified": "Son Düzenleme", "lastModified": "Última modificación",
"size": "Boyut", "size": "Tamaño",
"parentDirectory": "Üst Dizin", "parentDirectory": "Directorio superior",
"empty": "boş", "empty": "vacío",
"folders": "[?folders?]", "folders": "folders",
"files": "[?files?]" "files": "files",
}, "download": "download"
},
"pt": { "tr": {
"lang": "português", "lang": "türkçe",
"details": "detalhes", "details": "detaylar",
"icons": "ícones", "icons": "ikonlar",
"name": "Nome", "name": "İsim",
"lastModified": "Última modificação", "lastModified": "Son Düzenleme",
"size": "Tamanho", "size": "Boyut",
"parentDirectory": "Diretório superior", "parentDirectory": "Üst Dizin",
"empty": "vazio", "empty": "boş",
"folders": "[?folders?]", "folders": "klasörler",
"files": "[?files?]" "files": "dosyalar",
}, "download": "indir"
},
"bg": { "pt": {
"lang": "[?lang?]", "lang": "português",
"details": "детайли", "details": "detalhes",
"icons": "икони", "icons": "ícones",
"name": "Име", "name": "Nome",
"lastModified": "Последна промяна", "lastModified": "Última modificação",
"size": "Размер", "size": "Tamanho",
"parentDirectory": "Предходна директория", "parentDirectory": "Diretório superior",
"empty": "празно", "empty": "vazio",
"folders": "[?folders?]", "folders": "pastas",
"files": "[?files?]" "files": "arquivos",
} "download": "download"
},
"bg": {
"lang": "български",
"details": "детайли",
"icons": "икони",
"name": "Име",
"lastModified": "Последна промяна",
"size": "Размер",
"parentDirectory": "Предходна директория",
"empty": "празно",
"folders": "папки",
"files": "файлове",
"download": "download"
},
"lv": {
"lang": "latviešu",
"details": "detaļas",
"icons": "ikonas",
"name": "Nosaukums",
"lastModified": "Pēdējoreiz modificēts",
"size": "Izmērs",
"parentDirectory": "Vecākdirektorijs",
"empty": "tukšs",
"folders": "mapes",
"files": "faili",
"download": "lejupielādēt"
},
"zh-cn": {
"lang": "简体中文",
"details": "详情",
"icons": "图标",
"name": "文件名",
"lastModified": "上次修改",
"size": "大小",
"parentDirectory": "上层文件夹",
"empty": "空文件夹",
"folders": "文件夹",
"files": "文件",
"download": "download"
},
"pl": {
"lang": "polski",
"details": "szczegóły",
"icons": "ikony",
"name": "Nazwa",
"lastModified": "Ostatnia modyfikacja",
"size": "Rozmiar",
"parentDirectory": "Katalog nadrzędny",
"empty": "pusty",
"folders": "foldery",
"files": "pliki",
"download": "download"
},
"ru": {
"lang": "русский",
"details": "детали",
"icons": "иконки",
"name": "Имя",
"lastModified": "Последние изменения",
"size": "Размер",
"parentDirectory": "Главная директория",
"empty": "пусто",
"folders": "папки",
"files": "файлы",
"download": "download"
},
"it": {
"lang": "italiano",
"details": "dettagli",
"icons": "icone",
"name": "Nome",
"lastModified": "Ultima modifica",
"size": "Dimensione",
"parentDirectory": "Cartella Superiore",
"empty": "vuota",
"folders": "cartelle",
"files": "file",
"download": "download"
}
}; };

View File

@@ -7,87 +7,87 @@
############################################## ##############################################
class Cache { class Cache {
private $dir; private $dir;
function __construct( $dir ) {
$this->dir = $dir; function __construct($dir) {
}
private function _name( $key ) { $this->dir = $dir;
}
return $this->dir . "/" . sha1( $key ); private function _name($key) {
}
public function get( $key, $expiration = 3600 ) { return $this->dir . "/" . sha1($key);
}
if ( !is_dir( $this->dir ) || !is_writable( $this->dir ) ) { public function get($key, $expiration = 3600) {
return false;
}
$cache_path = $this->_name( $key ); if (!is_dir($this->dir) || !is_writable($this->dir)) {
return false;
}
if ( !@file_exists( $cache_path ) ) { $cache_path = $this->_name($key);
return false;
}
if ( filemtime( $cache_path ) < ( time() - $expiration ) ) { if (!@file_exists($cache_path)) {
$this->clear( $key ); return false;
return false; }
}
if ( !$fp = @fopen( $cache_path, "rb" ) ) { if (filemtime($cache_path) < (time() - $expiration)) {
return false; $this->clear($key);
} return false;
}
flock( $fp, LOCK_SH ); if (!$fp = @fopen($cache_path, "rb")) {
$cache = ""; return false;
}
if ( filesize( $cache_path ) > 0 ) { flock($fp, LOCK_SH);
$cache = unserialize( fread( $fp, filesize( $cache_path ) ) ); $cache = "";
} else {
$cache = null;
}
flock( $fp, LOCK_UN ); if (filesize($cache_path) > 0) {
fclose( $fp ); $cache = unserialize(fread($fp, filesize($cache_path)));
} else {
$cache = null;
}
return $cache; flock($fp, LOCK_UN);
} fclose($fp);
public function set( $key, $data ) { return $cache;
}
if ( !is_dir( $this->dir ) || !is_writable( $this->dir ) ) { public function set($key, $data) {
return false;
}
$cache_path = $this->_name( $key ); if (!is_dir($this->dir) || !is_writable($this->dir)) {
return false;
}
if ( ! $fp = fopen( $cache_path, "wb" ) ) { $cache_path = $this->_name($key);
return false;
}
if ( flock( $fp, LOCK_EX ) ) { if (! $fp = fopen($cache_path, "wb")) {
fwrite( $fp, serialize( $data ) ); return false;
flock( $fp, LOCK_UN ); }
} else {
return false;
}
fclose( $fp );
@chmod( $cache_path, 0777 );
return true;
}
public function clear( $key ) { if (flock($fp, LOCK_EX)) {
fwrite($fp, serialize($data));
flock($fp, LOCK_UN);
} else {
return false;
}
fclose($fp);
@chmod($cache_path, 0777);
return true;
}
$cache_path = $this->_name( $key ); public function clear($key) {
if ( file_exists( $cache_path ) ) { $cache_path = $this->_name($key);
unlink( $cache_path );
return true; if (file_exists($cache_path)) {
} unlink($cache_path);
return false; return true;
} }
return false;
}
} }
?> ?>

View File

@@ -1,52 +1,52 @@
<?php <?php
class Crumb { class Crumb {
private $h5ai, $parts; private $h5ai, $parts;
public function __construct( $h5ai ) { public function __construct($h5ai) {
$this->h5ai = $h5ai; $this->h5ai = $h5ai;
$this->parts = array(); $this->parts = array();
$href = $h5ai->getAbsHref(); $href = $h5ai->getAbsHref();
while ( $href !== "/" && $href !== "//" ) { while ($href !== "/" && $href !== "//") {
$this->parts[] = $href; $this->parts[] = $href;
$href = dirname( $href ) . "/"; $href = dirname($href) . "/";
} }
$this->parts[] = "/"; $this->parts[] = "/";
$this->parts = array_reverse( $this->parts ); $this->parts = array_reverse($this->parts);
} }
public function toHtml() { public function toHtml() {
$html = ""; $html = "";
$idx = 0; $idx = 0;
foreach( $this->parts as $href ) { foreach($this->parts as $href) {
$idx++; $idx++;
$classes = "crumb folder" . ( $idx === 1 ? " domain" : "" ) . ( $idx === count( $this->parts ) ? " current" : "" ); $classes = "crumb folder" . ($idx === 1 ? " domain" : "") . ($idx === count($this->parts) ? " current" : "");
$image = "/h5ai/images/" . ( $idx === 1 ? "home.png" : "crumb.png" ); $image = "/h5ai/images/" . ($idx === 1 ? "home.png" : "crumb.png");
$label = $this->h5ai->getLabel( $href ); $label = $this->h5ai->getLabel($href);
$hint = ""; $hint = "";
$code = $this->h5ai->getHttpCode( $href ); $code = $this->h5ai->getHttpCode($href);
$classes .= " checkedHttpCode"; $classes .= " checkedHttpCode";
if ( $code !== "h5ai" ) { if ($code !== "h5ai") {
if ( $code === 200 ) { if ($code === 200) {
$hint = "<img class='hint' src='/h5ai/images/page.png' alt='page' />"; $hint = "<img class='hint' src='/h5ai/images/page.png' alt='page' />";
} else { } else {
$hint = "<span class='hint'>(" . $code . ")</span>"; $hint = "<span class='hint'>(" . $code . ")</span>";
} }
} }
$html .= "<li class='$classes'>\n"; $html .= "<li class='$classes'>\n";
$html .= "\t<a href='$href'>\n"; $html .= "\t<a href='$href'>\n";
$html .= "\t\t<img src='$image' alt='>' />" . $label . $hint . "\n"; $html .= "\t\t<img src='$image' alt='>' />" . $label . $hint . "\n";
$html .= "\t</a>\n"; $html .= "\t</a>\n";
$html .= "</li>\n"; $html .= "</li>\n";
} }
return $html; return $html;
} }
} }
?> ?>

View File

@@ -1,27 +1,27 @@
<?php <?php
class Customize { class Customize {
private $h5ai; private $h5ai;
public function __construct( $h5ai ) { public function __construct($h5ai) {
$this->h5ai = $h5ai; $this->h5ai = $h5ai;
} }
public function getHeader() { public function getHeader() {
return $this->getContent( $this->h5ai->getAbsPath() . "/" . "h5ai.header.html", "header" ); return $this->getContent($this->h5ai->getAbsPath() . "/" . "h5ai.header.html", "header");
} }
public function getFooter() { public function getFooter() {
return $this->getContent( $this->h5ai->getAbsPath() . "/" . "h5ai.footer.html", "footer" ); return $this->getContent($this->h5ai->getAbsPath() . "/" . "h5ai.footer.html", "footer");
} }
private function getContent( $file, $tag ) { private function getContent($file, $tag) {
return file_exists( $file ) ? ( "<" . $tag . ">" . file_get_contents( $file ) . "</" . $tag . ">" ) : ""; return file_exists($file) ? ("<" . $tag . ">" . file_get_contents($file) . "</" . $tag . ">") : "";
} }
} }
?> ?>

View File

@@ -1,205 +1,223 @@
<?php <?php
require_once "thumbnail.php";
class Entry { class Entry {
private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size; private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size, $thumbTypes;
public function __construct( $h5ai, $absPath, $absHref, $type = null, $label = null ) { public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) {
$this->h5ai = $h5ai; $this->h5ai = $h5ai;
$this->label = $label !== null ? $label : $this->h5ai->getLabel( $absHref ); $this->label = $label !== null ? $label : $this->h5ai->getLabel($absHref);
$this->absPath = $this->h5ai->normalizePath( $absPath, false ); $this->absPath = $this->h5ai->normalizePath($absPath, false);
$this->isFolder = is_dir( $this->absPath ); $this->isFolder = is_dir($this->absPath);
$this->absHref = $this->h5ai->normalizePath( $absHref, $this->isFolder ); $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder);
$this->date = filemtime( $this->absPath );
if ( $this->isFolder ) { $this->date = filemtime($this->absPath);
$this->type = $type !== null ? $type : "folder";
$this->size = "";
} else {
$this->type = $type !== null ? $type : $this->h5ai->getType( $this->absPath );
$this->size = filesize( $this->absPath );
}
}
public function isFolder() { if ($this->isFolder) {
$this->type = $type !== null ? $type : "folder";
$this->size = "";
} else {
$this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath);
$this->size = filesize($this->absPath);
}
return $this->isFolder; $this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff");
} }
function compare( $that, $sortOrder ) { public function isFolder() {
if ( $this->isFolder && !$that->isFolder ) { return $this->isFolder;
return -1; }
}
if ( !$this->isFolder && $that->isFolder ) {
return 1;
}
$res = 0; function compare($that, $sortOrder) {
if ( $sortOrder[ "column" ] === "name" ) {
$res = strcasecmp( $this->absPath, $that->absPath );
} else if ( $sortOrder[ "column" ] === "date" ) {
$res = $this->date - $that->date;
} else if ( $sortOrder[ "column" ] === "size" ) {
$res = $this->size - $that->size;
}
if ( ! $sortOrder[ "ascending" ] ) {
$res = -$res;
}
return $res;
}
public function toHtml( $dateFormat ) { if ($this->isFolder && !$that->isFolder) {
return -1;
}
if (!$this->isFolder && $that->isFolder) {
return 1;
}
$classes = "entry " . $this->type; $res = 0;
$img = $this->type; if ($sortOrder[ "column" ] === "name") {
$hint = ""; $res = strcasecmp($this->absPath, $that->absPath);
$dateLabel = date( $dateFormat, $this->date ); } else if ($sortOrder[ "column" ] === "date") {
$res = $this->date - $that->date;
} else if ($sortOrder[ "column" ] === "size") {
$res = $this->size - $that->size;
}
if (! $sortOrder[ "ascending" ]) {
$res = -$res;
}
return $res;
}
if ( $this->isFolder && $this->type !== "folder-parent" ) { public function toHtml($dateFormat) {
$code = $this->h5ai->getHttpCode( $this->absHref );
$classes .= " checkedHttpCode";
if ( $code !== "h5ai" ) {
if ( $code === 200 ) {
$img = "folder-page";
} else {
$classes .= " error";
$hint = "<span class='hint'> " . $code . " </span>";
}
}
}
$html = "\t<li class='" . $classes . "'>\n"; $classes = "entry " . $this->type;
$html .= "\t\t<a href='" . $this->absHref . "'>\n"; $img = $this->type;
$html .= "\t\t\t<span class='icon small'><img src='/h5ai/icons/16x16/" . $img . ".png' alt='" . $img . "' /></span>\n"; $smallImg = "/h5ai/icons/16x16/" . $this->type . ".png";
$html .= "\t\t\t<span class='icon big'><img src='/h5ai/icons/48x48/" . $img . ".png' alt='" . $img . "' /></span>\n"; $bigImg = "/h5ai/icons/48x48/" . $this->type . ".png";
$html .= "\t\t\t<span class='label'>" . $this->label . $hint . "</span>\n"; $hint = "";
$html .= "\t\t\t<span class='date'>" . $dateLabel . "</span>\n"; $dateLabel = date($dateFormat, $this->date);
$html .= "\t\t\t<span class='size'>" . $this->formatSize( $this->size ) . "</span>\n";
$html .= "\t\t</a>\n";
$html .= "\t</li>\n";
return $html;
}
if ($this->isFolder && $this->type !== "folder-parent") {
private function formatSize( $size ) { $code = $this->h5ai->getHttpCode($this->absHref);
$classes .= " checkedHttpCode";
if ($code !== "h5ai") {
if ($code === 200) {
$img = "folder-page";
$smallImg = "/h5ai/icons/16x16/folder-page.png";
$bigImg = "/h5ai/icons/48x48/folder-page.png";
} else {
$classes .= " error";
$hint = "<span class='hint'> " . $code . " </span>";
}
}
}
if ($this->h5ai->showThumbs() && in_array($this->type, $this->thumbTypes)) {
$classes .= " thumb";
$thumbnail = new Thumbnail($this->absPath, "square", 16, 16);
$thumbnail->create();
$smallImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref();
$thumbnail = new Thumbnail($this->absPath, "rational", 96, 46);
$thumbnail->create();
$bigImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref();
}
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); $html = "\t<li class='" . $classes . "'>\n";
for ( $i = 0; $size >= 1024 && $i < 4; $i++ ) { $html .= "\t\t<a href='" . $this->absHref . "'>\n";
$size /= 1024; $html .= "\t\t\t<span class='icon small'><img src='" . $smallImg . "' alt='" . $img . "' /></span>\n";
} $html .= "\t\t\t<span class='icon big'><img src='" . $bigImg . "' alt='" . $img . "' /></span>\n";
return round( $size, 0 ) . " " . $units[$i]; $html .= "\t\t\t<span class='label'>" . $this->label . $hint . "</span>\n";
} $html .= "\t\t\t<span class='date'>" . $dateLabel . "</span>\n";
$html .= "\t\t\t<span class='size'>" . $this->formatSize($this->size) . "</span>\n";
$html .= "\t\t</a>\n";
$html .= "\t</li>\n";
return $html;
}
private function formatSize($size) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
for ($i = 0; $size >= 1024 && $i < 4; $i++) {
$size /= 1024;
}
return round($size, 0) . " " . $units[$i];
}
} }
class Extended { class Extended {
private $h5ai, $parent, $content; private $h5ai, $parent, $content;
public function __construct( $h5ai ) { public function __construct($h5ai) {
$this->h5ai = $h5ai; $this->h5ai = $h5ai;
$this->parent = null; $this->parent = null;
$this->content = array(); $this->content = array();
$this->loadContent(); $this->loadContent();
} }
private function loadContent() { private function loadContent() {
if ( $this->h5ai->getAbsHref() !== "/" ) { if ($this->h5ai->getAbsHref() !== "/") {
$options = $this->h5ai->getOptions(); $options = $this->h5ai->getOptions();
$parentPath = dirname( $this->h5ai->getAbsPath() ); $parentPath = dirname($this->h5ai->getAbsPath());
$parentHref = dirname( $this->h5ai->getAbsHref() ); $parentHref = dirname($this->h5ai->getAbsHref());
$label = $options["setParentFolderLabels"] === true ? $this->h5ai->getLabel( $parentHref ) : "<span class='l10n-parentDirectory'>Parent Directory</span>"; $label = $options["setParentFolderLabels"] === true ? $this->h5ai->getLabel($parentHref) : "<span class='l10n-parentDirectory'>Parent Directory</span>";
$this->parent = new Entry( $this->h5ai, $parentPath, $parentHref, "folder-parent", $label ); $this->parent = new Entry($this->h5ai, $parentPath, $parentHref, "folder-parent", $label);
} }
$this->content = array(); $this->content = array();
$files = $this->h5ai->readDir( $this->h5ai->getAbsPath() ); $files = $this->h5ai->readDir($this->h5ai->getAbsPath());
foreach ( $files as $file ) { foreach ($files as $file) {
$absPath = $this->h5ai->getAbsPath() . "/" . $file; $absPath = $this->h5ai->getAbsPath() . "/" . $file;
$absHref = $this->h5ai->getAbsHref() . rawurlencode( $file ); $absHref = $this->h5ai->getAbsHref() . rawurlencode($file);
$this->content[$absPath] = new Entry( $this->h5ai, $absPath, $absHref ); $this->content[$absPath] = new Entry($this->h5ai, $absPath, $absHref);
} }
$this->sort(); $this->sort();
} }
public function cmpEntries( $p1, $p2 ) { public function cmpEntries($p1, $p2) {
return $p1->compare( $p2, $this->h5ai->getSortOrder() ); return $p1->compare($p2, $this->h5ai->getSortOrder());
} }
public function sort() { public function sort() {
uasort( $this->content, array( $this, "cmpEntries" ) ); uasort($this->content, array($this, "cmpEntries"));
} }
public function getFolderCount() { public function getFolderCount() {
$count = 0; $count = 0;
foreach( $this->content as $entry ) { foreach($this->content as $entry) {
if ( $entry->isFolder() ) { if ($entry->isFolder()) {
$count++; $count++;
} }
} }
return $count; return $count;
} }
public function getFileCount() { public function getFileCount() {
$count = 0; $count = 0;
foreach( $this->content as $entry ) { foreach($this->content as $entry) {
if ( !$entry->isFolder() ) { if (!$entry->isFolder()) {
$count++; $count++;
} }
} }
return $count; return $count;
} }
public function toHtml() { public function toHtml() {
$html = "<section id='extended' class='" . $this->h5ai->getView() . "-view clearfix'>\n"; $html = "<section id='extended' class='" . $this->h5ai->getView() . "-view clearfix'>\n";
$html .= "<ul>\n"; $html .= "<ul>\n";
$html .= $this->generateHeaders(); $html .= $this->generateHeaders();
if ( $this->parent !== null ) { if ($this->parent !== null) {
$html .= $this->parent->toHtml( $this->h5ai->getDateFormat() ); $html .= $this->parent->toHtml($this->h5ai->getDateFormat());
} }
foreach( $this->content as $entry ) { foreach($this->content as $entry) {
$html .= $entry->toHtml( $this->h5ai->getDateFormat() ); $html .= $entry->toHtml($this->h5ai->getDateFormat());
} }
$html .= "</ul>\n"; $html .= "</ul>\n";
if ( count( $this->content ) === 0 ) { if (count($this->content) === 0) {
$html .= "<div class='empty l10n-empty'>empty</div>"; $html .= "<div class='empty l10n-empty'>empty</div>";
} }
$html .="</section>"; $html .="</section>";
return $html; return $html;
} }
public function generateHeaders() { public function generateHeaders() {
$asc = "<img src='/h5ai/images/ascending.png' class='sort' alt='ascending' />"; $asc = "<img src='/h5ai/images/ascending.png' class='sort' alt='ascending' />";
$desc = "<img src='/h5ai/images/descending.png' class='sort' alt='descending' />"; $desc = "<img src='/h5ai/images/descending.png' class='sort' alt='descending' />";
$so = $this->h5ai->getSortOrder(); $so = $this->h5ai->getSortOrder();
$order = $so["ascending"] ? $asc : $desc; $order = $so["ascending"] ? $asc : $desc;
$nameHref = "?col=name" . ( $so["column"] === "name" && $so["ascending"] ? "&asc=false" : "&asc=true" ); $nameHref = "?col=name" . ($so["column"] === "name" && $so["ascending"] ? "&asc=false" : "&asc=true");
$dateHref = "?col=date" . ( $so["column"] === "date" && $so["ascending"] ? "&asc=false" : "&asc=true" ); $dateHref = "?col=date" . ($so["column"] === "date" && $so["ascending"] ? "&asc=false" : "&asc=true");
$sizeHref = "?col=size" . ( $so["column"] === "size" && $so["ascending"] ? "&asc=false" : "&asc=true" ); $sizeHref = "?col=size" . ($so["column"] === "size" && $so["ascending"] ? "&asc=false" : "&asc=true");
$nameSort = $so["column"] === "name" ? $order : ""; $nameSort = $so["column"] === "name" ? $order : "";
$dateSort = $so["column"] === "date" ? $order : ""; $dateSort = $so["column"] === "date" ? $order : "";
$sizeSort = $so["column"] === "size" ? $order : ""; $sizeSort = $so["column"] === "size" ? $order : "";
$html = "\t<li class='header'>\n"; $html = "\t<li class='header'>\n";
$html .= "\t\t<a class='icon'></a>\n"; $html .= "\t\t<a class='icon'></a>\n";
$html .= "\t\t<a class='label' href='$nameHref'><span class='l10n-name'>Name</span>$nameSort</a>\n"; $html .= "\t\t<a class='label' href='$nameHref'><span class='l10n-name'>Name</span>$nameSort</a>\n";
$html .= "\t\t<a class='date' href='$dateHref'>$dateSort<span class='l10n-lastModified'>Last modified</span></a>\n"; $html .= "\t\t<a class='date' href='$dateHref'>$dateSort<span class='l10n-lastModified'>Last modified</span></a>\n";
$html .= "\t\t<a class='size' href='$sizeHref'>$sizeSort<span class='l10n-size'>Size</span></a>\n"; $html .= "\t\t<a class='size' href='$sizeHref'>$sizeSort<span class='l10n-size'>Size</span></a>\n";
$html .= "\t</li>\n"; $html .= "\t</li>\n";
return $html; return $html;
} }
} }
?> ?>

View File

@@ -3,261 +3,275 @@
require_once "cache.php"; require_once "cache.php";
class H5ai { class H5ai {
private static $SORT_ORDER = array( "column" => "name", "ascending" => true ); private static $SORT_ORDER = array("column" => "name", "ascending" => true);
private static $VIEWMODES = array( "details", "icons" ); private static $VIEWMODES = array("details", "icons");
private $docRoot, $domain, $options, $types, $cache, $absHref, $absPath, $ignore, $ignoreRE, $sortOrder, $dateFormat, $view; private $docRoot, $domain, $options, $types, $cache, $absHref, $absPath, $ignore, $ignoreRE, $sortOrder, $dateFormat, $view;
public function __construct() { public function __construct() {
$this->docRoot = getenv( "DOCUMENT_ROOT" ); $this->docRoot = getenv("DOCUMENT_ROOT");
$this->domain = getenv( "HTTP_HOST" ); $this->domain = getenv("HTTP_HOST");
$this->options = $this->loadOptions( $this->docRoot . "/h5ai/options.js" ); $this->options = $this->loadOptions($this->docRoot . "/h5ai/options.js");
$this->types = $this->loadTypes( $this->docRoot . "/h5ai/types.txt" ); $this->types = $this->loadTypes($this->docRoot . "/h5ai/types.txt");
$this->cache = new Cache( $this->docRoot . "/h5ai/cache" ); $this->cache = new Cache($this->docRoot . "/h5ai/cache");
$this->absHref = $this->normalizePath( preg_replace( '/\\?.*/', '', getenv( "REQUEST_URI" ) ), true ); $this->absHref = $this->normalizePath(preg_replace('/\\?.*/', '', getenv("REQUEST_URI")), true);
$this->absPath = $this->normalizePath( $this->docRoot . rawurldecode( $this->absHref ), false ); $this->absPath = $this->normalizePath($this->docRoot . rawurldecode($this->absHref), false);
$this->ignore = $this->options["options"]["ignore"]; $this->ignore = $this->options["options"]["ignore"];
$this->ignoreRE = $this->options["options"]["ignoreRE"]; $this->ignoreRE = $this->options["options"]["ignoreRE"];
$this->sortOrder = array(
"column" => array_key_exists( "col", $_REQUEST ) ? $_REQUEST["col"] : H5ai::$SORT_ORDER["column"],
"ascending" => array_key_exists( "asc", $_REQUEST ) ? $_REQUEST["asc"] !== "false" : H5ai::$SORT_ORDER["ascending"]
);
$this->dateFormat = $this->options["options"]["dateFormat"];
$this->view = array_key_exists( "view", $_REQUEST ) ? $_REQUEST["view"] : $this->options["options"]["viewmodes"][0];
if ( !in_array( $this->view, H5ai::$VIEWMODES ) ) {
$this->view = H5ai::$VIEWMODES[0];
}
}
$defaultSortOrder = $this->options["options"]["sortorder"];
private function loadOptions( $file ) { $this->sortOrder = array(
"column" => array_key_exists("col", $_REQUEST) ? $_REQUEST["col"] : $defaultSortOrder["column"],
$str = file_exists( $file ) ? file_get_contents( $file ) : ""; "ascending" => array_key_exists("asc", $_REQUEST) ? $_REQUEST["asc"] !== "false" : $defaultSortOrder["ascending"]
$str = preg_replace( "/\/\*.*?\*\//s", "", $str ); );
$this->dateFormat = $this->options["options"]["dateFormat"];
$optstr = preg_replace( "/^.*h5aiOptions\s*=\s*/s", "", $str ); $this->view = array_key_exists("view", $_REQUEST) ? $_REQUEST["view"] : $this->options["options"]["viewmodes"][0];
$optstr = preg_replace( "/;.*/s", "", $optstr ); if (!in_array($this->view, H5ai::$VIEWMODES)) {
$options = json_decode( $optstr, true ); $this->view = H5ai::$VIEWMODES[0];
}
$langstr = preg_replace( "/^.*h5aiLangs\s*=\s*/s", "", $str ); }
$langstr = preg_replace( "/;.*/s", "", $langstr );
$langs = json_decode( $langstr, true );
return array( "options" => $options, "langs" => $langs );
}
private function loadTypes( $file ) {
$lines = file( $file );
$types = array();
foreach( $lines as $line ) {
if ( substr( $line, 0, 1 ) === '#' ) {
continue;
}
$types[] = preg_split( "/\s+/", $line );
}
return $types;
}
public function getDocRoot() {
return $this->docRoot; private function loadOptions($file) {
}
public function getDomain() {
return $this->domain; $str = file_exists($file) ? file_get_contents($file) : "";
} $str = preg_replace("/\/\*.*?\*\//s", "", $str);
public function getView() {
return $this->view; $optstr = preg_replace("/^.*h5aiOptions\s*=\s*/s", "", $str);
} $optstr = preg_replace("/;.*/s", "", $optstr);
$options = json_decode($optstr, true);
public function getOptions() {
return $this->options["options"] ; $langstr = preg_replace("/^.*h5aiLangs\s*=\s*/s", "", $str);
} $langstr = preg_replace("/;.*/s", "", $langstr);
$langs = json_decode($langstr, true);
public function getLangs() {
return $this->options["langs"]; return array("options" => $options, "langs" => $langs);
} }
public function getAbsHref( $absPath = null, $endWithSlash = true ) {
if ( $absPath === null ) { private function loadTypes($file) {
return $this->absHref;
}
return $this->normalizePath( rawurlencode( preg_replace( "!^" . $this->docRoot . "!", "", $absPath ) ), $endWithSlash );
}
public function getAbsPath( $absHref = null ) {
if ( $absHref === null ) { $lines = file($file);
return $this->absPath; $types = array();
} foreach($lines as $line) {
return $this->normalizePath( $this->docRoot . rawurldecode( $absHref ), false ); if (substr($line, 0, 1) === '#') {
} continue;
}
public function getSortOrder() { $types[] = preg_split("/\s+/", $line);
}
return $types;
}
return $this->sortOrder; public function getDocRoot() {
}
public function getDateFormat() { return $this->docRoot;
}
return $this->dateFormat; public function getDomain() {
}
public function getTitle() {
$title = $this->domain . rawurldecode( $this->absHref ); return $this->domain;
$title = preg_replace( "/\/$/", "", $title ); }
$title = preg_replace( "/\//", " > ", $title );
if ( $this->absHref !== "/" ) {
$title = basename( $this->absPath ) . " - " . $title;
}
return $title;
}
public function getType( $absPath ) { public function getView() {
foreach( $this->types as $type ) { return $this->view;
foreach( array_slice( $type, 1 ) as $pattern ) { }
if ( $this->endsWith( $absPath, $pattern ) ) {
return $type[0];
}
}
}
return "unknown";
}
public function ignoreThisFile( $file ) { public function getOptions() {
# always ignore return $this->options["options"];
if ( $file === "." || $file === ".." || $this->startsWith( $file, '.ht' ) ) { }
return true;
}
if ( in_array( $file, $this->ignore ) ) { public function getLangs() {
return true;
}
foreach ( $this->ignoreRE as $re ) {
if ( preg_match( $re, $file ) ) {
return true;
}
}
return false; return $this->options["langs"];
} }
public function readDir( $path ) { public function getAbsHref($absPath = null, $endWithSlash = true) {
$content = array(); if ($absPath === null) {
if ( is_dir( $path ) ) { return $this->absHref;
if ( $dir = opendir( $path ) ) { }
while ( ( $file = readdir( $dir ) ) !== false ) { $absHref = preg_replace("!^" . $this->docRoot . "!", "", $absPath);
if ( ! $this->ignoreThisFile( $file ) ) { $parts = explode("/", $absHref);
$content[] = $file; $encodedParts = array();
} foreach ($parts as $part) {
} $encodedParts[] = rawurlencode($part);
closedir( $dir ); }
} $endodedAbsHref = implode("/", $encodedParts);
} return $this->normalizePath($endodedAbsHref, $endWithSlash);
return $content; }
}
public function getLabel( $absHref ) { public function getAbsPath($absHref = null) {
return $absHref === "/" ? $this->domain : rawurldecode( basename( $absHref ) ); if ($absHref === null) {
} return $this->absPath;
}
return $this->normalizePath($this->docRoot . rawurldecode($absHref), false);
}
public function normalizePath( $path, $endWithSlash ) { public function getSortOrder() {
return ( $path === "/" ) ? "/" : ( preg_replace( '#/$#', '', $path ) . ( $endWithSlash ? "/" : "" ) ); return $this->sortOrder;
} }
public function startsWith( $sequence, $start ) {
return substr( $sequence, 0, strlen( $start ) ) === $start;
}
public function endsWith( $sequence, $end ) { public function getDateFormat() {
return substr( $sequence, -strlen( $end ) ) === $end; return $this->dateFormat;
} }
public function getHttpCode( $absHref ) { public function showThumbs() {
return $this->cachedHttpCode( $absHref ); return $this->options["options"]["showThumbs"] === true;
#return $this->fetchHttpCode( $absHref ); }
#return $this->guessHttpCode( $absHref );
}
public function cachedHttpCode( $absHref ) { public function getTitle() {
$cached = $this->cache->get( $absHref ); $title = $this->domain . rawurldecode($this->absHref);
if ( $cached === false ) { $title = preg_replace("/\/$/", "", $title);
$folderStatus = $this->options["options"]["folderStatus"]; $title = preg_replace("/\//", " > ", $title);
if ( array_key_exists( $absHref, $folderStatus ) ) { if ($this->absHref !== "/") {
$code = $folderStatus[$absHref]; $title = basename($this->absPath) . " - " . $title;
} else { }
$code = $this->fetchHttpCode( $absHref ); return $title;
} }
$cached = array( "href" => $absHref, "code" => $code );
$this->cache->set( $absHref, $cached );
}
return $cached["code"];
}
public function fetchHttpCode( $absHref ) { public function getType($absPath) {
$contentType = "Content-Type:"; foreach($this->types as $type) {
$h5aiContentType = "Content-Type: text/html;h5ai="; foreach(array_slice($type, 1) as $pattern) {
$host = getenv( "HTTP_HOST" ); if ($this->endsWith($absPath, $pattern)) {
$port = getenv( "SERVER_PORT" ); return $type[0];
$msg = "HEAD $absHref HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n"; }
}
$errno = ""; }
$errstr = ""; return "unknown";
$socket = fsockopen( $host, $port, $errno, $errstr, 30 ); }
if( $socket === 0 ) {
return null;
}
fwrite( $socket, $msg ); public function ignoreThisFile($file) {
$content = fgets( $socket );
$code = intval( trim( substr( $content, 9, 4 ) ) );
if ( $code === 200 ) {
while ( ! $this->startsWith( $content, $contentType ) ) {
$content = fgets( $socket );
}
if ( $this->startsWith( $content, $h5aiContentType ) ) {
$code = "h5ai";
}
}
fclose( $socket );
return $code;
}
public function guessHttpCode( $absHref ) { # always ignore
if ($file === "." || $file === ".." || $this->startsWith($file, '.ht')) {
return true;
}
$indexFiles = array( "index.html", "index.cgi", "index.pl", "index.php", "index.xhtml", "index.htm" ); if (in_array($file, $this->ignore)) {
$absPath = $this->getAbsPath( $absHref ); return true;
$files = $this->readDir( $absPath ); }
foreach ( $files as $file ) { foreach ($this->ignoreRE as $re) {
if ( in_array( $file, $indexFiles ) ) { if (preg_match($re, $file)) {
return 200; return true;
} }
} }
return "h5ai";
} return false;
}
public function readDir($path) {
$content = array();
if (is_dir($path)) {
if ($dir = opendir($path)) {
while (($file = readdir($dir)) !== false) {
if (!$this->ignoreThisFile($file)) {
$content[] = $file;
}
}
closedir($dir);
}
}
return $content;
}
public function getLabel($absHref) {
return $absHref === "/" ? $this->domain : rawurldecode(basename($absHref));
}
public function normalizePath($path, $endWithSlash) {
return ($path === "/") ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : ""));
}
public function startsWith($sequence, $start) {
return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0;
}
public function endsWith($sequence, $end) {
return strcasecmp(substr($sequence, -strlen($end)), $end) === 0;
}
public function getHttpCode($absHref) {
return $this->cachedHttpCode($absHref);
#return $this->fetchHttpCode($absHref);
#return $this->guessHttpCode($absHref);
}
public function cachedHttpCode($absHref) {
$cached = $this->cache->get($absHref);
if ($cached === false) {
$folderStatus = $this->options["options"]["folderStatus"];
if (array_key_exists($absHref, $folderStatus)) {
$code = $folderStatus[$absHref];
} else {
$code = $this->fetchHttpCode($absHref);
}
$cached = array("href" => $absHref, "code" => $code);
$this->cache->set($absHref, $cached);
}
return $cached["code"];
}
public function fetchHttpCode($absHref) {
$contentType = "Content-Type:";
$h5aiContentType = "Content-Type: text/html;h5ai=";
$host = getenv("HTTP_HOST");
$port = getenv("SERVER_PORT");
$msg = "HEAD $absHref HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n";
$errno = "";
$errstr = "";
$socket = fsockopen($host, $port, $errno, $errstr, 30);
if($socket === 0) {
return null;
}
fwrite($socket, $msg);
$content = fgets($socket);
$code = intval(trim(substr($content, 9, 4)));
if ($code === 200) {
while (! $this->startsWith($content, $contentType)) {
$content = fgets($socket);
}
if ($this->startsWith($content, $h5aiContentType)) {
$code = "h5ai";
}
}
fclose($socket);
return $code;
}
public function guessHttpCode($absHref) {
$indexFiles = array("index.html", "index.cgi", "index.pl", "index.php", "index.xhtml", "index.htm");
$absPath = $this->getAbsPath($absHref);
$files = $this->readDir($absPath);
foreach ($files as $file) {
if (in_array($file, $indexFiles)) {
return 200;
}
}
return "h5ai";
}
} }
?> ?>

View File

@@ -2,22 +2,22 @@
require_once "h5ai.php"; require_once "h5ai.php";
function getHttpCodes( $h5ai, $hrefs ) { function getHttpCodes($h5ai, $hrefs) {
$codes = array(); $codes = array();
foreach ( $hrefs as $href ) { foreach ($hrefs as $href) {
$href = trim( $href ); $href = trim($href);
if ( strlen( $href ) > 0 ) { if (strlen($href) > 0) {
$codes[$href] = $h5ai->getHttpCode( $href ); $codes[$href] = $h5ai->getHttpCode($href);
} }
} }
return $codes; return $codes;
} }
$h5ai = new H5ai(); $h5ai = new H5ai();
$hrefs = preg_split( "/;/", array_key_exists( "hrefs", $_REQUEST ) ? $_REQUEST[ "hrefs" ] : "" ); $hrefs = preg_split("/;/", array_key_exists("hrefs", $_REQUEST) ? $_REQUEST[ "hrefs" ] : "");
$codes = getHttpCodes( $h5ai, $hrefs ); $codes = getHttpCodes($h5ai, $hrefs);
echo count( $codes ) === 0 ? "{}" : json_encode( $codes ); echo count($codes) === 0 ? "{}" : json_encode($codes);
?> ?>

202
src/h5ai/php/image.php Normal file
View File

@@ -0,0 +1,202 @@
<?php
class Image {
private $sourceFile;
private $source;
private $width;
private $height;
private $type;
private $dest;
public static function isUsable() {
return GD_VERSION != "GD_VERSION";
}
public function __construct($filename = null) {
$this->sourceFile = null;
$this->source = null;
$this->width = null;
$this->height = null;
$this->type = null;
$this->dest = null;
$this->setSource($filename);
}
public function __destruct() {
$this->releaseSource();
$this->releaseDest();
}
public function setSource($filename) {
$this->releaseSource();
$this->releaseDest();
if (is_null($filename))
return;
$this->sourceFile = $filename;
list($this->width, $this->height, $this->type) = getimagesize($this->sourceFile);
$this->source = imagecreatefromstring(file_get_contents($this->sourceFile));
}
public function showDest() {
if (!is_null($this->dest)) {
header("Content-type: image/jpeg");
imagejpeg($this->dest, null, 100);
}
}
public function saveDest($filename) {
if (!is_null($this->dest)) {
@imagejpeg($this->dest, $filename, 90);
@chmod($filename, 0775);
}
}
public function releaseDest() {
if (!is_null($this->dest)) {
imagedestroy($this->dest);
$this->dest = null;
}
}
public function releaseSource() {
if (!is_null($this->source)) {
imagedestroy($this->source);
$this->sourceFile = null;
$this->source = null;
$this->width = null;
$this->height = null;
$this->type = null;
}
}
public static function showImage($filename) {
$image = file_get_contents($filename);
header("content-type: image");
echo $image;
}
private function magic($destX, $destY, $srcX, $srcY, $destWidth, $destHeight, $srcWidth, $srcHeight, $canWidth = null, $canHeight = null, $color = null) {
if (!is_null($canWidth) && !is_null($canHeight)) {
$this->dest = imagecreatetruecolor($canWidth, $canHeight);
} else {
$this->dest = imagecreatetruecolor($destWidth, $destHeight);
}
if (is_null($color)) {
$color = array(255, 255, 255);
}
$icol = imagecolorallocate($this->dest, $color[0], $color[1], $color[2]);
imagefill($this->dest, 0, 0, $icol);
imagecopyresampled($this->dest, $this->source, $destX, $destY, $srcX, $srcY, $destWidth, $destHeight, $srcWidth, $srcHeight);
}
public function thumb($mode, $width, $height = null, $color = null) {
if ($height === null) {
$height = $width;
}
if ($mode === "square") {
$this->squareThumb($width);
} elseif ($mode === "rational") {
$this->rationalThumb($width, $height);
} elseif ($mode === "center") {
$this->centerThumb($width, $height, $color);
} else {
$this->freeThumb($width, $height);
}
}
public function squareThumb($width) {
$a = min($this->width, $this->height);
$x = intval(($this->width - $a) / 2);
$y = intval(($this->height - $a) / 2);
$this->magic(0, 0, $x, $y, $width, $width, $a, $a);
}
public function rationalThumb($width, $height) {
$r = 1.0 * $this->width / $this->height;
$h = $height;
$w = $r * $h;
if ($w > $width) {
$w = $width;
$h = 1.0 / $r * $w;
}
$w = intval($w);
$h = intval($h);
$this->magic(0, 0, 0, 0, $w, $h, $this->width, $this->height);
}
public function centerThumb($width, $height, $color = null) {
$r = 1.0 * $this->width / $this->height;
$h = $height;
$w = $r * $h;
if ($w > $width) {
$w = $width;
$h = 1.0 / $r * $w;
}
$w = intval($w);
$h = intval($h);
$x = intval(($width - $w) / 2);
$y = intval(($height - $h) / 2);
$this->magic($x, $y, 0, 0, $w, $h, $this->width, $this->height, $width, $height, $color);
}
public function freeThumb($width, $height) {
$w = intval($width);
$h = intval($height);
$this->magic(0, 0, 0, 0, $w, $h, $this->width, $this->height);
}
}
?>

View File

@@ -7,9 +7,9 @@ require_once "extended.php";
require_once "tree.php"; require_once "tree.php";
$h5ai = new H5ai(); $h5ai = new H5ai();
$crumb = new Crumb( $h5ai ); $crumb = new Crumb($h5ai);
$customize = new Customize( $h5ai ); $customize = new Customize($h5ai);
$extended = new Extended( $h5ai ); $extended = new Extended($h5ai);
$tree = new Tree( $h5ai ); $tree = new Tree($h5ai);
?> ?>

26
src/h5ai/php/thumb.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
require_once "thumbnail.php";
$src = $_REQUEST["src"];
$width = $_REQUEST["width"];
$height = $_REQUEST["height"];
$mode = $_REQUEST["mode"];
if (!Thumbnail::isUsable()) {
Image::showImage($src);
exit;
}
$thumbnail = new Thumbnail($src, $mode, $width, $height);
$thumbnail->create(1);
if (file_exists($thumbnail->getPath())) {
Image::showImage($thumbnail->getPath());
} else {
$image = new Image();
$image->setSource($src);
$image->thumb($mode, $width, $height);
$image->showDest();
}
?>

View File

@@ -0,0 +1,56 @@
<?php
require_once "image.php";
class Thumbnail {
private $src, $width, $height, $name, $href, $path;
public static function isUsable() {
return Image::isUsable();
}
public function __construct($src, $mode, $width, $height) {
$this->src = $src;
$this->width = $width;
$this->height = $height;
$this->mode = $mode;
$this->name = sha1("$this->src-$this->width-$this->height-$this->mode");
$this->href = "/h5ai/cache/thumb-" . $this->name . ".jpg";
$this->path = getenv("DOCUMENT_ROOT") . $this->href;
$this->liveHref = "/h5ai/php/thumb.php?src=" . $this->src . "&width=" . $this->width . "&height=" . $this->height . "&mode=" . $this->mode;
}
public function create($force = 0) {
if (
$force === 2
|| ($force === 1 && !file_exists($this->path))
|| (file_exists($this->path) && filemtime($this->src) >= filemtime($this->path))
) {
$image = new Image();
$image->setSource($this->src);
$image->thumb($this->mode, $this->width, $this->height);
$image->saveDest($this->path);
}
}
public function getHref() {
return $this->href;
}
public function getPath() {
return $this->path;
}
public function getLiveHref() {
return $this->liveHref;
}
}
?>

View File

@@ -1,146 +1,146 @@
<?php <?php
class TreeEntry { class TreeEntry {
private $h5ai, $label, $absPath, $absHref, $isFolder, $type, $content; private $h5ai, $label, $absPath, $absHref, $isFolder, $type, $content;
public function __construct( $h5ai, $absPath, $absHref, $type = null ) { public function __construct($h5ai, $absPath, $absHref, $type = null) {
$this->h5ai = $h5ai; $this->h5ai = $h5ai;
$this->label = $this->h5ai->getLabel( $absHref ); $this->label = $this->h5ai->getLabel($absHref);
$this->absPath = $this->h5ai->normalizePath( $absPath, false ); $this->absPath = $this->h5ai->normalizePath($absPath, false);
$this->isFolder = is_dir( $this->absPath ); $this->isFolder = is_dir($this->absPath);
$this->absHref = $this->h5ai->normalizePath( $absHref, $this->isFolder ); $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder);
$this->type = $type !== null ? $type : ( $this->isFolder ? "folder" : $this->h5ai->getType( $this->absPath ) ); $this->type = $type !== null ? $type : ($this->isFolder ? "folder" : $this->h5ai->getType($this->absPath));
$this->content = null; $this->content = null;
} }
public function loadContent() { public function loadContent() {
$this->content = array(); $this->content = array();
if ( $this->h5ai->getHttpCode( $this->absHref ) !== "h5ai" ) { if ($this->h5ai->getHttpCode($this->absHref) !== "h5ai") {
return; return;
} }
$files = $this->h5ai->readDir( $this->absPath );
foreach ( $files as $file ) {
$tree = new TreeEntry( $this->h5ai, $this->absPath . "/" . $file, $this->absHref . rawurlencode( $file ) );
if ( $tree->isFolder ) { $files = $this->h5ai->readDir($this->absPath);
$this->content[$tree->absPath] = $tree; foreach ($files as $file) {
} $tree = new TreeEntry($this->h5ai, $this->absPath . "/" . $file, $this->absHref . rawurlencode($file));
}
$this->sort(); if ($tree->isFolder) {
} $this->content[$tree->absPath] = $tree;
}
}
public function cmpTrees( $t1, $t2 ) { $this->sort();
}
if ( $t1->isFolder && !$t2->isFolder ) { public function cmpTrees($t1, $t2) {
return -1;
}
if ( !$t1->isFolder && $t2->isFolder ) {
return 1;
}
return strcasecmp( $t1->absPath, $t2->absPath );
}
public function sort() { if ($t1->isFolder && !$t2->isFolder) {
return -1;
}
if (!$t1->isFolder && $t2->isFolder) {
return 1;
}
return strcasecmp($t1->absPath, $t2->absPath);
}
if ( $this->content !== null ) { public function sort() {
uasort( $this->content, array( $this, "cmpTrees" ) );
}
}
public function toHtml() { if ($this->content !== null) {
uasort($this->content, array($this, "cmpTrees"));
}
}
$classes = "entry " . $this->type . ( $this->absHref === $this->h5ai->getAbsHref() ? " current" : "" ); public function toHtml() {
$img = $this->type;
if ( $this->absHref === "/" ) {
$img = "folder-home";
}
$hint = "";
$code = "h5ai";
if ( $this->isFolder ) { $classes = "entry " . $this->type . ($this->absHref === $this->h5ai->getAbsHref() ? " current" : "");
$code = $this->h5ai->getHttpCode( $this->absHref ); $img = $this->type;
$classes .= " checkedHttpCode"; if ($this->absHref === "/") {
if ( $code !== "h5ai" ) { $img = "folder-home";
if ( $code === 200 ) { }
$img = "folder-page"; $hint = "";
$hint = "<span class='hint'><img src='/h5ai/images/page.png' alt='page' /></span>"; $code = "h5ai";
} else {
$classes .= " error";
$hint = "<span class='hint'> " . $code . " </span>";
}
}
}
$html = "<div class='" . $classes ."'>\n"; if ($this->isFolder) {
if ( $this->content !== null && count( $this->content ) === 0 || $code !== "h5ai" ) { $code = $this->h5ai->getHttpCode($this->absHref);
$html .= "<span class='blank'></span>\n"; $classes .= " checkedHttpCode";
} else { if ($code !== "h5ai") {
$indicatorState = $this->content === null ? " unknown" : " open"; if ($code === 200) {
$html .= "<span class='indicator" . $indicatorState . "'><img src='/h5ai/images/tree.png' alt='>' /></span>\n"; $img = "folder-page";
} $hint = "<span class='hint'><img src='/h5ai/images/page.png' alt='page' /></span>";
$html .= "<a href='" . $this->absHref . "'>\n"; } else {
$html .= "<span class='icon'><img src='/h5ai/icons/16x16/" . $img . ".png' alt='" . $img . "' /></span>\n"; $classes .= " error";
$html .= "<span class='label'>" . $this->label . "</span>" . $hint . "\n"; $hint = "<span class='hint'> " . $code . " </span>";
$html .= "</a>\n"; }
$html .= $this->contentToHtml(); }
$html .= "</div>\n"; }
return $html;
}
public function contentToHtml() { $html = "<div class='" . $classes ."'>\n";
if ($this->content !== null && count($this->content) === 0 || $code !== "h5ai") {
$html .= "<span class='blank'></span>\n";
} else {
$indicatorState = $this->content === null ? " unknown" : " open";
$html .= "<span class='indicator" . $indicatorState . "'><img src='/h5ai/images/tree.png' alt='>' /></span>\n";
}
$html .= "<a href='" . $this->absHref . "'>\n";
$html .= "<span class='icon'><img src='/h5ai/icons/16x16/" . $img . ".png' alt='" . $img . "' /></span>\n";
$html .= "<span class='label'>" . $this->label . "</span>" . $hint . "\n";
$html .= "</a>\n";
$html .= $this->contentToHtml();
$html .= "</div>\n";
return $html;
}
$html = "<ul class='content'>\n"; public function contentToHtml() {
if ( $this->content !== null ) {
foreach( $this->content as $tree ) {
$html .= "<li>" . $tree->toHtml() . "</li>";
}
}
$html .= "</ul>\n";
return $html;
}
public function getRoot() { $html = "<ul class='content'>\n";
if ($this->content !== null) {
foreach($this->content as $tree) {
$html .= "<li>" . $tree->toHtml() . "</li>";
}
}
$html .= "</ul>\n";
return $html;
}
if ( $this->absHref === "/" ) { public function getRoot() {
return $this;
};
$tree = new TreeEntry( $this->h5ai, dirname( $this->absPath ), dirname( $this->absHref ) ); if ($this->absHref === "/") {
$tree->loadContent(); return $this;
$tree->content[ $this->absPath ] = $this; };
return $tree->getRoot(); $tree = new TreeEntry($this->h5ai, dirname($this->absPath), dirname($this->absHref));
} $tree->loadContent();
$tree->content[ $this->absPath ] = $this;
return $tree->getRoot();
}
} }
class Tree { class Tree {
private $h5ai; private $h5ai;
public function __construct( $h5ai ) { public function __construct($h5ai) {
$this->h5ai = $h5ai; $this->h5ai = $h5ai;
} }
public function toHtml() { public function toHtml() {
$options = $this->h5ai->getOptions(); $options = $this->h5ai->getOptions();
if ( $options["showTree"] === false ) { if ($options["showTree"] === false) {
return ""; return "";
} }
$tree = new TreeEntry( $this->h5ai, $this->h5ai->getAbsPath(), $this->h5ai->getAbsHref() ); $tree = new TreeEntry($this->h5ai, $this->h5ai->getAbsPath(), $this->h5ai->getAbsHref());
$tree->loadContent(); $tree->loadContent();
$root = $tree->getRoot(); $root = $tree->getRoot();
return "<section id='tree'>\n" . $root->toHtml() . "</section>\n"; return "<section id='tree'>\n" . $root->toHtml() . "</section>\n";
} }
} }

View File

@@ -1,18 +1,18 @@
<?php <?php
if ( ! array_key_exists( "href", $_REQUEST ) ) { if (!array_key_exists("href", $_REQUEST)) {
exit; exit;
} }
require_once "h5ai.php"; require_once "h5ai.php";
require_once "tree.php"; require_once "tree.php";
$h5ai = new H5ai(); $h5ai = new H5ai();
$absHref = trim( $_REQUEST[ "href" ] ); $absHref = trim($_REQUEST[ "href" ]);
$absPath = $h5ai->getAbsPath( $absHref ); $absPath = $h5ai->getAbsPath($absHref);
$tree = new TreeEntry( $h5ai, $absPath, $absHref ); $tree = new TreeEntry($h5ai, $absPath, $absHref);
$tree->loadContent(); $tree->loadContent();
echo $tree->contentToHtml(); echo $tree->contentToHtml();

View File

@@ -0,0 +1,28 @@
<?php
if (!array_key_exists("hrefs", $_REQUEST)) {
echo "failed";
exit;
}
require_once "h5ai.php";
require_once "zipit.php";
$h5ai = new H5ai();
$zipit = new ZipIt($h5ai);
$hrefs = explode(":", trim($_REQUEST["hrefs"]));
$zipFile = $zipit->zip($hrefs);
if ($zipFile !== false) {
header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\"");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($zipFile));
header("Connection: close");
readfile($zipFile);
} else {
echo "sorry, something went wrong while building the zip.";
}
?>

63
src/h5ai/php/zipit.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
class ZipIt {
private $h5ai;
public function __construct($h5ai) {
$this->h5ai = $h5ai;
}
public function zip($hrefs) {
$zipFile = tempnam("/tmp", "h5ai-download");
$zip = new ZipArchive();
if (!$zip->open($zipFile, ZIPARCHIVE::CREATE)) {
return false;
}
foreach ($hrefs as $href) {
$d = dirname($href);
$n = basename($href);
if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($d)) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) {
$localFile = $this->h5ai->getAbsPath($href);
$file = preg_replace("!^" . $this->h5ai->getDocRoot() . "!", "", $localFile);
if (is_dir($localFile)) {
$this->zipDir($zip, $localFile, $file);
} else {
$this->zipFile($zip, $localFile, $file);
}
}
}
$zip->close();
return $zipFile;
}
private function zipFile($zip, $localFile, $file) {
if (is_readable($localFile)) {
$zip->addFile($localFile, $file);
}
}
private function zipDir($zip, $localDir, $dir) {
if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") {
$zip->addEmptyDir($dir);
$files = $this->h5ai->readDir($localDir);
foreach ($files as $file) {
$localFile = $localDir . "/" . $file;
$file = $dir . "/" . $file;
if (is_dir($localFile)) {
$this->zipDir($zip, $localFile, $file);
} else {
$this->zipFile($zip, $localFile, $file);
}
}
}
}
}
?>

View File

@@ -9,115 +9,105 @@
################################ ################################
# IMPORTANT FOR XAMPP # h5ai header and footer
# if you're running XAMPP you might need to replace the
# following line with
# <IfModule autoindex_color_module>
################################ ################################
<IfModule autoindex_module>
HeaderName /h5ai/header.html
ReadmeName /h5ai/footer.html
################################ ################################
# h5ai header and footer # hide h5ai folder and config files from index
################################ ################################
HeaderName /h5ai/header.html IndexIgnore h5ai h5ai.header.html h5ai.footer.html
ReadmeName /h5ai/footer.html
################################ ################################
# hide h5ai folder and config files from index # table options
################################ ################################
IndexIgnore h5ai h5ai.header.html h5ai.footer.html # syntax for default sort order is: IndexOrderDefault Ascending|Descending Name|Date|Size
IndexOrderDefault Ascending Name
IndexOptions Type=text/html;h5ai=%BUILD_VERSION%
IndexOptions Charset=UTF-8
IndexOptions FancyIndexing
IndexOptions HTMLTable
IndexOptions XHTML
IndexOptions SuppressHTMLPreamble
IndexOptions SuppressRules
IndexOptions SuppressDescription
IndexOptions FoldersFirst
IndexOptions IgnoreCase
IndexOptions IconsAreLinks
IndexOptions VersionSort
IndexOptions NameWidth=*
################################ ################################
# table options # icon mapping
################################ ################################
IndexOrderDefault Ascending Name AddIcon /h5ai/icons/16x16/folder-parent.png ..
AddIcon /h5ai/icons/16x16/folder.png ^^DIRECTORY^^
AddIcon /h5ai/icons/16x16/blank.png ^^BLANKICON^^
IndexOptions Type=text/html;h5ai=%BUILD_VERSION% AddIcon /h5ai/icons/16x16/readme.png README
IndexOptions Charset=UTF-8 AddIcon /h5ai/icons/16x16/copying.png COPYING LICENSE
IndexOptions FancyIndexing AddIcon /h5ai/icons/16x16/install.png INSTALL
IndexOptions HTMLTable AddIcon /h5ai/icons/16x16/authors.png AUTHORS
IndexOptions XHTML AddIcon /h5ai/icons/16x16/log.png LOG Log log
IndexOptions SuppressHTMLPreamble
IndexOptions SuppressRules AddIcon /h5ai/icons/16x16/css.png .less
IndexOptions SuppressDescription AddIcon /h5ai/icons/16x16/script.png .conf .ini .sh .shar .csh .ksh .tcl
IndexOptions FoldersFirst AddIcon /h5ai/icons/16x16/makefile.png .pom pom.xml build.xml
IndexOptions IgnoreCase AddIcon /h5ai/icons/16x16/bin.png .so .o
IndexOptions IconsAreLinks
IndexOptions VersionSort AddIcon /h5ai/icons/16x16/archive.png .tar.gz .tgz .tar.bz2
IndexOptions NameWidth=* AddIcon /h5ai/icons/16x16/zip.png .zip .Z .z .jar .war .gz .bz2
AddIcon /h5ai/icons/16x16/tar.png .tar
AddIcon /h5ai/icons/16x16/pdf.png .pdf
################################ AddIcon /h5ai/icons/16x16/deb.png .deb
# icon mapping AddIcon /h5ai/icons/16x16/rpm.png .rpm
################################ AddIcon /h5ai/icons/16x16/cd.png .iso .cue
AddIcon /h5ai/icons/16x16/folder-parent.png .. AddIconByType /h5ai/icons/16x16/png.png image/png
AddIcon /h5ai/icons/16x16/folder.png ^^DIRECTORY^^ AddIconByType /h5ai/icons/16x16/jpg.png image/jpeg
AddIcon /h5ai/icons/16x16/blank.png ^^BLANKICON^^ AddIconByType /h5ai/icons/16x16/gif.png image/gif
AddIconByType /h5ai/icons/16x16/ico.png image/x-icon
AddIcon /h5ai/icons/16x16/readme.png README AddIconByType /h5ai/icons/16x16/bmp.png image/x-ms-bmp
AddIcon /h5ai/icons/16x16/copying.png COPYING LICENSE
AddIcon /h5ai/icons/16x16/install.png INSTALL AddIconByType /h5ai/icons/16x16/html.png text/html
AddIcon /h5ai/icons/16x16/authors.png AUTHORS AddIconByType /h5ai/icons/16x16/css.png text/css
AddIcon /h5ai/icons/16x16/log.png LOG Log log AddIconByType /h5ai/icons/16x16/xml.png application/xml
AddIconByType /h5ai/icons/16x16/js.png application/javascript application/json
AddIcon /h5ai/icons/16x16/css.png .less AddIconByType /h5ai/icons/16x16/php.png application/x-httpd-php
AddIcon /h5ai/icons/16x16/script.png .conf .ini .sh .shar .csh .ksh .tcl
AddIcon /h5ai/icons/16x16/makefile.png .pom pom.xml build.xml AddIconByType /h5ai/icons/16x16/py.png text/x-python
AddIcon /h5ai/icons/16x16/bin.png .so .o AddIconByType /h5ai/icons/16x16/rb.png application/x-ruby
AddIconByType /h5ai/icons/16x16/java.png text/x-java
AddIcon /h5ai/icons/16x16/archive.png .tar.gz .tgz .tar.bz2 AddIconByType /h5ai/icons/16x16/cpp.png text/x-c++src
AddIcon /h5ai/icons/16x16/zip.png .zip .Z .z .jar .war .gz .bz2 AddIconByType /h5ai/icons/16x16/hpp.png text/x-c++hdr
AddIcon /h5ai/icons/16x16/tar.png .tar AddIconByType /h5ai/icons/16x16/c.png text/x-csrc
AddIcon /h5ai/icons/16x16/pdf.png .pdf AddIconByType /h5ai/icons/16x16/h.png text/x-chdr
AddIcon /h5ai/icons/16x16/deb.png .deb
AddIcon /h5ai/icons/16x16/rpm.png .rpm AddIconByType /h5ai/icons/16x16/pdf.png application/pdf
AddIcon /h5ai/icons/16x16/cd.png .iso .cue
AddIconByType /h5ai/icons/16x16/rtf.png text/rtf application/rtf
AddIconByType /h5ai/icons/16x16/png.png image/png AddIconByType /h5ai/icons/16x16/tex.png text/x-tex
AddIconByType /h5ai/icons/16x16/jpg.png image/jpeg AddIconByType /h5ai/icons/16x16/makefile.png text/x-makefile
AddIconByType /h5ai/icons/16x16/gif.png image/gif
AddIconByType /h5ai/icons/16x16/ico.png image/x-icon AddIconByType /h5ai/icons/16x16/bin.png application/java-vm
AddIconByType /h5ai/icons/16x16/bmp.png image/x-ms-bmp AddIconByType /h5ai/icons/16x16/exe.png application/x-executable application/x-msdos-program
AddIconByType /h5ai/icons/16x16/html.png text/html AddIconByType /h5ai/icons/16x16/text.png text/*
AddIconByType /h5ai/icons/16x16/css.png text/css AddIconByType /h5ai/icons/16x16/image.png image/*
AddIconByType /h5ai/icons/16x16/xml.png application/xml AddIconByType /h5ai/icons/16x16/audio.png audio/*
AddIconByType /h5ai/icons/16x16/js.png application/javascript application/json AddIconByType /h5ai/icons/16x16/video.png video/*
AddIconByType /h5ai/icons/16x16/php.png application/x-httpd-php
AddIconByEncoding /h5ai/icons/16x16/zip.png x-compress x-gzip x-bzip2
AddIconByType /h5ai/icons/16x16/py.png text/x-python
AddIconByType /h5ai/icons/16x16/rb.png application/x-ruby DefaultIcon /h5ai/icons/16x16/unknown.png
AddIconByType /h5ai/icons/16x16/java.png text/x-java
AddIconByType /h5ai/icons/16x16/cpp.png text/x-c++src
AddIconByType /h5ai/icons/16x16/hpp.png text/x-c++hdr
AddIconByType /h5ai/icons/16x16/c.png text/x-csrc
AddIconByType /h5ai/icons/16x16/h.png text/x-chdr
AddIconByType /h5ai/icons/16x16/pdf.png application/pdf
AddIconByType /h5ai/icons/16x16/rtf.png text/rtf application/rtf
AddIconByType /h5ai/icons/16x16/tex.png text/x-tex
AddIconByType /h5ai/icons/16x16/makefile.png text/x-makefile
AddIconByType /h5ai/icons/16x16/bin.png application/java-vm
AddIconByType /h5ai/icons/16x16/exe.png application/x-executable application/x-msdos-program
AddIconByType /h5ai/icons/16x16/text.png text/*
AddIconByType /h5ai/icons/16x16/image.png image/*
AddIconByType /h5ai/icons/16x16/audio.png audio/*
AddIconByType /h5ai/icons/16x16/video.png video/*
AddIconByEncoding /h5ai/icons/16x16/zip.png x-compress x-gzip x-bzip2
DefaultIcon /h5ai/icons/16x16/unknown.png
</IfModule>

View File

@@ -8,22 +8,12 @@
# Options +FollowSymLinks # Options +FollowSymLinks
################################ HeaderName /h5ai/header.php
# IMPORTANT FOR XAMPP ReadmeName /h5ai/footer.php
# if you're running XAMPP you might need to replace the
# following line with
# <IfModule autoindex_color_module>
################################
<IfModule autoindex_module>
HeaderName /h5ai/header.php IndexIgnore *
ReadmeName /h5ai/footer.php
IndexIgnore * IndexOptions Type=text/html;h5ai=%BUILD_VERSION%
IndexOptions Charset=UTF-8
IndexOptions Type=text/html;h5ai=%BUILD_VERSION% IndexOptions SuppressHTMLPreamble
IndexOptions Charset=UTF-8
IndexOptions SuppressHTMLPreamble
</IfModule>

Binary file not shown.

4
tools/wepp Executable file
View File

@@ -0,0 +1,4 @@
#! /usr/bin/env node
// -*- js -*-
require("wepp").processArgs(process.argv);

40
tools/wepp.ant.xml Normal file
View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<project name="wepp.macros" basedir=".">
<macrodef name="wepp">
<attribute name="file" />
<attribute name="toFile" />
<attribute name="args" default="" />
<sequential>
<exec executable="${wepp}">
<arg line="@{args}" />
<arg value="--in" />
<arg value="@{file}" />
<arg value="--out" />
<arg value="@{toFile}" />
</exec>
</sequential>
</macrodef>
<macrodef name="wepp.dir">
<attribute name="dir" />
<attribute name="args" default="" />
<sequential>
<exec executable="${wepp}">
<arg line="@{args}" />
<arg value="--inDir" />
<arg value="@{dir}" />
<arg value="--outDir" />
<arg value="@{dir}" />
</exec>
<delete dir="@{dir}/inc">
<fileset
dir="."
includes="@{dir}/**/*.less"
excludes="@{dir}/inc/**,@{dir}/lib/**"
/>
</delete>
</sequential>
</macrodef>
</project>