Index: openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql,v
diff -u -r1.1.2.2 -r1.1.2.3
--- openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql	12 Dec 2002 20:02:37 -0000	1.1.2.2
+++ openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql	16 Dec 2002 03:22:17 -0000	1.1.2.3
@@ -22,6 +22,7 @@
 					default null,
 		context_id	in acs_objects.context_id%TYPE 
 					default null
+		,mime_type      in cr_revisions.mime_type%TYPE  default 'text/html'
 	) return static_pages.static_page_id%TYPE is
 		v_item_id	static_pages.static_page_id%TYPE;
 	begin
@@ -34,7 +35,7 @@
 			parent_id	=> static_page.new.folder_id,
 			name	=> static_page.new.filename,
 			title	=> static_page.new.title,
-			mime_type	=> 'text/html',
+			mime_type       => static_page.new.mime_type,
 			creation_date	=> static_page.new.creation_date,
 			creation_user	=> static_page.new.creation_user,
 			creation_ip	=> static_page.new.creation_ip,
Index: openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql	12 Dec 2002 18:39:40 -0000	1.1.2.1
+++ openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql	16 Dec 2002 03:22:17 -0000	1.1.2.2
@@ -28,6 +28,7 @@
 					default null,
 		context_id	in acs_objects.context_id%TYPE 
 					default null
+		,mime_type      in cr_revisions.mime_type%TYPE  default 'text/html'
 	) return static_pages.static_page_id%TYPE;
 
 	procedure delete (
Index: openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-4.2a-4.3.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-4.2a-4.3.sql,v
diff -u -r1.1.2.3 -r1.1.2.4
--- openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-4.2a-4.3.sql	15 Dec 2002 23:25:55 -0000	1.1.2.3
+++ openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-4.2a-4.3.sql	16 Dec 2002 03:22:27 -0000	1.1.2.4
@@ -12,6 +12,7 @@
 -- matter.  The names are still all unique from each other, which is
 -- all that matters.  --atp@piskorski.com, 2002/12/12 13:59 EST
 
+@static-page-ph.sql
 @static-page-pb.sql
 
 update apm_package_types  set singleton_p = 'f'
@@ -24,3 +25,21 @@
 -- --atp@piskorski.com, 2002/12/12 16:17 EST
 
 update static_pages  set filename = '/www' || filename;
+
+
+-- Note: If you want to check that the non-html mime types are being
+-- set correctly, try this query: --atp@piskorski.com, 2002/12/15
+-- 22:19 EST
+-- 
+-- column filename  format a60
+-- select  s.folder_id  ,s.static_page_id
+--   ,c.item_id
+--   ,s.filename
+--   ,r.mime_type
+-- from static_pages s, cr_items c
+--   ,cr_revisions r
+-- where s.static_page_id = c.item_id
+--   and s.folder_id = c.parent_id
+--   and c.item_id = r.item_id
+--   --and r.mime_type != 'text/html'
+-- order by s.folder_id, s.filename ;
Index: openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql,v
diff -u -r1.1.2.2 -r1.1.2.3
--- openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql	12 Dec 2002 20:02:59 -0000	1.1.2.2
+++ openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql	16 Dec 2002 03:22:37 -0000	1.1.2.3
@@ -23,6 +23,7 @@
                 integer, 	-- context_id	in acs_objects.context_id%TYPE
                                 --        default null
 		integer		-- mtime
+		,varchar        -- mime_type	in cr_revisions.mime_type%TYPE  default 'text/html'
         ) returns integer as '
 	declare
                 p_static_page_id        alias for $1;
@@ -36,12 +37,12 @@
                 p_creation_ip           alias for $9;
                 p_context_id            alias for $10;
 		p_mtime			alias for $11;
+		p_mime_type		alias for $12;
 
                 v_item_id	        static_pages.static_page_id%TYPE;
                 v_permission_row        RECORD;
 		v_revision_id		integer;
 		v_is_live		boolean default ''t'';
