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

Compare commits

..

7 Commits
v0.5.3 ... v0.6

Author SHA1 Message Date
Lars Jung
e4646734f2 Added localization. 2011-07-05 01:39:45 +02:00
Lars Jung
e54abe08ca Added folder effects to details and icons view. Moved some icons. 2011-07-04 20:14:24 +02:00
Lars Jung
faaddd8d60 Remove screenshots. 2011-07-04 16:31:05 +02:00
Lars Jung
d599425452 Some comments and documentation. 2011-07-04 16:26:35 +02:00
Lars Jung
3e6197d2fc Added comments in options.js. 2011-07-04 12:51:34 +02:00
Lars Jung
ecf93da505 Forgot to remove local options. 2011-07-04 02:24:12 +02:00
Lars Jung
e91a127771 Forgot to remove local options. 2011-07-04 02:23:43 +02:00
30 changed files with 347 additions and 79 deletions

View File

@@ -1,14 +1,14 @@
# h5ai v0.5.3   ·   a beautified Apache index
# h5ai v0.6   ·   a beautified Apache index
## Screenshots
<a href="http://github.com/lrsjng/h5ai/raw/master/resources/h5ai-v0.4-details.png" target="_blank">
<img src="http://github.com/lrsjng/h5ai/raw/master/resources/h5ai-v0.4-details.png" width="400px" alt="screenshot" title="screenshot" style="display: inline" />
<a href="http://larsjung.de/h5ai/sample/screenshots/h5ai-v0.5.2-details.png" target="_blank">
<img src="http://larsjung.de/h5ai/sample/screenshots/h5ai-v0.5.2-details.png" width="400px" alt="screenshot" title="details view" style="display: inline" />
</a>
&#160; &#160; &#160;
<a href="http://github.com/lrsjng/h5ai/raw/master/resources/h5ai-v0.4-icons.png" target="_blank">
<img src="http://github.com/lrsjng/h5ai/raw/master/resources/h5ai-v0.4-icons.png" width="400px" alt="screenshot" title="screenshot" style="display: inline" />
<a href="http://larsjung.de/h5ai/sample/screenshots/h5ai-v0.5.2-icons.png" target="_blank">
<img src="http://larsjung.de/h5ai/sample/screenshots/h5ai-v0.5.2-icons.png" width="400px" alt="screenshot" title="icons view" style="display: inline" />
</a>
@@ -24,9 +24,9 @@ Everything you need is located in folder `target`.
* Copy folder `h5ai` to the web-root directory of your server or alternativly set an alias `/h5ai/` to
this folder.
* Add the content of file `dot.htaccess` to the `.htaccess` file inside the directory
you want to be styled (you might have to create this file). This directory and any subdirectories will be
styled by h5ai.
* Add the content of file `dot.htaccess` to the `.htaccess` file inside the directory you want to be
styled (you might have to create this file). This directory and any subdirectories will be styled by h5ai.
* Adjust `options.js` inside the `h5ai` folder to your needs. Defaults will be fine for a start.
Optionally add `h5ai.header.html` and/or `h5ai.footer.html` files to any of the styled folders to [display
custom top or bottom sections](http://larsjung.de/h5ai/sample/customize). The content of those files
@@ -47,11 +47,20 @@ please respect their rights.
## Changelog
### v0.6
*2011-07-05*
* refactored js
* added localization, see options.js
### v0.5.3
*2011-07-04*
* refactored js
* added basic options support
* commented options.js
* optional tree sidebar
### v0.5.2

View File

@@ -3,7 +3,7 @@ custom = true
# project
project.name = h5ai
project.version = 0.5.3
project.version = 0.6
# src

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -44,6 +44,12 @@
color: #e80;
}
}
&.notListable {
> a, > a:visited {
opacity: 0.7;
color: #999;
}
}
}
.icon, .label, .date, .size {
padding: 6px;
@@ -65,17 +71,22 @@
}
.label {
display: block;
margin: 0 220px 0 24px;
margin: 0 270px 0 24px;
overflow: hidden;
white-space: nowrap;
text-align: left;
.error {
font-size: 0.9em;
font-style: italic;
color: #c55;
}
}
.date {
position: absolute;
right: 70px;
right: 100px;
top: 0;
text-align: right;
width: 140px;
width: 160px;
white-space: nowrap;
}
.size {
@@ -83,7 +94,7 @@
right: 0;
top: 0;
text-align: right;
width: 50px;
width: 80px;
white-space: nowrap;
}
}
@@ -150,11 +161,22 @@
.label {
display: block;
word-wrap: break-word;
.error {
font-size: 0.9em;
font-style: italic;
color: #c55;
}
}
.date, .size {
display: none;
}
}
&.notListable {
> a, > a:visited {
opacity: 0.7;
color: #999;
}
}
}
}
}

