Skip to content

Commit

Permalink
Fixing <Module> step queries support
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Jan 3, 2017
1 parent 7fb8cb0 commit 39fefe0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
37 changes: 29 additions & 8 deletions Controllers/FeedServiceController.cs
Expand Up @@ -96,11 +96,11 @@ IWorkContextAccessor workContextAccessor
} }


private string GetExtensionType(string filter) { private string GetExtensionType(string filter) {
if (filter.Contains("PackageType eq 'Module'")) { if (filter.IndexOf("PackageType eq 'Module'", StringComparison.OrdinalIgnoreCase) != -1) {
return "Module"; return "Module";
} }


if (filter.Contains("PackageType eq 'Theme'")) { if (filter.IndexOf("PackageType eq 'Theme'", StringComparison.OrdinalIgnoreCase) != -1) {
return "Theme"; return "Theme";
} }


Expand All @@ -110,19 +110,36 @@ IWorkContextAccessor workContextAccessor
private string GetPackageId(string filter) { private string GetPackageId(string filter) {


// tolower(Id) eq 'orchard.module.contrib.googleanalytics' // tolower(Id) eq 'orchard.module.contrib.googleanalytics'
var index = filter.IndexOf("tolower(Id) eq "); var index = filter.IndexOf("tolower(Id) eq ", StringComparison.OrdinalIgnoreCase);
if (index != -1) { if (index != -1) {
return filter.Substring(index + 15).Replace("'", ""); return filter.Substring(index + 15).Replace("'", "");
} }


index = filter.IndexOf("Id eq ", StringComparison.OrdinalIgnoreCase);
if (index != -1) {
return filter.Substring(index + 6).Replace("'", "");
}

return null;
}

private string GetVersion(string filter)
{

// Version eq '1.2'
var index = filter.IndexOf("Version eq ", StringComparison.OrdinalIgnoreCase);
if (index != -1) {
return filter.Substring(index + 1).Replace("'", "");
}

return null; return null;
} }


private string GetSearchTerms(string filter) { private string GetSearchTerms(string filter) {
string q = ""; string q = "";
int end; int end;


var index = filter.IndexOf("substringof('"); var index = filter.IndexOf("substringof('", StringComparison.OrdinalIgnoreCase);
if (index != -1) { if (index != -1) {
end = filter.IndexOf("'", index + 13); end = filter.IndexOf("'", index + 13);


Expand All @@ -145,6 +162,7 @@ IWorkContextAccessor workContextAccessor
var q = GetSearchTerms(filter); var q = GetSearchTerms(filter);
var type = GetExtensionType(filter); var type = GetExtensionType(filter);
var packageId = GetPackageId(filter); var packageId = GetPackageId(filter);
var version = GetVersion(filter);


if (!String.IsNullOrWhiteSpace(q)) { if (!String.IsNullOrWhiteSpace(q)) {
searchBuilder.Parse( searchBuilder.Parse(
Expand All @@ -154,15 +172,18 @@ IWorkContextAccessor workContextAccessor
); );
} }


if (!String.IsNullOrWhiteSpace(type)) {
searchBuilder.WithField("package-extension-type", type.ToLowerInvariant()).NotAnalyzed().ExactMatch();
}

if (!String.IsNullOrEmpty(packageId)) { if (!String.IsNullOrEmpty(packageId)) {

searchBuilder.WithField("package-id", packageId).ExactMatch(); searchBuilder.WithField("package-id", packageId).ExactMatch();
searchBuilder.Slice(0, 1); searchBuilder.Slice(0, 1);
} }


if (!String.IsNullOrWhiteSpace(type)) {
searchBuilder.WithField("package-extension-type", type.ToLowerInvariant()).NotAnalyzed().AsFilter().ExactMatch();
}


// Only apply custom order if there is no search filter. Otherwise some oddly related packages // Only apply custom order if there is no search filter. Otherwise some oddly related packages
// might appear at the top. // might appear at the top.
if (String.IsNullOrWhiteSpace(q) && !String.IsNullOrWhiteSpace(orderby)) { if (String.IsNullOrWhiteSpace(q) && !String.IsNullOrWhiteSpace(orderby)) {
Expand Down
30 changes: 15 additions & 15 deletions Orchard.Gallery.csproj
Expand Up @@ -13,7 +13,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.Gallery</RootNamespace> <RootNamespace>Orchard.Gallery</RootNamespace>
<AssemblyName>Orchard.Gallery</AssemblyName> <AssemblyName>Orchard.Gallery</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews> <MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>false</UseIISExpress> <UseIISExpress>false</UseIISExpress>
<FileUpgradeFlags> <FileUpgradeFlags>
Expand Down Expand Up @@ -128,20 +128,6 @@
<ItemGroup> <ItemGroup>
<Content Include="Module.txt" /> <Content Include="Module.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839c-39fc-4ceb-a5af-89ca7e87119f}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Tags\Orchard.Tags.csproj">
<Project>{5d0f00f0-26c9-4785-ad61-b85710c60eb0}</Project>
<Name>Orchard.Tags</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Recipes\Gallery.recipe.xml"> <Content Include="Recipes\Gallery.recipe.xml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
Expand Down Expand Up @@ -184,6 +170,20 @@
<ItemGroup> <ItemGroup>
<Content Include="Views\Parts.PackageVersion.Fields.SummaryAdmin.cshtml" /> <Content Include="Views\Parts.PackageVersion.Fields.SummaryAdmin.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2d1d92bb-4555-4cbe-8d0e-63563d6ce4c6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839c-39fc-4ceb-a5af-89ca7e87119f}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Tags\Orchard.Tags.csproj">
<Project>{5d0f00f0-26c9-4785-ad61-b85710c60eb0}</Project>
<Name>Orchard.Tags</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
2 changes: 1 addition & 1 deletion Web.config
Expand Up @@ -24,7 +24,7 @@
</pages> </pages>
</system.web.webPages.razor> </system.web.webPages.razor>
<system.web> <system.web>
<compilation targetFramework="4.5.1"> <compilation targetFramework="4.5.2">
<assemblies> <assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Expand Down

0 comments on commit 39fefe0

Please sign in to comment.