-		v_mime_type		cr_revisions.mime_type%TYPE default ''text/html'';
 		v_storage_type		cr_items.storage_type%TYPE default ''file'';
         begin
                 -- Create content item; this also makes the content revision.
@@ -59,7 +60,7 @@
                         p_context_id,                   -- context_id
                         p_creation_ip,                  -- creation_ip
                         v_is_live,                          -- is_live
-                        v_mime_type,                  -- mime_type
+                        p_mime_type,			-- mime_type
 			p_content,                       -- text
 			v_storage_type,			 -- storage_type
 			FALSE,				 -- security_inherit_p
@@ -111,12 +112,14 @@
                 varchar, 	-- filename	in static_pages.filename%TYPE default null,
                 varchar, 	-- title	in cr_revisions.title%TYPE default null
 		integer		-- mtime
+		,varchar        -- mime_type	in cr_revisions.mime_type%TYPE  default 'text/html'
         ) returns integer as '
 	declare
                 p_folder_id             alias for $1;
                 p_filename              alias for $2;
                 p_title                 alias for $3;
 		p_mtime			alias for $4;
+		p_mime_type		alias for $5;
                
 	        v_static_page_id	static_pages.static_page_id%TYPE;	       
                 v_item_id	        static_pages.static_page_id%TYPE;
@@ -134,6 +137,7 @@
 			   NULL,	       -- creation_ip
 			   NULL,	       -- conext_id
 			   p_mtime	       -- mtime
+			   ,p_mime_type	       -- mime_type
 			   );
 	       
 end;' language 'plpgsql';
Index: openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql,v
diff -u -r1.9.2.2 -r1.9.2.3
--- openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql	12 Dec 2002 22:02:01 -0000	1.9.2.2
+++ openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql	16 Dec 2002 03:22:47 -0000	1.9.2.3
@@ -40,26 +40,23 @@
 
 <fullquery name="sp_sync_cr_with_filesystem_internal.do_sp_new">
       <querytext>
-
-		    begin
-			:1 := static_page.new(
-				  filename => :sp_filename,
-				  title => :page_title,
-				  folder_id => :parent_folder_id
-			      );
-		    end;
-
+begin
+:1 := static_page.new(
+  filename   => :sp_filename
+  ,title     => :page_title
+  ,folder_id => :parent_folder_id
+  ,mime_type => :mime_type
+);
+end;
       </querytext>
 </fullquery>
 
 
 <fullquery name="sp_sync_cr_with_filesystem_internal.insert_file_contents">
       <querytext>
-
 		    update cr_revisions set content = empty_blob()
 		    where revision_id = content_item.get_live_revision(:static_page_id)
 		    returning content into :1
-
       </querytext>
 </fullquery>
 
Index: openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql,v
diff -u -r1.17.2.2 -r1.17.2.3
--- openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql	12 Dec 2002 22:02:01 -0000	1.17.2.2
+++ openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql	16 Dec 2002 03:22:47 -0000	1.17.2.3
@@ -58,24 +58,20 @@
 
 <fullquery name="sp_sync_cr_with_filesystem_internal.do_sp_new">      
       <querytext>
-                select static_page__new(
-                        :parent_folder_id,       -- folder_id
-                        :sp_filename,                  -- filename
-                        :page_title,            -- title
-			:mtime_from_fs			-- mtime
-
-                );
+select static_page__new(
+  :parent_folder_id,  -- folder_id
+  :sp_filename,       -- filename
+  :page_title,        -- title
+  :mtime_from_fs      -- mtime
+  ,:mime_type         -- mime_type
+);
       </querytext>
 </fullquery>
 
 <fullquery name="sp_sync_cr_with_filesystem_internal.insert_file_contents">
       <querytext>
-
 		update cr_revisions set content = :sp_filename
-		where revision_id = content_item__get_live_revisions(:static_page_id)
-
-
-      </querytext>
+		where revision_id = content_item__get_live_revisions(:static_page_id)      </querytext>
 </fullquery>
 
 
