>
>
>I changed my sesConverter.cfm to add fuseaction to the path_info
>before parsing it. So my URL /idx.cfm/news.read/id/1234.htm will
>translate into:
>
>attributes.fuseaction = "news.read"
>attributes.id = "1234"
>
I've been playing around with the same concept, but using a slash to
separate the circuit and fuseaction. For me, "news/read" looks more
"normal," like a directory/file combination.
This file requires the circuit/fuseaction pair to be the first
name/value pair. The only exception is when it finds CFID and CFTOKEN
first. It will extract those first, and then look for the next
name/value pair. (This is for those of you who like to include CFID and
CFTOKEN in your #self# variable.)
To make sure we can force these to be first, I've been playing with
including them in form action attributes and link href attributes.
Everything seems to be working fine on my system. Just remember that
you have to use the SESrBaseName variable you defined in any URLs, e.g.
<form action="#baseHREF##self#/home/login.htm" ...>
or
<a href="#baseHREF##self#/home/login.htm">Login</a>
Both of the above examples will generate:
attributes.fuseaction="home.login"
If anyone tries it out, let me know how it works for you. I don't have
any other server environments to test it on.
Pete
--
Pete Krueger
[EMAIL PROTECTED]
==^================================================================
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrFMa.bV0Kx9
Or send an email to: [EMAIL PROTECTED]
T O P I C A -- Register now to manage your mail!
http://www.topica.com/partner/tag02/register
==^================================================================
<!--- -->
<fusedoc language="ColdFusion 4.5.2" specification="2.0">
<responsibilities>
I take a search engine safe URL and copy the variables
it contains into the URL structure, based on the SES
functionality of formurl2attributessearch.cfm by
Steve Nelson.
Instead of using index.cfm?variable=value you would use:
index.cfm/variables/value.cfm
If you are using formURL2attributes, you will call this tag first
If you use this tag you won't use formurl2attributesSearch
</responsibilities>
<properties>
<property name="version" value="1.41" />
<property name="lastUpdated" value="28-Feb-2002" />
<history author="Bert Dawson" email="[EMAIL PROTECTED]"
role="Architect" type="Create"/>
<history author="Erik Voldengen" email="[EMAIL PROTECTED]"
role="Architect" type="Create">
Made a ton of changes to Bert's code to make it
more vanilla, and suited as a fbx file. BETA!
</history>
<history author="Bert Dawson" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
ping
</history>
<history author="Erik Voldengen" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
pong
</history>
<history author="Bert Dawson" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
ping
</history>
<history author="Erik Voldengen" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
pong
</history>
<history author="Bert Dawson" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
ping
</history>
<history author="Erik Voldengen" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
pong!
Added the "super friendly" option of making this file
called as a tag or not. You can pass the variables in
via request, variables, or attributes scope. The variable
containing the basehref is set to caller.* when called
as a custom tag.
</history>
<history author="Erik Voldengen" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
(ping pong ping)
Bert submitted code to add a user defined variable for the
string we use to denote NULL values (sesEmptyString).
Removed check for Len(SESdummyExtension) in the initialization
code
since it's redundant (Bert).
1.3 didn't work right with some Apache web servers.
Apache/cgi.request_uri
seems to be the equiv to IIS/cgi.path_info. path_info can
still exist
with Apache, but without the template information. Added code
to
check for request_uri, then path_info, then just set it blank
if
neither has a value (Erik).
</history>
<history author="Bert Dawson" email="[EMAIL PROTECTED]"
role="Architect" type="Update">
pang!
removed IsDefined() checks on cgi vars since this will always
return true
the line that adds null values between adjacent slashes was
using the
string "null" - now uses the variable #emptyString# (NB the //
trick
doesn't work on win2k/CF5/IIS - the cgi.path_info never has
double slashes in it...)
</history>
<history author="Pete Krueger" email="[EMAIL PROTECTED]" role="Architect"
type="Update" date="28-Feb-2002">
Added ability to remove "fuseaction" from the SES URL. It first looks for cfid
and cftoken, in case the developer has to preserve state and includes it in the
'self'
variable. It then looks for the existence of "fuseaction" in the URL. If it
doesn't
exist, we're using shortened notation, so it grabs the very next name/value pair
and
treats it as circuit/fuseaction (e.g.
http://server.com/app/index.cfm/home/welcome.cfm).
Creates a fuseaction variable and assigns it to the URL scope (e.g.
URL.fuseaction=
home.welcome) for normal processing.
</history>
<history author="Pete Krueger" email="[EMAIL PROTECTED]" role="Architect"
type="Update" date="17-Apr-2002">
Adjusted the automatic assignment of fuseaction to include the case where the
fuseaction
might not exist, i.e. "index.cfm/circuit//" translates to "fuseaction=circuit."
This
allows for the use of "fusebox.defaultfuseaction" in the switch statement.
</history>
<note author="Pete Krueger" date="17-Apr-2002">
Using SESConverter, it's possible to include the fuseaction in your form's action
attribute (e.g. "form action='index.cfm/home/start/' method='get'"), but you
must use
the SESrBaseName variable you defined to build the url (e.g. "form
action='#baseHREF#index.cfm/home/start/').
</note>
</properties>
<io>
<in>
<string name="SESrBaseName" scope="variables" default="base"
optional="Yes" comments="the variable name to return the base ref in" oncondition="set
in variables scope before this file is run"/>
<string name="SESrBaseName" scope="attributes" default="base"
optional="Yes" comments="the variable name to return the base ref in"
oncondition="called as custom tag and passed as a parameter"/>
<string name="SESrBaseName" scope="request" default="base"
optional="Yes" comments="the variable name to return the base ref in" oncondition="set
in request scope before this file is run"/>
<string name="SESdummyExtension" scope="variables"
optional="Yes" comments="the dummy extension (including the '.') to remove from the
end if the cgi.path_info before it is converted to URL scope variables"
oncondition="called as a custom tag"/>
<string name="SESdummyExtension" scope="attributes"
optional="Yes" comments="the dummy extension (including the '.') to remove from the
end if the cgi.path_info before it is converted to URL scope variables"
oncondition="called as a custom tag"/>
<string name="SESdummyExtension" scope="request"
optional="Yes" comments="the dummy extension (including the '.') to remove from the
end if the cgi.path_info before it is converted to URL scope variables"
oncondition="called as a custom tag"/>
<string name="SESemptyString" scope="variables" optional="Yes"
default="#request.SESemptyString#" comments="url values which equal this will be
changed to be empty string"/>
<string name="SESemptyString" scope="attributes"
optional="Yes" default="#request.SESemptyString#" comments="url values which equal
this will be changed to be empty string"/>
<string name="SESemptyString" scope="request" optional="Yes"
default="null" comments="url values which equal this will be changed to be empty
string"/>
</in>
<out>
<string scope="variables" name="#rBaseName#" optional="No"
comments="the variable containing the <base href>, name passed in above" />
</out>
</io>
</fusedoc> ---><cfscript>
//First off - get the variable names defined
/* Depending on how this tag was called, set the baseHREF
variable name, and dummy Extension value */
if (listlast(getbasetaglist()) IS "CF_SESCONVERTER") {
baseVarName="caller.baseHREF";
if (isDefined("attributes.SESrBaseName") AND Len(attributes.SESrBaseName))
{
baseVarName="caller." & attributes.SESrBaseName;
}
else if (isDefined("request.SESrBaseName") and Len(request.SESrBaseName))
{
baseVarName="caller." & request.SESrBaseName;
}
// Now Check for the dummy extension variable
dummyExtension=".htm";
if (isDefined("attributes.SESdummyExtension"))
{
dummyExtension=attributes.SESdummyExtension;
}
else if (isDefined("request.SESdummyExtension"))
{
dummyExtension=request.SESdummyExtension;
}
// We use 'null' to denote null values by default. You can can change it.
emptyString = "null";
if (isDefined("attributes.SESemptyString") AND Len(attributes.SESemptyString))
{
emptyString=attributes.SESemptyString;
}
else if (isDefined("request.SESemptyString") AND Len(request.SESemptyString))
{
emptyString=request.SESemptyString;
}
}
//Otherwise, it's not a custom tag
else {
baseVarName="baseHREF";
if (isDefined("variables.SESrBaseName") and Len(variables.SESrBaseName))
{
baseVarName = variables.SESrBaseName;
}
else if (isDefined("request.SESrBaseName") and Len(request.SESrBaseName))
{
baseVarName = request.SESrBaseName;
}
// Now Check for the dummy extension variable
dummyExtension=".htm";
if (isDefined("variables.SESdummyExtension"))
{
dummyExtension=variables.SESdummyExtension;
}
else if (isDefined("request.SESdummyExtension"))
{
dummyExtension=request.SESdummyExtension;
}
// We use 'null' to denote null values by default. You can can change it.
emptyString = "null";
if (isDefined("variables.SESemptyString") AND Len(variables.SESemptyString))
{
emptyString=variables.SESemptyString;
}
else if (isDefined("request.SESemptyString") AND Len(request.SESemptyString))
{
emptyString=request.SESemptyString;
}
}
// Now, on with the SES conversion.
/* depending on the web server, get the info from different cgi vars:
cgi.request_uri for Apache
cgi.path_info for IIS
*/
currentPath = '';
if (Len(cgi.request_uri))
{
currentPath = cgi.request_uri;
}
else if (Len(cgi.path_info))
{
currentPath = cgi.path_info;
}
/* only do stuff if currentPath has len, otherwise it breaks the RemoveChars()
function */
if (Len(currentPath)) {
/* replace any ?,&,= characters that are in the url for some reason */
cleanpathinfo=REReplace(currentPath, "\&|\=", "/" ,"ALL");
writeoutput(cleanpathinfo & "<br>");
writeoutput(currentPath & "<br>");
/* get everything after the first occurence of ".XXX/",
where XXX is .cfm, or whatever you use for your templates
In other words, get the query string */
cleanpathinfo=RemoveChars(cleanpathinfo,1,Find("/",cleanpathinfo,Find(".",cleanpathinfo,1)));
/* If it's a SES url, do all the crunching. If not, skip it */
if (Len(cleanpathinfo) AND cleanpathinfo NEQ CGI.Script_Name) {
// Remove fake file extension, pass empty value to skip this
if (Len(dummyextension)) {
if (Right(cleanpathinfo,Len(dummyextension)) IS
dummyextension) {
cleanpathinfo =
Left(cleanpathinfo,Len(cleanpathinfo)-Len(dummyextension));
}
}
// add a null value if there is a trailing slash
if (Right(cleanpathinfo,1) IS '/') {
cleanpathinfo = cleanpathinfo & emptyString;
}
//add null values between adjacent slashes
cleanpathinfo = Replace(cleanpathinfo,"//","/" & emptyString &
"/","all");
// get a copy of anything in the url scope
originalURL = Duplicate(url);
SlashLen = ListLen(cleanpathinfo,"/");
// try to get fuseaction as first name/value pair
start=1;
if ((SlashLen gte 2) and (not ListFindNoCase(cleanpathinfo, "fuseaction", "/"))) {
urlname=ListGetAt(cleanpathinfo, start, '/');
// if cfid and cftoken are first, take care of them
if ((urlname is "cfid") or (urlname is "cftoken")) {
StructInsert(url, urlname, ListGetAt(cleanpathinfo, start+1, '/'), true);
StructInsert(url, ListGetAt(cleanpathinfo, start+2, '/'),
ListGetAt(cleanpathinfo, start+3, '/'), true);
start=start+4;
urlname=ListGetAt(cleanpathinfo, start, '/');
}
circuitname=urlname;
fuseactionname=ListGetAt(cleanpathinfo, start+1, '/');
if (fuseactionname eq emptyString) {
urlvalue=urlname & ".";
}
else {
urlvalue=urlname & "." & fuseactionname;
}
urlname="fuseaction";
StructInsert(url, urlname, urlvalue, true);
start=start+2;
}
// get rest of the name/value pairs
for (i=start; i LTE SlashLen; i=i+2) {
/* get this item from the list into the local var i */
urlname = ListGetAt(cleanpathinfo, i, '/');
if (i LT SlashLen) {
urlvalue = ListGetAt(cleanpathinfo, i+1, '/');
urlvalue = replacenocase(urlvalue,"slash_","/","all");
if (urlvalue IS emptyString) {
urlvalue = "";
}
StructInsert(url, urlname, urlvalue, true);
}
}
// return stuff that was in the url scope originally
StructAppend(url,originalURL,true);
}
}
// now sort out the base href
s_Prefix = "http";
if (CGI.HTTPS EQ "ON") {
s_Prefix = "https";
}
s_Port = "";
if (CGI.SERVER_PORT NEQ "80") {
s_Port = ":" & CGI.SERVER_PORT;
}
s_Base = REReplace(CGI.SCRIPT_NAME, "[^/]+\.cfm.*", "");
s_Base= s_Prefix & "://" & CGI.SERVER_NAME & s_Port & s_Base;
"#baseVarName#" = s_Base;
</cfscript>