-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support of @import directives in sass #378
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using LibSassHost; | ||
|
||
namespace VirtoCommerce.LiquidThemeEngine | ||
{ | ||
public interface ISassFileManager: IFileManager | ||
{ | ||
string CurrentDirectory { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.IO; | ||
using LibSassHost; | ||
using VirtoCommerce.Storefront.Model; | ||
using VirtoCommerce.Storefront.Model.Common; | ||
using VirtoCommerce.Storefront.Model.StaticContent; | ||
|
||
namespace VirtoCommerce.LiquidThemeEngine | ||
{ | ||
public class SassFileManager: ISassFileManager | ||
{ | ||
private readonly IContentBlobProvider _contentBlobProvider; | ||
|
||
public bool SupportsConversionToAbsolutePath { get; } = false; | ||
|
||
public string CurrentDirectory { get; set; } | ||
|
||
public SassFileManager(IContentBlobProvider contentBlobProvider) | ||
{ | ||
_contentBlobProvider = contentBlobProvider; | ||
} | ||
|
||
public string GetCurrentDirectory() => CurrentDirectory; | ||
|
||
public bool FileExists(string path) | ||
asvishnyakov marked this conversation as resolved.
Show resolved
Hide resolved
asvishnyakov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
// Workaround for directories | ||
if (string.IsNullOrEmpty(Path.GetExtension(path))) | ||
{ | ||
return false; | ||
} | ||
return _contentBlobProvider.PathExists(path); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cosmetic note: we have a stylecop rule which required add empty space after closed brackets. we going to use stylecop in all backend projects so it can be simply corrected now |
||
} | ||
|
||
public bool IsAbsolutePath(string path) | ||
{ | ||
return Path.GetDirectoryName(path).StartsWith(CurrentDirectory); | ||
} | ||
|
||
public string ToAbsolutePath(string path) | ||
{ | ||
throw new NotImplementedException(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it a part of interface implementation then it must be implemented anyway. Otherwise, this is a violation of SOLID principles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is 3rd party interface and we can't change it. |
||
} | ||
|
||
public string ReadFile(string path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you read the file why you return the string? |
||
{ | ||
return _contentBlobProvider.OpenRead(path).ReadToString(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to add some comments to this abstraction with a description of the purpose.