[interchange-cvs] interchange - heins modified dist/lib/UI/ui.cfg

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sun Jul 27 17:51:00 EDT 2003


User:      heins
Date:      2003-07-27 20:51:02 GMT
Modified:  dist/lib/UI ui.cfg
Log:
* Add ability to manipulate any [set setting]value[/set] (tmpn?, seti also)
  via meta header edit on Mozilla.

  Same procedure, just add a meta_header:

  	<meta name=setting content="tmpn;setting_name;The setting value">

  and that setting will be modified accordingly.

  Does not remove settings, only sets the ones found in headers.

* By the way, to test this you can do:

	 1. Build stock foundation demo with latest CVS.

	 2. Open home page with Mozilla 1.2 or higher (1.0 may work),
		log in as admin.

	 3. Go to catalog home page and click "show tags" link at
		lower left.

	 4. Hit Ctrl-E (or File->Edit Page) and edit the page.

	 5. Go to "HTML source" and find <meta ...> settings. Change
		any, or go to BEGIN CONTENT and change page content.

	 6. Go to File->Publish As

	 7. Accept existing filename, or adjust filename to save
		as new file

	 8. Check "include images and other files".

	 9. Click "same location as page".

	10. Click Settings tab.

	11. Publishing address:

			http://yourserver.com/cgi-bin/foundation/publish_admin/

	12. Home page address:

			http://yourserver.com/cgi-bin/foundation/

	13. Click Publish button.

Revision  Changes    Path
2.13      +55 -12    interchange/dist/lib/UI/ui.cfg


rev 2.13, prev_rev 2.12
Index: ui.cfg
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/ui.cfg,v
retrieving revision 2.12
retrieving revision 2.13
diff -u -r2.12 -r2.13
--- ui.cfg	27 Jul 2003 06:34:43 -0000	2.12
+++ ui.cfg	27 Jul 2003 20:51:02 -0000	2.13
@@ -114,6 +114,24 @@
 		}
 	}
 
+	while($$html =~ m{
+						\[ (seti?|tmpn?) \s+ (\w+) \s*\]
+							(.*?)
+						\[/\1\]
+						(?=.*
+							(<!--+\s+BEGIN\s+PREAMBLE|\@_\w+_TOP_\@)
+						)
+					}isgx
+				)
+	{
+		my $type = $1;
+		my $parm = $2;
+		my $val = HTML::Entities::encode_entities($3);
+		next if $parm eq 'meta_header';
+		next if $parm eq 'page_title';
+		push @headers, qq{<meta name="setting" content="$type;$parm;$val">};
+	}
+
 	my $meta_string = join "\n", @headers;
 	if($meta_string) {
 		$$html =~ s{(\[(seti?|tmpn?)\s+meta_header\s*\])(.*?\[/\2])}
@@ -230,22 +248,37 @@
 		$p->parse($content);
 		$header{page_title} = $p->header('title');
 		
+		my %sets;
 		my @components;
 		my $compcheck = sub {
 			my($hname, $value) = @_;
 #::logDebug("Calling compcheck name=$hname value=$value");
-			return unless lc($hname) eq 'x-meta-component';
+			$hname = lc $hname;
+			return unless $hname =~ /^x-meta-(\w+)/;
+			$hname = $1;
+			if($hname eq 'component') {
 #::logDebug("doing $value");
-			my ($idx, $name, $val) = split /;/, $value, 3;
-			return unless $idx > 0;
-			$components[$idx - 1] ||= [];
-			$val = HTML::Entities::decode_entities($val);
-			my $string = join "",
-							"[$name]",
-							$val,
-							"[/$name]",
-							;
-			push @{$components[$idx - 1]}, $string;
+				my ($idx, $name, $val) = split /;/, $value, 3;
+				return unless $idx > 0;
+				$components[$idx - 1] ||= [];
+				$val = HTML::Entities::decode_entities($val);
+				my $string = join "",
+								"[$name]",
+								$val,
+								"[/$name]",
+								;
+				push @{$components[$idx - 1]}, $string;
+			}
+			elsif ($hname eq 'setting') {
+				my ($type, $name, $val) = split /;/, $value, 3;
+				$val = HTML::Entities::decode_entities($val);
+				my $string = join "",
+								"[$type $name]",
+								$val,
+								"[/$type]",
+								;
+				$sets{$name} = $string;
+			}
 		};
 
 		$p->header->scan($compcheck);
@@ -267,6 +300,13 @@
 			$top =~ s{(\[control\s+reset=1\s*\]).*(\[control\s+reset=1\s*\])}
 			         {$1$cstring$2}si;
 		}
+
+		for(keys %sets) {
+			$top =~ s{\[(seti?|tmpn?)\s+$_\s*\].*?\[/\1\]}
+					 {$sets{$_}}s
+			  or $top =~ s{\[/comment]\s*}{[/comment]\n$sets{$_}}
+			  or $top =~ s{^}{$sets{$_}\n};
+		}
 #::logDebug("header title=$header{page_title} object" . ::uneval($p));
 		$top =~ s{(\[(seti?|tmpn?)\s+(\w+)\s*\])(.*?)(\[/\2\])}
 				{$1 . ($header{$3} || $4) . $5}eg;
@@ -322,7 +362,10 @@
 							$1 . $dir . $2#ige;
 		}
 
-		$$CGI::put_ref = join "\n",
+		$top =~ s/\s+$//;
+		$content =~ s/^\s+//;
+		$content =~ s/\s+$//;
+		$$CGI::put_ref = join "\n\n",
 							$top,
 							'<!-- BEGIN CONTENT -->',
 							$content,







More information about the interchange-cvs mailing list