backbone app is now fully served from nancy including css,js,htmlpull/3113/head
@ -0,0 +1,56 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using dotless.Core;
|
||||
using dotless.Core.Importers;
|
||||
using dotless.Core.Input;
|
||||
using dotless.Core.Parser;
|
||||
|
||||
namespace NzbDrone.Api.FrontendModule
|
||||
{
|
||||
public interface ICompileLess
|
||||
{
|
||||
string Compile(string filePath);
|
||||
}
|
||||
|
||||
public class LessCompiler : ICompileLess
|
||||
{
|
||||
|
||||
public string Compile(string filePath)
|
||||
{
|
||||
var parser = new Parser()
|
||||
{
|
||||
Importer = new Importer(new LessFileReader(filePath))
|
||||
};
|
||||
|
||||
var lessEngine = new LessEngine(parser, null, false, true);
|
||||
var lessContent = File.ReadAllText(filePath);
|
||||
return lessEngine.TransformToCss(lessContent, filePath);
|
||||
}
|
||||
|
||||
|
||||
class LessFileReader : IFileReader
|
||||
{
|
||||
private readonly string _rootFolders;
|
||||
|
||||
public LessFileReader(string masterFile)
|
||||
{
|
||||
_rootFolders = new FileInfo(masterFile).Directory.FullName;
|
||||
}
|
||||
|
||||
public byte[] GetBinaryFileContents(string fileName)
|
||||
{
|
||||
return File.ReadAllBytes(Path.Combine(_rootFolders, fileName));
|
||||
}
|
||||
|
||||
public string GetFileContents(string fileName)
|
||||
{
|
||||
return File.ReadAllText(Path.Combine(_rootFolders, fileName));
|
||||
}
|
||||
|
||||
public bool DoesFileExist(string fileName)
|
||||
{
|
||||
return File.Exists(Path.Combine(_rootFolders, fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 152 B |
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 172 B |
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 816 B |
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 665 B After Width: | Height: | Size: 665 B |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 491 B |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 752 B After Width: | Height: | Size: 752 B |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 554 B After Width: | Height: | Size: 554 B |
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 411 B |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 541 B |