View File

@@ -12,7 +12,7 @@
<img class="techclass" src="/h5ai/images/html5-css3.png" alt="html5-css3" />
</a>
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai %BUILD_VERSION%">h5ai</a>
using
<span class="l10n-footerUsing">using</span>
<a href="http://tiheum.deviantart.com/art/Faenza-Icons-173323228" target="_blank" title="icon theme for Gnome">Faenza icons</a>
</footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

View File

@@ -16,9 +16,15 @@
<nav>
<span class="jsDisabledFallback">Directory index · JavaScript is disabled</span>
<ul>
<li id="domain" class="crumb"><a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a></li>
<li id="viewicons" class="view"><a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" />icons</a></li>
<li id="viewdetails" class="view" ><a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" />details</a></li>
<li id="domain" class="crumb">
<a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a>
</li>
<li id="viewicons" class="view">
<a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-viewIcons">icons</span></a>
</li>
<li id="viewdetails" class="view" >
<a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-viewDetails">details</span></a>
</li>
</ul>
<div class="clearfix"></div>
</nav>

View File

Before

Width:  |  Height:  |  Size: 441 B

After

Width:  |  Height:  |  Size: 441 B

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

View File

@@ -69,7 +69,7 @@ var File = function ( utils, folder, tableRow ) {
if ( this.isFolder ) {
$entry.addClass( "folder" );
if ( this.absHref === document.location.pathname ) {
$a.find( ".icon img" ).attr( "src", "/h5ai/images/folder-open.png" );
$a.find( ".icon img" ).attr( "src", "/h5ai/icons/16x16/folder-open.png" );
$entry.addClass( "current" );
};
if ( this.content instanceof Array ) {
@@ -80,7 +80,7 @@ var File = function ( utils, folder, tableRow ) {
} else if ( this.content === undefined ) {
$a.append( $( "<span class='hint'><img src='/h5ai/images/loading.png' /></span>" ) );
} else if ( this.content === 200 ) {
$a.find( ".icon img" ).attr( "src", "/h5ai/images/folder-page.png" );
$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 {
$a.append( $( "<span class='hint error'>" + this.content + "</span>" ) );

View File

@@ -26,7 +26,9 @@ var H5ai = function ( options ) {
viewmodes: [ "details", "icons" ],
showTree: false,
folderStatus: {
}
},
lang: undefined,
useBrowserLang: true
};
this.config = $.extend( {}, defaults, options );
@@ -65,6 +67,7 @@ var H5ai = function ( options ) {
this.initBreadcrumb();
this.initViews();
this.customize();
this.localize( h5aiLangs, this.config.lang, this.config.useBrowserLang );
};
@@ -202,9 +205,9 @@ var H5ai = function ( options ) {
var $label = $( "th.name a" );
var $date = $( "th.date a" );
var $size = $( "th.size a" );
$( "<a class='label' href='" + $label.attr( "href" ) + "'>" + $label.text() + "</a>" ).appendTo( $li );
$( "<a class='date' href='" + $date.attr( "href" ) + "'>" + $date.text() + "</a>" ).appendTo( $li );
$( "<a class='size' href='" + $size.attr( "href" ) + "'>" + $size.text() + "</a>" ).appendTo( $li );
$( "<a class='label' href='" + $label.attr( "href" ) + "'><span class='l10n-columnName'>" + $label.text() + "</span></a>" ).appendTo( $li );
$( "<a class='date' href='" + $date.attr( "href" ) + "'><span class='l10n-columnLastModified'>" + $date.text() + "</span></a>" ).appendTo( $li );
$( "<a class='size' href='" + $size.attr( "href" ) + "'><span class='l10n-columnSize'>" + $size.text() + "</span></a>" ).appendTo( $li );
// header sort icons
var order = document.location.search;
@@ -254,12 +257,22 @@ var H5ai = function ( options ) {
$( "#extended" ).append( $ul );
// empty
$entries = $( "#extended .entry" );
// empty
if ( $entries.size() === 0 || $entries.size() === 1 && $entries.find( ".label" ).text() === "Parent Directory" ) {
$( "#extended" ).append( $( "<div class='empty'>empty</div>" ) );
};
// parent folder
if ( $entries.size() > 0 ) {
$entry0 = $( $entries.get(0) );
if ( $entry0.find( ".label" ).text() === "Parent Directory" ) {
$entry0.find( ".label" ).addClass( "l10n-parentDirectory" );
$entry0.addClass( "parentfolder" );
};
};
// in case of floats
$( "#extended" ).append( $( "<div class='clearfix' />" ) );
@@ -320,4 +333,32 @@ var H5ai = function ( options ) {
}
} );
};
/*******************************
* localization
*******************************/
this.localize = function ( data, lang, useBrowserLang ) {
if ( useBrowserLang === true ) {
var browserLang = navigator.language;
if ( data[ browserLang ] !== undefined ) {
lang = browserLang;
} else if ( browserLang.length > 2 && data[ browserLang.substr( 0, 2 ) ] !== undefined ) {
lang = browserLang.substr( 0, 2 );
};
if ( lang === "en" ) {
lang = undefined;
};
};
if ( data[ lang ] !== undefined ) {
var selected = data[ lang ];
for ( key in selected ) {
$( ".l10n-" + key ).text( selected[key] );
};
};
};
};

View File

@@ -8,6 +8,7 @@ var Tree = function ( utils, h5ai ) {
if ( h5ai.config.showTree ) {
this.checkCrumb();
this.checkCurrentFolder();
this.initShifting();
this.populateTree();
};
@@ -32,6 +33,32 @@ var Tree = function ( utils, h5ai ) {
};
this.checkCurrentFolder = function () {
$( "#extended li.entry.folder" ).each( function() {
var $entry = $( this );
if ( $entry.hasClass( "parentfolder" ) ) {
return;
};
var $a = $entry.find( "a" );
var pathname = decodeURI( document.location.pathname ) + $a.attr( "href" );
thistree.checkPathname( pathname, function ( status ) {
if ( status === 200 ) {
$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 if ( status !== 0 ) {
$entry.addClass( "notListable" );
$a.find( ".label" )
.append( " " )
.append( $( "<span class='error'>" + status + "</span>" ) );
};
} );
} );
};
this.shiftTree = function ( show ) {
var $tree = $( "#tree" );
@@ -132,52 +159,61 @@ var Tree = function ( utils, h5ai ) {
console.log( "checkPathname", pathname, status );
if ( status !== 0 ) {
callback( status );
} else {
$.ajax( {
url: pathname,
type: "GET",
dataType: "html",
error: function ( xhr ) {
// since it was checked before this should never happen
callback( xhr.status );
},
success: function ( html, status, xhr ) {
if ( !contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
// since it was checked before this should never happen
callback( xhr.status );
} else {
var entries = [];
$( html ).find( "#table table td" ).closest( "tr" ).each( function () {
var entry = new File( utils, pathname, this );
if ( !entry.isParentFolder || includeParent ) {
entries.push( entry );
};
} );
callback( entries );
};
}
} );
return;
};
$.ajax( {
url: pathname,
type: "GET",
dataType: "html",
error: function ( xhr ) {
callback( xhr.status ); // since it was checked before this should never happen
},
success: function ( html, status, xhr ) {
if ( !contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
callback( xhr.status ); // since it was checked before this should never happen
return;
};
var entries = [];
$( html ).find( "#table table td" ).closest( "tr" ).each( function () {
var entry = new File( utils, pathname, this );
if ( !entry.isParentFolder || includeParent ) {
entries.push( entry );
};
} );
callback( entries );
}
} );
} );
};
var pathnameCache = {};
this.checkPathname = function ( pathname, callback ) {
if ( h5ai.config.folderStatus[ pathname ] !== undefined ) {
callback( h5ai.config.folderStatus[ pathname ] );
} else {
$.ajax( {
url: pathname,
type: "HEAD",
complete: function ( xhr ) {
if ( xhr.status === 200 && contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
callback( 0 );
} else {
callback( xhr.status );
};
}
} );
return;
};
if ( pathnameCache[ pathname ] !== undefined ) {
callback( pathnameCache[ pathname ] );
return;
};
$.ajax( {
url: pathname,
type: "HEAD",
complete: function ( xhr ) {
var status = xhr.status;
if ( xhr.status === 200 && contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
status = 0;
};
pathnameCache[ pathname ] = status;
callback( status );
}
} );
};
};

View File

@@ -1,8 +1,82 @@
h5aiOptions = {
viewmodes: [ "icons", "details" ],
showTree: true,
/*
* An array of view modes the user may choose from. Currently there
* are two possible values: "details" and "icons". The first value
* indicates the default view mode. If only one value is given the
* view mode is fixed and the selector buttons are hidden.
* The user selected view mode is also stored local in modern browsers
* so that it will be persistent.
*/
viewmodes: [ "details", "icons" ],
/*
* Show a folder tree, boolean.
* Note that this tree might have side effects as it sends HEAD requests
* to the folders, and therefore will invoke index.php scripts. Use
* folderStatus below to avoid such requests.
* It might also affect performance significantly.
*/
showTree: false,
/*
* Associative array of folders and their HTTP status codes to
* avoid HEAD requests to that folders. The key (folder) must start
* and end with a slash (/).
* For example:
* "/some/folder/": 200
* will always return HTTP status 200 (OK), which will be interpreted
* as a non auto indexed folder, that means a folder containing an
* appropriate default index file.
*/
folderStatus: {
"/develop/folder-types/phpsite/": 200
}
/*
* for example:
* "/some/folder/": 200
*/
},
/*
* Localization, for example "en", "de" etc. - see h5aiLangs below for
* possible values. Adjust it to your needs. If lang is not found in
* h5aiLangs the displayed labels stay unchanged.
*/
lang: undefined,
/*
* Try to use browser language, falls back to previous specified lang.
*/
useBrowserLang: true
};
/*
* Available translations.
* "en" is just an example - see it as a reference. Those values
* are "hardcoded" and will be displayed if all labels stay unchanged.
*/
h5aiLangs = {
"en": {
viewDetails: "details",
viewIcons: "icons",
columnName: "Name",
columnLastModified: "Last modified",
columnSize: "Size",
footerUsing: "using",
parentDirectory: "Parent Directory"
},
"de": {
viewDetails: "Details",
viewIcons: "Icons",
columnName: "Name",
columnLastModified: "Geändert",
columnSize: "Größe",
footerUsing: "nutzt",
parentDirectory: "Übergeordnetes Verzeichnis"
}
};

View File

@@ -1,5 +1,5 @@
################################
# h5ai 0.5.3
# h5ai 0.6
# customized .htaccess
################################
@@ -56,7 +56,7 @@
IndexOrderDefault Ascending Name
IndexOptions Type=text/html;h5ai=0.5.3
IndexOptions Type=text/html;h5ai=0.6
IndexOptions Charset=UTF-8
IndexOptions FancyIndexing
IndexOptions HTMLTable

File diff suppressed because one or more lines are too long

View File

@@ -11,8 +11,8 @@
<img class="techclass" src="/h5ai/images/html5-storage.png" alt="html5-storage" />
<img class="techclass" src="/h5ai/images/html5-css3.png" alt="html5-css3" />
</a>
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai 0.5.3">h5ai</a>
using
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai 0.6">h5ai</a>
<span class="l10n-footerUsing">using</span>
<a href="http://tiheum.deviantart.com/art/Faenza-Icons-173323228" target="_blank" title="icon theme for Gnome">Faenza icons</a>
</footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Directory index · styled with h5ai</title>
<meta name="h5ai-version" content="h5ai 0.5.3">
<meta name="h5ai-version" content="h5ai 0.6">
<meta name="description" content="Directory index styled with h5ai (http://larsjung.de/h5ai)">
<meta name="keywords" content="directory, index, autoindex, h5ai">
<link rel="shortcut icon" type="image/png" href="/h5ai/images/h5ai-16x16.png">
@@ -16,9 +16,15 @@
<nav>
<span class="jsDisabledFallback">Directory index · JavaScript is disabled</span>
<ul>
<li id="domain" class="crumb"><a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a></li>
<li id="viewicons" class="view"><a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" />icons</a></li>
<li id="viewdetails" class="view" ><a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" />details</a></li>
<li id="domain" class="crumb">
<a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a>
</li>
<li id="viewicons" class="view">
<a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-viewIcons">icons</span></a>
</li>
<li id="viewdetails" class="view" >
<a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-viewDetails">details</span></a>
</li>
</ul>
<div class="clearfix"></div>
</nav>

View File

Before

Width:  |  Height:  |  Size: 441 B

After

Width:  |  Height:  |  Size: 441 B

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,82 @@
h5aiOptions = {
viewmodes: [ "icons", "details" ],
showTree: true,
/*
* An array of view modes the user may choose from. Currently there
* are two possible values: "details" and "icons". The first value
* indicates the default view mode. If only one value is given the
* view mode is fixed and the selector buttons are hidden.
* The user selected view mode is also stored local in modern browsers
* so that it will be persistent.
*/
viewmodes: [ "details", "icons" ],
/*
* Show a folder tree, boolean.
* Note that this tree might have side effects as it sends HEAD requests
* to the folders, and therefore will invoke index.php scripts. Use
* folderStatus below to avoid such requests.
* It might also affect performance significantly.
*/
showTree: false,
/*
* Associative array of folders and their HTTP status codes to
* avoid HEAD requests to that folders. The key (folder) must start
* and end with a slash (/).
* For example:
* "/some/folder/": 200
* will always return HTTP status 200 (OK), which will be interpreted
* as a non auto indexed folder, that means a folder containing an
* appropriate default index file.
*/
folderStatus: {
"/develop/folder-types/phpsite/": 200
}
/*
* for example:
* "/some/folder/": 200
*/
},
/*
* Localization, for example "en", "de" etc. - see h5aiLangs below for
* possible values. Adjust it to your needs. If lang is not found in
* h5aiLangs the displayed labels stay unchanged.
*/
lang: undefined,
/*
* Try to use browser language, falls back to previous specified lang.
*/
useBrowserLang: true
};
/*
* Available translations.
* "en" is just an example - see it as a reference. Those values
* are "hardcoded" and will be displayed if all labels stay unchanged.
*/
h5aiLangs = {
"en": {
viewDetails: "details",
viewIcons: "icons",
columnName: "Name",
columnLastModified: "Last modified",
columnSize: "Size",
footerUsing: "using",
parentDirectory: "Parent Directory"
},
"de": {
viewDetails: "Details",
viewIcons: "Icons",
columnName: "Name",
columnLastModified: "Geändert",
columnSize: "Größe",
footerUsing: "nutzt",
parentDirectory: "Übergeordnetes Verzeichnis"
}
};