Code Monkey home page Code Monkey logo

fw1's Introduction

fw1_logo

FW/1 (Framework One)

Build Status 4.3.2 Deploy Status

This FW/1 directory is a complete web application and expects to live in its own webroot if you plan to run the applications within it. To use FW/1 in a separate webroot you can either copy the framework directory to that webroot or add a mapping for /framework to the framework folder inside this FW/1 directory. Note that since your Application.cfc needs to extend framework.one, you have to add the mapping in your admin - you can't just use a per-application mapping.

Please read the Framework One Code of Conduct - we want FW/1 to be a welcoming and supportive environment for everyone to feel comfortable contributing!

Resources

Demo sites: v4.3.2 - https://fw1-4.3.2.mycfspace.org

Project home: https://github.com/framework-one/fw1

Documentation / Wiki: http://framework-one.github.io/documentation/ / http://github.com/framework-one/fw1/wiki

Blog: http://framework-one.github.io

Support: http://groups.google.com/group/framework-one/

Chat: The CFML team Slack has a dedicated #fw1 channel.

Running the Tests

FW/1 is setup to run tests using GitHub Actions using the fw1_java11.yml and fw1_boxlang.yml workflow files.

To run tests locally, you'll need CommandBox installed.

Then run box install once to install the dependencies (TestBox is the only one currently).

Then start a server on port 8500 with your choice of CFML engine, e.g.,

box server start cfengine=lucee@5 port=8500

This will open a browser, running the FW/1 "Introduction" app.

You can then run the tests:

box testbox run verbose=false

If you get any failures, you can run this with more verbose, but still compact output:

box testbox run reporter=mintext

Copyright and License

Copyright (c) 2009-2024, Sean Corfield (and others -- see individual files for additional copyright holders). All rights reserved. The use and distribution terms for this software are covered by the Apache Software License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) which can also be found in the file LICENSE at the root of this distribution and in individual licensed files. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.

fw1's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fw1's Issues

populate() to gain one more argument, trim=false ?

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);

Way To override url paths in FW/1

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.

Rename models to model in examples

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?

variables.framework.baseURL should be able to be request specific

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.

Provide a way to include FW/1 rather than force the use of Application.cfc

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!

Proposal for Another Option for framework.baseURL

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.).

Omit default item in buildURL()

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).

CFMX 7 and FW/1 1.2 compatibility

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.

controller to capture OnMissingView

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

Pass data to a view()

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.

Add onPopulateError()

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.

buildURL('.foo') defaults to main.foo instead of currentSection.foo

Setup:

  • Default section: main
  • Additional section: learn
  • Items: 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.

Add setView() method to override default view convention

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.

Enhance SES handling by generating SES URLs in buildURL() and redirect()

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.

Address Mura integration for $ Mura object / scope

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.

1.2RC breaks context preservation

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...

base href must be an absolute URI

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

Enable FW/1 reference when controllers are managed by DI

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.

Abstract internal references to session variables

(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.

Provide easy way to allow certain requests to bypass FW/1

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.

Railo Strict Scoping

From AJ Mercer:

I was also wondering about the 'rc' variable in Railo if Scope Cascading was set to 'Strict' what would happen?

Could fw1pk be SES'd?

When using SES URLs, fw1pk is still appended with ?fw1pk=N - could it be handled via SES?

viewNotFound() can show misleading path in detail on customizeViewOrLayoutPath() override

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.

FW/1 Incorrectly Parsing Base of application

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.

Wiki Reference Guide Menu

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

Option to omit default subsystem in buildURL()

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?

Optional Filename Strategy

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().

AJAX and reloadApplicationOnEveryRequest

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.

Provide Mechanism to Override Default "Layout" rule

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

Feature Request - JS Functions

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.

Cache existance of Views and Layouts.

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.

viewNotFound message does not reflect usage of setView

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.

Provide way to run view and capture output in a controller

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.

handle deployment in with context paths other than "/"

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.