Index: trunk/extensions/ee/ee.pl |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | # By default, config will be searched for in your Unix home directory |
24 | 24 | # (e.g. ~/.ee-helper/ee.ini). Change path of the configuration file if needed! |
25 | 25 | $cfgfile=$ENV{HOME}."/.ee-helper/ee.ini"; |
| 26 | +$cfgfile=getunixpath($cfgfile); |
26 | 27 | |
27 | 28 | $DEBUG=0; |
28 | 29 | $NOGUIERRORS=0; |
— | — | @@ -39,10 +40,13 @@ |
40 | 41 | # Remove slash at the end of the directory name, if existing |
41 | 42 | $/="/"; |
42 | 43 | chomp($tempdir); |
| 44 | +$/="\\"; |
| 45 | +chomp($tempdir); |
| 46 | +my $unixtempdir=getunixpath($tempdir); |
43 | 47 | |
44 | 48 | if($DEBUG) { |
45 | 49 | # Make a copy of the control (input) file in the log |
46 | | - open(DEBUGLOG,">$tempdir/debug.log"); |
| 50 | + open(DEBUGLOG,">$unixtempdir/debug.log"); |
47 | 51 | open(INPUT,"<$args"); |
48 | 52 | $/=undef; # slurp mode |
49 | 53 | while(<INPUT>) { |
— | — | @@ -153,7 +157,9 @@ |
154 | 158 | $response=$browser->get($fileurl); |
155 | 159 | if($type eq "Edit file") { |
156 | 160 | |
157 | | - open(OUTPUT,">$tempdir/".$filename); |
| 161 | + open(OUTPUT,">$unixtempdir/".$filename); |
| 162 | + binmode(OUTPUT); |
| 163 | + select OUTPUT; $|=1; select STDOUT; |
158 | 164 | print OUTPUT $response->content; |
159 | 165 | close(OUTPUT); |
160 | 166 | |
— | — | @@ -187,7 +193,7 @@ |
188 | 194 | } |
189 | 195 | |
190 | 196 | # Flush the raw text of the page to the disk |
191 | | - open(OUTPUT,">$tempdir/".$filename); |
| 197 | + open(OUTPUT,">$unixtempdir/".$filename); |
192 | 198 | select OUTPUT; $|=1; select STDOUT; |
193 | 199 | print OUTPUT $text; |
194 | 200 | close(OUTPUT); |
— | — | @@ -209,23 +215,34 @@ |
210 | 216 | # In most cases, we'll want to run the GUI for managing saves & previews, |
211 | 217 | # and run the external editor application. |
212 | 218 | 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); |
215 | 227 | makegui(); |
216 | 228 | |
217 | 229 | } else { |
218 | 230 | # For external diffs, we need to create two temporary files. |
219 | 231 | $response1=$browser->get($fileurl); |
220 | 232 | $response2=$browser->get($secondurl); |
221 | | - open(DIFF1, ">$tempdir/diff-1.txt"); |
| 233 | + open(DIFF1, ">$unixtempdir/diff-1.txt"); |
222 | 234 | select DIFF1; $|=1; select STDOUT; |
223 | | - open(DIFF2, ">$tempdir/diff-2.txt"); |
| 235 | + open(DIFF2, ">$unixtempdir/diff-2.txt"); |
224 | 236 | select DIFF2; $|=1; select STDOUT; |
225 | 237 | print DIFF1 $response1->content; |
226 | 238 | print DIFF2 $response2->content; |
227 | 239 | close(DIFF1); |
228 | 240 | 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); |
230 | 247 | } |
231 | 248 | |
232 | 249 | # Create the GTK2 graphical user interface |
— | — | @@ -312,7 +329,7 @@ |
313 | 330 | $response=$browser->post($upload_url, |
314 | 331 | @ns_headers,Content_Type=>'form-data',Content=> |
315 | 332 | [ |
316 | | - wpUploadFile=>["$tempdir/".$filename], |
| 333 | + wpUploadFile=>["$unixtempdir/".$filename], |
317 | 334 | wpUploadDescription=>$summary, |
318 | 335 | wpUploadAffirm=>"1", |
319 | 336 | wpUpload=>"Upload file", |
— | — | @@ -325,7 +342,7 @@ |
326 | 343 | } |
327 | 344 | # Save text back to the server & load in browser |
328 | 345 | } elsif($type eq "Edit text") { |
329 | | - open(TEXT,"<$tempdir/".$filename); |
| 346 | + open(TEXT,"<$unixtempdir/".$filename); |
330 | 347 | $/=undef; |
331 | 348 | while(<TEXT>) { |
332 | 349 | $text=$_; |
— | — | @@ -343,14 +360,14 @@ |
344 | 361 | wpEditToken=>$token, |
345 | 362 | wpPreview=>"true", |
346 | 363 | ]); |
347 | | - open(PREVIEW,">$tempdir/preview.html"); |
| 364 | + open(PREVIEW,">$unixtempdir/preview.html"); |
348 | 365 | $preview=$response->content; |
349 | 366 | # Replace relative URLs with absolute ones |
350 | 367 | $preview=~s|<head>|<head>\n <base href="$server$path">|gi; |
351 | 368 | print PREVIEW $preview; |
352 | 369 | close(PREVIEW); |
353 | 370 | if($previewclient) { |
354 | | - $previewurl="file://$tempdir/preview.html"; |
| 371 | + $previewurl="file://$unixtempdir/preview.html"; |
355 | 372 | $previewclient=~s/\$url/$previewurl/i; |
356 | 373 | system(qq|$previewclient|); |
357 | 374 | $previewclient=$cfg->val("Settings","Browser"); |
— | — | @@ -396,28 +413,37 @@ |
397 | 414 | |
398 | 415 | sub vdie { |
399 | 416 | |
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); |
405 | 422 | |
406 | 423 | } |
407 | 424 | |
408 | 425 | sub errorbox { |
409 | 426 | |
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; |
419 | 436 | |
420 | 437 | } |
421 | 438 | |
| 439 | +sub getunixpath { |
| 440 | + |
| 441 | + my $getpath=shift; |
| 442 | + if($^O eq 'MSWin32') { |
| 443 | + $getpath=~s|\\|/|gi; |
| 444 | + } |
| 445 | + return $getpath; |
| 446 | +} |
| 447 | + |
422 | 448 | sub initmsg { |
423 | 449 | |
424 | 450 | %messages=( |