framework-one / fw1 Goto Github PK
View Code? Open in Web Editor NEWFW/1 - Framework One - is a lightweight, convention over configuration, MVC application framework for ColdFusion / CFML.
Home Page: http://framework-one.github.io
License: Other
FW/1 - Framework One - is a lightweight, convention over configuration, MVC application framework for ColdFusion / CFML.
Home Page: http://framework-one.github.io
License: Other
Add an option, default false, to suppress the implicit service() call.
In 2.0, this option will default to true.
It would be nice to pass data to a view().
I'm currently do this with an alternate version of view() and internalView() in my Application.cfc.
function partial( path, data="" ) {
var viewPath = parseViewOrLayoutPath( arguments.path, 'view' );
return getViewPartial( viewPath, data );
}
<cffunction name="getViewPartial" access="private" output="false" hint="Returns the UI generated by the named view.">
<cfargument name="viewPath" />
<cfargument name="data" default="" required="false" />
<cfset var rc = request.context />
<cfset var response = '' />
<cfset var local = structNew() />
<cfif not structKeyExists( request, "controllerExecutionComplete" ) >
<cfset raiseException( type="FW1.viewExecutionFromController", message="Invalid to call the view method at this point.",
detail="The view method should not be called prior to the completion of the controller execution phase." ) />
</cfif>
<cfsavecontent variable='response'><cfinclude template="#viewPath#"/></cfsavecontent>
<cfreturn response />
</cffunction>
I would be nice to see view() support this by default, instead of as a secondary method.
This is how I'm calling it
partial( "section/viewFile", rc.something.childData )
In my view, I can access it as #arguments.data# or simply #data#. There may be a better arg name, but I used "data" since that what comes back when a service is implicitly called.
User manager has a models folder. Should be model, singular. Also should check whether it really uses services/ folder since I think it manages CFCs in the bean factory?
Add a flag to enable SES URL handling (default 'off') - document that existing apps that rely on SES URLs will need to explicitly turn this 'on'.
If SES enabled, handle inbound links (as currently happens unconditionally). Need input on the breakage this may cause?
If SES enabled, buildURL() and redirect() should construct SES URLs.
Need to consider how to specify elements of paths and whether index.cfm should be omitted.
Mura developers are used to $ being a 'local' variable in a view. The Mura adapter passes its magic object into FW/1 via the URL (which ends up in the request scope). This enhancement would make life easier for Mura devs at the cost of adding a small conditional to the view & layout.
Recently added options are missing (unhandled extensions / paths for example).
From AJ Mercer:
I was also wondering about the 'rc' variable in Railo if Scope Cascading was set to 'Strict' what would happen?
The unhandledPath functionality should be moved to the beginning of the onRequestStart Method as discussed here: http://groups.google.com/group/framework-one/browse_thread/thread/a4e6eece3a62abb0
It would be a great help if FW/1 supported file names like the following: userservice, usercontroller, defaultmain etc. as an option inside the folders views, controllers, and services. I tend to have a large number of files open in CF Builder and it is a pain to find the correct tab for editing as it is very easy to have a few "default.cfm's" open. This optional naming convention would in line with controller method naming i.e. startitem().
in some cases you want to be able to redirect to a url that has an anchor like:
http://domain.com/apps/index.cfm?action=foo.edit&ID=196941#someAnchor
It would be nice if the redirect() method would allow for this. Some options that have been discussed are to add another optional parameter to redirect() or allow the action parameter like "section.item#someAnchor" and parse out the anchor.
Update to BuildUrl that sets basePath = arguments.path when arguments.action is your default action. This will allow Redirect() to actually redirect your website to the base url when using your default action. variables.fw.redirect('main.default') will redirect to http://www.site.com/ instead of http://www.site.com/index.cfm?action=main.default
This is an issue only when developing.
Scenario: if FW/1's config setting reloadApplicationOnEveryRequest = 'true' and a request is made via a cfajaxproxy the framework loads itself and ignores the unhandledExtensions and unhandledPaths config settings so the ajax request fails.
Set the reloadApplicationOnEveryRequest = 'false' and the cfajaxproxy requests work properly.
The error details produced by viewNotFound are misleading if setView has been called. The current code is also a bit of a maintenance problem since it is duplicating some of the logic of determining the view for the current action. I've sent a pull request that addresses this by recording the missing view in a separate request variable within buildViewAndLayoutQueue and then simply refers to that variable in viewNotFound.
It looks like all that is needed is this change to onRequestStart(), around line 531 (barely tested, might be other issues):
var pathInfo = replace(CGI.PATH_INFO,getContextroot(),"");
Otherwise it picks up the context path from CGI.PATH_INFO, which it shouldn't, I don't think.
FWIW, It might be nice to avoid accessing the CGI scope directly so much, in general.
Currently, it appears that FW/1 will test fileExists for various views and layouts on each request.
Since, on a production system, the existence of these files is not expected to change, caching their existence would afford some measure of performance increase.
On GoogleAppEngine, for instance, if a file does not exist in the package, App Engine seems to go to the "virtual filesystem" to check if its there - this behavior consists of a memcache and a datastore hit, which combined seem to take roughly 50ms.
The docs don't make it clear that '' is a valid key (and tells FW/1 to ignore the result of the service call).
I recently updated a legacy application to FW/1 and there are places where someone may have an old location bookmarked from within the application directory. However, when attempting to navigate to a nonexistent directory within the application, FW/1 automatically assumes that the nonexistent directory is the base of the application and will invoke the default error handling template for missing templates.
For instance, my application is at /myapp. If I try to navigate to /myapp/dne/index.cfm, FW/1 assumes that /myapp/dne is the base of the application and attempts to load templates from that location instead of the correct path of /myapp.
Introduce a configuration parameter to make the lowercasing of view references in FW/1 optional.
It will be more convenient and will not break existing code.
var Car = variables.fw.populate(new Car());
I've got an app with two subsystems - public and admin.
If I call ?action=user.edit
, then FW/1 automatically uses the default subsystem (public). But if I call buildURL('user.edit')
, it returns the fully-qualified querystring, ?action=public:user.edit
.
Would it be possible to have an option for buildURL()
to omit the default subsystem when generating URLs?
Error:
Element AUTH.ISLOGGEDIN is undefined in SESSION.
C:\Inetpub\wwwroot\FW1\examples\userManagerAccessControl\controllers\security.cfc(16) @ 14:24:34.072
From Jeff Gladnick:
It seems that you are forced to use urls that is based on the path, and you cannot modify this.
As a result, you have urls like /home/pages/user/view
For SEO purposes, it would be more optimal to be able to override this, with things like
/view-user-profile/
or whatever your heart desires.
The simplest way I can think of to do this (while knowing very little of fw/1) is gasp an xml file.
I know. i know.. but still.
Ok, it seems like the proper place to put this code in might be in the onMissingView() function.
I'm still not sure what the optimial way to store all of the overrides would be. it could just be a struct loaded in the application.cfc or you could store it in an ini or xml.
This would be a good feature to add to 2.0, here is a link to the commit where an example can be found.
I tried out 1.2RC to verify that it now handled the preserved contexts when maxNumContextsPreserved = 1
, and all seemed fine.
But when I changed my app back to maxNumContextsPreserved = 10
, it seems that no contexts are preserved - no data is preserved when redirected. (I tried restarting the server and launching in a different browser, so it wasn't a problem with session or application caching).
Looks like a new bug may have been introduced...
From Devin (on the forums):
So, I read in the documentation that if you use an IoC container to manage your controllers, you don't get an a reference to the framework in the constructor.
I understand why this is, but why pass the framework reference in the constructor rather than a setter? Then it would work regardless if an IoC container is being used.
When the framework goes through the method calling phase on the controller (before, start, request.item, etc.) it should first check for a setFramework() method, and if exists, pass it the framework reference.
From Henry Ho:
Please include a demo / sample app on how do access control cleanly and efficiently with FW/1.
(Per thread on the list, as suggested by Sean)
Rather than directly references session data, create setSessionData() / getSessionData() to allow developers to cleanly override where state is stored.
love the move to github, but i miss the top level menu on the wiki's reference guide page. it was helpful to see all the api methods at a glance. useful for when you want to do something but don't know the right function.
thx, Daria
FW/1 1.2 generates the following error when running on Adobe ColdFusion MX 7.
The value "" cannot be converted to a number
The error occurred in C:\CFusionMX7\wwwroot\org\corfield\framework.cfc: line 19
17 :
18 : this.name = hash( getBaseTemplatePath() );
19 : variables.cgiScriptName = CGI.SCRIPT_NAME.replace( getContextRoot(), '' );
20 : variables.cgiPathInfo = CGI.PATH_INFO.replace( getContextRoot(), '' );
21 :
Appears to be caused by the underlying 1.4.2 JVM that ACF 7 uses. JVM 1.5 added an additional method signature, replace(CharSequence target, CharSequence replacement) on String which is what the code uses.
I would like to be able, at the view level, to say "setLayout(''')" just like I can do setView()...
What I'd like the setLayout() to do is to ignore the default layout rules of (view, section, site) and to do the layout specified in setLayout() then the site layout (if request.layout=true)..
Basically I want to do this so I don't have to create a bunch of layout files that basically just do the same thing: set an xml header and then dump the body and then set request.layout=true.
Right now I just include an "xml.cfm" file in all of these page specific layout files but it would be nice to not have to create all these files just because the framework insists on it.
Thanks
I use a lot of AJAX with my FW/1 applications and would love to see a JS file built into FW/1 that contains JS versions of some of the public FW/1 functions. For example a JS example of the buildURL function.
According to W3C standard, the href atribute for the HTML base tag must be absolute. See: http://www.w3.org/TR/html4/struct/links.html#edef-BASE
Using relative URLs produces inconsistent results across browsers. E.g., IE8 cannot read the CSS or build links correctly for the "introduction" app. To fix this problem I recommend creating fully-qualified, absolute URLs for the base href attribute.
For example, in introduction/layouts/default.cfm rather than:
<base href="<cfoutput>#getDirectoryFromPath( CGI.SCRIPT_NAME )#</cfoutput>" />
it should be something like:
<base href="<cfoutput>#IIF(CGI.HTTPS EQ "on",DE("https"),DE("http")) & "://" & CGI.HTTP_HOST & getDirectoryFromPath( CGI.SCRIPT_NAME )#</cfoutput>" />
This may also affect other example application files such as examples/common/layouts/default.cfm and others.
Thanks,
Seth
The Flash Context variables are not being restored when using the generated SES URLs and the number of Preserved Contexts is greater than 1. All other situations restore the Context variables correctly.
To support googlesitemap or a custom 404 handler, it would be convenient if FW/1 had a hook to allow a user to determine with the request should be handled "normally" (included) or via FW/1.
Proposal: onRequest(targetPath) would start by calling isNonFrameworkRequest(targetPath) stub which would return false. Users could override in Application.cfc to return true for selected requests. onRequest() would then either just cfinclude the targetPath or process the request as usual.
Something for 1.2.
When customizeViewOrLayoutPath() is overridden and an "FW1.viewNotFound" exception is raised by the viewNotFound() method, the view path shown in the error detail may not be where FW/1 was actually looking for the missing view.
To reproduce, force an exception by overriding customizeViewOrLayoutPath() in Application.cfc as follows:
function customizeViewOrLayoutPath( pathInfo, type, fullPath ) {
return '/non-existent/view.cfm';
}
If you browse to a default action of "main.default" you will see this error detail:
Either '/views/main/default.cfm' does not exist or variables.framework.base is not set correctly.
You should see:
Either '/non-existent/view.cfm' does not exist or variables.framework.base is not set correctly.
I have a revised viewNotFound() to fix this, for which I'll send a pull request.
It would be really cool to see SES URLs for subsystems that rather than say /subsystem:section/item would have /subsystem/section/item.
If you link to foo.main and main is your default item, use just foo instead (as long as you're not doing SES URLs with extra stuff).
I have an application where the URL has an "event ID" in it that drives functionality in the app -- the web server strips this out with a rewrite rule, establishing an HTTP Header I grab in my setupRequest for the user - thus, all my buildURL and redirect (etc) need to honor the event ID. I was setting up variables.framework.baseURL to reflect the eventID, but I know realize that was setting it for all users all the time creating a possible race condition with concurrent requests (one user with eventID 123 hits the app and while they are generating their page another with eventID 456 comes, and the first user may now get erroneous behavior in buildURL, for instance). Should baseURL be something we can set to be request specific? That would allow this kind of scenario where the URL has meaning to a specific request but the app need to know what the URL is across many users.
in the Application.cfc, this.name should be 'fw1-hello7' vs. 'fw1-hello1'
Low priority but as FW/1 stands it would be hard to use with Mura (and hard, in general, to "plug in" to other sites/applications). It would be nice to offer an includable version of FW/1 that could manage the setup lifecycle automatically and a way to "bleed" the variables.framework structure into FW/1's CFC.
Mike Schierberl said: I'm interested in seeing this feature more as a way to reduce the dependency on an "org" mapping. I'd like to be able to distribute a FW/1 application in a container without worrying about users installing the project having a dependency on a mapping.
Could FW/1 function as a mixin in application.cfc?
Sean Corfield said: As it stands, it couldn't easily be mixed into Application.cfc but when I get around to this (post-1.0 now) I'll look at that as a possible approach (although that's really just another form of include). I agree about the mapping dependency.
Mike Schierberl said: For the time being I've been copying the framework file to my app root then have Application.cfc extend "framework". As long as it's one file without dependencies I would think that might be an option for eliminating the "org" mapping.
Sean Corfield said: Doh! That's such a simple solution I ought to just document it! Thanx Mike!
Controller auto-wiring does not currently support CF9's style of property with accessors=true
Add a new variables.framework variable, e.g. autowireWithMetaData = true / false
Use code similar to Bob Silverberg's to collect properties from getMetaData() and call setter on it.
discussed here: http://groups.google.com/group/framework-one/browse_thread/thread/32eafdd82d90a90b
setView( fully-qualified-action ) would stash the action and at the start of buildViewAndLayoutQueue(), it would use local variables for subsystem, section and item - instead of request scope - and override them with the stash action if present.
Suggested by Ryan. In try/catch for trustKeys = true, keys = '' path, call onPopulateError() if an exception occurs. Default is empty. Users can override to provide custom functionality.
Setup:
main
learn
learn.basics
, learn.single
Bug/Request:
In my view learn.basics
a call to buildUrl('.single')
should expand to 'learn.single'
instead of 'main.single'
.
Details:
Given this enhancement my links are more portable. I can then rename an entire section without having to find/replace all of the buildUrl
calls in that section. Or, more likely, when a section grows large enough that I want to divide it into smaller logical sections, I can move files without having to poke around. I still have to ensure that any links across sections (such as from main.default
to learn.single
) are fully-qualified, but this default is more sane.
Suggested Fix:
Add an optional argument defaultSection
to getFullyQualifiedAction and buildUrl
that defaults (or can be overridden) to request.section
instead of variables.framework.defaultSection
.
It appears the defacto option for BaseURL today is 'useCgiScriptName' and I would like to propose another option: 'useRequestURI' (that's a captial 'i').
So throughout the framework.cfc, a few mods would be needed obviously to accept this new option which would use getPageContext().getRequest().getRequestURI() vs. cgi.script_name.
getRequestURI() could return '/index.cfm/path/to/page/' which could then be appended with the appropriate action resulting in something like '/index.cfm/path/to/page/?action=main.default'
This option could help solve a number of issues for people wishing to use FW/1 within an existing application (i.e., Mura, BlogCFC, etc.).
I wonder if it is possible for controller to capture OnMissingView() event.
for example:
I only have
views/search/default.cfm
So if user enters any of these following urls:
/index.cfm/search/name/Mary
/index.cfm/search/company/ABC
/index.cfm/search/whatever-view-that-you-have
then the controller search.cfc will have a customised OnMissingView() method to redirect all request context back to default.cfm
A discussion with Richard Tugwell indicated that there probably should be a way to 'turn off' the fancy session management machinery for redirects so that a single, simple session variable is used and no URL parameter is needed.
When using SES URLs, fw1pk is still appended with ?fw1pk=N - could it be handled via SES?
This would be useful for email templates or caching view fragments or similar use cases. Need to preserve control over the request lifecycle (so you should only run a view after services or instead of implicit services). Need to provide safeguards to deter abuse of this feature.
Wouldn't it be useful if we can populate with trimmed value in populate()?
rc.name = " Henry Ho ";
rc.address = " some address ";
user = entityNew("user");
variables.fw.populate(cfc=user, keys="name, address", trustKeys=true, trim=true);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.