Пример #1
0
        protected override Parsing createParsing(IFubuApplicationFiles files)
        {
            if (RelativePath().IsEmpty())
            {
                return(new Parsing
                {
                    Master = null,
                    Namespaces = new String[0],
                    ViewModelType = null
                });
            }

            try
            {
                var chunk = Retry.Times(_settings.RetryViewLoadingCount, () => Loader.Load(this, files)).ToList();

                return(new Parsing
                {
                    Master = chunk.Master(),
                    ViewModelType = chunk.ViewModel(),
                    Namespaces = chunk.Namespaces()
                });
            }
            catch (Exception e)
            {
                throw new Exception("Failed while trying to parse template file " + FilePath, e);
            }
        }
Пример #2
0
        public IEnumerable<Chunk> Load(ISparkTemplate template, IFubuApplicationFiles files)
        {
            if (template.RelativePath().IsEmpty())
            {
                throw new ArgumentOutOfRangeException("Invalid template path for file " + template.FilePath);
            }

            try
            {
                var viewLoader = _loaders[files.RootPath];
                var chunks = viewLoader.Load(template.RelativePath());
                if (chunks == null)
                {
                    throw new Exception("Unable to parse file '{0}'".ToFormat(template.RelativePath()));
                }

                return chunks.ToList();
            }
            catch (Exception e)
            {
                if (e.Message.StartsWith("Unable to parse file")) throw;

                throw new Exception("Unable to parse file '{0}'".ToFormat(template.RelativePath()), e);
            }
        }
Пример #3
0
        public IEnumerable <Chunk> Load(ISparkTemplate template, IFubuApplicationFiles files)
        {
            if (template.RelativePath().IsEmpty())
            {
                throw new ArgumentOutOfRangeException("Invalid template path for file " + template.FilePath);
            }

            try
            {
                var viewLoader = _loaders[files.RootPath];
                var chunks     = viewLoader.Load(template.RelativePath());
                if (chunks == null)
                {
                    throw new Exception("Unable to parse file '{0}'".ToFormat(template.RelativePath()));
                }

                return(chunks.ToList());
            }
            catch (Exception e)
            {
                if (e.Message.StartsWith("Unable to parse file"))
                {
                    throw;
                }

                throw new Exception("Unable to parse file '{0}'".ToFormat(template.RelativePath()), e);
            }
        }
Пример #4
0
        public Template(IFubuFile file, IFubuApplicationFiles files)
        {
            _file = file;

            _parsing = new Lazy<Parsing>(() => createParsing(files));

            _relativeDirectoryPath = _file.RelativePath.ParentDirectory().Replace('\\', '/');
        }
Пример #5
0
 public FubuDiagnosticsEndpoint(JavascriptRouteWriter routeWriter, DiagnosticJavascriptRoutes routes, IAssetFinder assets, IHttpRequest request, IFubuApplicationFiles files)
 {
     _routeWriter = routeWriter;
     _routes = routes;
     _assets = assets;
     _request = request;
     _files = files;
 }
 // TODO -- if anyone starts to care, we'll make the location be variable
 public FlatFileMembershipRepository(IFubuApplicationFiles files)
 {
     _passwordConfigFile = files.GetApplicationPath().AppendPath("fubu.auth.config");
     _users = new Lazy<IList<UserInfo>>(() =>
     {
         return ReadFromFile(_passwordConfigFile);
     });
 }
Пример #7
0
 public FubuDiagnosticsEndpoint(JavascriptRouteWriter routeWriter, DiagnosticJavascriptRoutes routes, IAssetFinder assets, IHttpRequest request, IFubuApplicationFiles files)
 {
     _routeWriter = routeWriter;
     _routes      = routes;
     _assets      = assets;
     _request     = request;
     _files       = files;
 }
 // TODO -- if anyone starts to care, we'll make the location be variable
 public FlatFileMembershipRepository(IFubuApplicationFiles files)
 {
     _passwordConfigFile = files.GetApplicationPath().AppendPath("fubu.auth.config");
     _users = new Lazy <IList <UserInfo> >(() =>
     {
         return(ReadFromFile(_passwordConfigFile));
     });
 }
