r8809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r8808‎ | r8809 | r8810 >
Date:17:12, 2 May 2005
Author:eloquence
Status:old
Tags:
Comment:
first take at making this fully windows-compatible
Modified paths:
  • /trunk/extensions/ee/ee.pl (modified) (history)

Diff [purge]

Index: trunk/extensions/ee/ee.pl
@@ -22,6 +22,7 @@
2323 # By default, config will be searched for in your Unix home directory
2424 # (e.g. ~/.ee-helper/ee.ini). Change path of the configuration file if needed!
2525 $cfgfile=$ENV{HOME}."/.ee-helper/ee.ini";
 26+$cfgfile=getunixpath($cfgfile);
2627
2728 $DEBUG=0;
2829 $NOGUIERRORS=0;
@@ -39,10 +40,13 @@
4041 # Remove slash at the end of the directory name, if existing
4142 $/="/";
4243 chomp($tempdir);
 44+$/="\\";
 45+chomp($tempdir);
 46+my $unixtempdir=getunixpath($tempdir);
4347
4448 if($DEBUG) {
4549 # Make a copy of the control (input) file in the log
46 - open(DEBUGLOG,">$tempdir/debug.log");
 50+ open(DEBUGLOG,">$unixtempdir/debug.log");
4751 open(INPUT,"<$args");
4852 $/=undef; # slurp mode
4953 while(<INPUT>) {
@@ -153,7 +157,9 @@
154158 $response=$browser->get($fileurl);
155159 if($type eq "Edit file") {
156160
157 - open(OUTPUT,">$tempdir/".$filename);
 161+ open(OUTPUT,">$unixtempdir/".$filename);
 162+ binmode(OUTPUT);
 163+ select OUTPUT; $|=1; select STDOUT;
158164 print OUTPUT $response->content;
159165 close(OUTPUT);
160166
@@ -187,7 +193,7 @@
188194 }
189195
190196 # Flush the raw text of the page to the disk
191 - open(OUTPUT,">$tempdir/".$filename);
 197+ open(OUTPUT,">$unixtempdir/".$filename);
192198 select OUTPUT; $|=1; select STDOUT;
193199 print OUTPUT $text;
194200 close(OUTPUT);
@@ -209,23 +215,34 @@
210216 # In most cases, we'll want to run the GUI for managing saves & previews,
211217 # and run the external editor application.
212218 if($type ne "Diff text") {
213 -
214 - system("$app $tempdir/$filename &");
 219+
 220+ if($^O eq "MSWin32") {
 221+
 222+ $appstring="$app $tempdir\\$filename";
 223+ } else {
 224+ $appstring="$app $tempdir/$filename &";
 225+ }
 226+ system($appstring);
215227 makegui();
216228
217229 } else {
218230 # For external diffs, we need to create two temporary files.
219231 $response1=$browser->get($fileurl);
220232 $response2=$browser->get($secondurl);
221 - open(DIFF1, ">$tempdir/diff-1.txt");
 233+ open(DIFF1, ">$unixtempdir/diff-1.txt");
222234 select DIFF1; $|=1; select STDOUT;
223 - open(DIFF2, ">$tempdir/diff-2.txt");
 235+ open(DIFF2, ">$unixtempdir/diff-2.txt");
224236 select DIFF2; $|=1; select STDOUT;
225237 print DIFF1 $response1->content;
226238 print DIFF2 $response2->content;
227239 close(DIFF1);
228240 close(DIFF2);
229 - system("$diffcommand $tempdir/diff-1.txt $tempdir/diff-2.txt");
 241+ if($^O eq "MSWin32") {
 242+ $appstring="$diffcommand $tempdir\\diff-1.txt $tempdir\\diff-2.txt";
 243+ } else {
 244+ $appstring="$diffcommand $tempdir/diff-1.txt $tempdir/diff-2.txt";
 245+ }
 246+ system($appstring);
230247 }
231248
232249 # Create the GTK2 graphical user interface
@@ -312,7 +329,7 @@
313330 $response=$browser->post($upload_url,
314331 @ns_headers,Content_Type=>'form-data',Content=>
315332 [
316 - wpUploadFile=>["$tempdir/".$filename],
 333+ wpUploadFile=>["$unixtempdir/".$filename],
317334 wpUploadDescription=>$summary,
318335 wpUploadAffirm=>"1",
319336 wpUpload=>"Upload file",
@@ -325,7 +342,7 @@
326343 }
327344 # Save text back to the server & load in browser
328345 } elsif($type eq "Edit text") {
329 - open(TEXT,"<$tempdir/".$filename);
 346+ open(TEXT,"<$unixtempdir/".$filename);
330347 $/=undef;
331348 while(<TEXT>) {
332349 $text=$_;
@@ -343,14 +360,14 @@
344361 wpEditToken=>$token,
345362 wpPreview=>"true",
346363 ]);
347 - open(PREVIEW,">$tempdir/preview.html");
 364+ open(PREVIEW,">$unixtempdir/preview.html");
348365 $preview=$response->content;
349366 # Replace relative URLs with absolute ones
350367 $preview=~s|<head>|<head>\n <base href="$server$path">|gi;
351368 print PREVIEW $preview;
352369 close(PREVIEW);
353370 if($previewclient) {
354 - $previewurl="file://$tempdir/preview.html";
 371+ $previewurl="file://$unixtempdir/preview.html";
355372 $previewclient=~s/\$url/$previewurl/i;
356373 system(qq|$previewclient|);
357374 $previewclient=$cfg->val("Settings","Browser");
@@ -396,28 +413,37 @@
397414
398415 sub vdie {
399416
400 -my $errortext=shift;
401 -if(!$NOGUIERRORS) {
402 - errorbox($errortext);
403 -}
404 -die($errortext);
 417+ my $errortext=shift;
 418+ if(!$NOGUIERRORS) {
 419+ errorbox($errortext);
 420+ }
 421+ die($errortext);
405422
406423 }
407424
408425 sub errorbox {
409426
410 -my $errortext=shift;
411 -
412 -my $dialog = Gtk2::MessageDialog->new ($window,
413 - [qw/modal destroy-with-parent/],
414 - 'error',
415 - 'ok',
416 - $errortext);
417 -$dialog->run;
418 -$dialog->destroy;
 427+ my $errortext=shift;
 428+
 429+ my $dialog = Gtk2::MessageDialog->new ($window,
 430+ [qw/modal destroy-with-parent/],
 431+ 'error',
 432+ 'ok',
 433+ $errortext);
 434+ $dialog->run;
 435+ $dialog->destroy;
419436
420437 }
421438
 439+sub getunixpath {
 440+
 441+ my $getpath=shift;
 442+ if($^O eq 'MSWin32') {
 443+ $getpath=~s|\\|/|gi;
 444+ }
 445+ return $getpath;
 446+}
 447+
422448 sub initmsg {
423449
424450 %messages=(

Status & tagging log