From 37564366416e379f7f2454348cd9a55405f87254 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Fri, 17 Jan 2025 13:15:11 +0100 Subject: [PATCH] publish recipes on lucee docs --- api/data/DocTree.cfc | 11 +- api/data/PageCache.cfc | 2 +- api/data/PageReader.cfc | 20 +- builders/html/templates/aToZIndex.cfm | 3 +- docs/00.home/homepage.md | 6 + .../04.cookbooks/04.basic-date/page.md | 44 ---- .../page.md | 25 -- .../page.md | 135 ---------- .../12.filesystem-mapping/page.md | 19 -- .../04.cookbooks/14.check-for-changes/page.md | 44 ---- .../04.cookbooks/20.query-of-queries/page.md | 116 -------- .../04.cookbooks/21.Exeception-Output/page.md | 52 ---- .../22.Extension-Installation/page.md | 66 ----- .../04.cookbooks/24.Query-Handling/page.md | 247 ------------------ .../26.Vitural-FileSystem/page.md | 187 ------------- .../04.cookbooks/27.PreCompiled-Code/page.md | 33 --- .../04.cookbooks/30.NullSupport/page.md | 74 ------ .../31.Externalize_Strings/page.md | 44 ---- .../04.cookbooks/33.Hidden_gems/page.md | 110 -------- .../35.loop_through_files/page.md | 62 ----- .../04.cookbooks/36.thread_task/page.md | 138 ---------- .../38.supercharge_website/page.md | 37 --- docs/04.guides/04.cookbooks/39.Retry/page.md | 69 ----- .../04.cookbooks/41.Encrypt_Decrypt/page.md | 67 ----- docs/recipes/basic-date.md | 3 + docs/recipes/configuration-lucee5.md | 2 +- docs/recipes/exception-cause.md | 6 + docs/recipes/loop-labels.md | 3 + docs/recipes/query-async.md | 6 + docs/recipes/query-indexes.md | 9 + docs/recipes/query-listener.md | 6 + docs/recipes/query-return-type.md | 3 + docs/recipes/sub-components.md | 5 +- 33 files changed, 70 insertions(+), 1584 deletions(-) delete mode 100644 docs/04.guides/04.cookbooks/04.basic-date/page.md delete mode 100644 docs/04.guides/04.cookbooks/11.configuration-administrator-cfc/page.md delete mode 100644 docs/04.guides/04.cookbooks/12.filesystem-mapping/01.filesystem-mapping-define-mapping/page.md delete mode 100644 docs/04.guides/04.cookbooks/12.filesystem-mapping/page.md delete mode 100644 docs/04.guides/04.cookbooks/14.check-for-changes/page.md delete mode 100644 docs/04.guides/04.cookbooks/20.query-of-queries/page.md delete mode 100644 docs/04.guides/04.cookbooks/21.Exeception-Output/page.md delete mode 100644 docs/04.guides/04.cookbooks/22.Extension-Installation/page.md delete mode 100644 docs/04.guides/04.cookbooks/24.Query-Handling/page.md delete mode 100644 docs/04.guides/04.cookbooks/26.Vitural-FileSystem/page.md delete mode 100644 docs/04.guides/04.cookbooks/27.PreCompiled-Code/page.md delete mode 100644 docs/04.guides/04.cookbooks/30.NullSupport/page.md delete mode 100644 docs/04.guides/04.cookbooks/31.Externalize_Strings/page.md delete mode 100644 docs/04.guides/04.cookbooks/33.Hidden_gems/page.md delete mode 100644 docs/04.guides/04.cookbooks/35.loop_through_files/page.md delete mode 100644 docs/04.guides/04.cookbooks/36.thread_task/page.md delete mode 100644 docs/04.guides/04.cookbooks/38.supercharge_website/page.md delete mode 100644 docs/04.guides/04.cookbooks/39.Retry/page.md delete mode 100644 docs/04.guides/04.cookbooks/41.Encrypt_Decrypt/page.md diff --git a/api/data/DocTree.cfc b/api/data/DocTree.cfc index bb724735c..e7d74a9ad 100644 --- a/api/data/DocTree.cfc +++ b/api/data/DocTree.cfc @@ -311,10 +311,17 @@ component accessors=true { variables.tree.append(guide); } break; - /* case "recipes": + var recipeTree = folder.getChildren(); + for (var recipe in recipeTree){ + if (recipe.getForceSortOrder() gt 0){ + recipe.setSortOrder(recipe.getForceSortOrder()); + } else { + recipe.setSortOrder(5 + NumberFormat(recipe.getSortOrder()/100,"0.00")); + } + variables.tree.append(recipe); + } break; - */ } } _sortChildren( variables.tree ); diff --git a/api/data/PageCache.cfc b/api/data/PageCache.cfc index 0bf3af363..5932d15ce 100644 --- a/api/data/PageCache.cfc +++ b/api/data/PageCache.cfc @@ -83,7 +83,7 @@ component accessors=true { var timestamp = CreateDate(2000,1,1);// for( var file in local.files){ file = _removeRootDirectoryFromFilePath(file); - if ( ListFirst( file, "/" ) eq "recipes") continue; + // if ( ListFirst( file, "/" ) eq "recipes") continue; var row = QueryAddRow(local.q_files); querySetCell(local.q_files, "name", ListLast(file, "/") , row); querySetCell(local.q_files, "fullpath", file , row); diff --git a/api/data/PageReader.cfc b/api/data/PageReader.cfc index 2833cacc7..74d8d9c5d 100644 --- a/api/data/PageReader.cfc +++ b/api/data/PageReader.cfc @@ -50,11 +50,17 @@ component { if (page.getPageType() eq "README"){ page.setPath( page.getPath() ); page.setPageType( "listing" ); + page.setListingStyle( "flat" ); page.setVisible( true ); - page.setReference( false ); - page.setBody( "Recipes" ); + page.setReference( true ); + page.setBody( "Detailed Recipes showing you how to take advantage of the wide range of features in Lucee" ); + page.setMenuTitle( "Recipes" ); page.setTitle( "Lucee Recipes" ); - page.setDescription( "Lucee Recipes" ); + page.setDescription( "Detailed Recipes showing you how to take advantage of the wide range of features in Lucee" ); + page.setForceSortOrder( 5.5 ); + page.setSortOrder( 4.5 ); + page.setSlug("recipes"); + page.setId("recipes"); } else { page.setPath( page.getPath() & "/" & replace( page.getPageType(), ".md", "" ) ); page.setPageType( "page" ); @@ -149,7 +155,6 @@ component { } else if ( len( trim( arguments.pageContent ) ) ){ parsed = _splitCommentStructAndBody( arguments.pageContent, arguments.filePath ); } - return parsed; } @@ -194,10 +199,9 @@ component { var body = mid( str, endComment + 3 ); if ( len( trim( body ) ) eq 0 ) throw "empty content after metadata [#arguments.filePath#]"; - return { - yaml = deserializeJson( meta ) - , body = body - } + meta = deserializeJson( meta ); + meta.body = body; + return meta; } private string function _convertToUnixLineEnding( required string content ){ diff --git a/builders/html/templates/aToZIndex.cfm b/builders/html/templates/aToZIndex.cfm index 46383f4f3..93d1b92be 100644 --- a/builders/html/templates/aToZIndex.cfm +++ b/builders/html/templates/aToZIndex.cfm @@ -9,8 +9,7 @@ #getEditLink(path=local.pg.getSourceFile(), edit=args.edit)# #_markdownToHtml( local.pg.getBody() )# - - +
diff --git a/docs/00.home/homepage.md b/docs/00.home/homepage.md index f03f6160c..08c915185 100644 --- a/docs/00.home/homepage.md +++ b/docs/00.home/homepage.md @@ -16,6 +16,12 @@ Our documentation is an open source and community driven effort. It is also a co To find out more about getting involved as a developer with Lucee, checkout our [Git Repo](https://github.com/lucee/Lucee/blob/6.0/CONTRIBUTING.md) +## Recipes + +**New!** We have added a whole series of detailed [[Recipes]] showing you how to take advantage of the wide range of features in Lucee. + + + ## Lucee 6.2 Lucee 6.2 is our upcoming next major release, including enhanced Java and Maven integration, with even better runtime performance. diff --git a/docs/04.guides/04.cookbooks/04.basic-date/page.md b/docs/04.guides/04.cookbooks/04.basic-date/page.md deleted file mode 100644 index 8f4943e1d..000000000 --- a/docs/04.guides/04.cookbooks/04.basic-date/page.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Basic Date -id: cookbook-basic-date ---- - -## Output the current date ## - -The following examples shows you how to output the current date. - -```coldfusion - - - Current date - - - -

The time is #lsdateTimeFormat(now())#

-
- - -``` - -Executing this code you will see something like the following: - -> The time is 31-Jan-2038 11:12:08 - -The tag [[tag-output]] defines for the compiler that everything within a `##` is a code expression and needs to be parsed accordingly. [[function-now]] is a function call that is returning a date object containing the current time, [[function-lsDateTimeFormat]] then converts that date to a string using "locale" specific formatting rules (default en_US). - -You can configure a different locale globally in the Lucee admin under "Settings/Regional". - -You can then configure a different locale for the current request in the Application.cfc file (for example: `this.locale="de_CH"`) or with help of the function [[function-setLocale]] or as argument of the function call itself as follows: - -```coldfusion - - - Current date - - - -

The time is #lsDateTimeFormat(date:now(),locale:'de_CH')#

-
- - -``` diff --git a/docs/04.guides/04.cookbooks/11.configuration-administrator-cfc/page.md b/docs/04.guides/04.cookbooks/11.configuration-administrator-cfc/page.md deleted file mode 100644 index c23ff961f..000000000 --- a/docs/04.guides/04.cookbooks/11.configuration-administrator-cfc/page.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: Configure Lucee within your Application -id: cookbook-configuration-administrator-cfc ---- - -# Configure Lucee within your application # - -Lucee provides a web frontend to configure the server and each web context, but you can also do this configuration from within your application -(For per request settings, please check out the" Application.cfc" section in the [Cookbook](/guides/cookbooks.html)). - -## Administrator.cfc ## - -Lucee is providing the component "Administrator.cfc" in the package "org.lucee.cfml" a package auto imported in any template, so you can simply use that component as follows - -```cfs -admin=new Administrator("web","myPassword"); // first argument is the admin type you wanna load (web|server), second the password for the Administrator -dump(admin); // show me the doc for the component -admin.updateCharset(resourceCharset:"UTF-8"); // set the resource charset - -``` - -## cfadmin Tag ## - -The component "Administrator" is far from being feature complete, so if you miss a functionality, best consult the unofficial tag "cfadmin" (undocumented) and check out how this tag is used inside the [Lucee Administrator](https://github.com/lucee/Lucee/blob/5.2/core/src/main/java/resource/component/org/lucee/cfml/Administrator.cfc). -Of course, it would be great if you could contribute your addition to the "Administrator" component. diff --git a/docs/04.guides/04.cookbooks/12.filesystem-mapping/01.filesystem-mapping-define-mapping/page.md b/docs/04.guides/04.cookbooks/12.filesystem-mapping/01.filesystem-mapping-define-mapping/page.md deleted file mode 100644 index dde0f457b..000000000 --- a/docs/04.guides/04.cookbooks/12.filesystem-mapping/01.filesystem-mapping-define-mapping/page.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: Define a mapping -id: cookbook-filesystem-mapping-define-mapping -related: -- tag-application -- function-expandpath -- cookbook-application-context-set-mapping -categories: -- application -- files -description: All about the different mappings in Lucee and how to use them ---- - -# How to define a regular Mapping # - -Lucee allows you to define a mappings to a specific location in a filesystem, so you don't always have to use the full path, in most cases the full path is not working anyway, for example with [[tag-include] does not work with a full path. - -This is supported with all the various [[lucee-resources]] supported (local, ftp, http, ram, zip ,s3 etc ). - -## Create a regular Mapping in the Administrator ## - -The most common way is to define a regular Mapping is in the Lucee Server or Web Administrator. - -The only difference between the Web and Server Administrator is, that a mapping defined in the Server Administrator is visible to all web contexts and a mapping defined in the Web Administrator only to the current web context. - -In your Administrator go to the Page "Archives & Resources/Mappings", in the section "create new Mapping" that looks like this. - -![create-mapping.png](https://bitbucket.org/repo/rX87Rq/images/4035761629-create-mapping.png) - -With "Virtual" choose the virtual path for the mapping, this is the path you will later use to address this mapping. - -"Resource" is the physical location where the mapping is pointing to, for example `C:\Projects\whatever\test`. - -With "Archive" you can map a Lucee archive (more below) to the mapping. - -"Primary" defines where a template is searched first, let's say you have set primary to "archive" and you execute the following code - -```coldfusion - -``` - -In that case Lucee is first checking the archive associated with the "/myMapping" mapping for "test.cfm", if the template is not found it there, Lucee also checks the physical location. - -"Inspect templates" defines the rule for Lucee when and if to check changes in source templates and if necessary recompile them. - -* never - once the template is compiled and loaded Lucee never check for changes as long the template is not unloaded (restart server) -* once - Lucee only checks with the first access within a request if the template has changed -* always - Lucee checks with every access to the file if the file has changed -* inherit - The mapping has no setting at all, it inherits the "inspect templates" setting made in "Settings - Performance/Caching" - -"Web accessible" defines if you can call the mapping directly from the browser or not, "/lucee" for example is a web accessible mapping, because of that you can call it in the browser as follows "/lucee/admin.cfm". - -### Compile the CFML Code inside a mapping ### - -In the detail view of a single mapping you can compile all cfm and cfc files in that mapping to test if they are syntactically correct. - -With the flag "stop on error" you can define if the process should stop if the compiler fails. - -![compile.png](https://bitbucket.org/repo/rX87Rq/images/362153996-compile.png) - -### Create an archive from a mapping ### - -In the detail view of a single mapping you can create an archive that contains all templates of the mapping in compiled form. - -With the flag "Add CFML Templates" you can define if Lucee should add the source version of the templates as well, this make sense when you need a proper error output in case of an exception (source code output) or you need to read the content of this files for example with [[tag-file]]. - -With the flag "Add Non CFML Templates" you can define if Lucee should add all non CFML files (PNG,JS,GIF,CSS ...) as well, this make sense when you need to read the content of this files for example with [[tag-file]]. - -![create-archive.png](https://bitbucket.org/repo/rX87Rq/images/2720116188-create-archive.png) - -By clicking the button "download archive" you create the archive and then you can download it directly, with the button "assign archive to mapping" you can create the mapping and directly add to the current mapping. - -## Create a Mapping in the Application.cfc ## - -Lucee allows to create mappings in your [[tag-application]], these mappings are only valid for the current request. - -```cfs -// Application.cfc -component { - this.mappings['/shop']=getDirectoryFromPath(getCurrentTemplatePath())&"shop"; -} -``` - -We define the mappings as a struct, where the key of the struct is the virtual path. - -Now you can simply use that mapping in your code - -```coldfusion - - -``` - -## Advanced ## - -In the previous example we have simply set a path, like you can see in the Administrator, a mapping can contain more data than only a physical path, of course you can use this settings also with a mapping done in the [[tag-application]]. - -```cfs -// Application.cfc -component { - this.mappings['/shop']={ - physical:getDirectoryFromPath(getCurrentTemplatePath())&"shop", - archive:getDirectoryFromPath(getCurrentTemplatePath())&"shop.lar", - primary:"archive" - }; -} -``` - -In that case we not only define a physical path, we cam also define a Lucee archive (.lar). - -"primary" defines where Lucee is checking first for a resource, let's say you have the following code - -```coldfusion - -``` - -In that case Lucee first checks in the archive for`"whatever.cfm`, if not found there, it looks inside the physical path. - -### Site Note ### - -Of course this can be done for all mapping types - -```cfs -// Application.cfc -component { - this.componentpaths=[{archive:getDirectoryFromPath(getCurrentTemplatePath())&"testbox.lar"}];// loading testbox from an archive - this.customtagpaths=[{archive:getDirectoryFromPath(getCurrentTemplatePath())&"helper.lar"}];// a collection of helper custom tags - - }; -} -``` - -### See Also ### - -- [Forcing Lucee to re-check the physical paths of application defined mappings without a restart](https://blog.simplicityweb.co.uk/123/forcing-lucee-to-re-check-the-physical-paths-of-application-defined-mappings-without-a-restart) -- [Confusion Over this.mappings And expandPath() Not Working In Lucee](https://www.bennadel.com/blog/3718-confusion-over-this-mappings-and-expandpath-not-working-in-lucee-cfml-5-3-3-62.htm) diff --git a/docs/04.guides/04.cookbooks/12.filesystem-mapping/page.md b/docs/04.guides/04.cookbooks/12.filesystem-mapping/page.md deleted file mode 100644 index 58a722220..000000000 --- a/docs/04.guides/04.cookbooks/12.filesystem-mapping/page.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: File system - Mappings -id: cookbook-filesystem-mapping -categories: -- files ---- - -## Mapping ## - -We distinguish 3 different mapping types: - -- "component" mappings used to map components (similar to a classpath in Java), -- "custom tag" mappings used to map custom tags -- "regular mappings" for the rest ([[tag-include]], [[tag-file]] ...). - -* [[cookbook-filesystem-mapping-define-mapping]] -* [[cookbook-application-context-set-mapping]] -* Define a component Mapping (TODO) -* Define a custom tag Mapping (TODO) diff --git a/docs/04.guides/04.cookbooks/14.check-for-changes/page.md b/docs/04.guides/04.cookbooks/14.check-for-changes/page.md deleted file mode 100644 index fa563975a..000000000 --- a/docs/04.guides/04.cookbooks/14.check-for-changes/page.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Check for changes -id: cookbook-check-for-changes ---- - -# Check for changes in your configuration file automatically # - -Lucee can automatically check for changes in your configuration files from the complete server or a single web context. - -This is useful if you are doing scripted deploys and/or synchronization from, for example, a master instance to many slave instances of Lucee. - -### Check for Changes in ALL the contexts - -To enable this for a whole Lucee server find lucee server XML file in: - - /lib/ext/lucee-server/context/lucee-server.xml - -At the top of this file, you should see something along the lines of: - - - -Now it's simple to add the following: - - - -Now that you have made the change you can either restart Lucee server from the administrator in: - - http://localhost:8888/lucee/admin/server.cfm?action=services.restart - -Or actually make any change in the Server Admin for the configuration to be picked up. This should now allow it to pick up any changes you have written to the lucee-server.xml file. - -### Check for changes in an individual context - -If you only want an individual context to check for changes, you can do the same configuration but you would have to go to: - - /WEB-INF/lucee/lucee-web.xml.cfm - -And and the same changes from above: - - - -Lucee will now check for any changes in the lucee configuration files every minute and if there is a change, reload it and enable those changes. - -A very handy little feature for those automated deployments! diff --git a/docs/04.guides/04.cookbooks/20.query-of-queries/page.md b/docs/04.guides/04.cookbooks/20.query-of-queries/page.md deleted file mode 100644 index 1ab4f15df..000000000 --- a/docs/04.guides/04.cookbooks/20.query-of-queries/page.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: Query of Queries (QoQ) -id: query-of-queries -related: -- tag-query -categories: -- query -description: 'Query of queries (QoQ) is a technique for re-querying an existing (in - memory) query without another trip to the database.' ---- - -### Introduction ### - -Query of queries (QoQ) is a technique for re-querying an existing (in memory) query without another trip to the database. This allows you to dynamically combine queries from different databases. - -```lucee - - - SELECT * - FROM my_db_table - - - - - SELECT * - FROM sourceQry - -``` - -The above example isn't very useful, because ```newQry``` is a straight copy of the source query, but it demonstrates the two requirements of ```QoQ```: - -* The dbtype="query" attribute -* A source query object name (e.g., sourceQry) instead of table name in the FROM clause. - -### Example: Filtering ### - -Let's say you have the following database query, ```myQuery```: - -```lucee - - SELECT Name, Age, Location - FROM People - -``` - -You would now have a list of names, ages and locations for all the people in a query called ```myQuery```. - -Say you want to filter out people under 90 and over 18, but you don't want to hit the database again: - -```lucee - - SELECT Name, Age, Location - FROM myQuery - WHERE Age >= 18 - AND Age <= 90 - -``` - -```filteredQry``` contains the desired records. - -### Internals ### - -Lucee uses its own SQL implementation for QoQ; when that fails, HSQLDB is tried. - -Lucee's SQL implementation is a basic subset of ANSI92, but it is relatively fast. [HSQLDB is a more complete SQL implementation](http://hsqldb.org/doc/2.0/guide/sqlgeneral-chapt.html), but it is slow, as compared to Lucee's implementation. - -### Supported Constructs ### - -Even though under the hood, Lucee handles the fallback to HSQLDB automatically, it still can be useful to know what's possible with the fast Lucee SQL implementation versus the slower, fallback HSQLDB SQL implementation. - -### Lucee's SQL Implementation ### - -**Keywords and Operators** - -* <= -* <> -* = -* => -* = -* != -* ALL -* AND -* AS -* BETWEEN x AND y -* DESC/ASC -* DISTINCT -* FROM -* GROUP BY -* HAVING -* IN () -* IS -* IS NOT NULL -* IS NULL -* LIKE -* NOT -* NOT IN () -* NOT LIKE -* OR -* ORDER BY -* SELECT -* TOP -* UNION -* WHERE -* XOR - -Functions - -TODO: Flesh this out. - -### HSQLDB SQL Implementation ### - -This is the fallback for when Lucee's SQL implementation can't handle the QoQ syntax. See the [HSQLDB documentation](http://hsqldb.org/doc/2.0/guide/sqlgeneral-chapt.html) for details. - -### Footnotes ### - -Lucee Google Groups Post: SQL syntax supported by query-of-queries? diff --git a/docs/04.guides/04.cookbooks/21.Exeception-Output/page.md b/docs/04.guides/04.cookbooks/21.Exeception-Output/page.md deleted file mode 100644 index 265c5de21..000000000 --- a/docs/04.guides/04.cookbooks/21.Exeception-Output/page.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: Exception Output -id: exception-output -related: -- tag-catch -- tag-rethrow -- tag-throw -- tag-try -categories: -- debugging -description: How to catch and display exceptions ---- - -## Output Exceptions ## - -How to catch and display exceptions - -#### Example #### - -```lucee - -try { - throw "an error happened"; -} -catch ( any e ){ - dump(e); -} - -Go on with your code -``` - -Result - -[[tag-Dump]] shows the full exception structure without blocking your code. Dump include all stack trace with it. - -#### Example 2 #### - -```lucee - -try { - throw "an error happened"; -} -catch ( any e ){ - echo(e); -} - -Go on with your code -``` - -Here we simply echo the exception, It shows the normal exception without blocking your code. - - diff --git a/docs/04.guides/04.cookbooks/22.Extension-Installation/page.md b/docs/04.guides/04.cookbooks/22.Extension-Installation/page.md deleted file mode 100644 index f1e4ab56b..000000000 --- a/docs/04.guides/04.cookbooks/22.Extension-Installation/page.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: Extension Installation -id: extension-installation -categories: -- extensions -description: How to install Lucee extensions, manually, via a environment variable or via the admin ---- - -## Extensions ## - -In this section, you'll find information about Lucee extension installation, which can be used to add Functions, Tags, JDBC/Cache drivers and Admin Plugins to Lucee Server. - -There are several different ways to install extensions in Lucee. - -### Extension installation via Admin ### - -Extensions can be installed via the web or server admin. - -If you want to use an Extension for the whole server, you should install it under the Server Admin. If you want the extension for just for only a single web context, install it via the Web admin. - -All available Extensions are listed under **Extension -> Applications** - -![Extension](/assets/images/screenImages/Extension.png) - -Here you can see which extensions are installed and not installed. - -Installed extensions, with an update available have a red overlay. - -![Extension Details](/assets/images/screenImages/Extension_Detail.png) - -On the Extension detail page, you can upgrade or downgrade the version or uninstall it. - -With JDBC drivers, choose the version you require, the version numbers are based on the underlying JDBC Library. - -By default Lucee allows installing extensions from the following sites - -- (Official LAS Extensions) -- and (third party, community) - -### Extension installation via lex file ### - -To install an extension using the file system, first download the `.lex` file for the extension. - -You can download it from the url [https://download.lucee.org/](https://download.lucee.org/) - -Copy the `.lex` file into your ```lucee-server/deploy/``` folder. Wait for a minute, it deploy the extension automatically. You can see the installation message on `deploy.log` files. - -Another way you can upload the `.lex` file in admin, You can see "Upload new extension (experimental)" at bottom of **Extension -> Applications** page. - -* Click the browse button, -* Choose the `.lex` file, -* Click the upload button, and the Extension will be automatically installed - -### Extension installation via an Environment Variable ### - -Lucee will automatically install extensions on startup, if an environment variable is set. - -`LUCEE_EXTENSIONS=D46B46A9-A0E3-44E1-D972A04AC3A8DC10;version=1.0.19.19` - -See [[running-lucee-system-properties]] - -### Footnotes ### - -Here you can see this details on video also - -[Extension Installation](https://www.youtube.com/watch?time_continue=184&v=Vcu0OENm_ks) diff --git a/docs/04.guides/04.cookbooks/24.Query-Handling/page.md b/docs/04.guides/04.cookbooks/24.Query-Handling/page.md deleted file mode 100644 index c2f21a7bf..000000000 --- a/docs/04.guides/04.cookbooks/24.Query-Handling/page.md +++ /dev/null @@ -1,247 +0,0 @@ ---- -title: Query Handling In Lucee -id: query-handling-lucee -related: -- tag-query -- tag-queryparam -- function-queryexecute -categories: -- query -description: How to do SQL Queries with Lucee ---- - -This document explains how SQL queries are supported in Lucee. - -## Query tags ## - -[[tag-query]] different ways to use the tags in Lucee and how we can the pass the value into the query - -```lucee - - select * from Foo1890 - - -``` - -The above example just shows how to retrieve the data from the database. - -### Using QueryParam ### - -The [[tag-QueryParam]] is used inside the [[tag-query]] tag. It is used to bind the value with the SQL statement. - -```lucee - - select * from Foo1890 - where title= - - -``` - -Passing values with [[tag-QueryParam]] has two advantages: - -* The value you pass in QueryParam is very secure, -* Lucee is able to cache the query statement and reuse it as long as the value is unchanged. - -### Params ### - -Here we use params as part of [[tag-query]] tag, used to pass the value with SQL statement. - -Pass the params value with struct - -```lucee - - select * from Foo1890 - where title=:title - - -``` - -referenced as ```:key``` in sql. - -The below example shows how to pass more information using a struct. - -```lucee - - select * from Foo1890 - where title=:title - - -``` - -You can pass the params value using an array. It is referenced as '?' in SQL. - -```lucee - - select * from Foo1890 - where title=? - - -``` - -The below example shows how to pass more information using an array. - -```lucee - - select * from Foo1890 - where title=? - -``` - -## Query with script tag ## - -Lucee supports two types of script statements as shown below: - -```lucee - -query name="qry" datasource="test" params={title:{type:'varchar',value:'Susi'}} { - echo(" - select * from Foo1890 - where title=:title - "); -} -dump(qry); - -``` - -```lucee - -cfquery(name="qry",datasource="test",params={title:{type:'varchar',value:'Susi'}}) { - echo(" - select * from Foo1890 - where title=:title - "); -} -dump(qry); - -``` - -## QueryExecute ## - -Lucee includes support for [[function-QueryExecute]] via script or tag. You can pass all the arguments to the function. - -```lucee - -qry=queryExecute( - sql:"select * from Foo1890 where title=:title" - ,options:{datasource="test"} - ,params={title:{type:'varchar',value:'Susi'}} -); -dump(qry); - -``` - -Pass the values in params same as we saw in cfquerytag, In options we can pass other arguments like datasource,cachename,dbtype - -### Query Component ### - -You can do a query with component like "Query()". - -```lucee - - query=new Query(sql:"select * from Foo1890 where title=?"); - query.setParams([{type:'varchar',value:'Susi'}]); - query.setDatasource('test'); - dump(query.execute().getResult()); - -``` - -In the above example we pass the sql as part of the constructor. - -* Use setDatasource() function to set the datasource. -* Use setParams() function to set the param values. The value used is the same as we used in the tag. - -```query.execute()``` function returns detail of the component, ```query.execute().getResult()``` returns query result. - -### Query Future ### - -We are always in discussion how to improve the functions in lucee. - -This output technique ```$("Hi there")``` can be used anywhere in the file (not just inside a query). - -```lucee - -query name="qry" datasource="test" params={title:{type:'varchar',value:'Susi'}} { - $(" - select * from Foo1890 - where title=:title - "); -} -dump(qry); - -``` - -We can use not only for query, you can use any where in the file ```$("Hi there")``` make our output. This idea to make a code better - -Lucee also supports static functions as shown in the example code below: - -```lucee - -// Component gets more static functions -q=Query::new("a,b,c"); // equal to queryNew("a,b,c"), already exists -Query::execute(...); // equal to queryExecute(), coming soon - -``` - -### Query Builder ### - -Query Builder use as extension, it will not come up with core. - -It is much easier to do a simple query. - -You can - -```lucee - -// Query Builder (creates SQL in dialect based on the datasource defined) - qb=new QueryBuilder("test") - .select("lastName") - .from("person") - .where(QB::eq("firstname","Susi")); - qb.execute(); - dump(res); - -``` - -Use ```QueryBuilder("test")``` as constructor - -* define a datasource with constructor or 'setDatasource('test')' function, -* Use ```select("lastName")``` to select the column -* Use ```from("person")``` from which table you want to retrieve data, -* where statement like ```where(QB::eq("firstname","Susi"))```, - -Use ```qb.execute()``` to obtain the result. - -You can change selected column like below example - -```lucee - -// change select -qb.select(["age","firstname"]); -qb.execute(); -dump(res); - -``` - -You can also change the where condition also like below example - -```lucee - -// change where -qb.clear("where"); -qb.where( - QB::and( - QB::eq("firstname","Susi"), - QB::neq("lastname","Moser"), - QB::lt("age",18) - ) -); -qb.execute(); -dump(res); - -``` - -### Footnotes ### - -Here you can see above details in video - - diff --git a/docs/04.guides/04.cookbooks/26.Vitural-FileSystem/page.md b/docs/04.guides/04.cookbooks/26.Vitural-FileSystem/page.md deleted file mode 100644 index 8a02ac13a..000000000 --- a/docs/04.guides/04.cookbooks/26.Vitural-FileSystem/page.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -title: Virtual File Systems -id: virtual-file-system -related: -- function-getvfsmetadata -categories: -- s3 -- system -description: 'Lucee support the following virtual file systems: ram, file, s3, http, - https, zip and tar' ---- - -## Virtual File Systems ## - -Lucee supports the following virtual file systems: - -- ram -- file -- s3 -- http / https -- zip -- tar - -### Local File System ### - -You may already be familiar with local file systems, the local file system is the default file system in Lucee. -That means if there is no other definition, Lucee will always use the local file system. - -A simple example - -```lucee - - sct.file=getCurrenttemplatepath(); - sct.directory=getDirectoryFromPath(sct.file); - dump(sct); - - dump(fileRead(sct.file)); - dump(directoryList(sct.directory)); - -``` - -* [[function-getcurrenttemplatepath]] returns current template path, -* [[function-getDirectoryFromPath]] returns directory, -* pass the file path to the [[function-fileRead]], to read the content of the file, -* pass the directory to [[function-directoryList]] to list all the directories in the given folder path. - -However, you can explicitly define the file system you want to use. To use a local file system, use the "//file" prefix. - -As seen in the example code above, the local file system is the default, so it is not necessary to explicitly define it. The example below shows how you can explicitly define a local file system. The result is the same as the code above. - -```lucee - -sct.file=getCurrenttemplatepath(); -sct.directory=getDirectoryFromPath(sct.file); -dump(sct); - -sct.file="file://"&sct.file; -sct.directory="file://"&sct.directory; - -dump(fileRead(sct.file)); -dump(directoryList(sct.directory)); - -``` - -### ZIP File System ### - -Another file system you can use in Lucee is the ZIP file system. -To tell Lucee to use the ZIP file system, use the prefix "zip://" and end with ! -Now the file path will look like zip://xxx/xxx/xxx/xxx/testbox-2.2.0.zip! - -A detailed example is provided below: - -```lucee - -sct.file=getCurrenttemplatepath(); -sct.directory=getDirectoryFromPath(sct.file); -dump(sct); - -sct.zipFile=sct.directory&"testbox-2.2.0.zip"; -sct.zip="Zip://"&sct.zipFile&"!" - -dump(directoryList(sct.zip)); -dump(directoryList(sct.zip&"/testbox")); -echo("
");echo(fileRead(sct.zip&"/testbox/readme.md"));echo("
") -
-``` - -### http/https File System ### - -Lucee also support the HTTP file system. Simply use the HTTP URL like you would use a file system definition. - -The below example shows how to read the file content from the Lucee docs: - -```lucee - - uri="https://docs.lucee.org/reference/functions/abs.html"; - dump(fileRead(uri)); - dump(directoryList("https://lucee.org/index.cfm")); - -``` - -### RAM File System ### - -RAM is an in Memory Filesystem that stores Files in the Memory of the Java Virtual Machine (JVM) simply by using "ram://", -unless you define a Cache in the Lucee Administrator for this Resource. - -The RAM file system has much faster access than a local file system. - -Each Web Context has it's own independent RAM Cache, it cannot be shared between multiple contexts. - -**When the available memory is low, files maybe (somewhat randomly) garbage collected (CG-ed) by the JVM from the RAM file system, increasing the memory assigned to the JVM will help avoid this** - -```lucee - -sct.ram = "ram://"; -dump(sct); -dump(directoryCreate(sct.ram&"/heidi/")); -fileWrite(sct.ram&"susi.txt", "sorglos"); -dump(directoryList(sct.ram)); - -``` - -### S3 File System ### - -S3 is a remote file system you can use from Amazon S3 storage. You will need access credentials for accessing the S3 bucket. - -Set up the S3 file system using the prefix "s3://" - -In Lucee, we can define an S3 file system in two ways: - -* Define credentials in the Application.cfc file -* Pass the credentials with the S3 URL - -```lucee - -//In Application.cfc -this.s3.accesskeyid= "xxxxxxx" -this.s3.awssecretkey= "xxxxxxx" - -sct.s3 = s3://#request.s3.accesskeyid#:#request.s3.awssecretkey#; // simply as file path -sct.s3 = "s3:///"; //If you define in cfc use like this - -dir = directoryList(sct.s3); -dump(dir); - -dir = directoryList(sct.s3&"testcasesS3/"); -dump(dir); - -dir = directoryList(sct.s3&"testcasesS3/a"); -dump(dir); - -c = fileRead(sct.s3&"testcasesS3/a/foo.txt"); -dump(c); - -``` - -### FTP File System ### - -Lucee allows you to treat a remote FTP server as a virtual filesystem. - -You will need access credentials for accessing FTP. Set up an FTP file system using the prefix "ftp://" - -```lucee - -/* How to configure default FTP settings via Application.cfc */ -this.ftp.username="..."; -this.ftp.password="..."; -this.ftp.host="ftp.lucee.org"; -this.ftp.port=21; - -/* index.cfm */ -ftp = ftp://#request.ftp.user#:#request.ftp.pass#@ftp53.world4you.com:21/; -//ftp="ftp:///"; // take credentials and host/port from Application.cfc -//ftp="ftp://ftp53.world4you.com:21/"; // take credentials from Application.cfc -//ftp="ftp://#request.ftp.user#:#request.ftp.pass#@/"; // take host/port from Application.cfc - -dir = directoryList(ftp); -dump(dir); - - -``` - -### Footnotes ### - -Here you can see above details in video - -[Lucee virtual File System](https://www.youtube.com/watch?time_continue=693&v=AzUNVYrbWiQ) diff --git a/docs/04.guides/04.cookbooks/27.PreCompiled-Code/page.md b/docs/04.guides/04.cookbooks/27.PreCompiled-Code/page.md deleted file mode 100644 index 810c7b491..000000000 --- a/docs/04.guides/04.cookbooks/27.PreCompiled-Code/page.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: Precompiled -id: precompiled-code ---- -## Precompiled Code ## - -This document explains how to pre-compile code for a production server while the source code is deployed. This method avoids compilation on the production server for security reasons. We explain this method with a simple example below: - -Example: - -```lucee -//index.cfm page in current instance location like \webapps\ROOT\sample\index.cfm - -Time is -writeoutput(now()); - -``` - -Run this index.cfm page in the browser. - -* When a cfm or cfc file is executed for the first time (or after the file has been edited), a class file holding the java byte-code representing that CFML file is automatically created within the cfclasses folder, webroot --> WEB-INF --> lucee --> cfclasses folder, in a sub-folder representing your application's context, for example `CFC__lucee_tomcat_webapps_ROOT4900`. (Differently from Adobe ColdFusion, a separate class file is not created for each method/function within a cfc/cfm file.) - -* After executing a request to our `/sample/index.cfm` example above, a class file named `index_cfm$cf.class` will be created within a `sample` folder of the cfclasses folder for our application's context. - -* To demonstrate how you can deploy that compiled byte-code for a cfm as if it was the cfm itself, you can copy that class file and paste it into your original application folder (\webapps\ROOT\sample). Since you already have the original index.cfm there, rename this class file to `test.cfm`. - -* Finally, run the `/sample/test.cfm` file in your browser. It should show the same results as the index.cfm file would. - -### Footnotes ### - -Here you can see above details in video - -[Lucee Precompiled Code](https://www.youtube.com/watch?v=Yjy3bQJgphA) diff --git a/docs/04.guides/04.cookbooks/30.NullSupport/page.md b/docs/04.guides/04.cookbooks/30.NullSupport/page.md deleted file mode 100644 index 9f7290f41..000000000 --- a/docs/04.guides/04.cookbooks/30.NullSupport/page.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: Null Support -id: null_support -related: -- function-isnull -- function-nullvalue ---- - -## Null Support - -This document explains how to set null support in the Lucee server admin, assigning `null` value for a variable and how to use `null` and `nullvalue`. It is an annotation of the video found here: [https://www.youtube.com/watch?v=GSlWfLR8Frs](https://www.youtube.com/watch?v=GSlWfLR8Frs) - -### Enabling NULL support - -You can enable null support via the **Lucee Server Admin** --> **Language/compiler** and setting Null support to **complete support** (exclusive to Lucee) or **partial support** (default, same as Adobe CF). - -Or via [[tag-application]] - -``` -this.nullSupport = true; -``` - -### Explanation - -#### Illustration 1: - -```lucee - - function test() { - } - dump( test() ); - - t=test(); - dump(t); - - dump( isNull( t ) ); - dump( isNull( notexisting ) ); - -``` - -In this example, the function `test()` does not return a value. This, in effect, is the same as returning `null`. If you dump the result of the function (`dump( test( ) );`), you will see that the dump outputs `Empty: Null`. - -If we assign the function result to a variable, i.e. `t = test();`, and reference the variable, i.e. `dump( t );` an error will be thrown when using **partial support** for null: "the key [T] does not exist". If we enable **full support**, you will be able to reference the variable without error, the dump output will be `Empty: Null` and `IsNull( t )` will evaluate `true`. - -In all cases, `dump( isNull( notexisting ) );` will throw an error. - -#### Illustration 2: - -```luceescript -query datasource="test" name="qry" { - echo("select '' as empty, null as _null"); -} -dump( qry ); -dump( qry._null ); -``` - -With **partial support** for NULL enabled, `dump(qry._null);` will output an **empty string**. -With **full support**, `Empty: null` will be output and `IsNull( qry._null );` will evaluate `true`. - -### NullValue() function and null keyword - -With **partial support** for NULL, the `NullValue()` function must be used to explicitly return a null value (this will work in all scenarios). For example: - -```luceescript -var possibleVariable = functionThatMayOrMayNotReturnNull(); -return possibleVariable ?: NullValue(); -``` - -With **full support**, you are able to use the `null` keyword directly and, as illustrated above, can assign it to a variable directly: - -```luceescript -t = null; -dump( t ); -``` diff --git a/docs/04.guides/04.cookbooks/31.Externalize_Strings/page.md b/docs/04.guides/04.cookbooks/31.Externalize_Strings/page.md deleted file mode 100644 index 844a92727..000000000 --- a/docs/04.guides/04.cookbooks/31.Externalize_Strings/page.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Externalize strings -id: Externalizing_Strings ---- -## Externalize strings ## - -Externalize strings from generated class files to separate files. This method is used to reduce the memory of the static contents for templates. We explain this method with a simple example below: - -**Example:** - -//index.cfm - -```lucee - - - -

....

- ....... - ....... - It was popular in the #year# - ....... - .... - - -``` - -1. Here the Index.cfm file contains a lot of strings (static contents), but there is no functionality. The file just gives a cfoutput with year. The variable string 'year' is already declared by using in top of the Index.cfm page. - -2. Execute the CFMpage in a browser. A class file is created in the ``webapps\ROOT\WEB-INF\lucee\cfclasses\`` directory while the CFM file is executed. The run time compiler compiles that file to load the Java bytecode and execute it. - -3. Right click the class file. Then see ``Get info``. For example, in my class file there is 8Kb size on the disk. In Lucee the cfm file with its strings was also loaded. So a lot of memory could be occupied just by string loading the bytecode. To avoid this problem, the Lucee admin has the following solution: - - - Lucee admin --> Language/compiler --> Externalize strings - - This ``Externalize strings`` setting has four options. Select any one option to test. We selected the fourth option (externalize strings larger than 10 characters). - - Again run the cfm page in a browser. The class file is created with lower memory size than the original 8Kb on disk. - - In addition, it created a text file too. The txt file contains the strings from the CFM page. The cfoutput with year is simply not there. The byte code will crop the piece of cfoutput content from the CFM file. - -So, the string 'year' is no longer in memory. When the bytecode is called, it loads the string into memory. The memory is not occupied forever and this reduces the footprint of our application. - -### Footnotes ### - -Here you can see above details in video - -[Externalize strings](https://youtu.be/AUcsHkVFXHE) \ No newline at end of file diff --git a/docs/04.guides/04.cookbooks/33.Hidden_gems/page.md b/docs/04.guides/04.cookbooks/33.Hidden_gems/page.md deleted file mode 100644 index 9131f9adf..000000000 --- a/docs/04.guides/04.cookbooks/33.Hidden_gems/page.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Hidden Gems -id: hidden_gems ---- -## Hidden Gems ## - -This document explains how to declare a variables, function call with dot and bracket notation, Passing arguments via URL/form scopes as array. Explain this three with simple example below: - -#### Example 1 : Declare variables #### - -// test.cfc - -```luceescript -component { - function getName() { - return "Susi"; - } -} -``` - -// example1.cfm - -```luceescript -function test() { - var qry; - dump(qry); - query name="qry" datasource="test" { - echo("select 1 as one"); - } - dump(qry); -} -test(); -``` - -* In cfm page have test() function with local variable scope, it normally assigned in empty string ``var qry``. Then execute this cfm, the qry is returns "1". -* Then dump the ``qry`` below of the var declaration. It returns empty string. - -#### Example 2 : Dot and bracket notation for function calls #### - -Lucee allow you to use bracket notations to call a component function. - -//example2.cfm - -```luceescript -// UDF call via dot notation - test=new Test(); - dump( test.getName() ); -// Dynamic function name - funcName="getName"; - dump(evaluate('test.#funcName#()')); -// UDF call via bracket notation - funcName="getName"; - dump( test[funcName]() ); -``` - -Here this three different types of function call. There are, - -* Calling the user defined function ``getname()`` from component. -* Second type of function call is dynamic function name with evaluate function. -* Third type of function call is user defined function via bracket notation. - -These all three different function call returns as same content ``susi`` what you defined in CFC page. - -#### Example 3 : Passing arguments via URL/form scopes as Array #### - -Lucee allow to pass URL and Form scope data as an Array instead of a string list. - -//example3.cfm - -```lucee - - dump(label:"URL",var:url); - dump(label:"Form",var:form); - // current name - curr=listLast(getCurrentTemplatePath(),'\/'); - - - -

Countries

-
-
-			Countries Europe:	
-			Countries America:	
-			
-		
-
-
-``` - -// index.cfm - -```luceescript -directory sort="name" action="list" directory=getDirectoryFromPath(getCurrentTemplatePath()) filter="example*.cfm" name="dir"; -loop query=dir { - echo('#dir.name#
'); -} -``` - -* In this cfm page have available in URL and form scopes. Here names are used as same as two times. -* Query string on URL scope have same name ``country`` as two times. Similarly form also have two same name ``country``. -* Execute this cfm page in browser & submit the form. It will showing a single URL string list in merged format instead of two fields & Form fields also merged as single ``country`` field. -* If we add square bracket behind the name ``country[]`` means, it returns as two separated strings in array format. We will see the difference on browser while dumping that name with square bracket. - -These simple ways are helpful for defining a variable as different methods. - -### Footnotes ### - -Here you can see above details in video - -[Lucee Hidden Gems](https://youtu.be/4MUKPiQv1kAsss) \ No newline at end of file diff --git a/docs/04.guides/04.cookbooks/35.loop_through_files/page.md b/docs/04.guides/04.cookbooks/35.loop_through_files/page.md deleted file mode 100644 index 1c59621bd..000000000 --- a/docs/04.guides/04.cookbooks/35.loop_through_files/page.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Looping Through File -id: loop_through_files ---- -## Looping Through File ## - -This document explains how to handle big files in Lucee in a better way. The classic way that you are familiar with uses cffile tag, fileRead, and fileReadBinary functions to read the file into memory. This is a simple solution, but it consumes a lot of memory. - -Example: - -Handle files with cffile tag, fileRead, and fileReadBinary functions - -```luceescript -include "_getPath2BigFile.cfm"; -NL=""; -// read the complete file into memory -content=fileRead(path); -// no we split, again everything lands in memory as an array -arr=listToArray(content,NL); -// now we loop over every single line -loop array=arr index="i" item="line" { - handle(line); -} -function handle(line) {} -dump(label:"String Size",var:len(content)); -dump(label:"Array Size",var:len(arr)); -``` - -In the example above, - -* Read the file into the memory -* Split into array -* loop over the array - -It consumes lot of memory. - -### Use Loop - File ### - -Use cfloop file, It allows you to read a file line by line, so you do not have to load an entire file into memory. You only load a line at a time into the memory. - -```lucee - -``` - -Example Using Loop - -```luceesript -include "_getPath2BigFile.cfm"; -// now we loop over every single line -loop file=path item="line" { - handle(line); -} -function handle(line) {} -``` - -In the above example, loop through the file and get each line, so in memory there is only ever the one line. This not only faster, it also consumes less memory. - -### Footnotes ### - -Here you can see above details in video - -[Looping through Files](https://www.youtube.com/watch?v=6w2Wr8snk50) diff --git a/docs/04.guides/04.cookbooks/36.thread_task/page.md b/docs/04.guides/04.cookbooks/36.thread_task/page.md deleted file mode 100644 index acaa8636c..000000000 --- a/docs/04.guides/04.cookbooks/36.thread_task/page.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: Thread Task -id: thread_task -related: -- tag-thread -categories: -- thread -description: 'How to use Thread Tasks ' ---- - -## Thread Task ## - -This document explains about the thread tasks. It useful to know the differences between regular threads and task threads. - -When a regular thread throws an exception, the default exception type is ``type='daemon'``. After an exception, the thread is dumped. If a regular thread is terminated due to an error, the information from the thread will be output with a 'terminated' status. - -Regular Threads have the following characteristics: - -1) **Bound to current request** : With the help of CFThread you can always see what the thread is doing. With ``action='join'`` you can wait until the thread ends and join it. You can also call "action='terminate'" and end the thread. You always have control over the thread with the various actions. - -2) **Runs only once** : The thread runs only once. It ends at the end of the Cfthread tag or if there is an exception. - -3) **It fails when it fails** : There is no special exception handling so when the thread fails it fails unless you have Cftry, cfcatch inside the thread and you have exception handling there. - -### Example 1 : ### - -In addition to daemon (regular) threads, Lucee also supports task threads. The main differences is that task threads execute completely Independent of the request that is calling the thread. We log the thread and can re-execute it. - -This example shows a task thread. It is similar to the daemon thread, but we do not have the join and output of the thread because these are not allowed with a task thread. - -```luceescript -thread name="test" type="daemon" { - throw "hopala!"; -} -thread action="join" name="test"; -dump(cfthread.test); -``` - -Note that when you execute example code, you will get no output. This is expected since no output was written in the code. - -However, view the Lucee _Admin --> Services --> Tasks_ and see the name of the tasks and their ``Type`` is cfthread. It could be mail or other tasks. - -We see the ``Number of tries`` is 1 because we only ran it once. When we go to detailed view, we see the exception that was thrown by the task, the template where it was executes, and the state. (The state is closed in this case.) - -### Example 2 : ### - -This example shows how to create a retry interval. A retry interval is useful when a task fails and you want to try it again. For example if you are contacting an external service and it does not always respond. - -```luceescript -thread name="test" type="task" - retryinterval={ - tries:3, - interval:createTimeSpan(0,0,0,1) - } { - throw "hopala!"; -} -``` - -In this example: - -1) It retries 3 times every 1 second when it fails. - -2) It will retry 3 times at 1 second intervals every time it does not get an output. Go to _admin --> Services --> Tasks_, we see two tasks. The tasks are closed, but you can see that the new task was executed 4 times. - -3) If you view the details, you can see that the ``Number of tries`` is 4,``Remaining tries`` are 0, ``State`` is closed. If we execute the thread again, the ``Number of tries`` will be increased to 5. - -### Example 3 : ### - -```luceescript -thread name="test" type="task" - retryinterval=[ - {tries:3, interval:createTimeSpan(0,0,0,1)}, - {tries:5, interval:createTimeSpan(0,0,0,5)}, - {tries:10, interval:createTimeSpan(0,0,0,10)}, - {tries:10, interval:createTimeSpan(0,0,1,0)}, - {tries:20, interval:createTimeSpan(0,0,10,0)} - ] { - throw "hopala!"; -} -``` - -This example is similar to the previous one, but it more complex. Here We have an array of multiple retry intervals defined. - -1) This example has the following retry intervals: - tries:3, interval:createTimeSpan(0,0,0,1), this means try 3 times every one second - {tries:5, interval:createTimeSpan(0,0,0,5)}, this means try 5 times every 5 seconds - {tries:10, interval:createTimeSpan(0,0,0,10)}, this means try 10 times every 10 seconds - {tries:10, interval:createTimeSpan(0,0,1,0)}, this means try 10 times every 1 minute - {tries:20, interval:createTimeSpan(0,0,10,0) this means try 20 times every 10 minutes - -2) When we execute, we again get no output. However, we see the result and it is not 'read', because it is not done retrying. We have only tried 5 times. - -3) Refresh the page, we see now it has tried more times. (Go to admin _Admin --> Services --> Tasks_) - -**Task thread** : Different than daemon threads, task threads can run more than once if they fail. You can schedule a later retry, and you can control it in the administrator. - -Task threads are not bound to the requests starting the threads as demon threads are, but you still can control them with help of the component administrator. That component is available everywhere so we can use it in a test page. - -### Example 4 : ### - -```luceescript -/**/thread name="test" type="task" - retryinterval=[ - {tries:3, interval:createTimeSpan(0,0,0,1)}, - {tries:5, interval:createTimeSpan(0,0,0,5)}, - {tries:10, interval:createTimeSpan(0,0,0,10)}, - {tries:10, interval:createTimeSpan(0,0,1,0)}, - {tries:20, interval:createTimeSpan(0,0,10,0)} - ] { - throw "hopala!"; -} -// wait for it( title="", body=any, labels=any, skip=any, data={} ) - sleep(1000); -// get admin component - admin=new Administrator(type:"web",password:"server"); -// list all tasks - tasks=admin.getTasks(); - dump(tasks); -// reexecute - admin.executeTask(tasks.id); -// delete a single task - admin.removeTask(tasks.id[tasks.recordcount]); -//delete all tasks - admin.removeAllTask(); -``` - -This example for getting the admin component and task is physically created on the system. - -1) ``admin.getTasks()`` is used to list out the all existing tasks. When executed, it returns a query that contains the information from the task. - -2) ``admin.executeTask()`` is used to execute the task and we see it in the browser. It throws an exception. - -3) ``admin.removeTask()`` and "admin.removeAllTask()" is used to remove tasks from administrator. - -### Footnotes ### - -Here you can see the details in the video: -[Thread Task](https://youtu.be/-SUbVWqJRME) diff --git a/docs/04.guides/04.cookbooks/38.supercharge_website/page.md b/docs/04.guides/04.cookbooks/38.supercharge_website/page.md deleted file mode 100644 index a3f16168e..000000000 --- a/docs/04.guides/04.cookbooks/38.supercharge_website/page.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: Supercharge your website -id: supercharge-your-website ---- - -## Supercharge your website ## - -This document explains how you can improve the performance of your website in a very short time with Lucee. - -### Example: ### - -```luceescript - -// index.cfm -writeDump(now()); - -``` - -Run the above index.cfm, and you get a timestamp. Whenever we call our file, Lucee checks once at every request if a file has changed or not (for files currently residing in the template cache). If a files has changed, Lucee recompiles it, and executes it. Checking the files at every request takes time. If you have a published server, and you know your server does not produce or change any files, you can simply avoid that check that happens all the time. - -### Using Admin ### - -* Go to _Admin -> Performance/ Caching -> Inspect Templates (CFM/CFC) -> Never_ - -* The default is "Once", checking any requested files one time within each request. You should check "Never" to avoid the checking at every request. - -* Change the index.cfm and run it again. No changes happen in the output because Lucee does not check if the file changed or not. Now, let's see the faster execution and less performance memory being used. - -* You can clear the cache by code using `pagePoolClear()`. This clears all template cache so that Lucee will check again if the template has changed. On the next request Lucee will check initially for the file. - -* Another option to clear the template cache is to use clear cache via the admin by clicking the button in _Admin -> Settings -> Performance/ Caching -> Page Pool Cache_. - -### Footnotes ### - -Here you can see this details on video also - -[Charge Your website](https://youtu.be/w-eeigEkmn0) diff --git a/docs/04.guides/04.cookbooks/39.Retry/page.md b/docs/04.guides/04.cookbooks/39.Retry/page.md deleted file mode 100644 index e935d5fb4..000000000 --- a/docs/04.guides/04.cookbooks/39.Retry/page.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: Retry -id: retry -related: -- tag-catch -- tag-retry -- tag-try ---- - -## Retry ## - -This document explains how to use retry functionality with some simple examples. - -### Example 1 : ### - -```luceescript -// example1.cfm - -path="test.txt"; -function fr(){ - dump(fileRead(path)); -} -try { - fr(); -} -catch(e) { - if(!fileExists(path)) { - fileWrite(path,"content of the file"); - fr(); - } - else echo(e); -} -if(fileExists(path)) fileDelete(path); - -``` - -In this example have the "try" and "catch" blocks for reading a file and outputting the file content. Maybe that file does not exist in every case. So we have to checked in advanced if the file exists or not. In this example, the file read is a function ``fr()``, and we will call this function in the "try" block. If the file does not exist, the "catch" block is executed and the ``fr()`` function is called again. - -This is not a best way. 'Retry' is a better option. The retry code looks like example2.cfm - -### Example 2 : ### - -```luceescript -// example2.cfm - -path="test.txt"; -try { - dump(fileRead(path)); -} -catch(e) { - if(!fileExists(path)) { - fileWrite(path,"content of the file"); - retry; - } - echo(e); -} -if(fileExists(path)) fileDelete(path); - -``` - -In this example we use the retry functionality. Here we also still check if the file exist or not. If the file does not exist, we create a new file by using ``fileWrite``. Then call retry to avoid duplicate code ``fr()``. Retry points to the beginning of the try block and then it will read again the file and output the file content. - -We do not get an exception because if the file does not exist, we call retry (read the file again and output the file content). For this case we simply use retry, and if it fails we correct what is wrong. - -### Footnotes ### - -Here you can see this details on video also - -[Retry](https://youtu.be/zA9aAAimkk8) diff --git a/docs/04.guides/04.cookbooks/41.Encrypt_Decrypt/page.md b/docs/04.guides/04.cookbooks/41.Encrypt_Decrypt/page.md deleted file mode 100644 index 612095279..000000000 --- a/docs/04.guides/04.cookbooks/41.Encrypt_Decrypt/page.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -title: Encryption/Decryption with RSA public and private keys -id: encryption_decryption -related: -- function-decrypt -- function-encrypt -- function-generatersakeys -categories: -- crypto -description: This document explains about Encryption/Decryption with public and private keys with simple examples. -menuTitle: 'Public and Private keys ' ---- - -## Encryption/Decryption ## - -This document explains about Encryption/Decryption with public and private keys with simple examples. - -Encryption/Decryption is a new functionality in Lucee 5.3. We have new way to encrypt/decrypt string values. First we start with keys. In this case, there are two keys: - -* Private key to encrypt -* Public key to decrypt - -#### Example 1 : #### - -```luceescript -//index.cfm -directory action="list" directory=getDirectoryFromPath(getCurrentTemplatePath()) filter="example*.cfm" name="dir"; -loop query=dir { - echo('#dir.name#
'); -} -``` - -```luceescript -key=generateRSAKeys(); -dump(key) -``` - -This function generates RSA keys. Execute the example code above in the browser and a struct is returned containing the two keys: a private key and a public key. So, we can create these keys, and store them somewhere for later use. - -#### Example 2 : #### - -```luceescript -key=generateRSAKeys(); -raw="Hi, Hello !!!"; -enc=encrypt(raw,key.private,"rsa"); -dump(enc); -``` - -We now create RSA keys using the [[function-generatersakeys]] function, and then use the key to encrypt using the [[function-encrypt]] function. The encrypt() function has some arguments. It has ``key.private`` which defines the key as the private key, and ``rsa`` indicates use of the RSA encryption algorithm. Then run the dump in the browser and we see the encrypted string for your input string. - -#### Example 3 : #### - -```luceescript -key=generateRSAKeys(); -raw="Hi, Hello !!!"; -enc=encrypt(raw,key.private,"rsa"); -dec=decrypt(enc,key.public,"rsa"); -dump(dec); -``` - -This is full detailed example of encrypt/decrypt functions. We create a key and we encrypt with the private key. Then we [[function-decrypt]] with the public key. Then run the dump in the browser and we see the original string returned as expected. - -### Footnotes ### - -Here you can see this details on video also - -[Encryption/Decryption with public and private keys](https://www.youtube.com/watch?v=2fgfq-3nWfk) diff --git a/docs/recipes/basic-date.md b/docs/recipes/basic-date.md index 4e26da217..7e7c471eb 100644 --- a/docs/recipes/basic-date.md +++ b/docs/recipes/basic-date.md @@ -3,6 +3,9 @@ "title": "Basic Date", "id": "cookbook-basic-date", "description": "Learn how to output the current date in Lucee.", + "categories": [ + "datetime" + ], "keywords": [ "Date", "Current date", diff --git a/docs/recipes/configuration-lucee5.md b/docs/recipes/configuration-lucee5.md index a1b0fc7b4..2237f7890 100644 --- a/docs/recipes/configuration-lucee5.md +++ b/docs/recipes/configuration-lucee5.md @@ -2,7 +2,7 @@ diff --git a/docs/recipes/loop-labels.md b/docs/recipes/loop-labels.md index 7295bbf7c..e3566005b 100644 --- a/docs/recipes/loop-labels.md +++ b/docs/recipes/loop-labels.md @@ -10,6 +10,9 @@ "while", "continue", "break" + ], + "related": [ + "tag-loop" ] } --> diff --git a/docs/recipes/query-async.md b/docs/recipes/query-async.md index b8ecb2902..97d9d3247 100644 --- a/docs/recipes/query-async.md +++ b/docs/recipes/query-async.md @@ -10,6 +10,12 @@ "listener", "thread", "parallel" + ], + "categories": [ + "query" + ], + "related": [ + "tag-query" ] } --> diff --git a/docs/recipes/query-indexes.md b/docs/recipes/query-indexes.md index bdf3692d0..00e5ee4e6 100644 --- a/docs/recipes/query-indexes.md +++ b/docs/recipes/query-indexes.md @@ -8,6 +8,15 @@ "query", "indexes", "cfquery" + ], + "categories": [ + "query" + ], + "related": [ + "tag-query", + "function-queryrowbyindex", + "function-querygetcellbyindex", + "function-queryrowdatabyindex" ] } --> diff --git a/docs/recipes/query-listener.md b/docs/recipes/query-listener.md index 063d19cc1..7fd0bab0b 100644 --- a/docs/recipes/query-listener.md +++ b/docs/recipes/query-listener.md @@ -10,6 +10,12 @@ "Lucee", "Application.cfc", "component" + ], + "categories": [ + "query" + ], + "related": [ + "tag-query" ] } --> diff --git a/docs/recipes/query-return-type.md b/docs/recipes/query-return-type.md index e0523e5c0..cfd40aeac 100644 --- a/docs/recipes/query-return-type.md +++ b/docs/recipes/query-return-type.md @@ -12,6 +12,9 @@ "Struct return type", "Foreign key", "Lucee" + ], + "related": [ + "tag-query" ] } --> diff --git a/docs/recipes/sub-components.md b/docs/recipes/sub-components.md index 79580c067..5ef60a460 100644 --- a/docs/recipes/sub-components.md +++ b/docs/recipes/sub-components.md @@ -1,9 +1,12 @@