From 0100b76412d054d67d66011cd92aa044059b5e15 Mon Sep 17 00:00:00 2001 From: Sean Coyne Date: Thu, 24 Jul 2014 20:48:50 -0400 Subject: [PATCH] distinguish between ColdFusion HTML and ColdFusion CFCs allows for using both ColdFusion Lexers provided by pigments and allows for proper syntax highlighting of cfscript based CFCs Signed-off-by: Sean Coyne --- lib/linguist/languages.yml | 13 ++ lib/linguist/samples.json | 234 +++++++++++++++++++++- samples/ColdFusion CFC/exampleScript.cfc | 239 +++++++++++++++++++++++ samples/ColdFusion CFC/exampleTag.cfc | 18 ++ samples/ColdFusion/example.cfm | 50 +++++ 5 files changed, 551 insertions(+), 3 deletions(-) create mode 100644 samples/ColdFusion CFC/exampleScript.cfc create mode 100644 samples/ColdFusion CFC/exampleTag.cfc create mode 100644 samples/ColdFusion/example.cfm diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 5996fc8ca4..5cd0c9a4af 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -403,14 +403,27 @@ CoffeeScript: ColdFusion: type: programming + group: ColdFusion lexer: Coldfusion HTML ace_mode: coldfusion color: "#ed2cd6" search_term: cfm aliases: - cfm + - cfml extensions: - .cfm + +ColdFusion CFC: + type: programming + group: ColdFusion + lexer: Coldfusion CFC + ace_mode: coldfusion + color: "#ed2cd6" + search_term: cfc + aliases: + - cfc + extensions: - .cfc Common Lisp: diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index c78ed491d7..890010afbf 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -97,6 +97,12 @@ "CoffeeScript": [ ".coffee" ], + "ColdFusion": [ + ".cfm" + ], + "ColdFusion CFC": [ + ".cfc" + ], "Common Lisp": [ ".cl", ".lisp" @@ -797,8 +803,8 @@ "exception.zep.php" ] }, - "tokens_total": 630435, - "languages_total": 869, + "tokens_total": 631177, + "languages_total": 872, "tokens": { "ABAP": { "*/**": 1, @@ -16022,6 +16028,224 @@ "xFF": 1, "ip.join": 1 }, + "ColdFusion": { + "-": 12, + "": 1, + "": 1, + "": 1, + "Date": 1, + "Functions": 1, + "": 1, + "": 1, + "": 1, + "": 15, + "RightNow": 7, + "Now": 1, + "": 3, + "#RightNow#": 1, + "
": 8, + "#DateFormat": 2, + "(": 8, + ")": 8, + "#": 8, + "#TimeFormat": 2, + "#IsDate": 3, + "#DaysInMonth": 1, + "
": 3, + "x=": 1, + "y=": 1, + "z=": 1, + "group=": 1, + "#x#": 1, + "#y#": 1, + "#z#": 1, + "": 1, + "": 1, + "person": 2, + "Paul": 1, + "greeting": 2, + "Hello": 2, + "world": 1, + "a": 7, + "5": 1, + "b": 7, + "10": 1, + "c": 6, + "MOD": 1, + "comment": 1 + }, + "ColdFusion CFC": { + "component": 1, + "extends": 1, + "singleton": 1, + "{": 22, + "//": 16, + "DI": 1, + "property": 10, + "name": 10, + "inject": 10, + ";": 55, + "ContentService": 1, + "function": 12, + "init": 2, + "(": 58, + "entityName": 2, + ")": 58, + "it": 1, + "super.init": 1, + "arguments.entityName": 1, + "useQueryCaching": 1, + "true": 12, + "Test": 1, + "scope": 1, + "coloring": 1, + "in": 1, + "pygments": 1, + "this.colorTestVar": 1, + "cookie.colorTestVar": 1, + "client.colorTestVar": 1, + "session.colorTestVar": 1, + "application.colorTestVar": 1, + "return": 11, + "this": 10, + "}": 22, + "clearAllCaches": 1, + "boolean": 6, + "async": 7, + "false": 7, + "var": 15, + "settings": 6, + "settingService.getAllSettings": 6, + "asStruct": 6, + "Get": 6, + "appropriate": 6, + "cache": 12, + "provider": 6, + "cacheBox.getCache": 6, + "settings.cb_content_cacheName": 6, + "cache.clearByKeySnippet": 3, + "keySnippet": 3, + "arguments.async": 3, + "clearAllPageWrapperCaches": 1, + "clearPageWrapperCaches": 1, + "required": 5, + "any": 5, + "slug": 2, + "clearPageWrapper": 1, + "cache.clear": 3, + "searchContent": 1, + "searchTerm": 1, + "numeric": 2, + "max": 2, + "offset": 2, + "asQuery": 2, + "sortOrder": 2, + "isPublished": 1, + "searchActiveContent": 1, + "results": 2, + "c": 1, + "newCriteria": 1, + "only": 1, + "published": 1, + "content": 2, + "if": 4, + "isBoolean": 1, + "arguments.isPublished": 3, + "Published": 2, + "bit": 1, + "c.isEq": 1, + "javaCast": 1, + "eq": 1, + "evaluate": 1, + "other": 1, + "params": 1, + "c.isLt": 1, + "now": 2, + ".": 1, + "or": 3, + "c.restrictions.isNull": 1, + "c.restrictions.isGT": 1, + ".isEq": 1, + "Search": 1, + "Criteria": 1, + "len": 1, + "arguments.searchTerm": 1, + "like": 1, + "disjunctions": 1, + "c.createAlias": 1, + "Do": 1, + "we": 1, + "search": 1, + "title": 2, + "and": 2, + "active": 1, + "just": 1, + "arguments.searchActiveContent": 1, + "c.": 1, + "c.restrictions.like": 2, + "else": 1, + "c.like": 1, + "run": 1, + "criteria": 1, + "query": 1, + "projections": 1, + "count": 1, + "results.count": 1, + "c.count": 1, + "results.content": 1, + "c.resultTransformer": 1, + "c.DISTINCT_ROOT_ENTITY": 1, + ".list": 1, + "arguments.offset": 1, + "arguments.max": 1, + "arguments.sortOrder": 1, + "arguments.asQuery": 1, + "private": 4, + "syncUpdateHits": 1, + "contentID": 1, + "q": 1, + "new": 1, + "Query": 1, + "sql": 1, + ".execute": 1, + "closureTest": 1, + "methodCall": 1, + "param1": 2, + "arg1": 4, + "arg2": 2, + "StructliteralTest": 1, + "foo": 3, + "bar": 1, + "brad": 3, + "func": 1, + "array": 1, + "[": 2, + "wood": 2, + "null": 2, + "]": 2, + "last": 1, + "arrayliteralTest": 1, + "": 1, + "": 2, + "name=": 4, + "access=": 2, + "returntype=": 2, + "": 2, + "type=": 2, + "required=": 2, + "": 2, + "myVariable": 1, + "arguments": 2, + "": 1, + "": 2, + "": 1, + "structKeyExists": 1, + "writeoutput": 1, + "Argument": 1, + "exists": 1, + "": 1, + "": 1 + }, "Common Lisp": { ";": 152, "@file": 1, @@ -69764,6 +69988,8 @@ "Cirru": 244, "Clojure": 510, "CoffeeScript": 2951, + "ColdFusion": 131, + "ColdFusion CFC": 611, "Common Lisp": 2186, "Component Pascal": 825, "Coq": 18259, @@ -69964,6 +70190,8 @@ "Cirru": 9, "Clojure": 7, "CoffeeScript": 9, + "ColdFusion": 1, + "ColdFusion CFC": 2, "Common Lisp": 3, "Component Pascal": 2, "Coq": 12, @@ -70137,5 +70365,5 @@ "fish": 3, "wisp": 1 }, - "md5": "1edee1d2c454fb877027ae980cd163ef" + "md5": "9f2e70b08b9943b57c05e7ce6196827f" } \ No newline at end of file diff --git a/samples/ColdFusion CFC/exampleScript.cfc b/samples/ColdFusion CFC/exampleScript.cfc new file mode 100644 index 0000000000..33ec70ef44 --- /dev/null +++ b/samples/ColdFusion CFC/exampleScript.cfc @@ -0,0 +1,239 @@ +/** +******************************************************************************** +ContentBox - A Modular Content Platform +Copyright 2012 by Luis Majano and Ortus Solutions, Corp +www.gocontentbox.org | www.luismajano.com | www.ortussolutions.com +******************************************************************************** +Apache License, Version 2.0 + +Copyright Since [2012] [Luis Majano and Ortus Solutions,Corp] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +******************************************************************************** +* A generic content service for content objects +*/ +component extends="coldbox.system.orm.hibernate.VirtualEntityService" singleton{ + + // DI + property name="settingService" inject="id:settingService@cb"; + property name="cacheBox" inject="cachebox"; + property name="log" inject="logbox:logger:{this}"; + property name="customFieldService" inject="customFieldService@cb"; + property name="categoryService" inject="categoryService@cb"; + property name="commentService" inject="commentService@cb"; + property name="contentVersionService" inject="contentVersionService@cb"; + property name="authorService" inject="authorService@cb"; + property name="populator" inject="wirebox:populator"; + property name="systemUtil" inject="SystemUtil@cb"; + + /* + * Constructor + * @entityName.hint The content entity name to bind this service to. + */ + ContentService function init(entityName="cbContent"){ + // init it + super.init(entityName=arguments.entityName, useQueryCaching=true); + + // Test scope coloring in pygments + this.colorTestVar = "Just for testing pygments!"; + cookie.colorTestVar = ""; + client.colorTestVar = "" + session.colorTestVar = ""; + application.colorTestVar = ""; + + return this; + } + + /** + * Clear all content caches + * @async.hint Run it asynchronously or not, defaults to false + */ + function clearAllCaches(boolean async=false){ + var settings = settingService.getAllSettings(asStruct=true); + // Get appropriate cache provider + var cache = cacheBox.getCache( settings.cb_content_cacheName ); + cache.clearByKeySnippet(keySnippet="cb-content",async=arguments.async); + return this; + } + + /** + * Clear all page wrapper caches + * @async.hint Run it asynchronously or not, defaults to false + */ + function clearAllPageWrapperCaches(boolean async=false){ + var settings = settingService.getAllSettings(asStruct=true); + // Get appropriate cache provider + var cache = cacheBox.getCache( settings.cb_content_cacheName ); + cache.clearByKeySnippet(keySnippet="cb-content-pagewrapper",async=arguments.async); + return this; + } + + /** + * Clear all page wrapper caches + * @slug.hint The slug partial to clean on + * @async.hint Run it asynchronously or not, defaults to false + */ + function clearPageWrapperCaches(required any slug, boolean async=false){ + var settings = settingService.getAllSettings(asStruct=true); + // Get appropriate cache provider + var cache = cacheBox.getCache( settings.cb_content_cacheName ); + cache.clearByKeySnippet(keySnippet="cb-content-pagewrapper-#arguments.slug#",async=arguments.async); + return this; + } + + /** + * Clear a page wrapper cache + * @slug.hint The slug to clean + * @async.hint Run it asynchronously or not, defaults to false + */ + function clearPageWrapper(required any slug, boolean async=false){ + var settings = settingService.getAllSettings(asStruct=true); + // Get appropriate cache provider + var cache = cacheBox.getCache( settings.cb_content_cacheName ); + cache.clear("cb-content-pagewrapper-#arguments.slug#/"); + return this; + } + + /** + * Searches published content with cool paramters, remember published content only + * @searchTerm.hint The search term to search + * @max.hint The maximum number of records to paginate + * @offset.hint The offset in the pagination + * @asQuery.hint Return as query or array of objects, defaults to array of objects + * @sortOrder.hint The sorting of the search results, defaults to publishedDate DESC + * @isPublished.hint Search for published, non-published or both content objects [true, false, 'all'] + * @searchActiveContent.hint Search only content titles or both title and active content. Defaults to both. + */ + function searchContent( + any searchTerm="", + numeric max=0, + numeric offset=0, + boolean asQuery=false, + any sortOrder="publishedDate DESC", + any isPublished=true, + boolean searchActiveContent=true){ + + var results = {}; + var c = newCriteria(); + + // only published content + if( isBoolean( arguments.isPublished ) ){ + // Published bit + c.isEq( "isPublished", javaCast( "Boolean", arguments.isPublished ) ); + // Published eq true evaluate other params + if( arguments.isPublished ){ + c.isLt("publishedDate", now() ) + .$or( c.restrictions.isNull("expireDate"), c.restrictions.isGT("expireDate", now() ) ) + .isEq("passwordProtection",""); + } + } + + // Search Criteria + if( len( arguments.searchTerm ) ){ + // like disjunctions + c.createAlias("activeContent","ac"); + // Do we search title and active content or just title? + if( arguments.searchActiveContent ){ + c.$or( c.restrictions.like("title","%#arguments.searchTerm#%"), + c.restrictions.like("ac.content", "%#arguments.searchTerm#%") ); + } + else{ + c.like( "title", "%#arguments.searchTerm#%" ); + } + } + + // run criteria query and projections count + results.count = c.count( "contentID" ); + results.content = c.resultTransformer( c.DISTINCT_ROOT_ENTITY ) + .list(offset=arguments.offset, max=arguments.max, sortOrder=arguments.sortOrder, asQuery=arguments.asQuery); + + return results; + } + +/********************************************* PRIVATE *********************************************/ + + + /** + * Update the content hits + * @contentID.hint The content id to update + */ + private function syncUpdateHits(required contentID){ + var q = new Query(sql="UPDATE cb_content SET hits = hits + 1 WHERE contentID = #arguments.contentID#").execute(); + return this; + } + + + private function closureTest(){ + methodCall( + param1, + function( arg1, required arg2 ){ + var settings = settingService.getAllSettings(asStruct=true); + // Get appropriate cache provider + var cache = cacheBox.getCache( settings.cb_content_cacheName ); + cache.clear("cb-content-pagewrapper-#arguments.slug#/"); + return this; + }, + param1 + ); + } + + private function StructliteralTest(){ + return { + foo = bar, + brad = 'Wood', + func = function( arg1, required arg2 ){ + var settings = settingService.getAllSettings(asStruct=true); + // Get appropriate cache provider + var cache = cacheBox.getCache( settings.cb_content_cacheName ); + cache.clear("cb-content-pagewrapper-#arguments.slug#/"); + return this; + }, + array = [ + 1, + 2, + 3, + 4, + 5, + 'test', + 'testing', + 'testerton', + { + foo = true, + brad = false, + wood = null + } + ], + last = "final" + }; + } + + private function arrayliteralTest(){ + return [ + 1, + 2, + 3, + 4, + 5, + 'test', + 'testing', + 'testerton', + { + foo = true, + brad = false, + wood = null + }, + 'testy-von-testavich' + ]; + } + +} \ No newline at end of file diff --git a/samples/ColdFusion CFC/exampleTag.cfc b/samples/ColdFusion CFC/exampleTag.cfc new file mode 100644 index 0000000000..ad82c57147 --- /dev/null +++ b/samples/ColdFusion CFC/exampleTag.cfc @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/ColdFusion/example.cfm b/samples/ColdFusion/example.cfm new file mode 100644 index 0000000000..f436c79325 --- /dev/null +++ b/samples/ColdFusion/example.cfm @@ -0,0 +1,50 @@ + + ---> + +---> + + + +Date Functions + + + + + #RightNow#
+ #DateFormat(RightNow)#
+ #DateFormat(RightNow,"mm/dd/yy")#
+ #TimeFormat(RightNow)#
+ #TimeFormat(RightNow,"hh:mm tt")#
+ #IsDate(RightNow)#
+ #IsDate("January 31, 2007")#
+ #IsDate("foo")#
+ #DaysInMonth(RightNow)# +
+ + + + + #x# + #y# + #z# + + + + + + + + + + + + + + + + + ---> comment ---> \ No newline at end of file