Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Little refactoring of asset files resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarincev committed Jul 29, 2016
1 parent a2465db commit e5e8a1e
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions VirtoCommerce.LiquidThemeEngine/ShopifyLiquidThemeEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,10 @@ public IEnumerable<string> DiscoveryPaths
public Stream GetAssetStream(string filePath, bool searchInGlobalThemeOnly = false)
{
Stream retVal = null;
//file.*.* => file.*.* || file.* || file.*.liquid
//file.* => file.* || file.*.liquid
var searchPatterns = new List<string>(new[] { filePath });
var parts = filePath.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

if (!parts.IsNullOrEmpty())
{
if (parts.Count() > 2)
{
//file.*
searchPatterns.Add(parts[0] + "." + parts[1]);
}
//file.*.liquid
searchPatterns.Add(string.Format(_liquidTemplateFormat, parts[0] + "." + parts[1]));
}

var filePathWithoutExtension = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath)).Replace("\\", "/");
//file.ext => file.ext || file || file.liquid || file.ext.liquid
var searchPatterns = new[] { filePath, filePathWithoutExtension, string.Format(_liquidTemplateFormat, filePathWithoutExtension), string.Format(_liquidTemplateFormat, filePath) };

string currentThemeFilePath = null;
//search in global theme first
var globalThemeFilePath = searchPatterns.SelectMany(x => _globalThemeBlobProvider.Search("assets", x, true)).FirstOrDefault();
Expand Down

0 comments on commit e5e8a1e

Please sign in to comment.