Пример #9
0
        public AssetFinderCache(AssetSettings settings, IFubuApplicationFiles files)
        {
            _settings           = settings;
            _files              = files;
            _searches.OnMissing = findAsset;

            _graph = new Lazy <AssetGraph>(findAll);
        }
Пример #10
0
        public AssetFinderCache(AssetSettings settings, IFubuApplicationFiles files)
        {
            _settings = settings;
            _files = files;
            _searches.OnMissing = findAsset;

            _graph = new Lazy<AssetGraph>(findAll);
        }
Пример #11
0
 public HomeEndpoint(IClientConnector connector, StorytellerContext context, FubuHtmlDocument document, IPersistenceController persistence, IAssetTagBuilder tags, IFubuApplicationFiles files)
 {
     _connector = connector;
     _context = context;
     _document = document;
     _persistence = persistence;
     _tags = tags;
     _files = files;
 }
Пример #12
0
 public HomeEndpoint(IClientConnector connector, StorytellerContext context, FubuHtmlDocument document,
                     IPersistenceController persistence, IAssetTagBuilder tags, IFubuApplicationFiles files)
 {
     _connector   = connector;
     _context     = context;
     _document    = document;
     _persistence = persistence;
     _tags        = tags;
     _files       = files;
 }
Пример #13
0
 public AntiForgeryValidator(IAntiForgeryTokenProvider tokenProvider, IAntiForgerySerializer serializer,
                             ICookies cookies, IFubuApplicationFiles fubuApplicationFiles,
                             IRequestData requestData)
 {
     _tokenProvider        = tokenProvider;
     _serializer           = serializer;
     _cookies              = cookies;
     _fubuApplicationFiles = fubuApplicationFiles;
     _requestData          = requestData;
 }
Пример #14
0
        public SparkTemplate(IFubuApplicationFiles files, IFubuFile file, ISparkViewEngine engine, SparkEngineSettings settings)
            : base(file, files)
        {
            _settings = settings;
            _full     = new Lazy <SparkViewDescriptor>(() => createSparkDescriptor(true));
            _partial  = new Lazy <SparkViewDescriptor>(() => createSparkDescriptor(false));

            _viewEntry        = new WatchedSparkEntry(() => engine.CreateEntry(_full.Value));
            _partialViewEntry = new WatchedSparkEntry(() => engine.CreateEntry(_partial.Value));
        }
Пример #15
0
        public Template(IFubuFile file, IFubuApplicationFiles files)
        {
            _file = file;


            _parsing = new Lazy <Parsing>(() => createParsing(files));


            _relativeDirectoryPath = _file.RelativePath.ParentDirectory().Replace('\\', '/');
        }
Пример #16
0
 public AntiForgeryValidator(IAntiForgeryTokenProvider tokenProvider, IAntiForgerySerializer serializer,
     ICookies cookies, IFubuApplicationFiles fubuApplicationFiles,
     IRequestData requestData)
 {
     _tokenProvider = tokenProvider;
     _serializer = serializer;
     _cookies = cookies;
     _fubuApplicationFiles = fubuApplicationFiles;
     _requestData = requestData;
 }
Пример #17
0
        public static BehaviorGraph Build(FubuRegistry registry, IPerfTimer perfTimer,
            IEnumerable<Assembly> packageAssemblies, IActivationDiagnostics diagnostics, IFubuApplicationFiles files)
        {
            var featureLoader = new FeatureLoader();
            featureLoader.LookForFeatures();

            if (registry.Mode.InDevelopment())
            {
                registry.AlterSettings<DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);
                registry.AlterSettings<AssetSettings>(_ => _.SetupForDevelopment());
            }

            
            

            var graph = new BehaviorGraph
            {
                ApplicationAssembly = registry.ApplicationAssembly,
                PackageAssemblies = packageAssemblies
            };

            var accessorRules = AccessorRulesCompiler.Compile(graph, perfTimer);



            var config = registry.Config;

            perfTimer.Record("Applying Settings", () => applySettings(config, graph, diagnostics, files));

            perfTimer.Record("Enable built in polling jobs", () => enableBuiltInJobs(graph));
            perfTimer.Record("Applying Feature Settings", () => featureLoader.ApplyAll(graph.Settings, registry).Wait());

            perfTimer.Record("Local Application BehaviorGraph", () => config.BuildLocal(graph, perfTimer));

            perfTimer.Record("Explicit Configuration", () => config.Global.Explicits.RunActions(graph));
            perfTimer.Record("Global Policies", () => config.Global.Policies.RunActions(graph));

            perfTimer.Record("Inserting Conneg and Authorization Nodes",
                () => insertConnegAndAuthorizationNodes(graph));

            perfTimer.Record("Applying Global Reorderings", () => config.ApplyGlobalReorderings(graph));


            if (registry.Mode.InDevelopment() || graph.Settings.Get<DiagnosticsSettings>().TraceLevel != TraceLevel.None)
            {
                perfTimer.Record("Applying Tracing", () => ApplyTracing.Configure(graph));
            }

            accessorRules.Wait();

            new AutoImportModelNamespacesConvention().Configure(graph);

            return graph;
        }
