public void Open(params Object[] parameters) { Window window = DialogExtensions.Get <HelpWindow>(); if (window == null) { var kernel = _app.Get <IKernel>() as Kernel; var commands = _app.Get <ICommandFactory>(); var console = _app.Get <IConsole>(); var context = new DocumentationViewModel(kernel.Help, commands, console); window = WindowFactory.Instance.Create(context); } else { window.Activate(); } if (parameters.Length == 1 && parameters[0] is HelpSection) { var model = window.DataContext as DocumentationViewModel; if (model != null) { model.Topic = (HelpSection)parameters[0]; } } window.Show(); }
public async Task <IActionResult> Get(string requestedDocmentation) { string docsDirectory = Path.Combine(_hostingEnvironment.ContentRootPath, "Docs"); var markdownFiles = Directory.GetFiles(docsDirectory) .Select(x => Path.GetFileNameWithoutExtension(x)) .OrderBy(x => x); if (requestedDocmentation == null) { requestedDocmentation = markdownFiles.First(); } else if (markdownFiles.Contains(requestedDocmentation) == false) { return(BadRequest()); } var requestedFile = $"{requestedDocmentation}.md"; var requestedFilePath = Path.Combine(docsDirectory, requestedFile); var markdownFileText = await System.IO.File.ReadAllTextAsync(requestedFilePath); var documentationDisplayContainer = new DocumentationViewModel { Docs = markdownFiles, Markdown = markdownFileText, Title = requestedDocmentation.Replace("-", " "), RequestedDoc = requestedDocmentation }; return(View("Get", documentationDisplayContainer)); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentationView"/> class. /// </summary> public DocumentationView() { this.InitializeComponent(); var viewmodel = new DocumentationViewModel(this.DocuBrowser, "", "", false); this.DataContext = viewmodel; }
public DocumentationModule(IRouteCacheProvider routeCacheProvider) : base("/documentation") { Get["/"] = parameters => { var model = new DocumentationViewModel(routeCacheProvider.GetCache().SelectMany(p => p.Value) .SelectMany(p => p.Item2.Metadata.Raw.Select(g => (DocumentationObject)g.Value).ToList()).Where(p => p != null).ToList()); return(Response.AsJson(model)); }; }
public async Task <bool> DeleteAsync(DocumentationViewModel model) { var client = await GetClient(); var json = await client.DeleteAsync(Url + "deletenote/" + model.DocumentationId); var result = JsonConvert.DeserializeObject <MobileResult>(await json.Content.ReadAsStringAsync()); return(result.Result); }
public async Task <MobileResult> PutAsync(DocumentationViewModel model) { var client = await GetClient(); var json = await client.PutAsync(Url + "editdoc", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); var result = JsonConvert.DeserializeObject <MobileResult>(await json.Content.ReadAsStringAsync()); return(result); }
public DocumentationWindow(IBackendContext backendContext) { InitializeComponent(); DataContext = new DocumentationViewModel(backendContext); (DataContext as DocumentationViewModel).OnFinished += delegate(object sender, EventArgs e) { Close(); }; }
private DocumentationViewModel GetPost(string filePath, string docName = null) { var model = new DocumentationViewModel(); if (_fileSystem.FileExists(filePath)) { var contents = string.Empty; using (var fileStream = System.IO.File.Open(filePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read)) using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { contents = streamReader.ReadToEnd(); } var urlOnePattern = @"\[\[(.*?)\|(.*?)\]\]"; MatchCollection urlOnePatternMatches = Regex.Matches(contents, urlOnePattern); foreach (Match match in urlOnePatternMatches) { contents = contents.Replace(match.Value, "[" + match.Groups[1].Value + "](/docs/" + match.Groups[2].Value.ToLower() + ")"); } var urlTwoPattern = @"\[(.*?)\]\((.*?)\)"; MatchCollection urlTwoPatternMatches = Regex.Matches(contents, urlTwoPattern); foreach (Match match in urlTwoPatternMatches) { contents = contents.Replace(match.Groups[2].Value, match.Groups[2].Value .Replace("f-a-q", "faq") .Replace("p-s1", "ps1") .Replace("---", "-") .Replace("--", "-")); } contents = contents .Replace("<!--remove", "") .Replace("remove-->", "") .Replace("~~~sh", "~~~language-none") .Replace("(images/", "(/content/images/docs/"); // Get Url model.UrlPath = GetUrl(filePath, docName); // Convert using Markdig model.Post = Markdown.ToHtml(contents, MarkdownPipeline); // Remove "." from header ID's var headerPattern = @"(<h\d id=)(.*?)(>)"; MatchCollection matches = Regex.Matches(model.Post, headerPattern); foreach (Match match in matches) { model.Post = Regex.Replace(model.Post, match.Groups[2].Value, match.Groups[2].Value.Replace(".", "")); } } return(model); }
public IActionResult Upload(DocumentationViewModel model) { if (!ModelState.IsValid) { return(this.View()); } files.UploadFileAsync(model.File); TempData["SuccessMessage"] = $"File {model.File.FileName} uploaded successfully"; return(RedirectToAction(nameof(Index))); }
/// <summary> /// Visit the generic base class <see cref="T:NuDoq.Member" />. /// </summary> /// /// <remarks> /// This method is called for all <see cref="T:NuDoq.Member" />-derived types. /// </remarks> /// public override void VisitMember(Member member) { if (member.Kind.HasFlag(MemberKinds.Class)) { this.currentClassName = member.Info.Name; current = new DocumentationViewModel(); Texts[currentClassName] = current; builder = new StringBuilder(); insideTextBlock = false; base.VisitMember(member); } }
// GET: Documentation public override ActionResult Index(RenderModel model) { // get the related pages var ids = Services.RelationService.GetByParentId(model.Content.Id).Select(x => x.ChildId); // convert them to LandingPage classes var products = Umbraco.TypedContent(ids).OfType <LandingPage>(); // Create a new view model and pass to the page var viewModel = new DocumentationViewModel(model.Content) { LandingPages = products }; // Return the new model to the view return(CurrentTemplate(viewModel)); }
public ActionResult Documentation(string docName, string q) { docName = docName.Replace("-", ""); var fileExists = _fileSystem.FileExists(Server.MapPath("~/Views/Documentation/{0}.cshtml".format_with(docName))); q = (q ?? string.Empty).Trim(); ViewBag.SearchTerm = q; var viewModel = new DocumentationViewModel(q); if (fileExists) { return(View(docName, viewModel)); } return(RedirectToAction("PageNotFound", "Error")); }
public void SetUp() { this.PathDocumentationIndex = Path.Combine(TestContext.CurrentContext.TestDirectory, @"Documentation\book.json"); this.RootAppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RHEA_Group"); RxApp.MainThreadScheduler = Scheduler.CurrentThread; //Initializes the web browser and its commands var browser = new Mock <IBrowser>(); this.webBrowser = new Mock <IWebBrowser>(); this.webBrowser.Setup(x => x.CanGoBack).Returns(true); this.webBrowser.Setup(x => x.CanGoForward).Returns(true); this.webBrowser.Setup(x => x.GetBrowser()).Returns(browser.Object); this.documentationViewModel = new DocumentationViewModel(this.webBrowser.Object, this.PathDocumentationIndex, this.RootAppData, true); }
// GET: Documentation public override ActionResult Index(RenderModel model) { //add here the logic that was in the view to get all the product that are referenced in the Documentation content //PRODUCTs page URL to be displayed - use the relation service to get the relations //get the 'related' landing pages var ids = UmbracoContext .Application.Services .RelationService.GetByParentId(model.Content.Id) .Select(x => x.ChildId); ////fetch them as nodes //var products = Umbraco.TypedContent(ids) // .Where(x => x.DocumentTypeAlias == "landingPage").ToList(); var products = Umbraco.TypedContent(ids).OfType <LandingPage>(); //IMAGES //var images = model.Content.Images.OfType<Folder>() // .SelectMany(x => x.Children().OfType<Image>()); //property in Documentation Model //IEnumerable<IPublishedContent> Images var images = model.Content.GetPropertyValue <IEnumerable <IPublishedContent> >("Images") //doc Typr property in Documentation .OfType <Folder>().SelectMany(x => x.Children().OfType <Image>()); //type to the VM property Ienum<Image> var list = CurrentPage.GetPropertyValue("Images"); //create the custom viewmodel adding the product to the custom property LnadingPages fo rthe products referenced in the content var viewmodel = new DocumentationViewModel(model.Content) // set the inherited content { //set the custom property LandingPages LandingPages = products, //get the property from the published content inherited and type to the custom property for images AllImages = images }; //returns the new model to the view return(CurrentTemplate(viewmodel)); //return base.Index(model); }
internal void SetDocumentationViewModel(DocumentationViewModel viewModel) { docuViewModel = viewModel; }
private DocumentationViewModel GetPost(string filePath, string docName = null) { var model = new DocumentationViewModel(); if (_fileSystem.FileExists(filePath)) { var contents = string.Empty; using (var fileStream = System.IO.File.Open(filePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read)) using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { contents = streamReader.ReadToEnd(); } var urlOnePattern = @"\[\[(.*?)\|(.*?)\]\]"; MatchCollection urlOnePatternMatches = Regex.Matches(contents, urlOnePattern); foreach (Match match in urlOnePatternMatches) { var hyphenatedValue = new StringBuilder(); Char previousChar = '^'; foreach (var valueChar in match.Groups[2].Value.ToString()) { // Filenames that contain both a "-" and camel casing if (match.Groups[2].Value.Contains("-") && Char.IsLower(previousChar) && Char.IsUpper(valueChar)) { hyphenatedValue.Append("-"); } if (Char.IsUpper(valueChar) && hyphenatedValue.Length != 0 && !Char.IsUpper(previousChar) && !match.Groups[2].Value.Contains("-")) { hyphenatedValue.Append("-"); } if (Char.IsDigit(valueChar) && !Char.IsDigit(previousChar) && hyphenatedValue.Length != 0) { hyphenatedValue.Append("-"); } previousChar = valueChar; hyphenatedValue.Append(valueChar.to_string()); } contents = contents.Replace(match.Value, "[" + match.Groups[1].Value + "](/docs/" + hyphenatedValue.ToString().ToLower() + ")"); } var urlTwoPattern = @"\[(.*?)\]\((.*?)\)"; MatchCollection urlTwoPatternMatches = Regex.Matches(contents, urlTwoPattern); foreach (Match match in urlTwoPatternMatches) { contents = contents.Replace(match.Groups[2].Value, match.Groups[2].Value .Replace("f-a-q", "faq") .Replace("p-s1", "ps1") .Replace("---", "-") .Replace("--", "-")); } contents = contents .Replace("<!--remove", "") .Replace("remove-->", "") .Replace("~~~sh", "~~~language-none") .Replace("(images/", "(/content/images/docs/"); // Get Url model.UrlPath = GetUrl(filePath, docName); // Convert using Markdig model.Post = Markdown.ToHtml(contents, MarkdownPipeline); // Remove "." from header ID's var headerPattern = @"(<h\d id=)(.*?)(>)"; MatchCollection matches = Regex.Matches(model.Post, headerPattern); foreach (Match match in matches) { model.Post = Regex.Replace(model.Post, match.Groups[2].Value, match.Groups[2].Value.Replace(".", "")); } } return(model); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var app = commandData.Application; if (app is null) { message = "No application object"; return(Result.Failed); } var uiDoc = app.ActiveUIDocument; if (uiDoc is null) { message = "No opent UIDocument"; return(Result.Failed); } var doc = uiDoc.Document; if (doc is null) { message = "No open Document"; return(Result.Failed); } if (doc.IsFamilyDocument == false) { message = "No family Document"; return(Result.Failed); } try { var viewModel = new DocumentationViewModel(); var view = new DocumentationView { DataContext = viewModel }; var dialog = new WpfDialog(view); var manager = new CreateJournalManager(commandData); if (manager.CanReadData == false) { dialog.ShowDialog(); } if (manager.CanReadData || dialog.DialogResult == true) { var setting = viewModel.Settings; var tran = new Transaction(doc, "Family Documentation"); try { tran.Start(); manager.CreateDocumentation(doc, setting); tran.Commit(); return(Result.Succeeded); } catch (Exception ex) { tran.RollBack(); throw ex; } } else { return(Result.Cancelled); } } catch (Exception ex) { message = $"Error: {ex.Message}\nStack: {ex.StackTrace}"; return(Result.Failed); } }
public DocumentationPage() { InitializeComponent(); BindingContext = viewModel = new DocumentationViewModel(); }