Bug 82439 - html direcotry listings not localisable. r=sfraser, sr=darin

This commit is contained in:
bbaetz%cs.mcgill.ca 2001-10-19 03:03:30 +00:00
Родитель 0bfc995a78
Коммит 268131e95e
5 изменённых файлов: 45 добавлений и 6 удалений

Просмотреть файл

@ -47,3 +47,6 @@ EnterUserPasswordForProxy=Enter username and password for proxy at %1$S
EnterUserPasswordFor=Enter username and password for %1$S
EnterPasswordFor=Enter password for %1$S on %2$S
DeniedPortAccess=Access to the port number given has been disabled for security reasons.
# Directory listing strings
DirTitle=Index of %1$S

Просмотреть файл

@ -32,6 +32,7 @@ REQUIRES = xpcom \
string \
mimetype \
locale \
intl \
unicharutil \
util \
pref \

Просмотреть файл

@ -28,6 +28,7 @@ REQUIRES = xpcom \
pref \
exthandler \
uconv \
intl \
unicharutil \
zlib \
$(NULL)

Просмотреть файл

@ -62,6 +62,12 @@ nsIndexedToHTML::Init(nsIStreamListener* aListener) {
mDateTime = do_CreateInstance(kDateTimeFormatCID, &rv);
nsCOMPtr<nsIStringBundleService> sbs =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = sbs->CreateBundle("chrome://necko/locale/necko.properties",
getter_AddRefs(mBundle));
return rv;
}
@ -137,8 +143,21 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
char* spec = nsCRT::strdup(tmp.get());
nsUnescape(spec);
buffer.Append(NS_LITERAL_STRING("<html>\n<head><title>Index of ")); //FIX i18n.
buffer.AppendWithConversion(spec);
buffer.Append(NS_LITERAL_STRING("<html>\n<head><title>"));
nsXPIDLString title;
nsAutoString uniSpec; uniSpec.AssignWithConversion(spec);
const PRUnichar* formatTitle[] = {
uniSpec.get()
};
rv = mBundle->FormatStringFromName(NS_LITERAL_STRING("DirTitle").get(),
formatTitle, sizeof(formatTitle),
getter_Copies(title));
if (NS_FAILED(rv)) return rv;
buffer.Append(title);
buffer.Append(NS_LITERAL_STRING("</title><base href=\""));
buffer.Append(baseUri);
buffer.Append(NS_LITERAL_STRING("\">\n"));
@ -153,14 +172,25 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
buffer.Append(NS_LITERAL_STRING("</head>\n<body><pre>\n"));
buffer.Append(NS_LITERAL_STRING("<H1> Index of ")); //FIX i18n.
buffer.Append(NS_LITERAL_STRING("<H1>"));
char* escaped = nsEscapeHTML(spec);
buffer.AppendWithConversion(escaped);
nsAutoString escapedSpec; escapedSpec.AssignWithConversion(escaped);
nsMemory::Free(escaped);
const PRUnichar* formatHeading[] = {
escapedSpec.get()
};
rv = mBundle->FormatStringFromName(NS_LITERAL_STRING("DirTitle").get(),
formatHeading, sizeof(formatHeading),
getter_Copies(title));
if (NS_FAILED(rv)) return rv;
buffer.Append(title);
buffer.Append(NS_LITERAL_STRING("</H1>\n"));
buffer.Append(NS_LITERAL_STRING("<hr><table border=0>\n"));
// buffer.AppendWithConversion("<tr><th>Name</th><th>Size</th><th>Last modified</th><th>Description</th></tr>\n"); //FIX i18n.
//buffer.Append(NS_LITERAL_STRING("<tr><th>Name</th><th>Size</th><th>Last modified</th></tr>\n"));
// Push buffer to the listener now, so the initial HTML will not
// be parsed in OnDataAvailable().
@ -262,7 +292,9 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
PRUint32 size;
aIndex->GetSize(&size);
if (size != PRUint32(-1)) {
if (size != PRUint32(-1) &&
type != nsIDirIndex::TYPE_DIRECTORY &&
type != nsIDirIndex::TYPE_SYMLINK) {
pushBuffer.AppendInt(size);
} else {
pushBuffer.Append(NS_LITERAL_STRING("&nbsp;"));

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsIDirIndexListener.h"
#include "nsILocaleService.h"
#include "nsIDateTimeFormat.h"
#include "nsIStringBundle.h"
#define NS_NSINDEXEDTOHTMLCONVERTER_CID \
{ 0xcf0f71fd, 0xfafd, 0x4e2b, {0x9f, 0xdc, 0x13, 0x4d, 0x97, 0x2e, 0x16, 0xe2} }
@ -87,6 +88,7 @@ protected:
nsCOMPtr<nsILocale> mLocale;
nsCOMPtr<nsIDateTimeFormat> mDateTime;
nsCOMPtr<nsIStringBundle> mBundle;
};
#endif