protected string RenderPageContent() { Page page; if (_pageName == null) { _pageName = string.Empty; } if (Version > 0) { page = Wiki.GetPage(_pageName, Version); } else { page = Wiki.GetPage(_pageName); } if (page == null) { return(RenderEmptyPage()); } RiseWikiPageLoaded(page); RisePublishVersionInfo(page); return(HtmlWikiUtil.WikiToHtml(page.PageName, page.Body, Page.ResolveUrl(Request.AppRelativeCurrentExecutionFilePath), Wiki.GetPagesAndFiles(page.Body), Page.ResolveUrl(ImageHandlerUrlFormat), TenantId, CanEditPage && Version == 0 ? ConvertType.Editable : ConvertType.NotEditable)); }
protected void cmdDelete_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(WikiPage) || IsFile) { return; } var pageName = PageNameUtil.Decode(WikiPage); var page = Wiki.GetPage(pageName); CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage); foreach (var cat in Wiki.GetCategoriesRemovedWithPage(pageName)) { WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.AddPageToCat, cat.CategoryName); } Wiki.RemoveCategories(pageName); WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.EditPage, pageName); foreach (var comment in Wiki.GetComments(pageName)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString()); } Wiki.RemovePage(pageName); Response.RedirectLC("Default.aspx", this); } catch (Exception err) { WikiMaster.PrintInfoMessage(err.Message, InfoType.Alert); } }
protected void Page_Load(object sender, EventArgs e) { (Master as WikiMaster).GetNavigateActionsVisible += new WikiMaster.GetNavigateActionsVisibleHandle(PageHistoryList_GetNavigateActionsVisible); var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage)); if (Request["page"] == null || page == null) { Response.RedirectLC("Default.aspx", this); } string PageName = page.PageName.Equals(string.Empty) ? WikiResource.MainWikiCaption : page.PageName; BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb() { Caption = PageName, NavigationUrl = ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName) }); BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb() { Caption = WikiResource.wikiHistoryCaption }); if (!IsPostBack) { cmdDiff.Text = WikiResource.cmdDiff; cmdDiff_Top.Text = WikiResource.cmdDiff; BindHistoryList(); } }
protected void cmdRevert_Click(object sender, EventArgs e) { if (CommunitySecurity.IsOutsider()) { throw new SecurityException(); } int ver; if (int.TryParse((sender as LinkButton).CommandName, out ver)) { var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage), ver); if (page != null) { page.Date = TenantUtil.DateTimeNow(); page.UserID = SecurityContext.CurrentAccount.ID; page.Version = Wiki.GetPageMaxVersion(page.PageName) + 1; Wiki.SavePage(page); Wiki.UpdateCategoriesByPageContent(page); BindHistoryList(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { return; } Wiki_FCKEditor.BasePath = VirtualPathUtility.ToAbsolute(BaseFCKRelPath); Wiki_FCKEditor.ToolbarSet = "WikiPanel"; if (PageName != null && Visible) { var page = Wiki.GetPage(PageNameUtil.Decode(PageName)); var isPageNew = (page == null || IsNew); RiseWikiPageLoaded(isPageNew, page); if (!isPageNew) { txtPageName.Value = page.PageName; if (PageSection < 0) { SetWikiFCKEditorValue(page.PageName, page.Body); } else { SetWikiFCKEditorValue(page.PageName, HtmlWikiUtil.GetWikiSectionBySectionNumber(page.Body, PageSection)); txtPageName.Attributes["readonly"] = "readonly"; txtPageName.Value += string.Format(WikiUCResource.wikiPageEditSectionCaptionFormat, HtmlWikiUtil.GetWikiSectionNameBySectionNumber(page.Body, PageSection)); } //Check for 'help' and 'main' page if (IsStandartName(page)) { txtPageName.Attributes["readonly"] = "readonly"; } PageVersion = page.Version; //if (page.PageName.Equals(string.Empty)) //txtPageName.ReadOnly = true; //We need to disable any changes for the one time saved page. RisePublishVersionInfo(page); } else if (!string.IsNullOrEmpty(PageName)) { txtPageName.Value = PageNameUtil.Decode(PageName); if (IsSpecialName) { txtPageName.Attributes["readonly"] = "readonly"; } } phPageName.Visible = txtPageName.Attributes["readonly"] == null; } hfFCKLastState.Value = (!IsWysiwygDefault).ToString().ToLower(); //txtPageName.Focus(); }
private void FindDiff() { var pageName = PageNameUtil.Decode(WikiPage); //Page oldPage = PagesProvider.PagesHistGetByNameVersion(pageName, OldVer, TenantId); //Page newPage = PagesProvider.PagesHistGetByNameVersion(pageName, NewVer, TenantId); var oldPage = Wiki.GetPage(pageName, OldVer); var newPage = Wiki.GetPage(pageName, NewVer); var oldVersion = oldPage == null ? string.Empty : oldPage.Body; var newVersion = newPage == null ? string.Empty : newPage.Body; var f = DiffHelper.DiffText(oldVersion, newVersion, true, true, false); var aLines = oldVersion.Split('\n'); var bLines = newVersion.Split('\n'); var n = 0; var sb = new StringBuilder(); foreach (var aItem in f) { // write unchanged lines while ((n < aItem.StartB) && (n < bLines.Length)) { WriteLine(n, null, bLines[n], sb); n++; } // while // write deleted lines for (var m = 0; m < aItem.deletedA; m++) { WriteLine(-1, "d", aLines[aItem.StartA + m], sb); } // for // write inserted lines while (n < aItem.StartB + aItem.insertedB) { WriteLine(n, "i", bLines[n], sb); n++; } // while } // while if (f.Length > 0 || (from bline in bLines where !bline.Trim().Equals(string.Empty) select bline).Count() > 0) { // write rest of unchanged lines while (n < bLines.Length) { WriteLine(n, null, bLines[n], sb); n++; } // while } litDiff.Text = sb.ToString(); }
public Wikipedia(IEnumerable <string> urls) { var templates = new List <string>(); foreach (TemplateElement templateName in Config.TemplateNames) { templates.Add(templateName.Name); } JObject mergedJson = null; foreach (var url in urls) { var pageName = ParseUrl(url).Value; Wiki sourceWiki = new Wiki("https://" + this.ParseUrl(url).Key + ".wikipedia.org/w"); var export = new Export(sourceWiki); Page page = sourceWiki.GetPage(HttpUtility.UrlDecode(pageName)); var json = export.ExportPages(new List <Page>() { page }, 1, templates); if (mergedJson == null) { mergedJson = JObject.Parse(json); } else { mergedJson.Merge(JObject.Parse(json)); } } ; Content = mergedJson.ToString(); var uri = new Uri(urls.First()); var splitedHost = uri.Host.Split('.').ToArray(); var host = (splitedHost.Count() > 2 ? $"{splitedHost[splitedHost.Count() - 2]}.{splitedHost[splitedHost.Count() - 1]}" : uri.Host); Meta = new Dictionary <string, object>() { { "ImportedFrom", host }, { "Url", uri.AbsoluteUri }, { "Source Content Type", "application/json" }, }; //return fileStorage.AddFile(path, GetFileName(), Encoding.UTF8.GetBytes(outputJson), meta); }
protected void cmdDelete_Click(object sender, EventArgs e) { try { var pageName = ((LinkButton)sender).CommandName; var page = Wiki.GetPage(pageName); CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage); foreach (var comment in Wiki.GetComments(pageName)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString()); } Wiki.RemovePage(pageName); BindRepeater(); } catch (Exception err) { WikiMaster.PrintInfoMessage(err.Message, InfoType.Warning); } }
protected void Page_Load(object sender, EventArgs e) { var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage)); if (Request["page"] == null || page == null) { Response.RedirectLC("Default.aspx", this); } var pageName = page.PageName.Equals(string.Empty) ? WikiResource.MainWikiCaption : page.PageName; WikiPageTitle = pageName; WikiPageIn = CommunityResource.InForParentPage; WikiPageURL = ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName); //WikiPageIn = CommunityResource.InForParentPage; WikiMaster.CurrentPageCaption = WikiResource.wikiHistoryCaption; if (!IsPostBack) { cmdDiff.Text = WikiResource.cmdDiff; BindHistoryList(); } }
public SaveResult Save(Guid userId, out string pageName) { try { if (SetNewFCKMode != null) { bool isSource; bool.TryParse(hfFCKLastState.Value, out isSource); SetNewFCKMode(!isSource); IsWysiwygDefault = !isSource; //We need to update the variable if SetNewFCKMode is used only!!! } Page page; string currentPageName = txtPageName.Text.Trim(); if (currentPageName.Length > 240) { currentPageName = currentPageName.Substring(0, 240).Trim(); } currentPageName = PageNameUtil.Clean(currentPageName); if (pageSection >= 0) { currentPageName = PageNameUtil.Decode(PageName); } pageName = currentPageName; bool isPageRename = pageName != PageNameUtil.Decode(PageName) && !string.IsNullOrEmpty(PageName); string oldPageName = PageName; if (currentPageName.Equals(string.Empty) && !txtPageName.ReadOnly) { SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value); return(SaveResult.PageNameIsEmpty); } if (!IsSpecialName && IsNameReserved(currentPageName)) { SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value); return(SaveResult.PageNameIsIncorrect); } if (userId.Equals(Guid.Empty)) { SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value); return(SaveResult.UserIdIsEmpty); } if (!PageNameUtil.Decode(PageName).Equals(currentPageName, StringComparison.InvariantCulture)) { page = Wiki.GetPage(currentPageName); if (page != null) { SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value); return(SaveResult.SamePageExists); } page = new Page(); } else { page = Wiki.GetPage(currentPageName); if (page == null) { page = new Page(); } } page.PageName = currentPageName; string PageResult; if (pageSection < 0) { PageResult = Wiki_FCKEditor.Value; } else { PageResult = HtmlWikiUtil.SetWikiSectionBySectionNumber(page.Body, pageSection, Wiki_FCKEditor.Value); } if (PageResult.Equals(page.Body)) { SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value); return(SaveResult.NoChanges); } page.Body = PageResult; if (pageVersion > 0 && pageVersion < Wiki.GetPageMaxVersion(page.PageName)) { SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value); return(SaveResult.OldVersion); } page.Date = TenantUtil.DateTimeNow(); page.UserID = userId; page.Version++; Wiki.SavePage(page); var newCats = Wiki.UpdateCategoriesByPageContent(page); if (newCats.Count > 0 && SaveNewCategoriesAdded != null) { SaveNewCategoriesAdded(this, newCats, page.PageName); } pageVersion = page.Version; RisePublishVersionInfo(page); SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value); if (pageSection >= 0) { return(SaveResult.SectionUpdate); } if (isPageRename) { //create dumb page var oldpage = Wiki.GetPage(PageNameUtil.Decode(oldPageName)); if (oldpage != null) { oldpage.Date = TenantUtil.DateTimeNow(); oldpage.UserID = userId; oldpage.Body = string.Format(WikiUCResource.wikiPageMoved, pageName); //Dummy oldpage.Version++; Wiki.SavePage(oldpage); return(SaveResult.OkPageRename); } else { return(SaveResult.SamePageExists); } } return(SaveResult.Ok); } catch (Exception) { pageName = txtPageName.Text.Trim(); return(SaveResult.Error); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { return; } _mobileVer = MobileDetector.IsMobile; //fix for IE 10 var browser = HttpContext.Current.Request.Browser.Browser; var userAgent = Context.Request.Headers["User-Agent"]; var regExp = new Regex("MSIE 10.0", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); var regExpIe11 = new Regex("(?=.*Trident.*rv:11.0).+", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (browser == "IE" && regExp.Match(userAgent).Success || regExpIe11.Match(userAgent).Success) { _mobileVer = true; } Wiki_FCKEditor.BasePath = VirtualPathUtility.ToAbsolute(BaseFCKRelPath); Wiki_FCKEditor.ToolbarSet = "WikiPanel"; if (PageName != null && Visible) { var page = Wiki.GetPage(PageNameUtil.Decode(PageName)); var isPageNew = (page == null || IsNew); RiseWikiPageLoaded(isPageNew, page); if (!isPageNew) { txtPageName.Text = page.PageName; if (PageSection < 0) { SetWikiFCKEditorValue(page.PageName, page.Body); } else { SetWikiFCKEditorValue(page.PageName, HtmlWikiUtil.GetWikiSectionBySectionNumber(page.Body, PageSection)); txtPageName.ReadOnly = true; txtPageName.Text += string.Format(WikiUCResource.wikiPageEditSectionCaptionFormat, HtmlWikiUtil.GetWikiSectionNameBySectionNumber(page.Body, PageSection)); } //Check for 'help' and 'main' page if (IsStandartName(page)) { txtPageName.ReadOnly = true; } PageVersion = page.Version; //if (page.PageName.Equals(string.Empty)) //txtPageName.ReadOnly = true; //We need to disable any changes for the one time saved page. RisePublishVersionInfo(page); } else if (!string.IsNullOrEmpty(PageName)) { txtPageName.Text = PageNameUtil.Decode(PageName); if (IsSpecialName) { txtPageName.ReadOnly = true; } } phPageName.Visible = !txtPageName.ReadOnly; } hfFCKLastState.Value = (!IsWysiwygDefault).ToString().ToLower(); }