public WebRequest Session() { WebRequest wr = new WebRequest(); Scaffold scaffold = new Scaffold(R, "/app/debug/debug.html", "", new string[] { "body" }); string jsonVs = R.Util.Str.GetString(R.Session["viewstates"]); string jsonUser = R.Util.Serializer.WriteObjectAsString(R.User); ViewStates vss = (ViewStates)R.Util.Serializer.ReadObject(jsonVs, Type.GetType("Rennder.ViewStates")); List<string> body = new List<string>(); double totalLen = R.Session["viewstates"].Length; double len = 0; body.Add("<h1>User (" + (jsonUser.Length * 2) + " bytes)</h1>" + jsonUser); body.Add("<h1>Viewstates (" + totalLen.ToString("N0") + " bytes)</h1>" + jsonVs); foreach(structViewStateInfo item in vss.Views) { ViewState vssItem = (ViewState)R.Util.Serializer.ReadObject(R.Util.Str.GetString(R.Session["viewstate-" + item.id]), Type.GetType("Rennder.ViewState")); len = R.Session["viewstate-" + item.id].Length; totalLen += len; body.Add("<h1>Viewstate \"" + item.id + "\" (" + len.ToString("N0") + " bytes)</h1>" + R.Util.Serializer.WriteObjectAsString(vssItem)); } body.Add("<h1>Total Memory Used: " + totalLen.ToString("N0") + " bytes"); scaffold.Data["body"] = ("<pre>" + string.Join("</pre></div><div><pre>", body.ToArray()).Replace("\\\"", "\"").Replace("\\n", "").Replace("},", "},\n").Replace("],", "],\n") + "</pre>"); //finally, scaffold debug HTML wr.html = scaffold.Render(); return wr; }
public Inject Load() { if (R.isSessionLost() == true) { return lostInject(); } Inject response = new Inject(); //setup response response.element = ".winDashboardInterface > .content"; //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/interface.html", "", new string[] { "website-title", "apps-list", "menu-pages", "menu-photos", "menu-analytics", "menu-users", "menu-apps", "menu-settings"}); scaffold.Data["website-title"] = R.Page.websiteTitle; //check security //if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == true) { } scaffold.Data["menu-pages"] = "true"; scaffold.Data["menu-photos"] = "true"; scaffold.Data["menu-analytics"] = "true"; scaffold.Data["menu-users"] = "true"; scaffold.Data["menu-apps"] = "true"; scaffold.Data["menu-settings"] = "true"; //load list of apps into dashboard menu scaffold.Data["apps-list"] = ""; //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public static string RenderCard(Query.Models.Card card) { var useLayout = false; Scaffold cardscaff; if (card.name.IndexOf("----") == 0) { //separator cardscaff = new Scaffold("/Views/Card/Kanban/Type/separator.html"); } else if (card.name.IndexOf("# ") == 0) { //header cardscaff = new Scaffold("/Views/Card/Kanban/Type/header.html"); cardscaff.Data["name"] = card.name.TrimStart(new char[] { '#', ' ' }); } else { //card cardscaff = new Scaffold("/Views/Card/Kanban/Type/card.html"); useLayout = true; } if (useLayout == true) { //load card custom design var scaffold = new Scaffold("/Views/Card/Kanban/Layout/" + card.layout.ToString() + ".html"); if (card.name.IndexOf("[x]") == 0 || card.name.IndexOf("[X]") == 0) { var checkmark = new Scaffold("/Views/Card/Kanban/Elements/checkmark.html"); scaffold.Data["name"] = checkmark.Render() + card.name.Substring(4); } else if (card.name.IndexOf("[!]") == 0 || card.name.IndexOf("[!]") == 0) { var checkmark = new Scaffold("/Views/Card/Kanban/Elements/warning.html"); scaffold.Data["name"] = checkmark.Render() + card.name.Substring(4); } else { scaffold.Data["name"] = card.name; } scaffold.Data["colors"] = ""; //render custom design inside card container cardscaff.Data["layout"] = scaffold.Render(); } //load card container cardscaff.Data["id"] = card.cardId.ToString(); //render card container return(cardscaff.Render()); }
public string AccessDenied(bool htmlOutput = true, Page login = null) { if (htmlOutput == true) { if (!CheckSecurity() && login != null) { return(login.Render(new string[] { })); } var scaffold = new Scaffold("/access-denied.html", S.Server.Scaffold); return(scaffold.Render()); } return("Access Denied"); }
public string GetList(int bookId, int start = 1, int length = 50, SortType sort = 0, bool includeCount = false) { if (!CheckSecurity()) { return(AccessDenied()); } var html = new StringBuilder(); var entries = new Scaffold("/Services/Entries/entries.html", S.Server.Scaffold); var item = new Scaffold("/Services/Entries/list-item.html", S.Server.Scaffold); var chapter = new Scaffold("/Services/Entries/chapter.html", S.Server.Scaffold); var books = new Query.Books(S.Server.sqlConnectionString); var query = new Query.Entries(S.Server.sqlConnectionString); var chapters = new Query.Chapters(S.Server.sqlConnectionString); var chapterlist = chapters.GetList(bookId); var list = query.GetList(S.User.userId, bookId, start, length, (int)sort); var chapterInc = -1; var book = books.GetDetails(S.User.userId, bookId); entries.Data["book-title"] = book.title; if (list.Count > 0) { list.ForEach((Query.Models.Entry entry) => { if (chapterInc != entry.chapter && sort == 0) { if (entry.chapter > 0) { //display chapter chapter.Data["chapter"] = "Chapter " + entry.chapter.ToString() + ": " + chapterlist.Find((Query.Models.Chapter c) => { return(c.chapter == entry.chapter); }).title; html.Append(chapter.Render()); } chapterInc = entry.chapter; } item.Data["id"] = entry.entryId.ToString(); item.Data["title"] = entry.title; item.Data["summary"] = entry.summary; item.Data["date-created"] = entry.datecreated.ToString("d/MM/yyyy"); html.Append(item.Render()); }); entries.Data["entries"] = html.ToString(); } else { html.Append(S.Server.LoadFileFromCache("/Services/Entries/no-entries.html")); } return((includeCount == true ? list.Count + "|" : "") + entries.Render()); }
public override string Render(string[] path, string body = "", object metadata = null) { if (User.userId == 0) { //load login page var page = new Login(context); return(page.Render(path)); } //load boards list var scaffold = new Scaffold("/Views/Boards/boards.html", Server.Scaffold); var query = new Query.Boards(); var boards = query.GetList(User.userId); var html = new StringBuilder(); var item = new Scaffold("/Views/Boards/list-item.html", Server.Scaffold); boards.ForEach((Query.Models.Board b) => { item.Data["favorite"] = b.favorite ? "1" : ""; item.Data["name"] = b.name; item.Data["color"] = "#" + b.color; item.Data["extra"] = b.favorite ? "fav" : ""; item.Data["id"] = b.boardId.ToString(); item.Data["type"] = b.type.ToString(); item.Data["url"] = Uri.EscapeUriString("/board/" + b.boardId + "/" + b.name.Replace(" ", "-").ToLower()); html.Append(item.Render()); }); scaffold.Data["list"] = html.ToString(); //load teams list var queryTeams = new Query.Teams(); var teams = queryTeams.GetList(User.userId); html = new StringBuilder(); teams.ForEach((Query.Models.Team t) => { html.Append("<option value=\"" + t.teamId + "\">" + t.name + "</option>\n"); }); scaffold.Data["team-options"] = html.ToString(); //load page resources AddScript("/js/dashboard.js"); AddCSS("/css/dashboard.css"); //load header LoadHeader(ref scaffold, false); //render page return(base.Render(path, scaffold.Render())); }
public structResponse PageSettings(int pageId) { if (R.isSessionLost() == true) { return(lostResponse()); } structResponse response = new structResponse(); response.window = "PageSettings"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return(response); } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/pagesettings.html", "", new string[] { "url", "page-title", "description", "secure", "page-type", "type" }); string parentTitle = ""; SqlReader reader = R.Page.SqlPage.GetParentInfo(pageId); if (reader.Rows.Count > 0) { reader.Read(); parentTitle = reader.Get("parenttitle"); scaffold.Data["page-title"] = R.Util.Str.GetPageTitle(reader.Get("title")); if (reader.GetBool("security") == true) { scaffold.Data["secure"] = "true"; } scaffold.Data["description"] = reader.Get("description"); } scaffold.Data["url"] = R.Page.Url.host.Replace("http://", "").Replace("https://", "") + scaffold.Data["page-title"].Replace(" ", "-") + "/"; if (!string.IsNullOrEmpty(parentTitle)) { parentTitle = R.Util.Str.GetPageTitle(parentTitle); scaffold.Data["page-type"] = "true"; scaffold.Data["type"] = "A sub-page for \"" + parentTitle + "\""; } //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return(response); }
public override string Render(string[] path, string body = "", object metadata = null) { if (path[1].ToLower() == "authenticate") { var scaffold = new Scaffold("/Views/Google/SignIn/signin.html"); title = "Gmaster - Authenticate with Google"; AddScript("https://apis.google.com/js/client:platform.js"); AddScript("/js/views/google/signin/signin.js"); scaffold["clientId"] = Settings.Google.OAuth2.clientId; scaffold["extensionId"] = Settings.Google.Chrome.Extension.Id; scaffold["email"] = context.Request.Query["emailaddr"].ToString(); return(RenderModal(scaffold.Render())); } return(Error404()); }
public virtual string Render(string[] path, string body = "", object metadata = null) { //renders HTML layout var scaffold = new Scaffold("/layout.html", S.Server.Scaffold); scaffold.Data["title"] = title; scaffold.Data["description"] = description; scaffold.Data["head-css"] = headCss; scaffold.Data["favicon"] = favicon; scaffold.Data["body"] = body; //add initialization script scaffold.Data["scripts"] = scripts; return(scaffold.Render()); }
public virtual string Render(string[] path, string body = "", object metadata = null) { //renders HTML layout var scaffold = new Scaffold("/Views/Shared/layout.html"); scaffold["title"] = title; scaffold["description"] = description; scaffold["head-css"] = css.ToString(); scaffold["favicon"] = favicon; scaffold["body"] = body; //add initialization script scaffold["scripts"] = scripts.ToString(); return(scaffold.Render()); }
public string RenderModal(string body = "") { //renders HTML layout var scaffold = new Scaffold("/Views/Shared/layout_modal.html"); scaffold["title"] = title; scaffold["description"] = description; scaffold["head-css"] = css.ToString(); scaffold["favicon"] = favicon; scaffold["body"] = body; //add initialization script scaffold["scripts"] = scripts.ToString(); return(scaffold.Render()); }
public string Create(int subscriptionId, string entryemail, string firstname, string lastname) { if (!HasPermissions()) { return(Error()); } //get accessable subscriptions for user var subscriptions = Query.Subscriptions.GetSubscriptions(User.userId); var subscription = subscriptions.Where(a => a.subscriptionId == subscriptionId).FirstOrDefault(); if (subscription != null) { //check if user has permission to create new addressbook entries if (subscription.roleType <= Query.Models.RoleType.contributer) { //check if address already exists in team's address book if (Query.AddressBookEntries.Exists(subscription.teamId, entryemail) == true) { return(Error("Email address already exists in address book")); } var addressId = Query.AddressBookEntries.Create(new Query.Models.AddressBookEntry() { teamId = subscription.teamId, email = entryemail, firstname = firstname, lastname = lastname }); //render addressbook entry HTML var entryItem = new Scaffold("/Views/Subscription/addressbook/entry-item.html"); entryItem.Bind(new { entry = new { addressid = addressId, email = entryemail, firstname, lastname } }); entryItem.Show("is-new"); return(JsonResponse(new { addressId = addressId.ToString(), html = entryItem.Render() })); } } return(Error("You do not have permission to create new address book entries")); }
public override string Render(string[] path, string body = "", object metadata = null) { if (path[1].ToLower() == "stripe") { //Stripe payment var scaffold = new Scaffold("/Views/Google/Pay/stripe.html"); var users = int.Parse(parameters["users"]); var planId = int.Parse(parameters["planId"]); scaffold["extensionId"] = Settings.Google.Chrome.Extension.Id; scaffold["devkey"] = parameters["key"]; scaffold["email"] = parameters["email"]; scaffold["stripe-key"] = Settings.Stripe.Keys.publicKey; //get price based on users var plan = Query.Plans.GetList().Where(p => p.planId == planId).First(); scaffold["price"] = (plan.price * users).ToString("C"); scaffold["schedule"] = plan.schedule == Query.Models.PaySchedule.monthly ? "month" : "year"; title = "Gmaster - Secure Pay with Stripe"; AddScript("https://js.stripe.com/v3/"); AddScript("/js/views/google/pay/stripe.js"); return(RenderModal(scaffold.Render())); } else if (path[1].ToLower() == "stripe-overdue") { //Stripe overdue payment var price = decimal.Parse(parameters["price"]); var scaffold = new Scaffold("/Views/Google/Pay/stripe-overdue.html"); scaffold["extensionId"] = Settings.Google.Chrome.Extension.Id; scaffold["devkey"] = parameters["key"]; scaffold["email"] = parameters["email"]; scaffold["stripe-key"] = Settings.Stripe.Keys.publicKey; //get price based on users scaffold["price"] = price.ToString("C"); title = "Gmaster - Secure Pay with Stripe"; AddScript("https://js.stripe.com/v3/"); AddScript("/js/views/google/pay/stripe-overdue.js"); return(RenderModal(scaffold.Render())); } else if (path[1].ToLower() == "paypal") { //PayPal payment } return(Error404()); }
private string GetTeams(int subscriptionId) { var subscription = Query.Subscriptions.GetInfo(subscriptionId); if (subscription != null) { var scaffold = new Scaffold("/Views/Subscription/team.html"); scaffold["team-name"] = subscription.teamName; if (subscription.roleType <= Query.Models.RoleType.moderator) { var members = Query.TeamMembers.GetList(subscription.teamId).OrderBy(a => a.roleType).ThenBy(a => a.email).ToList(); if (members != null) { var memberItem = new Scaffold("/Views/Subscription/team/member-item.html"); var html = new StringBuilder(); if (members.Count > 0) { scaffold["total-members"] = members.Count.ToString(); foreach (var member in members) { memberItem.Bind(new { member = new { member.email, roletype = member.roleType.ToString(), member.name } }); html.Append(memberItem.Render()); } scaffold["members"] = html.ToString(); } } } if (scaffold["members"] == null) { scaffold["members"] = Server.LoadFileFromCache("/Views/Subscription/team/no-members.html"); } return(scaffold.Render()); } else { return(Error("Subscription does not exist")); } }
private string GetCampaigns(int subscriptionId, int start = 1, int length = 20, string search = "") { var subscription = Query.Subscriptions.GetInfo(subscriptionId); if (subscription != null) { var campaigns = Query.Campaigns.GetList(subscription.teamId, start, length, search); var scaffold = new Scaffold("/Views/Subscription/campaigns.html"); var item = new Scaffold("/Views/Subscription/campaigns/campaign-item.html"); scaffold["team-name"] = subscription.teamName; if (campaigns.Count > 0) { var html = new StringBuilder(); foreach (var campaign in campaigns) { item.Bind(new { campaign = new { campaign.campaignId, campaign.label, status = campaign.status == 0 ? "New" : campaign.status == 1 ? "Running" : campaign.status == 2 ? "Ended" : "Unknown", draftonly = campaign.draftsOnly == true ? "Drafts Only" : "Customer Emails", datecreated = campaign.datecreated.ToString("MM-dd-yyyy") } }); html.Append(item.Render()); } scaffold["campaigns"] = html.ToString(); } else { scaffold["campaigns"] = Server.LoadFileFromCache("/Views/Subscription/campaigns/no-campaigns.html"); } return(scaffold.Render()); } else { return(Error("Subscription does not exist")); } }
public string View() { //load partial view var scaffold = new Scaffold("/Views/Profile/profile.html"); //bind model scaffold.Bind(new Header() { User = new Models.Profile() { Name = User.name, Username = User.displayName, Image = User.photo ? "/content/users/" + User.userId + ".jpg" : "/images/nophoto.jpg" } }); //render partial view return(RenderContent(User.name, "icon-user", scaffold.Render())); }
public string GetBooksList() { if (!CheckSecurity()) { return(AccessDenied()); } var html = new StringBuilder(); var scaffold = new Scaffold("/Services/Books/list-item.html", S.Server.Scaffold); var query = new Query.Books(S.Server.sqlConnectionString); var books = query.GetList(S.User.userId); books.ForEach((Query.Models.Book book) => { scaffold.Data["id"] = book.bookId.ToString(); scaffold.Data["title"] = book.title; html.Append(scaffold.Render()); }); return(html.ToString()); }
private string GetAddressBook(int subscriptionId, int start = 1, int length = 50, Query.AddressBookEntries.SortList sort = Query.AddressBookEntries.SortList.email, string search = "") { var subscription = Query.Subscriptions.GetInfo(subscriptionId); if (subscription != null) { var addresses = Query.AddressBookEntries.GetList(subscription.teamId, start, length, sort, search); var scaffold = new Scaffold("/Views/Subscription/addressbook.html"); scaffold["team-name"] = subscription.teamName; //load svg icons scaffold["svg"] = Server.LoadFileFromCache("/Content/Icons/iconEdit.svg"); if (addresses != null) { var entryItem = new Scaffold("/Views/Subscription/addressbook/entry-item.html"); var html = new StringBuilder(); if (addresses.Count > 0) { foreach (var entry in addresses) { entryItem.Bind(new { entry }); html.Append(entryItem.Render()); } scaffold["entries"] = html.ToString(); } else { scaffold["entries"] = Server.LoadFileFromCache("/Views/Subscription/addressbook/no-entries.html"); } } else { scaffold["entries"] = Server.LoadFileFromCache("/Views/Subscription/addressbook/no-entries.html"); } return(scaffold.Render()); } else { return(Error("Subscription does not exist")); } }
public static Tuple <Query.Models.Card, string> Details(int boardId, int cardId) { try { var card = Query.Cards.GetDetails(boardId, cardId); var scaffold = new Scaffold("/Views/Card/Kanban/details.html"); scaffold.Data["list-name"] = card.listName; scaffold.Data["description"] = card.description; scaffold.Data["no-description"] = card.description.Length > 0 ? "hide" : ""; scaffold.Data["has-description"] = card.description.Length <= 0 ? "hide" : ""; scaffold.Data["archive-class"] = card.archived ? "hide" : ""; scaffold.Data["restore-class"] = card.archived ? "" : "hide"; scaffold.Data["delete-class"] = card.archived ? "" : "hide"; return(new Tuple <Query.Models.Card, string>(card, scaffold.Render())); } catch (Exception) { throw new ServiceErrorException("Error loading card details"); } }
public string LoadTrash() { if (!CheckSecurity()) { return(AccessDenied()); } var scaffold = new Scaffold("/Services/Trash/trash.html", S.Server.Scaffold); var scaffBook = new Scaffold("/Services/Trash/trash-book.html", S.Server.Scaffold); scaffBook.Child("checkbox").Data["label"] = "Book Magic!"; scaffold.Data["books"] = scaffBook.Render(); return(Inject(new Response() { selector = ".trash", html = scaffold.Render() })); }
public static string RenderCard(Query.Models.Card card) { var type = "default"; var cardscaff = new Scaffold("/Views/Card/Kanban/card.html"); //load card custom design var scaffold = new Scaffold("/Views/Card/Kanban/Card/" + type + ".html"); scaffold.Data["title"] = card.name; scaffold.Data["colors"] = ""; //load card container cardscaff.Data["id"] = card.cardId.ToString(); //render custom design inside card container cardscaff.Data["layout"] = scaffold.Render(); //render card container return(cardscaff.Render()); }
public static string RenderList(Query.Models.List list, List <Query.Models.Card> cards) { //load html templates var scaffold = new Scaffold("/Views/List/Kanban/list.html"); var html = new StringBuilder(); //set up each card foreach (var card in cards) { html.Append(Card.Kanban.RenderCard(card)); } //set up list scaffold.Data["id"] = list.listId.ToString(); scaffold.Data["title"] = list.name; scaffold.Data["items"] = html.ToString(); //render list return(scaffold.Render()); }
public Inject LoadPages() { if (R.isSessionLost() == true) { return lostInject(); } Inject response = new Inject(); //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffold Scaffold scaffold = new Scaffold(R, "/app/dashboard/pages.html", "", new string[] { "page-title", "page-list", "help" }); scaffold.Data["page-title"] = ""; scaffold.Data["page-list"] = LoadPagesList(); scaffold.Data["help"] = RenderHelpColumn("/App/Help/dashboard/pages.html"); //setup response response.element = ".winWebPages > .content"; response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public Inject Load() { if (R.isSessionLost() == true) { return lostInject(); } Inject response = new Inject(); //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/timeline", 0) == false) { return response; } //setup response response.element = ".winDashboardTimeline > .content"; //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/timeline.html", "", new string[] { "test" }); scaffold.Data["test"] = R.Page.websiteTitle; //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public string Index(int page = 1, int length = 50, int sort = 0, string search = "") { if (!HasPermissions()) { return(Error()); } //get accessable subscriptions for user var subscriptions = Query.Subscriptions.GetSubscriptions(User.userId); var subscription = subscriptions.Where(a => a.userId == User.userId).FirstOrDefault(); if (subscription != null) { var entries = Query.AddressBookEntries.GetList(User.userId, page, length, (Query.AddressBookEntries.SortList)sort, search); var entryItem = new Scaffold("/Views/Subscription/addressbook/entry-item.html"); var html = new StringBuilder(); foreach (var entry in entries) { entryItem.Bind(new { entry = new { entry.addressId, entry.email, entry.firstname, entry.lastname } }); html.Append(entryItem.Render()); } return(JsonResponse(new { total = entries.Count.ToString(), html = html.ToString() })); } return(Error("You do not have permission to view address book entries")); }
public override string Render(string[] path, string body = "", object metadata = null) { var scaffold = new Scaffold("/Views/Home/home.html", Server.Scaffold); if (User.userId > 0) { scaffold.Data["user"] = "******"; scaffold.Data["username"] = User.name; } else { scaffold.Data["no-user"] = "******"; } //load header since it was included in home.html LoadHeader(ref scaffold); //add CSS file for home AddCSS("/css/views/home/home.css"); //finally, render base page layout with home page return(base.Render(path, scaffold.Render(), metadata)); }
public structResponse Components() { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "Components"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/editor/components.html", "", new string[] { "components", "categories" }); //get a list of components scaffold.Data["components"] = GetComponentsList(); //get a list of categories scaffold.Data["categories"] = GetComponentCategories(); //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public Inject Load() { if (R.isSessionLost() == true) { return(lostInject()); } Inject response = new Inject(); //setup response response.element = ".winDashboardInterface > .content"; //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/interface.html", "", new string[] { "website-title", "apps-list", "menu-pages", "menu-photos", "menu-analytics", "menu-users", "menu-apps", "menu-settings" }); scaffold.Data["website-title"] = R.Page.websiteTitle; //check security //if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == true) { } scaffold.Data["menu-pages"] = "true"; scaffold.Data["menu-photos"] = "true"; scaffold.Data["menu-analytics"] = "true"; scaffold.Data["menu-users"] = "true"; scaffold.Data["menu-apps"] = "true"; scaffold.Data["menu-settings"] = "true"; //load list of apps into dashboard menu scaffold.Data["apps-list"] = ""; //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return(response); }
private string renderMenuItem(Scaffold scaff, structMenuItem item, int level = 0) { var gutter = ""; var subs = new StringBuilder(); for (var x = 0; x < level; x++) { gutter += "<div class=\"gutter\"></div>"; } if (item.submenu != null) { if(item.submenu.Count > 0) { foreach(var sub in item.submenu) { subs.Append(renderMenuItem(scaff, sub, level + 1)); } } } scaff.Data["label"] = item.label; scaff.Data["href"] = item.href == "" ? "javascript:" : item.href; scaff.Data["icon"] = item.icon; scaff.Data["gutter"] = gutter; if(subs.Length > 0) { scaff.Data["target"] = " target=\"_self\""; scaff.Data["submenu"] = "<div class=\"row submenu\"><ul class=\"menu\">" + subs.ToString() + "</ul></div>"; } else { scaff.Data["submenu"] = ""; } return scaff.Render(); }
public App(Server server, HttpContext context) { //the Pipeline.App is simply the first page request for a Rennder website. //Scaffold the HTML, load the Rennder Core, then load a web page. R = new Core(server, context, "", "app"); R.App = this; R.isFirstLoad = true; //setup scaffolding variables scaffold = new Scaffold(R, "/app/pipeline/app.html", "", new string[] { "title", "description", "facebook", "theme-css", "website-css", "editor-css", "head-css", "favicon", "font-faces", "body-class", "custom-css", "background", "editor","webpage-class", "body-sides","body", "scripts", "https-url", "http-url"}); //default favicon scaffold.Data["favicon"] = "/images/favicon.gif"; //check for web bots such as gogle bot string agent = context.Request.Headers["User-Agent"].ToLower(); if (agent.Contains("bot") | agent.Contains("crawl") | agent.Contains("spider")) { R.Page.useAJAX = false; R.Page.isBot = true; } //check for mobile agent if (agent.Contains("mobile") | agent.Contains("blackberry") | agent.Contains("android") | agent.Contains("symbian") | agent.Contains("windows ce") | agent.Contains("fennec") | agent.Contains("phone") | agent.Contains("iemobile") | agent.Contains("iris") | agent.Contains("midp") | agent.Contains("minimo") | agent.Contains("kindle") | agent.Contains("opera mini") | agent.Contains("opera mobi") | agent.Contains("ericsson") | agent.Contains("iphone") | agent.Contains("ipad")) { R.Page.isMobile = true; } //get browser type scaffold.Data["body-class"] = R.Util.GetBrowserType(); //parse URL R.Page.GetPageUrl(); if(R.isLocal == true) { scaffold.Data["https-url"] = "http://" + R.Page.Url.host.Replace("/",""); }else { scaffold.Data["https-url"] = "https://" + R.Page.Url.host.Replace("/", ""); } //get page Info SqlReader reader = R.Page.GetPageInfoFromUrlPath(); if(reader.Rows.Count > 0) { //load initial web page R.Page.LoadPageInfo(reader); if(R.Page.pageId > 0) { string js = ""; //load page R.Page.LoadPage(R.Page.pageFolder + "page.xml", 1, R.Page.pageId, R.Page.pageTitle); //load website.css scaffold.Data["website-css"] = "/content/websites/" + R.Page.websiteId + "/website.css?v=" + R.Version; //load iframe resize code, so if a Rennder web page is loaded within an iframe, it can communicate //with the parent web page whenever the iframe resizes. if (R.Request.Query[ "ifr"] == "1") { js += "var frameSize = 0;" + "function checkResize(){" + "var wurl = \"" + R.Request.Query["w"] + "\";" + "if(frameHeight != frameSize){" + "parent.postMessage(\"resize|\"+(frameHeight),wurl);" + "}" + "frameSize = frameHeight;" + "setTimeout(\"checkResize();\",1000);" + "}" + "checkResize();"; R.Page.isEditable = false; } //register app javascript js += "R.init(" + R.Page.useAJAX.ToString().ToLower() + ",'" + R.ViewStateId + "',R.page.title);"; R.Page.RegisterJS("app", js); //display Page Editor if (R.Page.isEditable == true) { Editor editor = new Editor(R); string[] result = editor.LoadEditor(); scaffold.Data["editor"] = result[0]; R.Page.RegisterJS("editor", result[1]); } //setup scripts string scripts; if(R.isLocal == true) { scripts = "<script type=\"text/javascript\" src=\"/scripts/utility/jquery-2.1.3.min.js\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/core/global.js\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/core/fixes.js\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/core/rml.js\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/core/view.js\"></script>\n" + //"<script type=\"text/javascript\" src=\"/scripts/core/responsive.js\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/utility.js?v=" + R.Version + "\"></script>"; if(R.Page.isEditable == true) { scripts += "<script type=\"text/javascript\" src=\"/scripts/core/editor.js?v=" + R.Version + "\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/rangy/rangy-compiled.js?v=" + R.Version + "\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/utility/dropzone.js?v=" + R.Version + "\"></script>\n" + "<script type=\"text/javascript\">R.editor.load();</script>"; } } else { scripts = "<script type=\"text/javascript\" src=\"/scripts/rennder.js?v=" + R.Version + "\"></script>\n" + "<script type=\"text/javascript\" src=\"/scripts/utility.js?v=" + R.Version + "\"></script>"; if (R.Page.isEditable == true) { scripts += "<script type=\"text/javascript\" src=\"/scripts/editor.js?v=" + R.Version + "\"></script>\n" + "<script type=\"text/javascript\">R.editor.load();</script>"; } } if(R.Page.postJScode.Length > 0) { R.Page.postJS += string.Join("\n", R.Page.postJScode) + R.Page.postJSLast; } scaffold.Data["scripts"] = scripts + "\n" + "<script type=\"text/javascript\">" + R.Page.postJS + "</script>"; //render web page scaffold.Data["body"] = R.Page.Render(); } } //finally, scaffold Rennder platform HTML R.Response.ContentType = "text/html"; R.Response.WriteAsync(scaffold.Render()); //unload the core R.Unload(); }
public override string Render(string[] path, string body = "", object metadata = null) { var scaffold = new Scaffold("Views/Dashboard/dashboard.html"); return(base.Render(path, scaffold.Render(), metadata)); }
private void Setup(string file, string section = "", Dictionary <string, SerializedScaffold> cache = null, bool loadPartials = true) { SerializedScaffold cached = new SerializedScaffold() { Elements = new List <ScaffoldElement>() }; data = new ScaffoldData(); Section = section; if (cache == null && ScaffoldCache.cache != null) { cache = ScaffoldCache.cache; } if (cache != null) { if (cache.ContainsKey(file + '/' + section) == true) { cached = cache[file + '/' + section]; data = cached.Data; Elements = cached.Elements; Fields = cached.Fields; } } if (cached.Elements.Count == 0) { Elements = new List <ScaffoldElement>(); //try loading file from disk if (File.Exists(MapPath(file))) { HTML = File.ReadAllText(MapPath(file)); } if (HTML.Trim() == "") { return; } //next, find the group of code matching the scaffold section name if (section != "") { //find starting tag (optionally with arguments) //for example: {{button (name:submit, style:outline)}} int[] e = new int[3]; e[0] = HTML.IndexOf("{{" + section); if (e[0] >= 0) { e[1] = HTML.IndexOf("}", e[0]); if (e[1] - e[0] <= 256) { e[1] = HTML.IndexOf("{{/" + section + "}}", e[1]); } else { e[0] = -1; } } if (e[0] >= 0 & e[1] > (e[0] + section.Length + 4)) { e[2] = e[0] + 4 + section.Length; HTML = HTML.Substring(e[2], e[1] - e[2]); } } //get scaffold from html code var dirty = true; while (dirty == true) { dirty = false; var arr = HTML.Split("{{"); var i = 0; var s = 0; var c = 0; var u = 0; var u2 = 0; ScaffoldElement scaff; //types of scaffold elements // {{title}} = variable // {{address}} {{/address}} = block // {{button "/ui/button-medium"}} = HTML include // {{button "/ui/button" title:"save", onclick="do.this()"}} = HTML include with variables //first, load all HTML includes for (var x = 0; x < arr.Length; x++) { if (x == 0 && HTML.IndexOf(arr[x]) == 0) { arr[x] = "{!}" + arr[x]; } else if (arr[x].Trim() != "") { i = arr[x].IndexOf("}}"); s = arr[x].IndexOf(':'); u = arr[x].IndexOf('"'); if (i > 0 && u > 0 && u < i - 2 && (s == -1 || s > u) && loadPartials == true) { //read partial include & load HTML from another file scaff.Name = arr[x].Substring(0, u - 1).Trim(); u2 = arr[x].IndexOf('"', u + 2); var partial_path = arr[x].Substring(u + 1, u2 - u - 1); //load the scaffold HTML var newScaff = new Scaffold(partial_path, "", cache); //check for HTML include variables if (i - u2 > 0) { var vars = arr[x].Substring(u2 + 1, i - (u2 + 1)).Trim(); if (vars.IndexOf(":") > 0) { //HTML include variables exist try { var kv = (Dictionary <string, string>)JsonConvert.DeserializeObject("{" + vars + "}", typeof(Dictionary <string, string>)); foreach (var kvp in kv) { newScaff[kvp.Key] = kvp.Value; } } catch (Exception) { } } } //rename child scaffold variables with a prefix of "scaff.name-" var ht = newScaff.Render(newScaff.data, false); var y = 0; var prefix = scaff.Name + "-"; while (y >= 0) { y = ht.IndexOf("{{", y); if (y < 0) { break; } if (ht.Substring(y + 2, 1) == "/") { ht = ht.Substring(0, y + 3) + prefix + ht.Substring(y + 3); } else { ht = ht.Substring(0, y + 2) + prefix + ht.Substring(y + 2); } y += 2; } Partials.Add(new ScaffoldPartial() { Name = scaff.Name, Path = partial_path, Prefix = prefix }); Partials.AddRange(newScaff.Partials.Select(a => { var partial = a; partial.Prefix = prefix + partial.Prefix; return(partial); }) ); arr[x] = "{!}" + ht + arr[x].Substring(i + 2); HTML = JoinHTML(arr); dirty = true; //HTML is dirty, restart loop break; } } } if (dirty == false) { //next, process variables & blocks for (var x = 0; x < arr.Length; x++) { if (x == 0 && HTML.IndexOf(arr[0].Substring(3)) == 0)//skip "{!}" using substring { //first element is HTML only Elements.Add(new ScaffoldElement() { Htm = arr[x].Substring(3), Name = "" }); } else if (arr[x].Trim() != "") { i = arr[x].IndexOf("}}"); s = arr[x].IndexOf(' '); c = arr[x].IndexOf(':'); u = arr[x].IndexOf('"'); scaff = new ScaffoldElement(); if (i > 0) { scaff.Htm = arr[x].Substring(i + 2); //get variable name if (s < i && s > 0) { //found space scaff.Name = arr[x].Substring(0, s).Trim(); } else { //found tag end scaff.Name = arr[x].Substring(0, i).Trim(); } if (scaff.Name.IndexOf('/') < 0) { if (Fields.ContainsKey(scaff.Name)) { //add element index to existing field var field = Fields[scaff.Name]; Fields[scaff.Name] = field.Append(Elements.Count).ToArray(); } else { //add field with element index Fields.Add(scaff.Name, new int[] { Elements.Count }); } } //get optional path stored within variable tag (if exists) //e.g. {{my-component "list"}} if (u > 0 && u < i - 2 && (c == -1 || c > u)) { u2 = arr[x].IndexOf('"', u + 2); if (i - u2 > 0) { var data = arr[x].Substring(u + 1, u2 - u - 1); scaff.Path = data; } } else if (s < i && s > 0) { //get optional variables stored within tag var vars = arr[x].Substring(s + 1, i - s - 1); try { scaff.Vars = (Dictionary <string, string>)JsonConvert.DeserializeObject("{" + vars + "}", typeof(Dictionary <string, string>)); } catch (Exception) { } } } else { scaff.Name = ""; scaff.Htm = arr[x]; } Elements.Add(scaff); } } } } //cache the scaffold data if (cache != null) { var scaffold = new SerializedScaffold { Data = data, Elements = Elements, Fields = Fields, Partials = Partials }; cache.Add(file + '/' + section, scaffold); } } }
public override string Render(string[] path, string body = "", object metadata = null) { //check security if (!CheckSecurity()) { return(AccessDenied(true, new Login(context))); } //set up client-side dependencies AddCSS("/css/views/dashboard/dashboard.css"); AddScript("js/views/dashboard/dashboard.js"); //load the dashboard layout var scaffold = new Scaffold("/Views/Dashboard/dashboard.html", Server.Scaffold); var menuitem = new Scaffold("/Views/Dashboard/menu-item.html", Server.Scaffold); //load UI scaffold.Bind(new Header() { User = new Models.Profile() { Name = User.name, Username = User.displayName, Image = User.photo ? "/content/users/" + User.userId + ".jpg" : "/images/nophoto.jpg" } }); //load Options Menu UI var menuItems = new List <OptionsMenuItem>() { new OptionsMenuItem() { Id = "find-friends", Href = "Find-Friends", Icon = "icon-user", Label = "Find Friends" }, new OptionsMenuItem() { Id = "browse-communities", Href = "Browse-Communities", Icon = "icon-communities", Label = "Browse Communities" }, new OptionsMenuItem() { Id = "subscriptions", Href = "Subscriptions", Icon = "icon-subscriptions", Label = "My Subscriptions" }, new OptionsMenuItem() { Id = "subscribers", Href = "Subscribers", Icon = "icon-subscribers", Label = "Subscribers" } }; var optionMenu = new StringBuilder(); foreach (var item in menuItems) { menuitem.Bind(item); optionMenu.Append(menuitem.Render()); } scaffold.Data["options-menu"] = optionMenu.ToString(); scaffold.Data["body"] = body; //render base layout along with dashboard section return(base.Render(path, scaffold.Render())); }
public override string Render(string[] path, string body = "", object metadata = null) { if (!CheckSecurity()) { return(AccessDenied()); } //check security if (context.Request.QueryString.Value.Contains("?upload")) { //uploaded json file var files = context.Request.Form.Files; if (files.Count > 0) { Models.Trello.Board board = null; try { var ms = new MemoryStream(); files[0].CopyTo(ms); ms.Position = 0; var sr = new StreamReader(ms); var txt = sr.ReadToEnd(); board = (Models.Trello.Board)Serializer.ReadObject(txt.ToString(), typeof(Models.Trello.Board)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (board != null) { //show success page in iframe var scaffold = new Scaffold("/Views/Import/Trello/success.html"); scaffold.Data["name"] = board.name; //import board var merge = context.Request.QueryString.Value.Contains("merge"); var boardType = context.Request.Query.ContainsKey("type") ? int.Parse(context.Request.Query["type"]) : 0; var sort = 0; var sortCard = 0; var bgColor = board.prefs.backgroundColor != null ? board.prefs.backgroundColor : board.prefs.backgroundBottomColor; if (bgColor == null) { bgColor = board.prefs.backgroundTopColor; } var boardId = Query.Boards.Import(new Query.Models.Board() { name = board.name, archived = board.closed, color = bgColor, datecreated = board.actions.Last().date, lastmodified = board.dateLastActivity, ownerId = User.userId, favorite = board.pinned, security = (short)(board.prefs.permissionLevel == "private" ? 1 : 0), type = (Query.Models.Board.BoardType)boardType }, User.userId, merge); if (!Utility.Objects.IsEmpty(boardId)) { //import each list sort = 0; board.lists.ForEach((list) => { if (list.closed == false) { var listId = Query.Lists.Import(new Query.Models.List() { boardId = boardId, name = list.name, sort = sort }, merge); //import cards for each list sortCard = 0; board.cards.FindAll((c) => c.idList == list.id).ForEach((card) => { if (card.closed == false) { var cardDate = board.actions.FindLast((a) => a.data != null ? (a.data.card != null ? (a.data.card.id != null ? a.data.card.id == card.id : false) : false) : false); Query.Cards.Import(new Query.Models.Card() { boardId = boardId, archived = card.closed, colors = string.Join(",", card.labels.Select((a) => a.color).ToArray()), datecreated = cardDate != null ? cardDate.date : DateTime.Now, datedue = card.due, description = card.desc, listId = listId, name = card.name, sort = sortCard, layout = 0 }, merge); //import checklists for each card sortCard++; } }); sort++; } }); } return(scaffold.Render()); } else { return("Could not parse json file correctly"); } } //show upload form in iframe return(Server.LoadFileFromCache("/Views/Import/Trello/trello.html")); } else { //show upload form in iframe return(Server.LoadFileFromCache("/Views/Import/Trello/trello.html")); } }
public structResponse Dashboard() { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "Dashboard"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/editor/dashboard.html", "", new string[] { "website-title", "page-title", "pageid" }); scaffold.Data["website-title"] = R.Page.websiteTitle; scaffold.Data["page-title"] = R.Util.Str.GetPageTitle(R.Page.pageTitle); scaffold.Data["pageid"] = R.Page.pageId.ToString(); //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public static string RenderBoardsMenu(Datasilk.Request request) { Server Server = Server.Instance; var html = new StringBuilder(); var htm = new StringBuilder(); var section = new Scaffold("/Views/Boards/menu-section.html", Server.Scaffold); var item = new Scaffold("/Views/Boards/menu-item.html", Server.Scaffold); var query = new Query.Boards(); var boards = query.GetList(request.User.userId); var favs = boards.Where((a) => { return(a.favorite); }); var teams = boards.OrderBy((a) => { return(a.datecreated); }).Reverse().OrderBy((a) => { return(a.ownerId == request.User.userId); }); // Favorite Boards ////////////////////////////////////////// if (favs.Count() > 0) { section.Data["title"] = "Starred Boards"; section.Data["id"] = "favs"; section.Data["icon"] = "star-border-sm"; htm = new StringBuilder(); foreach (var fav in favs) { item.Data["id"] = fav.boardId.ToString(); item.Data["url"] = "/board/" + fav.boardId + "/" + fav.name.Replace(" ", "-").ToLower(); item.Data["color"] = "#" + fav.color; item.Data["title"] = fav.name; item.Data["owner"] = fav.ownerName; item.Data["star"] = fav.favorite ? "star" : "star-border"; htm.Append(item.Render()); } section.Data["items"] = htm.ToString(); html.Append(section.Render()); } // Team Boards ////////////////////////////////////////// if (teams.Count() > 0) { var teamId = 0; var isnewTeam = true; htm = new StringBuilder(); foreach (var team in teams) { if (team.teamId != teamId) { if (teamId > 0) { section.Data["items"] = htm.ToString(); html.Append(section.Render()); } isnewTeam = true; teamId = team.teamId; } if (isnewTeam == true) { section.Data["title"] = team.teamName; section.Data["id"] = "team" + team.teamId.ToString(); section.Data["icon"] = "user"; } item.Data["id"] = team.boardId.ToString(); item.Data["url"] = "/board/" + team.boardId + "/" + team.name.Replace(" ", "-").ToLower(); item.Data["color"] = "#" + team.color; item.Data["title"] = team.name; item.Data["owner"] = team.ownerName; item.Data["star"] = team.favorite ? "star" : "star-border"; htm.Append(item.Render()); } section.Data["items"] = htm.ToString(); html.Append(section.Render()); } // Team Boards (sort by user owned, then by date created) ///////// return(html.ToString()); }
private string GetSettings(int subscriptionId) { var subscription = Query.Subscriptions.GetInfo(subscriptionId); if (subscription != null) { var plans = Query.Plans.GetList(); var plan = plans.Where(p => p.planId == subscription.planId).First(); var scaffold = new Scaffold("/Views/Subscription/settings.html"); scaffold.Bind(new { subscription = new { plan.name, price = (subscription.pricePerUser * subscription.totalUsers).ToString("C"), users = subscription.totalUsers, schedule = subscription.paySchedule == 0 ? "month" : "year", plural = subscription.totalUsers > 1 ? "s" : "", owner = subscription.ownerName } }); if (subscription.userId == User.userId) { //subscription belongs to user, show billing info & other options (upgrade, downgrade, cancel) var outstanding = Query.Subscriptions.GetOutstandingBalance(User.userId); var subscriptionAge = (DateTime.Now - subscription.datestarted).TotalMinutes; scaffold.Bind(new { outstanding = new { price = outstanding.totalOwed.ToString("C"), duedate = outstanding.duedate.Value.ToShortDateString(), when = outstanding.duedate.Value < DateTime.Now ? "was" : "will be" } }); scaffold.Show("is-outstanding"); scaffold.Show("can-cancel"); if (outstanding.duedate.Value < DateTime.Now) { scaffold.Show("is-overdue"); } if (subscription.paySchedule == Query.Models.PaySchedule.monthly) { scaffold.Show("is-monthly"); } if (subscription.planId >= 1) { //show modify option scaffold.Show("can-modify"); if (subscription.totalUsers > 1) { scaffold.Show("is-team"); } else { scaffold.Show("is-not-team"); } if (subscription.planId == 1) { scaffold.Show("no-downgrade"); } } if ((subscription.planId != 4 && subscription.planId != 8) || subscription.totalUsers < 10000) { //show modify option scaffold.Show("can-modify"); } if (subscriptionAge < (5 * 24) * 60) { //TODO: Check for existing campaigns that have been ran //subscription is less than 5 days old & no campaigns have been run, //allow user to cancel subscription with a full refund scaffold.Show("is-new"); } else { if (subscription.paySchedule == Query.Models.PaySchedule.yearly) { scaffold.Show("is-old-year"); //get total months since subscription start until today var months = (int)Math.Round(((TimeSpan)(DateTime.Now - subscription.datestarted)).Days / 30.0); //calculate the end date for a yearly subscription ending //at the end of this monthly billing cycle var subscriptionEnd = subscription.datestarted.AddMonths(months + 1); subscriptionEnd = new DateTime(subscriptionEnd.Year, subscriptionEnd.Month, subscriptionEnd.Day, 0, 0, 0); //reset time to midnight scaffold.Bind(new { cancellation = new { enddate = subscriptionEnd.ToShortDateString() } }); } else { scaffold.Show("is-old-month"); } } //load payment history var paymentItem = new Scaffold("/Views/Subscription/settings/payment-item.html"); var payments = Query.Payments.GetList(User.userId); var html = new StringBuilder(); foreach (var payment in payments) { paymentItem.Bind(new { payment = new { datecreated = payment.datepaid.ToString("yyyy/MM/dd h:mm tt"), amount = payment.payment.ToString("C") } }); html.Append(paymentItem.Render()); } scaffold["payments"] = html.ToString(); //load invoices var invoiceItem = new Scaffold("/Views/Subscription/settings/invoice-item.html"); var invoices = Query.Invoices.GetList(User.userId); html = new StringBuilder(); var duedate = outstanding.duedate; if (duedate.HasValue) { duedate = (new DateTime(duedate.Value.Year, duedate.Value.Month, duedate.Value.Day)).AddDays(-3); } foreach (var invoice in invoices) { var item = new { datecreated = invoice.datedue.ToString("yyyy/MM/dd"), amount = invoice.subtotal.ToString("C"), status = outstanding.unpaidInvoiceId.HasValue ? (outstanding.unpaidInvoiceId.Value <= invoice.invoiceId ? (duedate >= DateTime.Now ? "Overdue" : "Due") : "Paid" ) : "Paid" }; invoiceItem.Bind(new { invoice = item }); if (item.status == "Due" || item.status == "Overdue") { invoiceItem.Show("important"); } html.Append(invoiceItem.Render()); } scaffold["invoices"] = html.ToString(); //load subscription changes var historyItem = new Scaffold("/Views/Subscription/settings/history-item.html"); var subscriptions = Query.Subscriptions.GetHistory(User.userId); var team = Query.Teams.GetByOwner(User.userId); var members = Query.TeamMembers.GetList(team.teamId).OrderByDescending(o => o.datecreated); html = new StringBuilder(); var items = new List <HistoryItem>(); var historyItems = new List <HistoryElement>(); //add list of members to history foreach (var member in members) { items.Add(new HistoryItem() { member = member, dateCreated = new DateTime(member.datecreated.Year, member.datecreated.Month, member.datecreated.Day), type = 0 }); } //add list of subscriptions to history foreach (var sub in subscriptions) { items.Add(new HistoryItem() { subscription = sub, dateCreated = new DateTime(sub.datestarted.Year, sub.datestarted.Month, sub.datestarted.Day), type = 1 }); } //sort history items items = items.OrderByDescending(o => o.dateCreated).ThenBy(o => o.type).ToList(); //generate subscription changes var currItem = new HistoryElement(); var currPlanId = -99; var count = 0; var actionType = ""; foreach (var item in items) { count += 1; var date = item.dateCreated.ToString("yyyy/MM/dd"); if (currItem.datecreated != date || item.type != currItem.type || item.type == 1) { if (item.type != 0 && item.subscription.planId == currPlanId) { continue; } if (item.type != 0) { currPlanId = item.subscription.planId; } if (currItem.description != null) { historyItems.Add(currItem); } if (count == items.Count) { actionType = "Started Subscription with "; } else { actionType = "Changed Subscription to "; } currItem = new HistoryElement() { datecreated = date, description = item.type == 0 ? "Added Member" : actionType + Common.Plans.NameFromId(item.subscription.planId) + " plan", members = item.type == 0 ? "1" : "", type = item.type }; } else { if (item.type == 0) { currItem.description = "Added Members"; currItem.members = (int.Parse(currItem.members) + 1).ToString(); } } } if (currItem.description != null) { historyItems.Add(currItem); } foreach (var item in historyItems) { historyItem.Bind(new { history = item }); html.Append(historyItem.Render()); } scaffold["history"] = html.ToString(); } return(scaffold.Render()); } else { return(Error("Subscription does not exist")); } }
public structResponse Layers() { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "Layers"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/editor/layers.html", "", new string[] { }); R.Page.RegisterJS("layers", "R.editor.layers.refresh();"); //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public structResponse NewPage(int parentId, string title) { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "NewPage"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/newpage.html", "", new string[] { "url", "data-page", "data-pagename" }); scaffold.Data["url"] = R.Page.Url.host.Replace("http://", "").Replace("https://", "") + title; scaffold.Data["data-page"] = ""; scaffold.Data["data-pagename"] = ""; R.Page.RegisterJS("newpage", "R.editor.pages.add.item.url = '" + scaffold.Data["url"] + "';"); //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public structResponse Options() { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "Options"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/editor/options.html", "", new string[] { "helpicon-grid", "helpicon-dragfrompanel", "helpicon-guidelines" }); scaffold.Data["helpicon-grid"] = ""; scaffold.Data["helpicon-dragfrompanel"] = ""; scaffold.Data["helpicon-guidelines"] = ""; //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public WebRequest LoadForm() { WebRequest wr = new WebRequest(); string htm = ""; SetupWebRequest(); Element.Textbox elemTextbox = (Element.Textbox)R.Elements.Load(ElementType.Textbox, arrDesign[0]); Element.Button elemButton = (Element.Button)R.Elements.Load(ElementType.Button, arrDesign[1]); //setup login form properties int designFieldsAlign = 1; //1=vertical, 2=horizontal int designLabelAlign = 1; //1=left, 2=top left, 3=top right int designButtonAlign = 1; //1=right, 2=bottom left, 3=bottom center, 4=bottom right, 5=hidden int designLabelPadding = 2; //top or bottom padding of label int designFieldPadding = 10; //vertical & horizontal padding between form items (textboxes & button) string designTextboxWidth = "200px"; string designButtonWidth = "100px"; string designButtonTitle = "Log In"; int designButtonOffset = 2; //top offset position of button int designWidth = 0; int designHeight = 0; int designPadding = 0; //load login form settings if (arrContent.Length > 4) { if (R.Util.Str.IsNumeric(arrContent[0]) == true) { designFieldsAlign = int.Parse(arrContent[0]); } if (R.Util.Str.IsNumeric(arrContent[1]) == true) { designLabelAlign = int.Parse(arrContent[1]); } if (R.Util.Str.IsNumeric(arrContent[2]) == true) { designButtonAlign = int.Parse(arrContent[2]); } if (R.Util.Str.IsNumeric(arrContent[3]) == true) { designLabelPadding = int.Parse(arrContent[3]); } if (R.Util.Str.IsNumeric(arrContent[4]) == true) { designFieldPadding = int.Parse(arrContent[4]); } } if (arrContent.Length > 8) { if (!string.IsNullOrEmpty(arrContent[5])) { designTextboxWidth = arrContent[5]; } if (!string.IsNullOrEmpty(arrContent[6])) { designButtonWidth = arrContent[6]; } if (!string.IsNullOrEmpty(arrContent[7])) { designButtonTitle = arrContent[7]; } if (!string.IsNullOrEmpty(arrContent[8])) { designButtonOffset = int.Parse(arrContent[8]); } } if (arrContent.Length > 14) { if (R.Util.Str.IsNumeric(arrContent[12]) == true) { designWidth = int.Parse(arrContent[12]); } if (R.Util.Str.IsNumeric(arrContent[13]) == true) { designHeight = int.Parse(arrContent[13]); } if (R.Util.Str.IsNumeric(arrContent[14]) == true) { designPadding = int.Parse(arrContent[14]); } } //email label htm += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%;"; if (designPadding >= 0) { //htm &= "padding:" & designPadding & "px;" } htm += "\"><tr>"; htm += "<td style=\"vertical-align:top;\">"; if (designLabelAlign != 4) { htm += "<div style=\""; if (designLabelAlign == 1) { htm += " float:left;"; } if (designLabelAlign > 1) { htm += " width:100%; padding-bottom:" + designLabelPadding + "px;"; } if (designLabelAlign == 1) { htm += " padding-right:" + designLabelPadding + "px;"; } if (designLabelAlign == 3) { htm += " text-align:right;"; } if (designFieldsAlign == 2) { htm += " padding-top:4px;"; } htm += "\">Email</div>"; } //email textbox if (designFieldsAlign == 1 & designLabelAlign == 1) { htm += "</td><td style=\"vertical-align:top;\">"; } htm += "<div style=\""; if (designLabelAlign > 1 & designFieldsAlign == 1) { htm += "padding-top:" + designLabelPadding + "px;"; } if (designLabelAlign == 1 & designFieldsAlign == 1) { htm += "padding-top:" + designFieldPadding + "px;"; } if (designLabelAlign == 1) { htm += "float:left;"; } htm += "\">"; if (designLabelAlign == 4) { //add hidden textbox for inside labels htm += elemTextbox.Render("email", "", "Email", "width:" + designTextboxWidth + ";"); } else { htm += elemTextbox.Render("email", "", "", "width:" + designTextboxWidth + ";"); } htm += "</div></td>"; //password label if (designFieldsAlign == 1) { htm += "</tr><tr>"; } htm += "<td style=\"vertical-align:top;"; if (designFieldsAlign == 2) { htm += "padding-left:" + designFieldPadding + "px;"; } if (designFieldsAlign == 1) { htm += "padding-top:" + designFieldPadding + "px;"; } htm += "\">"; if (designLabelAlign != 4) { htm += "<div style=\""; if (designLabelAlign == 1) { htm += " float:left;"; } if (designLabelAlign > 1) { htm += " width:100%; padding-bottom:" + designLabelPadding + "px;"; } if (designLabelAlign == 1) { htm += " padding-right:" + designLabelPadding + "px;"; } if (designLabelAlign == 3) { htm += " text-align:right;"; } if (designFieldsAlign == 2) { htm += " padding-top:4px;"; } htm += "\">Password</div>"; } //password textbox if (designFieldsAlign == 1 & designLabelAlign == 1) { htm += "</td><td style=\"vertical-align:top;\">"; } htm += "<div style=\""; if (designLabelAlign > 1 & designFieldsAlign == 1) { htm += "padding-top:" + designLabelPadding + "px;"; } if (designLabelAlign == 1 & designFieldsAlign == 1) { htm += "padding-top:" + designFieldPadding + "px;"; } if (designLabelAlign == 1) { htm += "float:left;"; } htm += "\">"; if (designLabelAlign == 4) { //add hidden textbox for inside labels htm += elemTextbox.Render("password", "", "Password", "width:" + designTextboxWidth + ";", Element.Textbox.enumTextType.password); } else { htm += elemTextbox.Render("password", "", "", "width:" + designTextboxWidth + ";", Element.Textbox.enumTextType.password); } //forgot password link htm += "<div style=\"padding:7px;\"><a href=\"" + R.Request.Path + "&forgotpass\">forgot password?</a></div>"; htm += "</div></td>"; //submit button if (designButtonAlign < 5) { if (designFieldsAlign == 1) { htm += "</tr><tr>"; } if (designFieldsAlign == 2 & designButtonAlign > 1) { htm += "</tr><tr>"; } htm += "<td style=\"vertical-align:top;"; if (designFieldsAlign == 2 & designButtonAlign == 1) { htm += "padding-left:" + designFieldPadding + "px;"; } if (designFieldsAlign == 1) { htm += "padding-top:" + designFieldPadding + "px;"; } htm += "\""; if (designFieldsAlign == 1) { htm += " colspan=\"2\""; } if (designButtonAlign == 1) { htm += " valign=\"bottom\""; } htm += "><div style=\""; switch (designButtonAlign) { //1=right, 2=bottom left, 3=bottom center, 4=bottom right, 5=hidden case 1: case 4: if (designFieldsAlign == 1) { htm += " float:right;"; } else { htm += "position:relative; top:" + designButtonOffset + "px;"; } break; case 3: htm += " margin-left:auto; margin-right:auto;"; break; } htm += "\">"; //add login button htm += elemButton.Render(itemId + "Login", "javascript:$('form')[0].submit()", designButtonTitle); htm += "</div></td>"; } htm += "</tr></table>"; scaffold.Data["body"] = htm; //finally, scaffold login HTML wr.html = scaffold.Render(); return(wr); }
public structResponse PageSettings(int pageId) { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "PageSettings"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/pagesettings.html", "", new string[] { "url", "page-title", "description", "secure", "page-type", "type" }); string parentTitle = ""; SqlReader reader = R.Page.SqlPage.GetParentInfo(pageId); if (reader.Rows.Count > 0) { reader.Read(); parentTitle = reader.Get("parenttitle"); scaffold.Data["page-title"] = R.Util.Str.GetPageTitle(reader.Get("title")); if (reader.GetBool("security") == true) { scaffold.Data["secure"] = "true"; } scaffold.Data["description"] = reader.Get("description"); } scaffold.Data["url"] = R.Page.Url.host.Replace("http://", "").Replace("https://", "") + scaffold.Data["page-title"].Replace(" ", "-") + "/"; if (!string.IsNullOrEmpty(parentTitle)) { parentTitle = R.Util.Str.GetPageTitle(parentTitle); scaffold.Data["page-type"] = "true"; scaffold.Data["type"] = "A sub-page for \"" + parentTitle + "\""; } //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }
public structResponse Profile() { if (R.isSessionLost() == true) { return lostResponse(); } structResponse response = new structResponse(); response.window = "Profile"; //check security if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false) { return response; } //setup scaffolding variables Scaffold scaffold = new Scaffold(R, "/app/dashboard/profile.html", "", new string[] { "websites", "admin" }); if (R.User.userId == 1) { scaffold.Data["admin"] = "true"; } //finally, scaffold Rennder platform HTML response.html = scaffold.Render(); response.js = CompileJs(); return response; }