Index: trunk/extensions/ee/ee.pl |
— | — | @@ -58,7 +58,10 @@ |
59 | 59 | $fileurl=$input->val("File","URL"); |
60 | 60 | $type=$input->val("Process","Type"); |
61 | 61 | $script=$input->val("Process","Script"); |
| 62 | +$server=$input->val("Process","Server"); |
| 63 | +$path=$input->val("Process","Path"); |
62 | 64 | |
| 65 | + |
63 | 66 | if($type eq "Edit file") { |
64 | 67 | $filename=substr($fileurl,rindex($fileurl,"/")+1); |
65 | 68 | } elsif($type eq "Edit text") { |
— | — | @@ -102,7 +105,8 @@ |
103 | 106 | # Do we need to convert UTF-8 into ISO 8859-1? |
104 | 107 | if($cfg->val("Settings","Transcode UTF-8") eq "true") { |
105 | 108 | $transcode=1; |
106 | | - } |
| 109 | + } |
| 110 | + $firefox=$cfg->val("Settings","Firefox"); |
107 | 111 | $ct=$response->header('Content-Type'); |
108 | 112 | $editpage=$response->content; |
109 | 113 | $editpage=~m|<input type='hidden' value="(.*?)" name="wpEditToken" />|i; |
— | — | @@ -154,9 +158,11 @@ |
155 | 159 | $hbox2 = Gtk2::HBox->new; |
156 | 160 | $savebutton = Gtk2::Button->new("Save"); |
157 | 161 | $savecontbutton = Gtk2::Button->new("Save and continue"); |
| 162 | + $previewbutton = Gtk2::Button->new("Preview"); |
158 | 163 | $cancelbutton = Gtk2::Button->new("Cancel"); |
159 | 164 | $hbox2->pack_start_defaults($savebutton); |
160 | 165 | $hbox2->pack_start_defaults($savecontbutton); |
| 166 | + $hbox2->pack_start_defaults($previewbutton); |
161 | 167 | $hbox2->pack_start_defaults($cancelbutton); |
162 | 168 | $vbox->pack_start_defaults($hbox); |
163 | 169 | $vbox->pack_start_defaults($hbox2); |
— | — | @@ -167,6 +173,7 @@ |
168 | 174 | $window->signal_connect (delete_event => sub {Gtk2->main_quit}); |
169 | 175 | $savebutton->signal_connect (clicked => \&save); |
170 | 176 | $savecontbutton->signal_connect ( clicked => \&savecont); |
| 177 | + $previewbutton->signal_connect ( clicked => \&preview); |
171 | 178 | $cancelbutton->signal_connect (clicked => \&cancel); |
172 | 179 | |
173 | 180 | # Add vbox to window |
— | — | @@ -181,6 +188,12 @@ |
182 | 189 | save("continue"); |
183 | 190 | |
184 | 191 | } |
| 192 | + |
| 193 | +sub preview { |
| 194 | + $preview=1; |
| 195 | + save("continue"); |
| 196 | +} |
| 197 | + |
185 | 198 | sub save { |
186 | 199 | |
187 | 200 | my $cont=shift; |
— | — | @@ -195,7 +208,7 @@ |
196 | 209 | if($is_utf8) { |
197 | 210 | $summary=Encode::encode('utf8',$summary); |
198 | 211 | } |
199 | | - if($type eq "Edit file") { |
| 212 | + if($type eq "Edit file") { |
200 | 213 | $response=$browser->post($upload_url, |
201 | 214 | @ns_headers,Content_Type=>'form-data',Content=> |
202 | 215 | [ |
— | — | @@ -204,7 +217,7 @@ |
205 | 218 | wpUploadAffirm=>"1", |
206 | 219 | wpUpload=>"Upload file", |
207 | 220 | wpIgnoreWarning=>"1" |
208 | | - ]); |
| 221 | + ]); |
209 | 222 | } elsif($type eq "Edit text") { |
210 | 223 | open(TEXT,"<$tempdir/".$filename); |
211 | 224 | $/=undef; |
— | — | @@ -215,13 +228,34 @@ |
216 | 229 | if($is_utf8 && $transcode) { |
217 | 230 | Encode::from_to($text,'iso-8859-1','utf8'); |
218 | 231 | } |
219 | | - $response=$browser->post($edit_url,@ns_headers,Content=> |
220 | | - [ |
221 | | - wpTextbox1=>$text, |
222 | | - wpSummary=>$summary, |
223 | | - wpEdittime=>$time, |
224 | | - wpEditToken=>$token |
225 | | - ]); |
| 232 | + if($preview) { |
| 233 | + $response=$browser->post($edit_url,@ns_headers,Content=> |
| 234 | + [ |
| 235 | + wpTextbox1=>$text, |
| 236 | + wpSummary=>$summary, |
| 237 | + wpEdittime=>$time, |
| 238 | + wpEditToken=>$token, |
| 239 | + wpPreview=>"true", |
| 240 | + ]); |
| 241 | + open(PREVIEW,">$tempdir/preview.htm"); |
| 242 | + $preview=$response->content; |
| 243 | + # Replace relative URLs with absolute ones |
| 244 | + $preview=~s|$path|$server$path|gi; |
| 245 | + print PREVIEW $preview; |
| 246 | + if($firefox) { |
| 247 | + print "$firefox\n"; |
| 248 | + system(qq|$firefox -remote "openURL(file://$tempdir/preview.htm)"|); |
| 249 | + } |
| 250 | + $preview=0; |
| 251 | + } else { |
| 252 | + $response=$browser->post($edit_url,@ns_headers,Content=> |
| 253 | + [ |
| 254 | + wpTextbox1=>$text, |
| 255 | + wpSummary=>$summary, |
| 256 | + wpEdittime=>$time, |
| 257 | + wpEditToken=>$token, |
| 258 | + ]); |
| 259 | + } |
226 | 260 | } elsif($type eq "Diff") { |
227 | 261 | die "Diffs not yet supported.\n"; |
228 | 262 | } else { |
Index: trunk/extensions/ee/ee.ini |
— | — | @@ -1,5 +1,7 @@ |
2 | 2 | [Settings] |
3 | 3 | Temp Path=/tmp |
| 4 | +Transcode UTF-8=false |
| 5 | +Firefox=/usr/local/bin/firefox |
4 | 6 | |
5 | 7 | [Editors] |
6 | 8 | jpg,png,gif,jpeg=/usr/bin/xpaint |