private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { FileBasedFunctionProvider<UserControlBasedFunction> provider; FileBasedFunction<UserControlBasedFunction> function; GetProviderAndFunction((FileBasedFunctionEntityToken)this.EntityToken, out provider, out function); string title = Path.GetFileName(function.VirtualPath); this.Bindings.Add("Title", title); string[] files = GetFiles(function); // Binding all the files for(int i=0; i<files.Length; i++) { var websiteFile = new WebsiteFile(files[i]); string bindingPrefix = GetBindingPrefix(i); this.Bindings.Add(bindingPrefix + "Content", websiteFile.ReadAllText()); this.Bindings.Add(bindingPrefix + "Name", websiteFile.FileName); this.Bindings.Add(bindingPrefix + "MimeType", websiteFile.MimeType); } }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { string filePath = GetFilePath(); WebsiteFile websiteFile = new WebsiteFile(filePath); this.Bindings.Add("FileContent", websiteFile.ReadAllText()); this.Bindings.Add("FileName", websiteFile.FileName); this.Bindings.Add("FileMimeType", websiteFile.MimeType); }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken; WebsiteFile websiteFile = new WebsiteFile(entityToken.Path); this.Bindings.Add("FileContent", websiteFile.ReadAllText()); this.Bindings.Add("FileName", websiteFile.FileName); this.Bindings.Add("FileMimeType", websiteFile.MimeType); }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken; WebsiteFile websiteFile = new WebsiteFile(entityToken.Path); this.Bindings.Add("FileContent", websiteFile.ReadAllText()); this.Bindings.Add("FileName", websiteFile.FileName); this.Bindings.Add("FileMimeType", websiteFile.MimeType); }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken; WebsiteFile websiteFile = new WebsiteFile(entityToken.Path); string content = this.GetBinding<string>("FileContent"); websiteFile.WriteAllText(content); SetSaveStatus(true); }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken; WebsiteFile websiteFile = new WebsiteFile(entityToken.Path); string content = this.GetBinding <string>("FileContent"); websiteFile.WriteAllText(content); SetSaveStatus(true); }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { string filePath = GetFilePath(); WebsiteFile websiteFile = new WebsiteFile(filePath); string content = this.GetBinding<string>("FileContent"); websiteFile.WriteAllText(content); SetSaveStatus(true); }
private static bool IsEditActionAllowed(WebsiteEntity websiteEntity) { if (websiteEntity is WebsiteFile) { WebsiteFile websiteFile = websiteEntity as WebsiteFile; return(MimeTypeInfo.IsTextFile(websiteFile.MimeType)); } if (websiteEntity is WebsiteFolder) { return(false); } throw new NotImplementedException(); }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { FileBasedFunctionProvider<RazorBasedFunction> provider; FileBasedFunction<RazorBasedFunction> function; GetProviderAndFunction((FileBasedFunctionEntityToken)this.EntityToken, out provider, out function); string title = Path.GetFileName(function.VirtualPath); this.Bindings.Add("Title", title); string file = GetFile(function); var websiteFile = new WebsiteFile(file); this.Bindings.Add("FileContent", websiteFile.ReadAllText()); this.Bindings.Add("FileName", websiteFile.FileName); this.Bindings.Add("FileMimeType", websiteFile.MimeType); }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { string virtualPath = GetFileVirtualPath(); string filePath = PathUtil.Resolve(virtualPath); WebsiteFile websiteFile = new WebsiteFile(filePath); string content = this.GetBinding<string>("FileContent"); string fixedSource = PageTemplateHelper.FixHtmlEscapeSequences(content); EntityToken newEntityToken; bool isValid = ValidateMarkup(virtualPath, fixedSource, out newEntityToken); if (isValid) { websiteFile.WriteAllText(fixedSource); PageTemplateProviderRegistry.FlushTemplates(); this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken); } if (isValid && newEntityToken != null) { SetSaveStatus(true, newEntityToken); SerializedEntityToken = EntityTokenSerializer.Serialize(newEntityToken); } else { SetSaveStatus(isValid); } if(isValid && fixedSource != content) { UpdateBinding("FileContent", fixedSource); RerenderView(); } }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { var functionEntityToken = (FileBasedFunctionEntityToken)this.EntityToken; FileBasedFunctionProvider<RazorBasedFunction> provider; FileBasedFunction<RazorBasedFunction> function; GetProviderAndFunction(functionEntityToken, out provider, out function); string file = GetFile(function); string fileContent = this.GetBinding<string>("FileContent"); string fixedFileContent = PageTemplateHelper.FixHtmlEscapeSequences(fileContent); if (!CompileAndValidate(file, fixedFileContent)) { SetSaveStatus(false); return; } var websiteFile = new WebsiteFile(file); websiteFile.WriteAllText(fixedFileContent); provider.ReloadFunctions(); this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken); SetSaveStatus(true); if(fixedFileContent != fileContent) { UpdateBinding("FileContent", fixedFileContent); RerenderView(); } }
private IEnumerable<Element> GetSharedCodeElements(SearchToken searchToken) { var result = new List<Element>(); foreach(SharedFile sharedFile in PageTemplateFacade.GetSharedFiles()) { string relativeFilePath = sharedFile.RelativeFilePath; string fullPath = relativeFilePath.StartsWith("~") ? PathUtil.Resolve(relativeFilePath) : relativeFilePath; var websiteFile = new WebsiteFile(fullPath); Element element = new Element(_context.CreateElementHandle(new SharedCodeFileEntityToken(relativeFilePath))) { VisualData = new ElementVisualizedData() { Label = websiteFile.FileName, ToolTip = websiteFile.FileName, HasChildren = false, Icon = FileElementProvider.WebsiteFileIcon(websiteFile.MimeType), OpenedIcon = FileElementProvider.WebsiteFileIcon(websiteFile.MimeType) } }; element.PropertyBag.Add("Uri", PathUtil.GetWebsitePath(websiteFile.FullPath)); element.PropertyBag.Add("ElementType", websiteFile.MimeType); // Adding "Edit" action for text-editable files if (sharedFile.DefaultEditAction && MimeTypeInfo.IsTextFile(websiteFile.MimeType)) { element.AddWorkflowAction( "Composite.Plugins.Elements.ElementProviders.PageTemplateElementProvider.EditSharedCodeFileWorkflow", new[] {PermissionType.Edit}, new ActionVisualizedData { Label = GetResourceString("EditSharedCodeFile.Label"), ToolTip = GetResourceString("EditSharedCodeFile.ToolTip"), Icon = CommonCommandIcons.Edit, Disabled = websiteFile.IsReadOnly, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = EditCodeFileActionGroup } }); } var customActions = sharedFile.GetActions(); foreach(var action in customActions) { element.AddAction(action); } result.Add(element); } return result; }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { var entityToken = this.EntityToken; string title; if (entityToken is PageTemplateEntityToken) { title = GetPageTemplate().Title; } else { var sharedFileEntityToken = (SharedCodeFileEntityToken)entityToken; title = Path.GetFileName(sharedFileEntityToken.VirtualPath); } this.Bindings.Add("TemplateTitle", title); string[] files = GetFiles(); // Binding all the files for(int i=0; i<files.Length; i++) { var websiteFile = new WebsiteFile(files[i]); string bindingPrefix = GetBindingPrefix(i); this.Bindings.Add(bindingPrefix + "Content", websiteFile.ReadAllText()); this.Bindings.Add(bindingPrefix + "Name", websiteFile.FileName); // Assigning "text/html" mimetype so CodeMirror will show it correctly // this.Bindings.Add(bindingPrefix + "MimeType", i == 0 ? HtmlMimeType : websiteFile.MimeType); this.Bindings.Add(bindingPrefix + "MimeType", websiteFile.MimeType); } }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { string[] files = GetFiles(); var fileContent = new List<string>(); for (int i = 0; i < files.Length; i++) { string bindingPrefix = GetBindingPrefix(i); fileContent.Add(this.GetBinding<string>(bindingPrefix + "Content")); } // Fixing html specific escape sequences in .master file string fixedMaster = PageTemplateHelper.FixHtmlEscapeSequences(fileContent[0]); bool viewNeedsUpdating = fileContent[0] != fixedMaster; fileContent[0] = fixedMaster; EntityToken newEntityToken; if (!CompileAndValidate(files, fileContent, out newEntityToken)) { SetSaveStatus(false); return; } for (int i = 0; i < files.Length; i++) { var websiteFile = new WebsiteFile(files[i]); websiteFile.WriteAllText(fileContent[i]); } PageTemplateProviderRegistry.FlushTemplates(); if (newEntityToken != null) { SetSaveStatus(true, newEntityToken); SerializedEntityToken = EntityTokenSerializer.Serialize(newEntityToken); } else { SetSaveStatus(true); } if(viewNeedsUpdating) { UpdateBinding(GetBindingPrefix(0) + "Content", fixedMaster); RerenderView(); } this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken); }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { var functionEntityToken = (FileBasedFunctionEntityToken)this.EntityToken; FileBasedFunctionProvider<UserControlBasedFunction> provider; FileBasedFunction<UserControlBasedFunction> function; GetProviderAndFunction(functionEntityToken, out provider, out function); string[] files = GetFiles(function); var fileContent = new List<string>(); for (int i = 0; i < files.Length; i++) { string bindingPrefix = GetBindingPrefix(i); fileContent.Add(this.GetBinding<string>(bindingPrefix + "Content")); } string fixedMarkup = PageTemplateHelper.FixHtmlEscapeSequences(fileContent[0]); bool viewShouldBeUpdated = fixedMarkup != fileContent[0]; fileContent[0] = fixedMarkup; if (!CompileAndValidate(files, fileContent)) { SetSaveStatus(false); return; } for (int i = 0; i < files.Length; i++) { var websiteFile = new WebsiteFile(files[i]); websiteFile.WriteAllText(fileContent[i]); } provider.ReloadFunctions(); this.CreateParentTreeRefresher().PostRefreshMesseges(this.EntityToken); SetSaveStatus(true); if(viewShouldBeUpdated) { UpdateBinding(GetBindingPrefix(0) + "Content", fileContent[0]); RerenderView(); } }
private IEnumerable <ElementAction> GetFileActions(WebsiteFile websiteFile) { IList <ElementAction> fileActions = new List <ElementAction>(); if (IsDeleteActionAllowed(websiteFile)) { fileActions.Add( new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.WebsiteFileElementProvider.DeleteWebsiteFileWorkflow"), _deleteWebsiteFilePermissionTypes))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DeleteWebsiteFileTitle"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DeleteWebsiteFileToolTip"), Icon = DeleteWebsiteFile, Disabled = websiteFile.IsReadOnly, ActivePositions = ElementActionActivePosition.NavigatorTree | ElementActionActivePosition.SelectorTree, ActionLocation = new ActionLocation { ActionType = ActionType.Delete, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryFileActionGroup } } }); } // Download fileActions.Add( new ElementAction(new ActionHandle(new DownloadFileActionToken())) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DownloadFileTitle"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DownloadFileToolTip"), Icon = DownloadWebsiteFile, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, // For sorting purpose IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryFileActionGroup } } }); if (IsEditActionAllowed(websiteFile)) { fileActions.Add( new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.WebsiteFileElementProvider.EditWebsiteFileTextContentWorkflow"), _editWebsiteFilePermissionTypes))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "EditWebsiteFileTitle"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "EditWebsiteFileToolTip"), Icon = EditWebsiteFile, Disabled = websiteFile.IsReadOnly, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryFileActionGroup } } }); } return(fileActions); }