Пример #18
0
        // TODO -- some commonality here between RazorTemplate and SparkTemplate!
        protected override Parsing createParsing(IFubuApplicationFiles files)
        {
            var chunks = ViewParser.Parse(FilePath).ToList();

            return(new Parsing
            {
                Master = chunks.Master(),
                ViewModelType = chunks.ViewModel(),
                Namespaces = chunks.Namespaces()
            });
        }
Пример #19
0
        // TODO -- some commonality here between RazorTemplate and SparkTemplate!
        protected override Parsing createParsing(IFubuApplicationFiles files)
        {
            var chunks = ViewParser.Parse(FilePath).ToList();

            return new Parsing
            {
                Master = chunks.Master(),
                ViewModelType = chunks.ViewModel(),
                Namespaces = chunks.Namespaces()
            };
        }
Пример #20
0
 public AntiForgeryService(IOutputWriter outputWriter,
                           IAntiForgeryTokenProvider tokenProvider,
                           IAntiForgerySerializer serializer,
                           IFubuApplicationFiles fubuApplicationFiles,
                           ICookies cookies)
 {
     _outputWriter         = outputWriter;
     _tokenProvider        = tokenProvider;
     _serializer           = serializer;
     _fubuApplicationFiles = fubuApplicationFiles;
     _cookies = cookies;
 }
Пример #21
0
 public AntiForgeryService(IOutputWriter outputWriter,
                           IAntiForgeryTokenProvider tokenProvider,
                           IAntiForgerySerializer serializer,
                           IFubuApplicationFiles fubuApplicationFiles,
                           ICookies cookies)
 {
     _outputWriter = outputWriter;
     _tokenProvider = tokenProvider;
     _serializer = serializer;
     _fubuApplicationFiles = fubuApplicationFiles;
     _cookies = cookies;
 }
Пример #22
0
        public CommandDocumentationSource(IFubuApplicationFiles files, IFileSystem fileSystem)
        {
            _applications = new Cache <string, CommandLineApplicationReport>(name => {
                var filename = "{0}.cli.xml".ToFormat(name);
                var file     = files.Find(filename);

                if (file == null)
                {
                    throw new ArgumentOutOfRangeException("name", name, "Unable to find a *.cli.xml file for the requested application name");
                }

                return(fileSystem.LoadFromFile <CommandLineApplicationReport>(file.Path));
            });
        }
Пример #23
0
        public ViewCollection(ViewFacility <T> facility, IFubuApplicationFiles files, Func <IFubuFile, T> builder, ViewEngineSettings settings, FileSet match)
        {
            if (match == null)
            {
                throw new ArgumentNullException("match");
            }
            _facility = facility;
            _files    = files;
            _builder  = builder;
            _settings = settings;
            _match    = match;

            _top = buildFolder(_files.RootPath);
        }
Пример #24
0
        private static void applySettings(ConfigGraph config, BehaviorGraph graph, IActivationDiagnostics diagnostics, IFubuApplicationFiles files)
        {
            // Might come back to this.
            config.Imports.Each(x => x.InitializeSettings(graph));
            config.Settings.Each(x => x.Alter(graph.Settings));

            var viewSettings = graph.Settings.Get<ViewEngineSettings>();

            var views = viewSettings.BuildViewBag(graph, diagnostics, files);

            var conneg = graph.Settings.Get<ConnegSettings>();

            conneg.ReadConnegGraph(graph);
            conneg.StoreViews(views);
        }
