/// <summary>
        /// Gets a particular version of a page.
        /// </summary>
        /// <param name="id">The Guid ID for the version.</param>
        /// <returns>A <see cref="PageViewModel"/> as the model, which contains the HTML diff
        /// output inside the <see cref="PageViewModel.Content"/> property.</returns>
        public ActionResult Version(Guid id)
        {
            MarkupConverter converter = _pageService.GetMarkupConverter();
            IList<PageViewModel> bothVersions = _historyService.CompareVersions(id).ToList();
            string diffHtml = "";

            if (bothVersions[1] != null)
            {
                string oldVersion = converter.ToHtml(bothVersions[1].Content).Html;
                string newVersion = converter.ToHtml(bothVersions[0].Content).Html;
                HtmlDiff diff = new HtmlDiff(oldVersion, newVersion);
                diffHtml = diff.Build();
            }
            else
            {
                diffHtml = converter.ToHtml(bothVersions[0].Content).Html;
            }

            PageViewModel model = bothVersions[0];
            model.Content = diffHtml;
            return View(model);
        }
Exemple #2
0
        /// <summary>
        /// Gets a particular version of a page.
        /// </summary>
        /// <param name="id">The Guid ID for the version.</param>
        /// <returns>A <see cref="PageSummary"/> as the model, which contains the HTML diff
        /// output inside the <see cref="PageSummary.Content"/> property.</returns>
        public ActionResult Version(Guid id)
        {
            HistoryManager manager = new HistoryManager();
            IList<PageSummary> bothVersions = manager.CompareVersions(id).ToList();
            string diffHtml = "";

            if (bothVersions[1] != null)
            {
                string oldVersion = bothVersions[1].Content.WikiMarkupToHtml();
                string newVersion = bothVersions[0].Content.WikiMarkupToHtml();
                HtmlDiff diff = new HtmlDiff(oldVersion, newVersion);
                diffHtml = diff.Build();
            }
            else
            {
                diffHtml = bothVersions[0].Content.WikiMarkupToHtml();
            }

            PageSummary summary = bothVersions[0];
            summary.Content = diffHtml;
            return View(summary);
        }