Commit Graph

98 Commits

Author SHA1 Message Date
agrath@gmail.com
bba0fcfd5f Merge 2011-02-27 09:00:00 -13:00
agrath@gmail.com
7ca429cb61 Added overloads to AncestorsOrSelf, Ancestors, Descendants, DecendentsOrSelf to filter by Level or NodeTypeAlias
Rewrote implementations internally so a Func<DynamicNode,bool> [or Func<INode,bool>] is used so that there's only one implementation of each
2011-02-27 08:55:15 -13:00
hartvig
1dae998eaf Work items: 30073
Encoding issues in temporary razor files and general developer scripting editor
2011-02-27 12:46:22 -01:00
hartvig
9729ad4d31 Work items: 30082
Properties from Richtext editor isn't encoded by razor anymore as DynamicNode will return an IHtmlString for RTE properties
Changed the lookups of Yes/no and tinmce datatypes ids to consts as these won't change anyway
2011-02-27 12:13:04 -01:00
hartvig
11da35ae5f Exclude IronPython and IronRuby from default distribution (will be separate download). Work items: 30081 2011-02-27 11:57:33 -01:00
agrath@gmail.com
cbe94ae6aa Refactored ExtensionMethod search code from DynamicNodeList (searches for extension methods e.g. .Random()) to tidy it up
Moved Extension Method searching code to seperate static class
Moved all the defined extension methods for DynamicNode into the same ExtensionMethods.cs file
Changed the way that .ContainsAny within a where is evaluated to use the ExtensionMethodFinder class - should allow extra search methods to be defined
2011-02-26 16:15:45 -13:00
Elijah
f58c453334 Fixed Unary StartsWith("~") Razor 2011-02-26 16:26:06 -11:00
Elijah
cfb21237c0 Added FileLocation To <umbraco:macro /> template control 2011-02-26 16:05:30 -11:00
agrath@gmail.com
1f05d43047 Added new overloads to MediaById and NodeById which take List<object> or params object[] and return DynamicNodeList or DynamicMediaList [new - doesn't support OrderBy,Where etc]
Added to allow retreiving multiple items by id when you know the Ids, e.g.: using MNTP to select nodes and then needing to get them in Razor
2011-02-26 11:43:23 -13:00
agrath@gmail.com
6bc71000af Commit of updated umbraco.MacroEngines.csproj 2011-02-26 11:12:26 -13:00
agrath@gmail.com
a32e8894cd Added support for calling non standard extension method style helpers within a .Where
Intended as a future extensibility point, provides a way for the parser to redirect into a static method library of helpers
Currently, only one method is available - ContainsAny
Functions like string.Contains but uses needles from a List<string>

var values = new Dictionary<string,object>();
var keywords = new List<string>();
keywords.Add("Five");
keywords.Add("Four");
values.Add("keywords",keywords);
var items = @Model.Children.Where("Name.ContainsAny(keywords)", values);
2011-02-26 11:12:06 -13:00
agrath@gmail.com
6d615e6762 Work on DynamicQueryable to support .Where("bodyText.Contains(\"string\")")
Chaining works too: .Where("Name.SubString(1,3).Contains(\"v\")");
2011-02-25 16:58:17 -13:00
agrath@gmail.com
b1ff0db8fe Work on DynamicQueryable to support .Where("shouldBeVisible && Level < 4") rather than .Where("shouldBeVisible == true && Level < 4")
Confirmed other test cases of .Where still work
2011-02-25 12:16:03 -13:00
agrath@gmail.com
3961787463 Added DynamicNode.HasProperty(string) method to check to see if a particular DynamicNode has a property 2011-02-25 00:51:41 -13:00
agrath@gmail.com
9b45a81f22 Rewrote implementation of HandleDynamicNodeLambdas in DynamicQueryable.cs to be easier to read and handle unboxing and type conversion when the output type of the lambda is convertable between the left and right side.
Allows this syntax to work now:
@Model.Children.Where("updateDate < DateTime.Now.AddDays(-2)")
This didn't work previously in 4.7beta because updateDate was still boxed as an object and object < DateTime can't be implicitly converted

@Model.Children.Where("bodyText.Contains('ipsum')") still doesn't work because the parser doesn't know how to invoke .Contains on a LambdaExpression (yet)
2011-02-25 00:39:53 -13:00
agrath@gmail.com
71c5e35443 Added DynamicNodeWalker and implementation on DynamicNode and DynamicNodeList
DynamicNodeWalker is our secret weapon in the fight against the Rebel XSLT Alliance
Navigate nodes by calling Up(), Down(), Next() and Previous() on them
Next(1) will jump two items along within the current list, whereas Next() will walk by one within the list
Previous(1) will move two items backwards within the current list
Up() is a special wrapper around .Parent which has an overload .Up(int) to replace @Model.Parent.Parent.Parent... [.Up(2)]
Down() will take you to the first Child item and is equivilent to .Children.First(), use .Down(1) to replace .Children.First().Children
If one of the NodeWalker functions fails to find a node at the requested position, it will return null
2011-02-24 17:19:50 -13:00
agrath@gmail.com
603a12c5a0 Split umbraco.MacroEngines.Juno into two subfolders (namespaces remain the same)
RazorCore contains all the core razor engine implementation
RazorDynamicNode contains all the DynamicNode functionality and associated support files
2011-02-24 16:05:54 -13:00
agrath@gmail.com
78ae4132eb Added IEnumerable Map method used in Descendants feature
Fixed DynamicNodeList.OrderBy where there was only one column and the ordering was descending
Added DateTime.TryParse support to DynamicNode property retrieval to allow OrderBy and Where to have date support
Added IsProtected & HasAccess to DynamicNode
Added .AncestorsOrSelf to DynamicNode
Added .Descendants to DynamicNode [Deep Children]
Added .DescendantsAndSelf [Deep Children]
Fixed .nodeTypeAlias children collection crashing when the node didn't contain any children of that type
Added cshtml templates first versions for DynamicNode, these are samples I demo'ed at the Auckland umbraco meetup the night of 4.7beta release
2011-02-24 15:56:52 -13:00
hartvig
ff3a776617 Fix for parents in DynamicNode by Agrath 2011-02-23 00:16:50 -01:00
Elijah
9d5c127c14 Resharper Renamed My Property!!! Now Fixed :( 2011-02-21 17:27:32 -11:00
Elijah
0071bfbb13 webPages:Enabled requires a lowercase "W" 2011-02-21 17:01:55 -11:00
hartvig
64914da779 Adding missing files 2011-02-21 10:05:13 -01:00
hartvig
16f78d0f4c Merge of razor query improvements (missing one file in merge, though - will be added in next commit!) 2011-02-21 09:28:13 -01:00
agrath@gmail.com
03441fab21 Added umbraco.Settings entry for controlling what document element types are parsed as DynamicXml
Added documentElement checking to DynamicXml convert for DynamicNode property get to solve a potential issue with XHTML RTEs
Fixed issue with calling @Model.Children.First() in testing (null Children in testing)
Put some commented placeholder code in .XPath->DynamicNodeList inside DynamicNode.cs for future return of DynamicXml if not valid List<NodeFactory.Node>
2011-02-20 19:55:06 -13:00
agrath@gmail.com
6b431eb000 Fixed a bug in DynamicNode when the string contained "false" it would fail and not return (bool)false
Decided that if using @Model.XPath and you were in testing, then the resulting DynamicNodeList should contain self/this, not be empty
Should allow chaining to work when in test mode

Fixed a potential issue when DynamicNode got returned during testing because there are no children
and then property accesses would return false causing chaining to break

Added [a somewhat experimental] DynamicXml and xml fragment detection within DynamicNode to DynamicXml,
When accessing a string property that contains XML, you can now continue your dot based access
Call .ToXml() to get the real XML string again
Call .XPath(string) to run a XPath query on the fragment and return another DynamicXml
Example:
	<Catalog>
	  <Book id="bk101">
	    <Author>Garghentini, Davide</Author>
	    <Title>XML Developer's Guide</Title>
	    <Genre>Computer</Genre>
	    ...
	@Model.Children.Random().someXmlProperty.Catalog.Book[1].Genre
	@Model.Children.Random().someXmlProperty.Book[1].XPath(".//Genre")
	@Model.Children.Random().someXmlProperty.Book[1].ToXml()
2011-02-19 21:19:45 -13:00
agrath@gmail.com
84d7999f32 Added .XPath helper to DynamicNode list that allows you to use XPath to query from the current node represented in XML (e.g. if you have a child DynamicNode which actually exists part way down the original dom from NodeFactory then get it at that position (allowing you to use .. to move to parent)
Nodes are attempted to be turned back into NodeFactory.Node when returned by XPath and then wrapped in DynamicNode and then DynamicNodeList

Added .Random parameterless overload to pick a single random node from the DynamicNodeList

Example of new Methods being used:
<img src='@Model.XPath("//ChildItem[catCount = 2]").Random().Media("catPicture","umbracoFile")'/>
2011-02-19 20:05:02 -13:00
hartvig
fa5e5de818 Updates to fetching macro parameters in a case insensitive way 2011-02-18 13:12:58 -01:00
hartvig
f64e902bf8 Merge 2011-02-18 13:03:47 -01:00
hartvig
b5c78d397d Updates to fetching extension methods in a more stable way in DynamicNodeList 2011-02-18 13:02:20 -01:00
PerPloug
fe514e15ea Removal of another post-build-event that fails if done in release mode 2011-02-18 12:52:06 -01:00
hartvig
7df518155d Clean up of merging 2011-02-18 10:09:20 -01:00
hartvig
90f5c4ce9a Merge initial merge of Agraths improvements (might break compilation atm) 2011-02-18 09:38:19 -01:00
agrath@gmail.com
cc23fdbd8e Added .Random implementation from the blog post so it's internal to 4.6.2 2011-02-17 20:57:12 -13:00
agrath@gmail.com
3a30c285fe Updated .OrderBy implementation to support OrderBy,OrderByDescending,ThenBy,ThenByDescending properly on DynamicNodeList
Usage is: @foreach(var item in home.ChildItems.OrderBy("catCount, colour desc"))
If you use the simple form of home.ChildItems.OrderBy("catCount") it will use a simpler/faster implementation
2011-02-17 19:07:22 -13:00
agrath@gmail.com
d9f420d45a Added .OrderBy method to DynamicNodeList
Only supports single pass, ascending currently, so no ThenBy implementation or Descending variants
The original query parser supports OrderBy("catCount, name desc") by nesting Expression.Call
Current implementation for DynamicNodeList supports OrderBy("catCount") only
2011-02-17 14:52:05 -13:00
agrath@gmail.com
300c975284 Moved caching of property data type from DynamicNode to a static method in ContentType
Simplified SQL query used for property type lookup
Added cache clearing for propertyType cache when ContentType.ClearCache is called
Improves performance of new razor property lookups - most improvement on large sets
2011-02-17 14:23:20 -13:00
Elijah
e277e4cadb Dynamic keyword is back for Parameters/Dictionary 2011-02-16 22:53:11 -10:00
Elijah
35cfee3f85 inline @inherts not required, fix 2011-02-16 21:42:45 -10:00
Elijah
3a76e9caae Supports default @inherits directive umbraco.MacroEngines.DynamicNodeContext 2011-02-16 21:29:35 -10:00
Elijah
2def8a520a .razor ext added as a Build Provider 2011-02-16 18:42:14 -10:00
Elijah
68ce71685d Updated config added factoryType 2011-02-16 01:49:31 -11:00
Elijah
ce83c8a1b9 Added SupportedUIExtensions to IMacroEngine 2011-02-16 01:48:40 -11:00
Elijah
3d5ed109af .razor proxy .cshtml file ext- #unbreakingcode 2011-02-16 01:32:04 -11:00
Elijah
8a1c8475b8 Update Interfaces BaseContext 2011-02-13 22:54:51 -11:00
Elijah
7f57fde279 Seperated Parameter & Culture Dict
Fixed inline auto inherit directive
2011-02-13 22:54:14 -11:00
agrath@gmail.com
b20d1bfd4c Added support for string Comparisons e.g. @Model.Children.Where("menuType = \"Top Menu\") and support for And/Or @Model.Children.Where("menuType == \"Top Menu\ || menuType == \"Bottom Menu\"") 2011-02-07 17:28:59 -13:00
agrath@gmail.com
070a03e827 Fixed DynamicNodeList extension method invocation finding the wrong method when the method being checked was defined on a class that implemented no interfaces
Caused user-loaded extension methods on DynamicNodeList to be pretty unreliable (would work sometimes, sometimes wouldn't find method - particularly after an iisreset)
2011-02-07 15:29:44 -13:00
agrath@gmail.com
313d67ed94 Added reference to datalayer (to get SqlHelper) from DynamicNode 2011-02-07 14:11:03 -13:00
agrath@gmail.com
e7ebcb29bc Broke string properties with new typecasting stuff by returning false instead of true if the typecasting failed (e.g. it was actually a string)
Changed this to a return true

Replaced some API calls via Document & Property (database level, not nodefactory) with a single SQL scalar where I was getting the control type (to determine if "0"/"1" should actually be "true"/"false")
Should perform a lot better now
2011-02-07 14:10:38 -13:00
agrath@gmail.com
e5c3c8869a Upgraded DynamicNode to do some type inferrence from the IProperty type .Value which is a string
Already had support for YesNoType (where the string value is 1 or 0) being converted/parsed to boolean
Added some TryParse calls to int and decimal respecitvely so that if a IProperty.Value is a valid decimal or int it will be returned from DynamicNode.TryGetMember as such
This enables the .Where operator to have the correct type after property retrieval so that some numerical comparisons will work

Added support for >, >=, <, <= and %[mod] to .Where
@Model.Children.Where("catCount > 1")
@Model.Children.Where("catCount % 2 == 0")
2011-02-07 13:12:34 -13:00