Пример #25
0
        public FileWatcherManifest CreateFileWatcherManifest(IFubuApplicationFiles files)
        {
            var manifest = new FileWatcherManifest(files.RootPath, AssemblyFinder.FindBinPath());

            if (Mode == SearchMode.PublicFolderOnly)
            {
                manifest.PublicAssetFolder = DeterminePublicFolder(files).Replace('\\', '/');
            }

            manifest.AssetExtensions =
                assetMimeTypes().SelectMany(x => x.Extensions).Union(AllowableExtensions).ToArray();

            manifest.ContentMatches = ContentMatches.ToArray();

            return(manifest);
        }
Пример #26
0
        /// <summary>
        /// Used internally to determine the public folder if the mode is set to
        /// PublicFolderOnly
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        public string DeterminePublicFolder(IFubuApplicationFiles files)
        {
            var candidate = files.RootPath.AppendPath(PublicFolder);

            if (Version.IsNotEmpty())
            {
                var versioned = candidate.AppendPath(Version);
                if (Directory.Exists(versioned))
                {
                    candidate = versioned;
                }
            }

            if (!Directory.Exists(candidate))
            {
                Console.WriteLine("The designated public asset folder '{0}' cannot be found".ToFormat(candidate));
            }

            return(candidate);
        }
 public AppDomainFubuDiagnostics(AppReloaded reloaded, IFubuApplicationFiles files)
 {
     _reloaded = reloaded;
     _files = files;
 }
 public SharingConfigActivator(SharingGraph sharingGraph, SharingLogsCache logs, IFubuApplicationFiles files)
 {
     _sharingGraph = sharingGraph;
     _diagnostics = new SharingRegistrationDiagnostics(_sharingGraph, logs);
     _files = files;
 }
 public void Fill(ViewEngineSettings settings, BehaviorGraph graph, IPerfTimer timer, IFubuApplicationFiles files)
 {
     throw new NotImplementedException();
 }
 public DefaultFeatureValidator(IFubuApplicationFiles fubuApplicationFiles)
 {
     _fubuApplicationFiles = fubuApplicationFiles;
 }
Пример #31
0
 public void Fill(ViewEngineSettings settings, BehaviorGraph graph, IPerfTimer timer, IFubuApplicationFiles files)
 {
     _views = tokens().Where(x => !graph.Settings.Get<ViewEngineSettings>().IsExcluded(x)).ToList();
 }
Пример #32
0
 public RazorTemplate(IFubuApplicationFiles files, IFubuFile file, ITemplateFactory factory)
     : base(file, files)
 {
     _factory = factory;
 }
Пример #33
0
 public StaticFileMiddleware(Func<IDictionary<string, object>, Task> inner, IFubuApplicationFiles files, AssetSettings settings)
     : base(inner)
 {
     _files = files;
     _settings = settings;
 }
 public PackageAwareXmlLocalizationStorage(IFubuApplicationFiles files) : base(new []{files.RootPath})
 {
 }
Пример #35
0
        private static void applySettings(ConfigGraph config, BehaviorGraph graph, IActivationDiagnostics diagnostics, IFubuApplicationFiles files)
        {
            // Might come back to this.
            config.Imports.Each(x => x.InitializeSettings(graph));
            config.Settings.Each(x => x.Alter(graph.Settings));

            var viewSettings = graph.Settings.Get <ViewEngineSettings>();


            var views = viewSettings.BuildViewBag(graph, diagnostics, files);

            var conneg = graph.Settings.Get <ConnegSettings>();


            conneg.ReadConnegGraph(graph);
            conneg.StoreViews(views);
        }
Пример #36
0
 public DefaultTextLocalizer(IFubuApplicationFiles fubuApplicationFiles, IEnumerable <ILocalizationVisitor> visitors)
 {
     _fubuApplicationFiles = fubuApplicationFiles;
     _visitors             = visitors;
 }
 public SnippetBuilder(ISnippetCache cache, IFubuApplicationFiles files, IEnumerable<ISnippetScanner> scanners)
 {
     _cache = cache;
     _files = files;
     _scanners = scanners;
 }
