[interchange-cvs] interchange - heins modified 5 files

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Thu Jun 27 16:21:26 2002


User:      heins
Date:      2002-06-27 20:18:36 GMT
Modified:  dist/lib/UI ContentEditor.pm
Modified:  dist/lib/UI/pages/admin content.html content_editor.html
Modified:           do_view.html
Modified:  dist/lib/UI/pages/include page_editor
Log:
* Fix multiple problems with creating a new page in the content
  editor. TODO: Check behavior with new templates and components.

* Change default for HTML files in File Transfer to view as text.

* Retain CWD for File Transfer. Before, since the [file-navigator ..]
  was used to display admin/content.html, it would get set to
  templates/components.

Revision  Changes    Path
2.4       +28 -9     interchange/dist/lib/UI/ContentEditor.pm


rev 2.4, prev_rev 2.3
Index: ContentEditor.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/ContentEditor.pm,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -r2.3 -r2.4
--- ContentEditor.pm	3 Jun 2002 17:46:00 -0000	2.3
+++ ContentEditor.pm	27 Jun 2002 20:18:36 -0000	2.4
@@ -2,7 +2,7 @@
 #
 # UI::ContentEditor - Interchange page/component edit
 # 
-# $Id: ContentEditor.pm,v 2.3 2002/06/03 17:46:00 kwalsh Exp $
+# $Id: ContentEditor.pm,v 2.4 2002/06/27 20:18:36 mheins Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -23,7 +23,7 @@
 
 package UI::ContentEditor;
 
-$VERSION = substr(q$Revision: 2.3 $, 10);
+$VERSION = substr(q$Revision: 2.4 $, 10);
 $DEBUG = 0;
 
 use POSIX qw/strftime/;
@@ -148,6 +148,7 @@
 	my ($tref, $opt) = @_;
 	$opt ||= {};
 
+	
 	my $type = $tref->{ui_type};
 
 	my $tdb = get_tdb();
@@ -349,14 +350,20 @@
 	}
 
 	if(! $tref) {
+#::logDebug("no tref first try...");
 		my $topt = { %$opt };
 		undef $topt->{dir};
+		undef $topt->{new};
 		$topt->{type} = 'template';
 		#$topt->{single} = 1;
 		$tref = read_template($tpl, $topt);
 	}
 
+	assert('template_reference', $tref, 'HASH')
+		or undef $tref;
+
 	if (! $tref) {
+#::logDebug("no tref second try...");
 		pain('read_template', '%s %s not found', 'template', $tpl);
 		$tref = read_template('', { new => 1, type => 'template'});
 	}
@@ -373,12 +380,12 @@
 	my $body = delete $pref->{ui_body};
 
 	unless(defined $body) {
-		### Already parsed, match slots and leave
+		### Already parsed, match slots and leave if not new page
 		match_slots($pref, $tref);
-		return;
+		return unless $opt->{new};
 	}
 
-	my @slots = @{ $tref->{ui_slots} || [] };
+	my @slots = @{ $pref->{ui_slots} || $tref->{ui_slots} || [] };
 
 	#$body =~ s/\r\n/\n/g;
 
