[prev in list] [next in list] [prev in thread] [next in thread]
List: bricolage-devel
Subject: Re: [Bricolage-Devel] Fixed URI prefs status: I think we need more
From: Adam Robinson <arobinson () about-inc ! com>
Date: 2002-03-18 19:48:01
[Download RAW message or body]
These patches make 'slug' an accepatable token for the 'Fixed URI
Format' pref. Additionally the uri_pref javascript has been removed
from 'lib.js' as well as the calls referring to it 'uri_pref.mc' (per
David's earlier request).
adam.
David Wheeler wrote:
>On Sun, 2002-03-17 at 22:43, Michael Slattery wrote:
>
>>Why is the slug forbidden to me in the fixed URI? Without the slug or
>>title or something to make a URI unique, all of the stories created
>>using the generic story template are at the root of the site.
>>
>
>IMO, you should have all the same options for the Fixed URI preference
>as for the normal URI pref. That means the slug, too. I should be able
>to make them both work the same way, if I like.
>
>Adam, would you put the slug back as an option for Fixed URI prefs?
>
>Thanks,
>
>David
>
["lib.js.diff" (text/plain)]
Index: comp/javascripts/lib.js
===================================================================
RCS file: /cvsroot/bricolage/bricolage/comp/javascripts/lib.js,v
retrieving revision 1.6
diff -u -r1.6 lib.js
--- comp/javascripts/lib.js 15 Mar 2002 22:55:02 -0000 1.6
+++ comp/javascripts/lib.js 18 Mar 2002 19:27:25 -0000
@@ -590,84 +590,3 @@
}
// end double list manager functions
-/* functions for validating uri format tokens */
-function checkURI( formName, fieldName ) {
- var val = eval( "document." + formName + "." + fieldName );
-
- if( val.value.substr( 0, 1 ) != '/' ) {
- eval( "'val.value = ' + '/' + 'val.value';" );
- }
- if( val.value.charAt( val.value.length - 1 ) != '/' ) {
- eval( "val.value = val.value + '/';" );
- }
-}
-
-function validateURI( formName, fieldName, fixed ) {
- var is_token, space, vals;
- var val = eval( "document." + formName + "." + fieldName + ".value" );
- var tmp = val;
- var j, k, token_count = 0;
- var acceptable_tokens = new Array( "categories", "day", "month", "year", "slug" );
- var bad_tokens = new Array();
- var good_tokens = new Array();
- var tokens = new Array();
-
- if( fixed == 1 ) {
- acceptable_tokens.pop();
- }
-
-//strip leading and trailing '/'s
- val = val.substr( 1, val.length - 2 );
-
-//load array of tokens
- var tmp_string;
- while( tmp.indexOf( '/' ) >= 0 ) {
-
- tmp_string = tmp.substr( 0, tmp.indexOf( '/' ) );
- if( tmp_string.length > 0 ) {
- tokens.push( tmp_string );
- }
-
- if( tmp.indexOf( '/' ) == -1 && tmp.length > 0 ) {
- tokens.push( tmp );
- } else {
- tmp = tmp.substr( ( tmp.indexOf( '/' ) + 1 ), ( tmp.length - 1 ) );
- }
- }
-
-//iterate through and validate tokens
- for( i = 0; i < tokens.length; i++ ) {
- if( tokens[i] != '' || tokens[i] != undefined ) {
- is_token = false;
- for( j = 0; j < acceptable_tokens.length; j++ ) {
- if( tokens[i] == acceptable_tokens[j] ) {
- is_token = true;
- break;
- }
- }
- if( !is_token ) {
- bad_tokens.push( tokens[i] );
- } else {
- good_tokens.push( tokens[i] );
- }
- }
- }
-
- if( bad_tokens.length > 0 ) {
- alert( "The following are not valid tokens: " + bad_tokens.join( ' ' ) +
- ". Invalid tokens will be excised from URI." );
- }
-
- if( good_tokens.length <= 0 ) {
- alert( 'No valid tokens found. Inserting default value.' );
- if( fixed == 1 ) {
- vals = 'categories';
- } else {
- vals = 'categories/year/month/day/slug';
- }
- } else {
- vals = good_tokens.join( '/' );
- }
-
- eval( "document." + formName + "." + fieldName + ".value = '/' + vals + '/'" );
-}
\ No newline at end of file
["pref.mc.diff" (text/plain)]
Index: comp/widgets/profile/pref.mc
===================================================================
RCS file: /cvsroot/bricolage/bricolage/comp/widgets/profile/pref.mc,v
retrieving revision 1.6
diff -u -r1.6 pref.mc
--- comp/widgets/profile/pref.mc 15 Mar 2002 22:55:02 -0000 1.6
+++ comp/widgets/profile/pref.mc 18 Mar 2002 19:19:19 -0000
@@ -30,12 +30,10 @@
my $disp_name = get_disp_name($type);
my $handle_parse_format = sub {
- my ( $value, $name ) = @_;
+ my ( $param, $name ) = shift( @_ );
my @acceptable_tokens = qw( categories day month year slug );
- my @bad_tokens;
-
- # slug is not a valid token for fixed URIs
- pop( @acceptable_tokens ) if( $name =~ /Fixed/ );
+ my ( @bad_tokens, @good_tokens );
+ my $value = $param->{ 'value' };
if( $value =~ /^\s*$/ ) {
return "No "$name" value specified."
@@ -43,9 +41,17 @@
$value =~ s#/?(.+)/?#$1#;
my @tokens = split( /\//, $value );
foreach my $token ( @tokens ) {
- my $match = grep( /$token/, @acceptable_tokens );
- push( @bad_tokens, $token ) unless( $match );
+ my $match = grep( $token eq $_ , @acceptable_tokens );
+
+ unless( $match ) {
+ push( @bad_tokens, $token );
+ } else {
+ push( @good_tokens, $token );
+ }
}
+
+ $param->{ 'value' } = '/' . join( '/', @good_tokens ) . '/';
+
return "The following invalid tokens were found: " . join( ", ", @bad_tokens )
if( scalar( @bad_tokens ) >= 1 );
}
@@ -68,7 +74,7 @@
# Validate URI Formats...
if( $name =~ /URI Format/ ) {
- if( my $err = &$handle_parse_format( $param->{ 'value' }, $name ) ) {
+ if( my $err = &$handle_parse_format( $param, $name ) ) {
add_msg( $err );
return;
}
["uri_pref.mc.diff" (text/html)]
Index: comp/widgets/profile/uri_pref.mc
===================================================================
RCS file: /cvsroot/bricolage/bricolage/comp/widgets/profile/uri_pref.mc,v
retrieving revision 1.1
diff -u -r1.1 uri_pref.mc
--- comp/widgets/profile/uri_pref.mc 15 Mar 2002 22:55:02 -0000 1.1
+++ comp/widgets/profile/uri_pref.mc 18 Mar 2002 19:19:38 -0000
@@ -5,13 +5,7 @@
</%args>
<%init>
-my @tokens;
-
- if( $fixed ) {
- @tokens = qw( categories day month year );
- } else {
- @tokens = qw( categories day month slug year );
- }
+my @tokens = qw( categories day month slug year );
</%init>
<table border="0" width="578">
@@ -21,11 +15,7 @@
<p>Assuming the current date is <i>03/07/2002</i> and a story in the
category <i>/subjects/articles/</i> with the slug <i>stuff</i>, the format string
<i>'/categories/year/month/day/slug/'</i> would yield the URI:
- <b>/subject/articles/2002/03/07/stuff/</b></p>
-% if( $fixed ) {
- <p><i>N.B.</i> the token, slug, is unavailable for Fixed URI Format</p>
-% }
- </td>
+ <b>/subject/articles/2002/03/07/stuff/</b></p></td>
</tr>
<tr>
<td colspan="2"> </td>
@@ -38,7 +28,5 @@
size => 128,
vals => $vals },
disp => 'Format String',
- value => $pref->get_value },
- js => 'onChange="checkURI( \'pref_profile\', \'value\' );
- validateURI( \'pref_profile\', \'value\', ' . $fixed . ' );"' );
+ value => $pref->get_value } );
</%perl>
_______________________________________________
Bricolage-Devel mailing list
Bricolage-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic