--- html_exportoriginal.module	2009-04-18 02:39:39.109375000 -0700
+++ html_export.module	2009-04-18 02:25:53.281250000 -0700
@@ -46,9 +46,25 @@ function html_export_menu($may_cache) {
       'callback' => 'drupal_get_form',
       'callback arguments' => 'html_export_settings',
       'type' => MENU_NORMAL_ITEM,
-    'access' => user_access('access administration pages'));
+      'access' => user_access('access administration pages'));
+  $node_id = arg(1);
+  if (is_numeric($node_id)) {
+    $node = node_load($node_id);
+  }
+  if ($node->path) {
+    $items[] = array(
+      'path' => 'node/'. arg(1) .'/file',
+      'title' => t('Preview'),
+      'callback' => 'html_export_redirection',
+      'callback arguments' => $node,
+      'access' => user_access('view revisions'),
+      'weight' => 5,
+      'type' => MENU_LOCAL_TASK,
+    ); 
+  } 
   return $items;
 }
+
 /**
 * Implementation of hook_settings
 */
@@ -214,4 +230,52 @@ function _html_export_copyr($source, $de
 	// Clean up
 	$dir->close();
 	return true;
+}
+
+function html_export_redirection($node) {
+  if (is_numeric($node)) {
+    $node = node_load($node);
+  }
+  if ($node->path) {
+    $stage_file_name = basename($node->path);
+    if(dirname($node->path) != '.') {
+      $stage_place = '/'.dirname($node->path);  
+    }
+    //create a folder html_export to put the directory in
+	$dir = file_create_path(file_directory_path().'/html_export');
+  file_check_directory($dir, 1);
+  $export_path = file_directory_path().'/html_export'.$stage_place;
+  file_check_directory(file_create_path($export_path),1);
+  file_check_directory(file_create_path($export_path . '/' . file_directory_path()),1);
+  file_check_directory(file_create_path($export_path . '/sites'),1);
+  file_check_directory(file_create_path($export_path . '/modules'),1);
+  file_check_directory(file_create_path($export_path . '/themes'),1);
+  file_check_directory(file_create_path($export_path . '/misc'),1);  
+  $export_path = $_SERVER['PATH_TRANSLATED'] . $export_path;
+  //run the copyr function, modified to work with zip archive; copy the files,themes,sites,and misc directories
+  _html_export_copyr($_SERVER['PATH_TRANSLATED'].file_directory_path(), $export_path. '/' .file_directory_path());
+  _html_export_copyr($_SERVER['PATH_TRANSLATED']. 'sites',$export_path . '/sites');
+  _html_export_copyr($_SERVER['PATH_TRANSLATED']. 'modules',$export_path . '/modules');
+  _html_export_copyr($_SERVER['PATH_TRANSLATED']. 'themes',$export_path . '/themes');
+  _html_export_copyr($_SERVER['PATH_TRANSLATED']. 'misc',$export_path . '/misc');
+  $stage_site = 'http://'.$_SERVER[HTTP_HOST].base_path().'node/'.$node->nid;
+  $drupal_site = drupal_http_request($stage_site);
+  $data = $drupal_site->data;
+  //strip out file paths that have the full server in them
+  $data = str_replace($root . base_path(),"",$data);
+  $data = str_replace($root,"",$data);    
+  //strip out just the node/ if it's left over and replace it with the correct form of the link so that they actually find each other
+  //get rid of a base path if there is one
+  if(base_path() != '/'){
+		$data = str_replace(base_path(),'',$data);
+  }
+  //account for links back to home where they are just a backslash cause it's at the root
+  $data = str_replace('<a href="/"','<a href="index.html"',$data);
+  $data = str_replace('<a href=""','<a href="index.html"',$data);
+  $file = fopen($export_path . "/" . $stage_file_name,"w");
+  fwrite($file,$data);
+  fclose($file);
+  $html_export_place = $export_path .'/'. $stage_file_name;  
+  drupal_goto($path = $html_export_place, $query = NULL, $fragment = NULL, $http_response_code = 302);
+  }
 }
\ No newline at end of file