Пример #38
0
        public override Func <IFubuFile, RazorTemplate> CreateBuilder(SettingsCollection settings, IFubuApplicationFiles files)
        {
            var razorSettings = settings.Get <RazorEngineSettings>();
            var namespaces    = settings.Get <CommonViewNamespaces>();

            var factory = new TemplateFactoryCache(namespaces, razorSettings, new TemplateCompiler(),
                                                   new RazorTemplateGenerator());

            return(file => new RazorTemplate(files, file, factory));
        }
Пример #39
0
        public FileWatcherManifest CreateFileWatcherManifest(IFubuApplicationFiles files)
        {
            var manifest = new FileWatcherManifest(files.RootPath, AssemblyFinder.FindBinPath());

            if (Mode == SearchMode.PublicFolderOnly)
            {
                manifest.PublicAssetFolder = DeterminePublicFolder(files).Replace('\\', '/');
            }

            manifest.AssetExtensions =
                assetMimeTypes().SelectMany(x => x.Extensions).Union(AllowableExtensions).ToArray();

            manifest.ContentMatches = ContentMatches.ToArray();

            return manifest;
        }
Пример #40
0
 public FileWriterEndpoint(IOutputWriter writer, IFubuApplicationFiles files)
 {
     _writer = writer;
     _files = files;
 }
Пример #41
0
 public RazorTemplate(IFubuApplicationFiles files, IFubuFile file, ITemplateFactory factory) : base(file, files)
 {
     _factory = factory;
 }
Пример #42
0
 public override Func <IFubuFile, SparkTemplate> CreateBuilder(SettingsCollection settings, IFubuApplicationFiles files)
 {
     return(file => new SparkTemplate(files, file, _engine, settings.Get <SparkEngineSettings>()));
 }
Пример #43
0
 public AppDomainFubuDiagnostics(AppReloaded reloaded, IFubuApplicationFiles files)
 {
     _reloaded = reloaded;
     _files    = files;
 }
Пример #44
0
        public override void Fill(ViewEngineSettings settings, BehaviorGraph graph, IPerfTimer timer, IFubuApplicationFiles files)
        {
            configureNamespaces(graph);

            base.Fill(settings, graph, timer, files);

            var bindingTemplates = files
                                   .FindFiles(FileSet.Shallow("Shared/bindings.xml"))
                                   .Select(x => new SparkTemplate(files, x, _engine, graph.Settings.Get <SparkEngineSettings>())).ToArray();

            _engine.ViewFolder          = new TemplateViewFolder(AllTemplates());
            _engine.DefaultPageBaseType = typeof(FubuSparkView).FullName;
            _engine.BindingProvider     = new FubuBindingProvider(bindingTemplates);
            _engine.PartialProvider     = new FubuPartialProvider(this);
        }
 public DefaultTextLocalizer(IFubuApplicationFiles fubuApplicationFiles, IEnumerable<ILocalizationVisitor> visitors)
 {
     _fubuApplicationFiles = fubuApplicationFiles;
     _visitors = visitors;
 }
Пример #46
0
        /// <summary>
        /// Used internally to determine the public folder if the mode is set to
        /// PublicFolderOnly
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        public string DeterminePublicFolder(IFubuApplicationFiles files)
        {
            var candidate = files.RootPath.AppendPath(PublicFolder);

            if (Version.IsNotEmpty())
            {
                var versioned = candidate.AppendPath(Version);
                if (Directory.Exists(versioned))
                {
                    candidate = versioned;
                }
            }

            if (!Directory.Exists(candidate))
            {
                Console.WriteLine("The designated public asset folder '{0}' cannot be found".ToFormat(candidate));
            }

            return candidate;
        }
 public DefaultFileUploader(IFubuApplicationFiles fubuApplicationFiles)
 {
     _fubuApplicationFiles = fubuApplicationFiles;
 }
Пример #48
0
 public BottleAwareXmlLocalizationStorage(IFubuApplicationFiles files) : base(files.AllFolders.Select(x => x.Path))
 {
 }
Пример #49
0
 public FileWriterEndpoint(IOutputWriter writer, IFubuApplicationFiles files)
 {
     _writer = writer;
     _files  = files;
 }
