cleaning up miscellaneous crap from recent changes

This commit is contained in:
myk%mozilla.org 2004-05-05 00:24:32 +00:00
Родитель 5ae83e147c
Коммит 14b5743771
7 изменённых файлов: 39 добавлений и 114 удалений

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

@ -11,7 +11,6 @@ use Doctor qw(:DEFAULT %CONFIG $template);
use File::Temp qw(tempfile);
# doesn't import "diff" to prevent conflicts with our own
# ??? perhaps that means we should inherit?
use Text::Diff ();
sub new {
@ -83,7 +82,45 @@ sub spec {
# The spec can only be set once.
if (@_ && !$self->{_spec}) {
$self->{_spec} = shift;
$self->_normalize();
# Canonicalize the spec:
# URL -> Spec Conversion
# Remove the absolute URI for files on the web site (if any)
# from the beginning of the path.
if ($CONFIG{WEB_BASE_URI_PATTERN}) {
$self->{_spec} =~ s/^$CONFIG{WEB_BASE_URI_PATTERN}//i;
}
else {
$self->{_spec} =~ s/^\Q$CONFIG{WEB_BASE_URI}\E//i;
}
# Entire Spec Issues
# Collapse multiple consecutive slashes (i.e. dir//file.txt) into one.
$self->{_spec} =~ s:/{2,}:/:;
# Beginning of Spec Issues
# Remove a preceding slash.
$self->{_spec} =~ s:^/::;
# Add the base path of the file in the CVS repository if necessary.
# (i.e. if the user entered a URL or a path based on the URL).
if ($self->{_spec} !~ /^\Q$CONFIG{WEB_BASE_PATH}\E/) {
$self->{_spec} = $CONFIG{WEB_BASE_PATH} . $self->{_spec};
}
# End of Spec Issues
# If the filename (the last name in the path) contains no period,
# it is probably a directory, so add a slash.
if ($self->{_spec} =~ m:^[^\./]+$: || $self->{_spec} =~ m:/[^\./]+$:) { $self->{_spec} .= "/" }
# If the file ends with a forward slash, it is a directory,
# so add the name of the default file.
if ($self->{_spec} =~ m:/$:) { $self->{_spec} .= "index.html" }
}
return $self->{_spec};
}
@ -128,55 +165,6 @@ sub relative_spec {
return $1;
}
# XXX This should just be part of the spec getter/setter.
sub _normalize {
my $self = shift;
# Make sure a path was entered.
$self->{_spec}
|| die("empty file spec");
# URL -> Path Conversion
# Remove the absolute URI for files on the web site (if any)
# from the beginning of the path.
if ($CONFIG{WEB_BASE_URI_PATTERN}) {
$self->{_spec} =~ s/^$CONFIG{WEB_BASE_URI_PATTERN}//i;
}
else {
$self->{_spec} =~ s/^\Q$CONFIG{WEB_BASE_URI}\E//i;
}
# Entire Path Issues
# Collapse multiple consecutive slashes (i.e. dir//file.txt) into one.
$self->{_spec} =~ s:/{2,}:/:;
# Beginning of Path Issues
# Remove a preceding slash.
$self->{_spec} =~ s:^/::;
# Add the base path of the file in the CVS repository if necessary.
# (i.e. if the user entered a URL or a path based on the URL).
if ($self->{_spec} !~ /^\Q$CONFIG{WEB_BASE_PATH}\E/) {
$self->{_spec} = $CONFIG{WEB_BASE_PATH} . $self->{_spec};
}
# End of Path Issues
# If the filename (the last name in the path) contains no period,
# it is probably a directory, so add a slash.
if ($self->{_spec} =~ m:^[^\./]+$: || $self->{_spec} =~ m:/[^\./]+$:) { $self->{_spec} .= "/" }
# If the file ends with a forward slash, it is a directory,
# so add the name of the default file.
if ($self->{_spec} =~ m:/$:) { $self->{_spec} .= "index.html" }
}
sub add {
my $self = shift;
my $content = shift;
@ -229,7 +217,6 @@ sub patch {
sub checkout {
my $self = shift;
# XXX Define a config constant incorporating username, password, and server.
my @args = ("-d",
":pserver:$CONFIG{READ_CVS_USERNAME}:$CONFIG{READ_CVS_PASSWORD}\@$CONFIG{READ_CVS_SERVER}",
"checkout",
@ -291,8 +278,6 @@ sub commit {
return ($rv, $output, $errors);
}
sub diff {
my $self = shift;
my $revision = shift;

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

@ -222,60 +222,3 @@ function createHiddenField(name, value) {
field.value = value;
return field;
}
/* Not used now that we are using an iframe instead of a div for the diff panel.
function requestDiff() {
var diffPanel = document.getElementById('diffPanel');
diffPanel.innerHTML = "<p>Loading diff. Please wait..<blink>.</blink></p>";
var file = encodeURIComponent(document.getElementById('file').getAttribute('value'));
var version = encodeURIComponent(document.getElementById('version').getAttribute('value'));
var line_endings = encodeURIComponent(document.getElementById('line_endings').getAttribute('value'));
var content = encodeURIComponent(document.getElementById('content').getAttribute('value'));
var request = new XMLHttpRequest();
request.open("POST", "doctor.cgi");
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request.onload = showDiff;
request.onerror = showDiffError;
request.send("action=" + "review" +
"&amp;raw=" + "1" +
"&amp;file=" + file +
"&amp;version=" + version +
"&amp;line_endings=" + line_endings +
"&amp;content=" + content);
}
function showDiff(evt) {
var request = evt.target;
var diffPanel = document.getElementById('diffPanel');
var pre = document.createElement("pre");
diffPanel.innerHTML = "";
diffPanel.appendChild(pre);
var diff = document.createTextNode(request.responseText);
pre.appendChild(diff);
//diffPanel.innerHTML = "<pre>" + escapeHTML(request.responseText) + "</pre>";
}
function escapeHTML(code) {
if (!code)
return code;
code = code.replace(/</g, "&lt;"); // less than
code = code.replace(/>/g, "&gt;"); // greater than
code = code.replace(/&/g, "&amp;"); // ampersand
code = code.replace(/'/g, "&apos;"); // apostrophe
code = code.replace(/"/g, "&quot;"); // quotation mark
return code;
}
function showDiffError(evt) {
var request = evt.target;
var diff = document.getElementById('diff');
// XXX Grab the error info from the request and display it.
diff.innerHTML = "Sorry, there was an error loading the diff.";
}
*/

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

@ -41,7 +41,6 @@
[% IF is_new %]
The new file has been committed to the repository.
[% ELSE %]
[%# XXX add some useful links and UI here %]
Your changes have been committed to the repository.
[% END %]
</p>

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

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

@ -50,8 +50,6 @@
<form id="form" method="post" action="doctor.cgi" enctype="multipart/form-data">
<input id="file" type="hidden" name="file" value="[% file.spec FILTER html %]">
<input id="version" type="hidden" name="version" value="[% version %]">
<input id="line_endings" type="hidden" name="line_endings" value="[% line_endings %]">
<input id="is_new" type="hidden" name="is_new" value="[% is_new %]">
<div id="bannernav">
Doctor - [% is_new ? "create" : "edit" %]

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

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