Index: openacs-4/packages/static-pages/tcl/static-pages-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs.tcl,v
diff -u -r1.11.2.5 -r1.11.2.6
--- openacs-4/packages/static-pages/tcl/static-pages-procs.tcl	15 Dec 2002 23:49:55 -0000	1.11.2.5
+++ openacs-4/packages/static-pages/tcl/static-pages-procs.tcl	16 Dec 2002 03:22:47 -0000	1.11.2.6
@@ -465,21 +465,11 @@
                 # calling static_page.new - thus the addition of mutex
                 # locking.  --atp@piskorski.com, 2001/08/27 01:20 EDT
 
-		set static_page_id [db_exec_plsql do_sp_new {
-		    begin
-			:1 := static_page.new(
-				  filename => :sp_filename,
-				  title => :page_title,
-				  folder_id => :parent_folder_id
-			      );
-		    end;
-		}]
+                set mime_type [sp_maybe_create_new_mime_type $sp_filename]
+		set static_page_id [db_exec_plsql do_sp_new {}]
 		# Check if -blobs [list $file_contents] would be faster:
-		db_dml insert_file_contents {
-		    update cr_revisions set content = empty_blob()
-		    where revision_id = content_item.get_live_revision(:static_page_id)
-		    returning content into :1
-		} -blob_files [list $file]
+		db_dml insert_file_contents {} -blob_files [list $file]
+
 		if { [string length $file_add_proc] > 0 } {
 		    uplevel $stack_depth "$file_add_proc $file $static_page_id"
 		}
@@ -684,6 +674,73 @@
 }
 
 
+ad_proc sp_maybe_create_new_mime_type {
+    file_name
+} {
+    This proc should be identical to fs_maybe_create_new_mime_type
+    from the file-storage package.  However, we don't want to depend
+    on file-storage being loaded, so if it isn't, define our own
+    implementation here.  --atp@piskorski.com, 2002/12/15 19:34 EST
+
+    <p>
+    The content repository expects the MIME type to already be defined
+    when you upload content.  We use this procedure to add a new type
+    when we encounter something we haven't seen before.
+
+    @author Andrew Piskorski (atp@piskorski.com)
+    @creation-date 2002-12-15
+} {
+    set func {fs_maybe_create_new_mime_type}
+
+    if { [nsv_exists api_proc_doc $func] ||
+         ![empty_string_p [namespace eval :: [list info procs $func]]]
+     } {
+        # The file-storage version of this proc exists, use it:
+        return [list $func $file_name]
+
+    } else {
+        # Fall back to local implementation:
+
+        set file_extension [string trimleft [file extension $file_name] "."]
+        if {[empty_string_p $file_extension]} {
+            return "*/*"
+        }
+
+        # TODO: This insert may fail due to a race condition.  Should be
+        # locking the cr_mime_types table first:
+        # --atp@piskorski.com, 2001/08/23 20:20 EDT
+
+        if {![db_0or1row select_mime_type {
+            select mime_type
+            from cr_mime_types
+            where file_extension = :file_extension
+        }]} {
+            # A mime type for this file extension does not exist
+            # in the database.  Check to see AOLServer can 
+            # generate a mime type.
+
+            set mime_type [ns_guesstype $file_name]
+            
+            # Note: If AOLServer can't determine a mime type, 
+            # ns_guesstype will return */*. We still record
+            # a mime type for this file extension.  At a later
+            # date, the mime type for the file extension may be
+            # updated and, as a result, the files with that
+            # file extension will be associated with the
+            # proper mime types.
+
+            db_dml new_mime_type {
+                insert into cr_mime_types
+                (mime_type, file_extension)
+                values
+                (:mime_type, :file_extension)
+            }
+        }
+        return $mime_type
+    }
+}
+
+
 ad_proc -public sp_package_key_is {} {
    Simply returns the package key string for this package.
    @author Andrew Piskorski (atp@piskorski.com)