@@ -485,7 +492,7 @@
     while($controls =~ s{
 						(?:
 							\[
-								(set|tmp(?:[-_]no)?|seti)
+								(seti?|tmpn?)
 							\s+
 								([^\]]+)
 							\]
@@ -724,6 +731,7 @@
 	my $might_be_single;
 
 	if(! @data and $opt->{new}) {
+#::logDebug("no data, and new");
 		$opt->{type} ||= 'page';
 		my $prefix = "ui_$opt->{type}";
 		my $ref = {
@@ -752,6 +760,7 @@
 
 	foreach my $dref (@data) {
 		my ($data, $source) = @{$dref || []};
+#::logDebug("data is $data");
 		my $type;
 		my $ref;
 
@@ -906,7 +915,6 @@
 }
 sub page_component_editor {
 	my ($name, $pos, $comp, $pref, $opt) = @_;
-#::logDebug("called page_component_editor, comp=" . ::uneval($comp));
 
 	assert('page reference', $pref, 'HASH')
 		or return undef;
@@ -914,9 +922,13 @@
 	assert('component reference', $comp, 'HASH')
 		or return undef;
 
+	$name ||= $comp->{code};
+
+#::logDebug("called page_component_editor, name=$name comp=" . ::uneval($comp));
 	my $hidden = { 
 			ui_name   => $pref->{ui_name},
 			ui_source => $pref->{ui_source},
+			ui_page_template => $pref->{ui_page_template},
 			ui_type   => $pref->{ui_type},
 			ui_content_op => 'modify_component',
 			ui_content_pos => $pos,
@@ -928,6 +940,7 @@
 
 	my $topt = { %$opt };
 	delete $topt->{dir};
+	delete $topt->{new};
 	$topt->{type} = 'component';
 	my $cref = $store->{$name} || read_template($name, $topt);
 
@@ -1182,6 +1195,7 @@
 	for my $c (@$slots) {
 		$pos++;
 		my $r = { %$c };
+		$r->{component} ||= $r->{code};
 #::logDebug("slot pos=$pos, slot=" . ::uneval($c));
 		delete $r->{_editor_table};
 		if($r->{where}) {
@@ -1447,7 +1461,7 @@
 			push @bods, $body;
 			push @bods, "<!-- END CONTENT -->";
 		}
-		else {
+		elsif ($var =~ /^[A-Z]/) {
 			push @bods, '@_' . $var . '_@';
 		}
 	}
@@ -2147,8 +2161,11 @@
 
 	my $tmp;
 	if(! $pref) {
-		$opt->{new} = 1;
+#::logDebug("No page template");
+		$opt->{new_page} = 1;
+		$opt->{template} ||= $opt->{ui_page_template};
 		$pref = read_template($opt->{ui_name}, $opt);
+#::logDebug("page template=$pref");
 		$name = $opt->{ui_name} || $opt->{name} || 'new';
 		$pref->{ui_name} = $name;
 	}
@@ -2163,6 +2180,7 @@
 
 	$pstore->{$name} = $pref;
 	parse_page($pref, $opt);
+	publish_page($pref, $opt) if $opt->{new_page};
 #::logDebug("found a template name=$pref->{ui_name} store=$pstore: " . uneval($pref));
 
 	my ($overall, $comp) = page_region($pref, $opt);
@@ -2340,6 +2358,7 @@
 	my $template;
 
 	$opt->{type} ||= 'page';
+	$opt->{ui_page_template} ||= $CGI->{ui_page_template};
 
 	## If we get a ref, assume it is already parsed
 	if(ref $item) {



1.2       +2 -0      interchange/dist/lib/UI/pages/admin/content.html


rev 1.2, prev_rev 1.1
Index: content.html
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/pages/admin/content.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- content.html	16 Feb 2002 09:39:10 -0000	1.1
+++ content.html	27 Jun 2002 20:18:36 -0000	1.2
@@ -20,6 +20,7 @@
 [/if]
 
 [calc]
+	$cwd = $Session->{ui_cwd};
 	sub tmp_display_in_progress {
 		my ($type) = shift;
 		my $store;
@@ -136,6 +137,7 @@
 			edit_page=content_editor
 			edit_form="ui_name=~RN~&ui_type=component"
 			]
+	[calc] $Session->{ui_cwd} = $cwd; return; [/calc]
 	</td>
 </tr>
 



1.2       +59 -1     interchange/dist/lib/UI/pages/admin/content_editor.html


rev 1.2, prev_rev 1.1
Index: content_editor.html
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/pages/admin/content_editor.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- content_editor.html	16 Feb 2002 09:39:10 -0000	1.1
+++ content_editor.html	27 Jun 2002 20:18:36 -0000	1.2
@@ -29,12 +29,70 @@
 	They can be relocated to a catalog-specific place
 	by copying to CATROOT/include.
 [/comment]
-[if cgi ui_type eq component]
+[if cgi new]
+<form action="[area __UI_BASE__/content_editor]">
+<table width="60%">
+<tr>
+	<td style="font-weight: bolder; text-align: right">
+		[calc] return "\u$CGI->{ui_type}"; [/calc] name
+	</td>
+	<td>
+		[set page_name_click]
+			[calc]
+				$CGI->{ui_name} =~ s/^\s+//;
+				$CGI->{ui_name} =~ s/\s+$//;
+				$CGI->{ui_name} = $Tag->filter({
+													op => 'filesafe',
+													body => $CGI->{ui_name},
+												});
+				my $pat = quotemeta $Config->{HTMLsuffix};
+		#Debug("pat=$pat");
+				$pat = qr/$pat$/;
+		#Debug("pat=$pat");
+				$CGI->{ui_name} .= $Config->{HTMLsuffix}
+					unless $CGI->{ui_name} =~ $pat;
+		#Debug("page=$CGI->{ui_name}");
+				return;
+			[/calc]
+		[/set]
+		<input type=text   name="ui_name" size=30>
+		<input type=hidden name="mv_action" value="back">
+		<input type=hidden name="mv_click" value="page_name_click">
+		<input type=hidden name="ui_type" value="[cgi ui_type]">
+		<input type=hidden name="ui_return_to" value="[cgi ui_return_to]">
+	</td>
+</tr>
+	[if cgi ui_type eq page]
+<tr>
+	<td style="font-weight: bolder; text-align: right">
+		Template type:
+	</td>
+	<td>
+			 [display
+							name=ui_page_template
+							type=select
+							default="[page-param ui_page_template]"
+							passed="[content-info templates=1]"
+							]
+	</td>
+</tr>
+	[/if]
+<tr>
+	<td> &nbsp; </td>
+	<td>
+		<input type=submit value="[L]Create new page[/L]">
+	</td>
+</tr>
+</table>
+</form>
+[elsif cgi ui_type eq component]
 	[include include/component_editor]
+[/elsif]
 [elsif cgi ui_type eq template]
 	[include include/template_editor]
 [/elsif]
 [else]
+	[set page_name_click][/set]
 	[include include/page_editor]
 [/else]
 [/if]



2.1       +2 -1      interchange/dist/lib/UI/pages/admin/do_view.html


rev 2.1, prev_rev 2.0
Index: do_view.html
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/pages/admin/do_view.html,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -r2.0 -r2.1
--- do_view.html	18 Jul 2001 02:22:00 -0000	2.0
+++ do_view.html	27 Jun 2002 20:18:36 -0000	2.1
@@ -50,7 +50,8 @@
 	else {
 		$Scratch->{content_type} = $Tag->filter('mime_type', $_);
 		$Scratch->{content_type} = $CGI->{content_type} || "text/plain"
-			if $Scratch->{content_type} eq 'application/octet-stream';
+			if $Scratch->{content_type} eq 'application/octet-stream'
+			or $Scratch->{content_type} eq 'text/html';
 	}
 	return;
 [/perl][if scratch violation]



1.2       +1 -1      interchange/dist/lib/UI/pages/include/page_editor


rev 1.2, prev_rev 1.1
Index: page_editor
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/pages/include/page_editor,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- page_editor	16 Feb 2002 09:39:10 -0000	1.1
+++ page_editor	27 Jun 2002 20:18:36 -0000	1.2
@@ -1,4 +1,4 @@
-[content-editor name="[cgi ui_name]" type="[cgi ui_type]"]
+[content-editor name="[cgi ui_name]" type="page"]
 [pages]
 
 <script language=JavaScript>