Пример #50
0
 public StaticFileMiddleware(Func <IDictionary <string, object>, Task> inner, IFubuApplicationFiles files, AssetSettings settings) : base(inner)
 {
     _files    = files;
     _settings = settings;
 }
 public DefaultFeatureValidator(IFubuApplicationFiles fubuApplicationFiles)
 {
     _fubuApplicationFiles = fubuApplicationFiles;
 }
Пример #52
0
 public void Fill(ViewEngineSettings settings, BehaviorGraph graph, IPerfTimer timer, IFubuApplicationFiles files)
 {
     throw new NotImplementedException();
 }
Пример #53
0
        public static BehaviorGraph Build(FubuRegistry registry, IPerfTimer perfTimer,
                                          IEnumerable <Assembly> packageAssemblies, IActivationDiagnostics diagnostics, IFubuApplicationFiles files)
        {
            var featureLoader = new FeatureLoader();

            featureLoader.LookForFeatures();

            if (registry.Mode.InDevelopment())
            {
                registry.AlterSettings <DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);
                registry.AlterSettings <AssetSettings>(_ => _.SetupForDevelopment());
            }



            var graph = new BehaviorGraph
            {
                ApplicationAssembly = registry.ApplicationAssembly,
                PackageAssemblies   = packageAssemblies
            };

            var accessorRules         = AccessorRulesCompiler.Compile(graph, perfTimer);
            var validationCompilation = ValidationCompiler.Compile(graph, perfTimer, registry);



            var config = registry.Config;

            perfTimer.Record("Applying Settings", () => applySettings(config, graph, diagnostics, files));

            perfTimer.Record("Enable built in polling jobs", () => enableBuiltInJobs(graph));
            perfTimer.Record("Applying Feature Settings", () => featureLoader.ApplyAll(graph.Settings, registry).Wait(30.Seconds()).AssertFinished());


            config.Add(new ActionlessViewChainSource());
            perfTimer.Record("Local Application BehaviorGraph", () => config.BuildLocal(graph, perfTimer));

            perfTimer.Record("Explicit Configuration", () => config.Global.Explicits.RunActions(graph));
            perfTimer.Record("Global Policies", () => config.Global.Policies.RunActions(graph));

            perfTimer.Record("Inserting Conneg and Authorization Nodes",
                             () => insertConnegAndAuthorizationNodes(graph));

            perfTimer.Record("Applying Global Reorderings", () => config.ApplyGlobalReorderings(graph));


            if (registry.Mode.InDevelopment() || graph.Settings.Get <DiagnosticsSettings>().TraceLevel != TraceLevel.None)
            {
                perfTimer.Record("Applying Tracing", () => ApplyTracing.Configure(graph));
            }


            Task.WaitAll(new Task[] { accessorRules, validationCompilation }, 30.Seconds()).AssertFinished();

            new AutoImportModelNamespacesConvention().Configure(graph);

            return(graph);
        }
Пример #54
0
 public SnippetEndpoints(ISnippetCache cache, IUrlRegistry urls, IFubuApplicationFiles files)
 {
     _cache = cache;
     _urls  = urls;
     _files = files;
 }
Пример #55
0
 public PackageSettingsSource(IFubuApplicationFiles files)
 {
     _files = files;
 }
 public PackageAwareXmlLocalizationStorage(IFubuApplicationFiles files) : base(new [] { files.RootPath })
 {
 }
Пример #57
0
 public void RegisterTemplates(IFubuApplicationFiles fubuFiles, SparkEngineSettings settings)
 {
     fubuFiles.FindFiles(settings.Search).Each(file =>
         _templateRegistry.Register(new Template(file.Path, file.ProvenancePath, file.Provenance)));
 }
 public FileReaderEndpoint(IFubuApplicationFiles files)
 {
     _files = files;
 }
Пример #59
0
 public void RegisterTemplates(IFubuApplicationFiles fubuFiles, RazorEngineSettings settings)
 {
     fubuFiles.FindFiles(settings.Search).Each(file =>
                                               _templateRegistry.Register(new Template(file.Path, file.ProvenancePath, file.Provenance)));
 }
Пример #60
0
 protected abstract Parsing createParsing(IFubuApplicationFiles files);