зеркало из https://github.com/mozilla/pjs.git
cleaning up miscellaneous crap from recent changes
This commit is contained in:
Родитель
5ae83e147c
Коммит
14b5743771
|
@ -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" +
|
||||
"&raw=" + "1" +
|
||||
"&file=" + file +
|
||||
"&version=" + version +
|
||||
"&line_endings=" + line_endings +
|
||||
"&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, "<"); // less than
|
||||
code = code.replace(/>/g, ">"); // greater than
|
||||
code = code.replace(/&/g, "&"); // ampersand
|
||||
code = code.replace(/'/g, "'"); // apostrophe
|
||||
code = code.replace(/"/g, """); // 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" %]
|
||||
|
|
Загрузка…
Ссылка в новой задаче