public static IServiceCollection AddSpeedWagon(this IServiceCollection services, string path, bool cached, IFileProvider contentFileProvider) { IContentService contentService; if (cached) { services.AddHostedService <CacheRefreshingHostedService>(); contentService = new CachedRuntimeContentService( path, null, contentFileProvider ); } else { contentService = new CacheLessRuntimeContentService( path, null, contentFileProvider ); } ISearchService searchService = new LuceneSearchService(contentService, Path.Combine(path, "search")); services.AddSingleton <ISpeedWagonWebContext>( s => new SpeedWagonWebContext( path, contentService, searchService)); return(services); }
public async Task <string> UploadFile(string parent, IFormFile file, string user) { if (parent.StartsWith("/content")) { parent = parent.Substring("/content".Length); } string urlName = RationalisePath(parent); CacheLessRuntimeContentService svc = ((CacheLessRuntimeContentService)this._cachelessContentService); string name = svc.PathMapper.RemoveInvalidFileNameChars(file.FileName); string path = svc.PathMapper.PathForUrl(urlName, true); path = path.Replace(@"\content.json", @"\" + name); using (var stream = await this._fileProvider.GetStream(path)) { await file.CopyToAsync(stream); } return(parent + "/" + name); }
public static IServiceCollection AddSpeedWagonCms(this IServiceCollection services, string path, string uploadsPath, IFileProvider contentFileProvider, IFileProvider uploadFileProvider) { IContentService contentService = new CacheLessRuntimeContentService(path, null, contentFileProvider); IEditorService editorService = new EditorService(contentService, SPEEDWAGON_HOST); IContentTypeService contentTypeService = new ContentTypeService(contentService, SPEEDWAGON_HOST); IWebContentService webContentService = new WebContentService(contentService, SPEEDWAGON_HOST); IContentService uploadContentService = new CacheLessRuntimeContentService(uploadsPath, null, uploadFileProvider); IFileUploadService fileUploadService = new FileUploadService(uploadContentService, string.Empty, uploadFileProvider); ISearchService searchService = new LuceneSearchService(contentService, Path.Combine(path, "search")); services.AddSingleton <ISpeedWagonAdminContext>(s => new SpeedWagonAdminContext( path, contentService, contentTypeService, editorService, webContentService, fileUploadService, searchService) ); return(services); }