private void LoadTemplate() { try { if (Properties.Settings.Default.Template != null) { var configuration = new HtmlConfiguration() { CharacterClass = CharacterClass.Trickster, DeadsAhead = 7, ExperienceAhead = 45527983, ExperienceBehind = 199532, ExperiencePerHour = 9523741, Level = 95, Rank = 27, RankByClass = 6, }; var content = htmlService.GetTemplate(Properties.Settings.Default.Template); content = htmlService.UpdateContent(content, configuration, false); webBrowser.Document.Write(content); webBrowser.Refresh(); CheckIfOkButtonCanBeEnabled(); } } catch (IOException e) { logger.Error(e, "Failed to load template"); Properties.Settings.Default.Template = null; InitializeTemplates(); } }
public static HtmlConfiguration AddTwitterBootstrap(this HtmlConfiguration html) { html.Editors.Always.AddClass("form-control"); html.Selects.Always.AddClass("form-select"); html.Submits.Always.AddClass("btn btn-primary"); // cfg.FormSummaries.Always.AddClass("alert alert-danger d-none"); html.Editors.IfPropertyIs <bool>().ModifyWith(m => m.CurrentTag.Class("form-check-input")); html.TableHeader.IfPropertyIs <decimal>().AddClass("text-right"); html.TableHeader.IfPropertyIs <long>().AddClass("text-right"); html.TableHeader.IfPropertyIs <int>().AddClass("text-right"); html.Cells.IfPropertyIs <decimal>().AddClass("text-right"); html.Cells.IfPropertyIs <long>().AddClass("text-right"); html.Cells.IfPropertyIs <int>().AddClass("text-right"); html.Editors.IfPropertyHasAttribute <RadioAttribute>() .ModifyTag(tag => tag.Class("form-check-input")); html.Editors.IfPropertyHasAttribute <CheckboxAttribute>() .ModifyTag(tag => tag.Class("form-check-input")); html.ValidationMessages.Always.AddClass("invalid-feedback"); return(html); }
public static HtmlConfiguration AddMiruForm(this HtmlConfiguration html) { html.Forms.Always.ModifyTag(tag => { tag.Attr("data-controller", "form"); }); return(html); }
public static HtmlConfiguration AddMiruBootstrapLayout(this HtmlConfiguration cfg) { // only when form is horizontal? // cfg.Labels.Always.AddClass("col-md-4 col-form-label text-md-right"); cfg.Labels.IfPropertyIs <bool>().ModifyTag(tag => tag.Class("form-check-label")); return(cfg); }
public static HtmlConfiguration AddRequiredLabels(this HtmlConfiguration html) { html.Labels .If(x => x.FindModel().GetType().Implements <INoRequiredLabels>() == false && x.FindModel().GetType().IsRequestCommand() && new RequiredLabelModifier().Matches(x)) .ModifyWith <RequiredLabelModifier>(); return(html); }
public static HtmlConfiguration AddMiruFormSummary(this HtmlConfiguration html) { html.FormSummaries.Always.ModifyTag(tag => { tag.Attr("hidden", "hidden"); tag.Attr("data-controller", "form-summary"); }); return(html); }
public HtmlConfiguration BuildHtmlConfiguration(List <IEntry> entries, IEntry entry) { Contract.Requires(entry != null); var configuration = new HtmlConfiguration() { CharacterClass = entry.Character.CharacterClass, Level = entry.Character.Level, Rank = entry.Rank, }; if (entries != null) { var rankByClass = 1; var deadsAhead = 0; int start = entries.IndexOf(entry); var data = entries.ToArray(); for (var i = start - 1; i >= 0; i--) { if (data[i].Character.CharacterClass == entry.Character.CharacterClass) { rankByClass++; } if (characterService.IsEntryInvalid(data[i])) { deadsAhead++; } } configuration.RankByClass = rankByClass; configuration.DeadsAhead = deadsAhead; configuration.ExperienceAhead = characterService.GetExperienceAhead(entries, entry); configuration.ExperienceBehind = characterService.GetExperienceBehind(entries, entry); } return(configuration); }
public static HtmlConfiguration AddTwitterBootstrap(this HtmlConfiguration html) { // form summaries html.FormSummaries.Always.AddClass("alert alert-danger"); // tables html.TableHeader.IfPropertyIsNumber().AddClass("text-end"); html.TableHeader.IfPropertyIs <bool>().AddClass("text-center"); html.Cells.IfPropertyIs <bool>().AddClass("text-center"); html.Cells.IfPropertyIsNumber().AddClass("text-end"); // editors html.Editors.Always.AddClass("form-control"); html.Selects.Always.AddClass("form-select"); html.Submits.Always.AddClass("btn btn-primary"); html.Editors.IfPropertyIs <bool>() .ModifyWith(m => m.CurrentTag.Class("form-check-input")); html.Editors.IfPropertyHasAttribute <RadioAttribute>() .ModifyTag(tag => tag.Class("form-check-input")); html.Editors.IfPropertyHasAttribute <CheckboxAttribute>() .ModifyTag(tag => tag.Class("form-check-input")); // validations html.ValidationMessages.Always.AddClass("invalid-feedback"); // labels html.Labels.IfPropertyIs <bool>().ModifyTag(tag => tag.Class("form-check-label")); return(html); }
public static HtmlConfiguration AddTurbo(this HtmlConfiguration cfg) { // cfg.Forms.Always.Attr("data-turbo", "false"); cfg.Editors.Always.AddClass("form-control"); cfg.Selects.Always.AddClass("form-select"); cfg.Submits.Always.AddClass("btn btn-primary"); // cfg.FormSummaries.Always.AddClass("alert alert-danger d-none"); cfg.Editors.IfPropertyIs <bool>().ModifyWith(m => m.CurrentTag.Class("form-check-input")); cfg.TableHeader.IfPropertyIs <decimal>().AddClass("text-right"); cfg.TableHeader.IfPropertyIs <long>().AddClass("text-right"); cfg.TableHeader.IfPropertyIs <int>().AddClass("text-right"); cfg.Cells.IfPropertyIs <decimal>().AddClass("text-right"); cfg.Cells.IfPropertyIs <long>().AddClass("text-right"); cfg.Cells.IfPropertyIs <int>().AddClass("text-right"); return(cfg); }
public static void InputHiddenForIds(this HtmlConfiguration cfg) { cfg.Editors .IfPropertyNameEnds("Id") .ModifyWith(m => m.CurrentTag.Attr("type", "hidden")); }
public static void InputForPassword(this HtmlConfiguration cfg) { cfg.Editors .If(_ => _.Accessor.Name.Contains("Password")) .ModifyWith(m => m.CurrentTag.Attr("type", "password")); }
public static void InputForBoolean(this HtmlConfiguration cfg) { cfg.Editors .IfPropertyIs <bool>() .ModifyWith(m => m.CurrentTag.Attr("type", "checkbox")); }
private void LoadSettings() { pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); //if (Request.Form.Count > 0) //{ // submittedContent = Server.UrlDecode(Request.Form.ToString()); // this gets the full content of the post //} if (Request.Form["html"] != null) { submittedContent = Request.Form["html"]; //log.Info("html does = " + Request.Form["html"]); } //using (Stream s = Request.InputStream) //{ // using (StreamReader sr = new StreamReader(s)) // { // string requestBody = sr.ReadToEnd(); // requestBody = Server.UrlDecode(requestBody); // log.Info("requestBody was " + requestBody); // JObject jObj = JObject.Parse(requestBody); // submittedContent = (string)jObj["html"]; // } //} module = GetHtmlModule(); if (module == null) { return; } currentUser = SiteUtils.GetCurrentSiteUser(); repository = new HtmlRepository(); moduleSettings = ModuleSettings.GetModuleSettings(module.ModuleId); config = new HtmlConfiguration(moduleSettings); enableContentVersioning = config.EnableContentVersioning; if ((CurrentSite.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } userCanOnlyEditAsDraft = UserCanOnlyEditModuleAsDraft(module.ModuleId, HtmlContent.FeatureGuid); if ((WebConfigSettings.EnableContentWorkflow) && (CurrentSite.EnableContentWorkflow)) { workInProgress = ContentWorkflow.GetWorkInProgress(module.ModuleGuid); } if (workInProgress != null) { switch (workInProgress.Status) { case ContentWorkflowStatus.Draft: //there is a draft version currently available, therefore dont allow the non draft version to be edited: if (ViewMode == PageViewMode.WorkInProgress) { editDraft = true; } break; case ContentWorkflowStatus.ApprovalRejected: //rejected content - allow update as draft only if (ViewMode == PageViewMode.WorkInProgress) { editDraft = true; } break; case ContentWorkflowStatus.AwaitingApproval: //pending approval - dont allow any edited: // 2010-01-18 let editors update the draft if they want to before approving it. editDraft = !userCanOnlyEditAsDraft; break; } } //for (int i = 0; i < Request.QueryString.Count; i++) //{ // log.Info(Request.QueryString.GetKey(i) + " query param = " + Request.QueryString.Get(i)); //} //if (Request.Form["c"] != null) //{ // submittedContent = Request.Form["c"]; // log.Info("c does = " + Request.Form["c"]); //} // this shows that a large html content post appears as multiple params //for (int i = 0; i < Request.Form.Count; i++) //{ // log.Info(Request.Form.GetKey(i) + " form param " + i.ToInvariantString() + " = " + Request.Form.Get(i)); //} }
public string UpdateContent(string content, HtmlConfiguration configuration, bool setProgressToMax) { Contract.Requires(configuration != null); var document = parser.ParseDocument(content); SetNodeHtml(document, "class", configuration.CharacterClass.ToString()); SetNodeHtml(document, "level", $"{configuration.Level}"); SetNodeHtml(document, "rank-label", Strings.GlobalRank); SetNodeHtml(document, "rank-value", formatterService.GetFormattedNumber(configuration.Rank)); SetNodeHtml(document, "rank-by-class-label", Strings.ClassRank); var rankByClass = formatterService.GetFormattedNumber(configuration.RankByClass); if (rankByClass == "0") { rankByClass = "-"; } SetNodeHtml(document, "rank-by-class-value", rankByClass); SetNodeHtml(document, "experience-ahead-label", formatterService.GetFormattedNumber(configuration.Rank - 1)); var experienceAhead = formatterService.GetFormattedExperience(configuration.ExperienceAhead); if (experienceAhead.Length == 0) { experienceAhead = "-"; } ; SetNodeHtml(document, "experience-ahead-value", experienceAhead); SetNodeHtml(document, "experience-behind-label", formatterService.GetFormattedNumber(configuration.Rank + 1)); var experienceBehind = formatterService.GetFormattedExperience(configuration.ExperienceBehind); if (experienceBehind.Length == 0) { experienceBehind = "-"; } ; SetNodeHtml(document, "experience-behind-value", experienceBehind); SetNodeHtml(document, "experience-per-hour-label", Strings.ExperiencePerHour); var experiencePerHour = formatterService.GetFormattedExperience(configuration.ExperiencePerHour); if (experiencePerHour.Length == 0) { experiencePerHour = "-"; } ; SetNodeHtml(document, "experience-per-hour-value", experiencePerHour); SetNodeHtml(document, "deads-ahead-label", Strings.DeadsAhead); var deadsAhead = formatterService.GetFormattedNumber(configuration.DeadsAhead); if (deadsAhead == "0") { deadsAhead = "-"; } SetNodeHtml(document, "deads-ahead-value", deadsAhead); if (setProgressToMax) { SetProgressBarToMaxValue(document); } var result = document.DocumentElement.OuterHtml; document.Dispose(); return(result); }