public static List <string> categories(this O2MediaWikiAPI wikiApi, bool autoRemoveCategoryPrefix) { var categoryString = "Category:"; var categories = new List <string>(); var results = wikiApi.categoriesRaw().attributes("title").values(); if (autoRemoveCategoryPrefix) { foreach (var category in results) { if (category.starts(categoryString)) { categories.add(category.Substring(categoryString.size())); } else { categories.add(category); } } } else { categories = results; } return(categories); }
public ascx_MediaWiki_Backup buildGui(O2MediaWikiAPI wikiApi) { WikiApi = wikiApi; //var controls = this.add_1x1(false); //var configPanel = controls[0].add_Panel(); //controls[1].add_LogViewer(); var configPanel = this.add_Panel(); configPanel.add_Label("Folder to store backup files",5,0); BackupFolder_TextBox = configPanel.add_TextBox().top(25); BackupFolder_TextBox.align_Right(configPanel) .widthAdd(-5); BackupPages_CheckBox = configPanel.add_CheckBox("Backup content pages", 50, 0, (value)=>{}).autoSize().tick(); BackupFiles_CheckBox = configPanel.add_CheckBox("Backup files", 70, 0,(value)=>{}).autoSize().untick(); BackupCategoryPages_CheckBox = configPanel.add_CheckBox("Backup category Pages", 90, 0,(value)=>{}).autoSize().tick(); BackupTemplates_CheckBox = configPanel.add_CheckBox("Backup template pages", 110, 0,(value)=>{}).autoSize().tick(); BackupUsers_CheckBox = configPanel.add_CheckBox("Backup users pages", 50, 150,(value)=>{}).autoSize().tick(); StartBackup_Button = configPanel.add_Button("Start Backup",140,0) .onClick(backup); CancelBackup_Button = configPanel.add_Button("Cancel Backup",140,100) .onClick(cancelBackup).enabled(false); Status_ProgressBar = configPanel.add_ProgressBar(170,0); Status_ProgressBar.align_Right(configPanel) .widthAdd(-5); var rightPanel = configPanel.insert_Right<Panel>(configPanel.width()/3); // there is a small gui frezee here which needs to be solved Backup_Directory = rightPanel.add_Directory(@"C:\O2"); setup(); return this; }
public static List <string> getIndexPhp_UsingXPath_AttributeValues(this O2MediaWikiAPI wikiApi, string wikiQueryString, string xPathQuery, string xPathAttribute, string limitVarName, int maxToFetchPerRequest, string offsetVarName, int maxItemsToFetch) { var currentOffset = 0; var result = new List <string>(); while (result.size() < maxItemsToFetch) { //var getRequest = "http://www.o2platform.com/index.php?title=Special:UncategorizedPages&limit={0}&offset={1}".format(maxToFetch,currentOffset); var getRequest = "{0}&{1}={2}&{3}={4}".format(wikiQueryString, limitVarName, maxToFetchPerRequest, offsetVarName, currentOffset); var htmlCode = wikiApi.getIndexPhp(getRequest); //"uncategorizedPages GET request: {0}".info(getRequest); var htmlDocument = htmlCode.htmlDocument(); var pages = htmlDocument.select(xPathQuery).attributes(xPathAttribute).values(); result.add(pages); if (pages.size() == 0 || pages.size() < maxToFetchPerRequest) { break; } currentOffset += maxToFetchPerRequest; } return(result); }
public void loadMediaWikiDetails(string mediaWikiEngine) { switch (mediaWikiEngine) { case "O2-Platform.com": WikiApi = new O2PlatformWikiAPI(); break; case "OWASP.org": //WikiApi = new O2MediaWikiAPI(); //WikiApi.init("http://www.owasp.org/api.php"); WikiApi = new OwaspWikiAPI(); break; case "Wikipedia.com": WikiApi = new O2MediaWikiAPI(); WikiApi.init("http://en.wikipedia.org/w/api.php"); break; default: WikiApi = new O2MediaWikiAPI(); break; } SetWikiApi(WikiApi); MediaWikiUrl_TextBox.set_Text(WikiApi.HostUrl); MediaWiki_API_php_TextBox.set_Text(WikiApi.ApiPhp); MediaWiki_Index_php_TextBox.set_Text(WikiApi.IndexPhp); if (MediaWikiUrl_TextBox.get_Text().valid()) { checkMediaWikiUrls(); } }
public static string post_from_MediaWiki(this API_WordPress wpApi, O2MediaWikiAPI wikiApi, string mediaWikiPage, string postTitle) { try { var code = wikiApi.parsePage(mediaWikiPage); var htmlDocument = new HtmlAgilityPack.HtmlDocument(); htmlDocument.LoadHtml(code); // remove MediaWiki comments foreach (var node in htmlDocument.DocumentNode.ChildNodes) { if (node is HtmlAgilityPack.HtmlCommentNode) { htmlDocument.DocumentNode.RemoveChild(node); } } // fix images links foreach (var a in htmlDocument.DocumentNode.SelectNodes("//img")) { var src = a.Attributes["src"]; if (src != null) { if (src.Value.starts("/")) { src.Value = wikiApi.HostUrl + src.Value; } } } // fix a href links foreach (var a in htmlDocument.DocumentNode.SelectNodes("//a")) { var href = a.Attributes["href"]; if (href != null) { if (href.Value.starts("/")) { href.Value = wikiApi.HostUrl + href.Value; } } } var postBody = htmlDocument.DocumentNode.OuterHtml; var messageToAppend = "[automatic O2 comment]:" + "<hr>" + "<b>Note:</b> This blog post was created by an <a href='http://www.o2platform.com'>O2 Script</a> and is a copy of the MediaWiki page with the title <i>'{0}'</i> located at: <a href='{1}'>{1}</a>" .format(mediaWikiPage, wikiApi.pageUrl(mediaWikiPage)).line() + "<b>Exported on</b>:{0}" .format(DateTime.Now.ToShortDateString()); postBody = postBody.add(messageToAppend); return(wpApi.post(postTitle, postBody)); } catch (Exception ex) { ex.logWithStackTrace("in WordPressAPI.post_from_MediaWiki, for MediaWikiAPI page '{0}'".format(mediaWikiPage)); return(""); } }
public MediaWikiEditor() { FileWithSecretData = @"C:\O2\_USERDATA\O2TestUsers.xml"; WikiApi = new O2MediaWikiAPI(); //buildGui_Internal(); //setMediaWikiTo_O2Platform(); //setMediaWikiTo_OWASP(); }
public MediaWikiEditor() { FileWithSecretData = @"C:\O2\_USERDATA\O2TestUsers.xml"; WikiApi = new O2MediaWikiAPI(); //buildGui_Internal(); //setMediaWikiTo_O2Platform(); //setMediaWikiTo_OWASP(); }
public static List <string> pagesInCategory(this O2MediaWikiAPI wikiApi, string category, bool autoAddCategoryPrefix) { if (autoAddCategoryPrefix) { category = "Category:" + category; } return(wikiApi.pagesInCategoryRaw(category).attributes("title").values()); }
/*public static List<string> uncategorizedPages(this O2MediaWikiAPI wikiApi) * { * //var maxToFetch = 500; * //var uri = link.uri(); * //var htmlCode = uri.getHtml(); * //var htmlDocument = htmlCode.htmlDocument(); * }*/ public static List <string> uncategorizedPages(this O2MediaWikiAPI wikiApi) { var maxToFetchPerRequest = 500; var maxItemsToFetch = 5000; return(wikiApi.getIndexPhp_UsingXPath_AttributeValues("title=Special:UncategorizedPages", "//div[@class='mw-spcontent']//li//a", "href", "limit", maxToFetchPerRequest, "offset", maxItemsToFetch)); }
public void setWikiApi(O2MediaWikiAPI newWikiApi) { //perform a shallow copy from newWikiApi to WikiApi) //"before:{0}".info(WikiApi.HostUrl); foreach (var property in WikiApi.type().properties()) { Reflection_ExtensionMethods_Properties.prop(WikiApi, property.Name, newWikiApi.prop(property.Name)); } //"after:{0}".info(WikiApi.HostUrl); }
public static List <XElement> categoriesRaw(this O2MediaWikiAPI wikiApi) { string pages = ""; string limitVar = "aclimit"; int limitValue = 200; string properyType = "generator"; string propertyName = "allcategories"; string continueVarName = "gacfrom"; string continueValue = ""; string dataElement = "page"; int maxItemsToFetch = -1; bool resolveRedirects = false; //"info&generator=allcategories","" return(wikiApi.getQueryContinueResults(pages, limitVar, limitValue, properyType, propertyName, continueVarName, continueValue, dataElement, maxItemsToFetch, resolveRedirects)); }
public ascx_MediaWiki_Backup buildGui(O2MediaWikiAPI wikiApi) { WikiApi = wikiApi; //var controls = this.add_1x1(false); //var configPanel = controls[0].add_Panel(); //controls[1].add_LogViewer(); var configPanel = this.add_Panel(); configPanel.add_Label("Folder to store backup files", 5, 0); BackupFolder_TextBox = configPanel.add_TextBox().top(25); BackupFolder_TextBox.align_Right(configPanel) .widthAdd(-5); BackupPages_CheckBox = configPanel.add_CheckBox("Backup content pages", 50, 0, (value) => {}).autoSize().tick(); BackupFiles_CheckBox = configPanel.add_CheckBox("Backup files", 70, 0, (value) => {}).autoSize().untick(); BackupCategoryPages_CheckBox = configPanel.add_CheckBox("Backup category Pages", 90, 0, (value) => {}).autoSize().tick(); BackupTemplates_CheckBox = configPanel.add_CheckBox("Backup template pages", 110, 0, (value) => {}).autoSize().tick(); BackupUsers_CheckBox = configPanel.add_CheckBox("Backup users pages", 50, 150, (value) => {}).autoSize().tick(); StartBackup_Button = configPanel.add_Button("Start Backup", 140, 0) .onClick(backup); CancelBackup_Button = configPanel.add_Button("Cancel Backup", 140, 100) .onClick(cancelBackup).enabled(false); Status_ProgressBar = configPanel.add_ProgressBar(170, 0); Status_ProgressBar.align_Right(configPanel) .widthAdd(-5); var rightPanel = configPanel.insert_Right <Panel>(configPanel.width() / 3); // there is a small gui frezee here which needs to be solved Backup_Directory = rightPanel.add_Directory(@"C:\O2"); setup(); return(this); }
public ascx_MediaWiki_PageEditor_Simple(O2MediaWikiAPI wikiApi) { buildGui(wikiApi); }
// O2MediaWikiAPi public static List <string> categories(this O2MediaWikiAPI wikiApi) { return(wikiApi.categories(true)); }
public ascx_MediaWiki_ConfigAndLogin(O2MediaWikiAPI wikiApi, Action <O2MediaWikiAPI> setWikiApi) { buildGui(wikiApi, setWikiApi); }
public ascx_MediaWiki_PageEditor_Simple(O2MediaWikiAPI wikiApi) { buildGui(wikiApi); }
public ascx_MediaWiki_Backup(O2MediaWikiAPI wikiApi) { buildGui(wikiApi); }
public static string post_from_MediaWiki(this API_WordPress wpApi, O2MediaWikiAPI wikiApi, string mediaWikiPage) { return wpApi.post_from_MediaWiki(wikiApi, mediaWikiPage, mediaWikiPage); }
public static string post_from_MediaWiki(this API_WordPress wpApi, O2MediaWikiAPI wikiApi, string mediaWikiPage) { return(wpApi.post_from_MediaWiki(wikiApi, mediaWikiPage, mediaWikiPage)); }
public void setWikiApi(O2MediaWikiAPI newWikiApi) { //perform a shallow copy from newWikiApi to WikiApi) //"before:{0}".info(WikiApi.HostUrl); foreach(var property in WikiApi.type().properties()) Reflection_ExtensionMethods_Properties.prop(WikiApi,property.Name,newWikiApi.prop(property.Name)); //"after:{0}".info(WikiApi.HostUrl); }
public ascx_MediaWiki_ConfigAndLogin buildGui(O2MediaWikiAPI wikiApi, Action <O2MediaWikiAPI> setWikiApi) { WikiApi = wikiApi; SetWikiApi = setWikiApi; var controls = this.add_1x1("Config", "Login Details", false); var config_Panel = controls[0]; var loginDetails_Panel = controls[1]; //config_Panel TargetMediaWiki_ComboBox = config_Panel.add_Label("Target MediaWiki website", 12, 10) .append_Control <ComboBox>() .dropDownList() .onSelection <string>(loadMediaWikiDetails); MediaWikiUrl_TextBox = config_Panel.add_Label("MediaWiki Url: ", 40, 10) .append_TextBox(""); MediaWiki_API_php_TextBox = config_Panel.add_Label("MediaWiki api.php: ", 60, 10) .append_TextBox(""); MediaWiki_Index_php_TextBox = config_Panel.add_Label("MediaWiki index.php: ", 80, 10) .append_TextBox(""); MediaWikiUrlCheck_Label = config_Panel.add_Link("Check MediaWiki Urls", 110, 128, checkMediaWikiUrls) .append_Label("") .autoSize(); MediaWikiUrl_TextBox.align_Right(config_Panel).leftAdd(2).widthAdd(-7); MediaWiki_API_php_TextBox.align_Right(config_Panel).widthAdd(-5); MediaWiki_Index_php_TextBox.align_Right(config_Panel).widthAdd(-5); //loginDetails_Panel loginDetails_Panel.add_Label("A) Login using local config file:", 20, 10); SecretsFile_TextBox = loginDetails_Panel.add_TextBox(40, 102, false) .set_Text(defaultSecretsFolder.pathCombine(defaultSecretsFile)) .onEnter(loadCredentials); Credential_ComboBox = loginDetails_Panel.add_ComboBox(60, 102).width(220).sorted(); Credential_ComboBox.onSelection <ICredential>(loadCredentialDetails); loginDetails_Panel.add_Label("B) Login using username & password: "******"Username:"******""); Password_TextBox = loginDetails_Panel.add_Label("Password: "******"") .isPasswordField(); SecretsFile_TextBox.align_Right(loginDetails_Panel).widthAdd(-40); SecretsFile_TextBox.append_Control <Button>() .set_Text("...") .width(30) .heightAdd(-2) .anchor_TopRight() .onClick(() => { var file = this.askUserForFileToOpen(defaultSecretsFolder, "Xml Files | *.xml"); if (file.valid()) { SecretsFile_TextBox.set_Text(file); loadCredentials(file); } });; UserName_TextBox.width(200); Password_TextBox.width(200); LoggedInStatus_Label = Password_TextBox.append_Link("Login", login) .topAdd(5) .append_Label("") .autoSize(); loadCredentials(SecretsFile_TextBox.get_Text()); loadDefaultMediaWikiEngines(); return(this); }
public static List <string> pagesInCategory(this O2MediaWikiAPI wikiApi, string category) { return(wikiApi.pagesInCategory(category, true)); }
//method called that will trigger the parsing public WikiText_Template parse(O2MediaWikiAPI wikiApi, string page) { base.parse(wikiApi, new WikiText_Template_Grammar(), page); return(this); }
public ascx_MediaWiki_PageEditor_Simple buildGui(O2MediaWikiAPI wikiApi) { try { WikiApi = wikiApi; var topPanel = this.add_Panel(); var horizontalSplitterPosition = topPanel.height()/2; var verticalSplitterPosition = topPanel.width()/2; var controls = topPanel.add_1x2("WikiText","Preview","Live (Current page)",false,horizontalSplitterPosition,verticalSplitterPosition); WikiTextEditor = controls[0].add_RichTextBox(); BrowserPreview = controls[1].add_WebBrowser(); BrowserCurrent = controls[2].add_WebBrowser(); WikiPage_TextBox = WikiTextEditor.insert_Above<TextBox>(50); var bottomPanel = WikiPage_TextBox.insert_Below<Panel>(30); RecentChangesComboBox = WikiPage_TextBox.insert_Right<Panel>(290) .add_Label("Recent Changes / Search") .top(3) .append_Control<ComboBox>() //.dropDownList() .width(150) .top(0); Action<string> populateRecentChangesComboBox = (filter) => { RecentChangesComboBox.backColor(Color.LightPink); O2Thread.mtaThread( ()=>{ RecentChangesComboBox.clear(); if (filter.valid().isFalse()) RecentChangesComboBox.add_Items(WikiApi.recentPages()); else RecentChangesComboBox.add_Items(WikiApi.pages(filter)); RecentChangesComboBox.backColor(Color.White); }); }; RecentChangesComboBox.onSelection( ()=>{ WikiPage_TextBox.set_Text(RecentChangesComboBox.get_Text()); loadCurrentPage(); }); RecentChangesComboBox.onEnter( (text)=>{ populateRecentChangesComboBox(text); }); //WikiTextEditor.insert_Below<ascx_LogViewer>(130); //default values BrowserPreview.silent(true); BrowserCurrent.silent(true); //WikiPage_TextBox.set_Text("Test"); // add controls with events CurrentPageUrl = BrowserCurrent.insert_Above<Panel>(20) .add_LabelAndComboBoxAndButton("Current page","","open",showInCurrentBrowser) .controls<ComboBox>(); CurrentPageUrl.insert_Item("www.google.com"); bottomPanel.add_Button("Load",0).onClick( ()=>{ loadCurrentPage(); }); bottomPanel.add_Button("Preview",0,100).onClick( ()=>{ O2Thread.mtaThread( ()=>{ BrowserPreview.set_Text(WikiApi.parseText(WikiTextEditor.get_Text(),true)); }); }); SaveButton = bottomPanel.add_Button("Save",0,200).onClick( ()=>{ saveCurrentPage(); }); StatusLabel = SaveButton.append_Label("").topAdd(3).autoSize(); /*WikiTextEditor.onKeyPress(Keys.Enter, (code)=>{ O2Thread.mtaThread(()=> { BrowserPreview.set_Text(WikiApi.parseText(code,true)); }); });*/ WikiTextEditor.onKeyPress((key)=> // add suport to paste images form Clipboard { if (key == (Keys.Control | Keys.V)) return pasteImageFromClipboard(); return false; }); WikiPage_TextBox.onEnter((text)=>loadPage(text)); WikiTextEditor.add_ContextMenu() .add_MenuItem("Wrap with source tag (defaults to lang=csharp)", ()=>{ WikiTextEditor.invokeOnThread( ()=>{ WikiTextEditor.SelectedText = "<source lang=csharp>".line() + WikiTextEditor.SelectedText.line() + "</source>".line(); }); }); populateRecentChangesComboBox(""); } catch(Exception ex) { ex.log("in ascx_MediaWiki_PageEditor_Simple buildGui"); } return this; }
public bool parse(O2MediaWikiAPI wikiApi, Grammar grammar, string page) //where T : WikiText { return(parse(wikiApi.raw(page, UseContentLocalCache), grammar)); }
public static string post_from_MediaWiki(this API_WordPress wpApi, O2MediaWikiAPI wikiApi, string mediaWikiPage, string postTitle) { try { var code = wikiApi.parsePage(mediaWikiPage); var htmlDocument = new HtmlAgilityPack.HtmlDocument(); htmlDocument.LoadHtml(code); // remove MediaWiki comments foreach(var node in htmlDocument.DocumentNode.ChildNodes) if (node is HtmlAgilityPack.HtmlCommentNode) htmlDocument.DocumentNode.RemoveChild(node); // fix images links foreach(var a in htmlDocument.DocumentNode.SelectNodes("//img")) { var src = a.Attributes["src"]; if (src!= null) if (src.Value.starts("/")) src.Value = wikiApi.HostUrl + src.Value; } // fix a href links foreach(var a in htmlDocument.DocumentNode.SelectNodes("//a")) { var href = a.Attributes["href"]; if (href!= null) if (href.Value.starts("/")) href.Value = wikiApi.HostUrl + href.Value; } var postBody = htmlDocument.DocumentNode.OuterHtml; var messageToAppend = "[automatic O2 comment]:" + "<hr>" + "<b>Note:</b> This blog post was created by an <a href='http://www.o2platform.com'>O2 Script</a> and is a copy of the MediaWiki page with the title <i>'{0}'</i> located at: <a href='{1}'>{1}</a>" .format(mediaWikiPage, wikiApi.pageUrl(mediaWikiPage)).line() + "<b>Exported on</b>:{0}" .format(DateTime.Now.ToShortDateString()); postBody = postBody.add(messageToAppend); return wpApi.post(postTitle, postBody); } catch(Exception ex) { ex.logWithStackTrace("in WordPressAPI.post_from_MediaWiki, for MediaWikiAPI page '{0}'".format(mediaWikiPage)); return ""; } }
public void loadMediaWikiDetails(string mediaWikiEngine) { switch(mediaWikiEngine) { case "O2-Platform.com": WikiApi = new O2PlatformWikiAPI(); break; case "OWASP.org": //WikiApi = new O2MediaWikiAPI(); //WikiApi.init("http://www.owasp.org/api.php"); WikiApi = new OwaspWikiAPI(); break; case "Wikipedia.com": WikiApi = new O2MediaWikiAPI(); WikiApi.init("http://en.wikipedia.org/w/api.php"); break; default : WikiApi = new O2MediaWikiAPI(); break; } SetWikiApi(WikiApi); MediaWikiUrl_TextBox.set_Text(WikiApi.HostUrl); MediaWiki_API_php_TextBox.set_Text(WikiApi.ApiPhp); MediaWiki_Index_php_TextBox.set_Text(WikiApi.IndexPhp); if (MediaWikiUrl_TextBox.get_Text().valid()) checkMediaWikiUrls(); }
public ascx_MediaWiki_ConfigAndLogin(O2MediaWikiAPI wikiApi, Action<O2MediaWikiAPI> setWikiApi) { buildGui(wikiApi, setWikiApi); }
public ascx_MediaWiki_ConfigAndLogin buildGui(O2MediaWikiAPI wikiApi, Action<O2MediaWikiAPI> setWikiApi) { WikiApi = wikiApi; SetWikiApi = setWikiApi; var controls = this.add_1x1("Config", "Login Details",false); var config_Panel = controls[0]; var loginDetails_Panel = controls[1]; //config_Panel TargetMediaWiki_ComboBox = config_Panel.add_Label("Target MediaWiki website",12,10) .append_Control<ComboBox>() .dropDownList() .onSelection<string>(loadMediaWikiDetails); MediaWikiUrl_TextBox = config_Panel.add_Label("MediaWiki Url: ",40,10) .append_TextBox(""); MediaWiki_API_php_TextBox = config_Panel.add_Label("MediaWiki api.php: ",60,10) .append_TextBox(""); MediaWiki_Index_php_TextBox = config_Panel.add_Label("MediaWiki index.php: ",80,10) .append_TextBox(""); MediaWikiUrlCheck_Label = config_Panel.add_Link("Check MediaWiki Urls", 110,128,checkMediaWikiUrls) .append_Label("") .autoSize(); MediaWikiUrl_TextBox.align_Right(config_Panel).leftAdd(2).widthAdd(-7); MediaWiki_API_php_TextBox.align_Right(config_Panel).widthAdd(-5); MediaWiki_Index_php_TextBox.align_Right(config_Panel).widthAdd(-5); //loginDetails_Panel loginDetails_Panel.add_Label("A) Login using local config file:",20,10); SecretsFile_TextBox = loginDetails_Panel.add_TextBox(40,102,false) .set_Text(defaultSecretsFolder.pathCombine(defaultSecretsFile)) .onEnter(loadCredentials); Credential_ComboBox = loginDetails_Panel.add_ComboBox(60,102).width(220).sorted(); Credential_ComboBox.onSelection<Credential>(loadCredentialDetails); loginDetails_Panel.add_Label("B) Login using username & password: "******"Username:"******""); Password_TextBox = loginDetails_Panel.add_Label("Password: "******"") .isPasswordField(); SecretsFile_TextBox.align_Right(loginDetails_Panel).widthAdd(-40); SecretsFile_TextBox.append_Control<Button>() .set_Text("...") .width(30) .heightAdd(-2) .anchor_TopRight() .onClick(()=>{ var file = this.askUserForFileToOpen(defaultSecretsFolder,"Xml Files | *.xml"); if (file.valid()) { SecretsFile_TextBox.set_Text(file); loadCredentials(file); } });; UserName_TextBox.width(200); Password_TextBox.width(200); LoggedInStatus_Label = Password_TextBox.append_Link("Login", login) .topAdd(5) .append_Label("") .autoSize(); loadCredentials(SecretsFile_TextBox.get_Text()); loadDefaultMediaWikiEngines(); return this; }
public ascx_MediaWiki_PageEditor_Simple buildGui(O2MediaWikiAPI wikiApi) { try { WikiApi = wikiApi; var topPanel = this.add_Panel(); var horizontalSplitterPosition = topPanel.height() / 2; var verticalSplitterPosition = topPanel.width() / 2; var controls = topPanel.add_1x2("WikiText", "Preview", "Live (Current page)", false, horizontalSplitterPosition, verticalSplitterPosition); WikiTextEditor = controls[0].add_RichTextBox(); BrowserPreview = controls[1].add_WebBrowser(); BrowserCurrent = controls[2].add_WebBrowser(); WikiPage_TextBox = WikiTextEditor.insert_Above <TextBox>(50); var bottomPanel = WikiPage_TextBox.insert_Below <Panel>(30); RecentChangesComboBox = WikiPage_TextBox.insert_Right <Panel>(290) .add_Label("Recent Changes / Search") .top(3) .append_Control <ComboBox>() //.dropDownList() .width(150) .top(0); Action <string> populateRecentChangesComboBox = (filter) => { RecentChangesComboBox.backColor(Color.LightPink); O2Thread.mtaThread( () => { RecentChangesComboBox.clear(); if (filter.valid().isFalse()) { RecentChangesComboBox.add_Items(WikiApi.recentPages()); } else { RecentChangesComboBox.add_Items(WikiApi.pages(filter)); } RecentChangesComboBox.backColor(Color.White); }); }; RecentChangesComboBox.onSelection( () => { WikiPage_TextBox.set_Text(RecentChangesComboBox.get_Text()); loadCurrentPage(); }); RecentChangesComboBox.onEnter( (text) => { populateRecentChangesComboBox(text); }); //WikiTextEditor.insert_Below<ascx_LogViewer>(130); //default values BrowserPreview.silent(true); BrowserCurrent.silent(true); //WikiPage_TextBox.set_Text("Test"); // add controls with events CurrentPageUrl = BrowserCurrent.insert_Above <Panel>(20) .add_LabelAndComboBoxAndButton("Current page", "", "open", showInCurrentBrowser) .controls <ComboBox>(); CurrentPageUrl.insert_Item("www.google.com"); bottomPanel.add_Button("Load", 0).onClick( () => { loadCurrentPage(); }); bottomPanel.add_Button("Preview", 0, 100).onClick( () => { O2Thread.mtaThread( () => { BrowserPreview.set_Text(WikiApi.parseText(WikiTextEditor.get_Text(), true)); }); }); SaveButton = bottomPanel.add_Button("Save", 0, 200).onClick( () => { saveCurrentPage(); }); StatusLabel = SaveButton.append_Label("").topAdd(3).autoSize(); /*WikiTextEditor.onKeyPress(Keys.Enter, * (code)=>{ * O2Thread.mtaThread(()=> * { * BrowserPreview.set_Text(WikiApi.parseText(code,true)); * }); * });*/ WikiTextEditor.onKeyPress((key) => // add suport to paste images form Clipboard { if (key == (Keys.Control | Keys.V)) { return(pasteImageFromClipboard()); } return(false); }); WikiPage_TextBox.onEnter((text) => loadPage(text)); WikiTextEditor.add_ContextMenu() .add_MenuItem("Wrap with source tag (defaults to lang=csharp)", () => { WikiTextEditor.invokeOnThread( () => { WikiTextEditor.SelectedText = "<source lang=csharp>".line() + WikiTextEditor.SelectedText.line() + "</source>".line(); }); }); populateRecentChangesComboBox(""); } catch (Exception ex) { ex.log("in ascx_MediaWiki_PageEditor_Simple buildGui"); } return(this); }
public ascx_MediaWiki_Backup(O2MediaWikiAPI wikiApi) { buildGui(wikiApi); }