public RequestLinksTag(RequestLog log, IUrlRegistry urls) { AddHeader("Chain Details"); Add("li").Add("a").Id("chain-summary").Attr("href", "#").Text("View Summary"); Add("li").Add("span/a").Attr("href", urls.UrlFor(new ChainDetailsRequest{Id = log.ChainId})).Text("View Details").AddClass("external").Attr("target", "_blank"); }
public void Write(string mimeType, GoogleLoginRequest resource) { var request = _request.Get <GoogleSignIn>(); HtmlTag tag = new HtmlTag("a").Attr("href", _urls.UrlFor(request)).Text(GoogleLoginKeys.LoginWithGoogle); _writer.WriteHtml(tag.ToString()); }
string IGridDefinition.SelectDataSourceUrl(IUrlRegistry urls) { if (_sourceType == null) { return(null); } if (_queryType != null) { return(urls.UrlFor(_queryType)); } var runnerType = DetermineRunnerType(); return(urls.UrlFor(runnerType)); }
public void Write(string mimeType, TwitterLoginRequest resource) { var request = _request.Get <TwitterSignIn>(); var tag = new HtmlTag("a").Attr("href", _urls.UrlFor(request)).Text(TwitterLoginKeys.LoginWithTwitter); _writer.WriteHtml(tag.ToString()); }
//[AsymmetricJson] public Resource Execute(ResourceRequest request) { var baseUrl = _urlRegistry.UrlFor(request); var absoluteBaseUrl = _currentHttpRequest.ToFullUrl(baseUrl); var apis = createSwaggerAPIs(request, baseUrl); //models support should go onto another branch. //var typeSet = new HashSet<Type>(); //actions.Each(a => // { // if(a.HasInput) typeSet.Add(a.InputType()); // if (a.HasOutput) typeSet.Add(a.OutputType()); // }); return(new Resource { basePath = absoluteBaseUrl, resourcePath = "/" + request.GroupKey, //SWAGGER HACK - this assumes that the resource path will always be relative to the basePath. apiVersion = Assembly.GetExecutingAssembly().GetVersion(), swaggerVersion = "1.0", apis = apis, //models = typeSet.ToArray() }); }
private void showSnippet(TableRowTag tr, Snippet snippet, IUrlRegistry urls) { var request = new SnippetRequest(snippet); var url = urls.UrlFor(request, "GET"); tr.Cell().Add("a").Attr("href", "#").Data("url", url).AddClass("snippet-link").Text(snippet.Name); tr.Cell(snippet.BottleName); var editUrl = urls.UrlFor(request, "POST"); tr.Cell().Add("a").Data("url", editUrl) .Data("name", snippet.Name) .Data("bottle", snippet.BottleName) .Attr("href", "#").AddClass("edit-snippet").Text(snippet.File); }
public virtual HtmlDocument BuildView(IUrlRegistry urls, IOutputWriter writer, LoginRequest request) { // TODO -- Revisit all of this when we get HTML conventions everywhere var view = new HtmlDocument(); var form = new FormTag(urls.UrlFor <LoginRequest>("POST")); form.Append(new HtmlTag("legend").Text(LoginKeys.Login)); if (request.Message.IsNotEmpty()) { form.Append(new HtmlTag("p").Text(request.Message).Style("color", "red")); } form.Append(new TextboxTag("UserName", request.UserName)); form.Append(new TextboxTag("Password", request.Password)); form.Append(new CheckboxTag(request.RememberMe).Name("RememberMe")); form.Append(new DivTag().Text(request.Message).Id("login-message")); form.Append(new HiddenTag().Name("Url").Attr("value", request.Url)); form.Append(new HtmlTag("input").Attr("type", "submit").Attr("value", LoginKeys.Login).Id("login-submit")); view.Add(form); return(view); }
public HomeOutput Index(HomeIn homeIn) { var links = new List <Link> { new Link { Url = _urls.UrlFor <LessIn>(), Text = "Less" }, new Link { Url = _urls.UrlFor <SassIn>(), Text = "Sass" } }; return(new HomeOutput { Links = links }); }
public DiagnosticMenuTag(IDiagnosticContext context, ICurrentHttpRequest currentHttpRequest, IUrlRegistry urls) : base("ul") { AddClass("nav"); var group = context.CurrentGroup(); var index = group.Index(); if (index != null) { addLink(index, context, currentHttpRequest); } else { var url = urls.UrlFor(new GroupRequest {Name = group.Name}); var li = Add("li"); li.Add("a").Attr("href", url).Text(group.Name).Attr("title", group.Description); if (context.CurrentChain() == null) { li.AddClass("active"); } } group.Links().Each(x => addLink(x, context, currentHttpRequest)); }
public CrudReport Create(CreationRequest <TEdit> request) { var input = request.Input; var notification = input.Notification; var model = (TEntity)input.Target; _validator.Validate(model, notification); var wasSaved = false; string editUrl = null; if (notification.IsValid()) { _saver.Create(model); wasSaved = true; editUrl = _urls.UrlFor(model); _newEntityHandler.HandleNew(input); } var flattenedValue = _flattener.Flatten(model); return(new CrudReport(notification, model, flattenedValue) { success = wasSaved, editUrl = editUrl }); }
public static HtmlDocument BuildDocument(IUrlRegistry urls, string title, params HtmlTag[] tags) { string css = GetDiagnosticCss(); var realTitle = "FubuMVC: " + title; var document = new HtmlDocument(); document.Title = realTitle; var mainDiv = new HtmlTag("div").AddClass("main"); mainDiv.Add("h2").Text("FubuMVC Diagnostics").Append(buildVersionTag()); var navBar = mainDiv.Add("div").AddClass("homelink"); if (urls != null) { navBar.Append(new LinkTag("Home", urls.UrlFor <BehaviorGraphWriter>(w => w.Index(), null))); } navBar.Add("span").Text(" > " + title); document.Add(mainDiv); mainDiv.Append(tags); document.AddStyle(css); return(document); }
private HtmlDocument buildDocument(FileUploadOutput model) { var document = new HtmlDocument(); document.Title = "File Upload View"; document.Add("h1").Text(model.Text); document.Add("form") .Attr("method", "post") .Attr("enctype", "multipart/form-data") .Attr("action", _urls.UrlFor <FileUploadInput>()); document.Add("br"); document.Push("p"); document.Add("span").Text("File 1: "); document.Add("input").Attr("type", "file").Attr("name", "File1"); document.Add("br"); document.Add("input").Attr("type", "submit"); return(document); }
public HtmlTag get_requests_missing() { return(new HtmlTag("p", p => { p.Add("span").Text("This request is not longer in the request cache. "); p.Add("a").Text("Return to the Request Explorer").Attr("href", _urls.UrlFor <RequestsEndpoint>()); })); }
/// <summary> /// Inline way to resolve a url for an input model type by defining the RouteParameters object by /// expressions /// </summary> /// <typeparam name="T"></typeparam> /// <param name="registry"></param> /// <param name="configure"></param> /// <returns></returns> public static string UrlFor <T>(this IUrlRegistry registry, string category, Action <RouteParameters <T> > configure) { var parameters = new RouteParameters <T>(); configure(parameters); return(registry.UrlFor(typeof(T), parameters, category)); }
/// <summary> /// Inline way to resolve a url for an input model type by defining the RouteParameters object by /// expressions /// </summary> /// <typeparam name="T"></typeparam> /// <param name="registry"></param> /// <param name="configure"></param> /// <returns></returns> public static string UrlFor <T>(this IUrlRegistry registry, Action <RouteParameters <T> > configure) { var parameters = new RouteParameters <T>(); configure(parameters); return(registry.UrlFor <T>(parameters)); }
public HtmlTag get_chain_missing() { return(new HtmlTag("p", p => { p.Add("span").Text("The requested BehaviorChain cannot be found. "); p.Add("a").Text("Return to the Request Explorer").Attr("href", _urls.UrlFor <EndpointExplorerModel>()); })); }
public DeleteCommandModel Query(DeleteProductRequest model) { return(new DeleteCommandModel { Id = model.Id, Name = _productService.GetById(model.Id).Name, HomeUrl = _urlRegistry.UrlFor <HomeQueryModel>() }); }
public AwesomeIndexModel DaisyChain(RestfulIndexModel <TEntity> model) { var createUrl = _urlRegistry.UrlFor <AwesomeCreateHandler <TEntity> >(x => x.Execute()); return(new AwesomeIndexModel() { Models = model.Models, Header = typeof(TEntity).Name + "s", CreateUrl = createUrl }); }
public AjaxContinuation BuildAjaxContinuation() { var url = _urls.UrlFor(new LoginRequest(), "GET"); var continuation = new AjaxContinuation { Success = false, NavigatePage = url }; return(continuation); }
protected virtual Func <string> toUrlSource(IUrlRegistry urls, Func <object> idSource) { return(() => { var parameters = new RouteParameters(); parameters[_idAccessor.InnerProperty.Name] = idSource().ToString(); return urls.UrlFor(_inputModelType, parameters); }); }
// ENDSAMPLE // SAMPLE: LookupByMethod public static void LookupByMethod(IUrlRegistry urls) { // By type and method name var url = urls .UrlFor(typeof(UserEndpoints), nameof(UserEndpoints.post_user)); // If you already have the MethodInfo somehow:/ // ReflectionHelper is from the Baseline library var method = ReflectionHelper.GetMethod <UserEndpoints>(x => x.post_user(null)); var url2 = urls .UrlFor(typeof(UserEndpoints), method); // Or by expression var url3 = urls.UrlFor <UserEndpoints>(x => x.post_user(null)); }
// ENDSAMPLE // SAMPLE: LookupByInputType public static void LookupByInputType(IUrlRegistry urls) { // Find the url that would handle the CreateUser // type as a request body that responds to "PUT" var url = urls.UrlForType <CreateUser>("PUT"); // Look up the Url if you already have the request // body var input = new CreateUser(); var url2 = urls.UrlFor(input); }
public FubuContinuation Redirect() { var url = _urls.UrlFor(new LoginRequest(), "GET"); var continuation = new AjaxContinuation { Success = false, NavigatePage = url }; _jsonWriter.Write(continuation.ToDictionary(), MimeType.Json.ToString()); return(FubuContinuation.EndWithStatusCode(HttpStatusCode.Unauthorized)); }
public SuccessOperationModel Query(SuccessOperationRequest request) { var productName = request.Operation == OperationType.Delete ? "" : _service.GetById(request.Id).Name; return(new SuccessOperationModel { HomeUrl = _registry.UrlFor <HomeQueryModel>(), ProductName = productName, Id = request.Id, Operation = request.Operation }); }
public FubuContinuation Execute(FormsLoginRequest request) { if (_verifier.Verify(request.Username, request.Password)) { //home url var homeUrl = _urls.UrlFor(PassportConfiguration.HomeInputModel); return(FubuContinuation.RedirectTo(homeUrl)); } //something like that? return(FubuContinuation.RedirectTo(PassportConfiguration.LogonRouteInputModel)); }
protected override DoNext performInvoke() { if (_fubuRequest.Has <TOutput>() && _fubuRequest.Get <TOutput>() != null) { return(DoNext.Continue); } var model = _fubuRequest.Get <NotFoundModel>(); var url = _urlRegistry.UrlFor(model); _outputWriter.RedirectToUrl(url); return(DoNext.Stop); }
public ProjectViewModel get_project_Name(ProjectRequest request) { var project = TopicGraph.AllTopics.TryFindProject(request.Name); var root = _tokenCache.TopicStructureFor(request.Name); var fileUrl = _urls.UrlFor <FileRequest>(); return(new ProjectViewModel { Name = project.Name, Project = project, Topics = new TopicTreeTag(root), SubmitUrl = _urls.UrlFor(new TopicToken { ProjectName = request.Name }, "POST"), Files = new AllTopicsTag(fileUrl, project), Snippets = new SnippetsTableTag(_urls, _cache.All()), TodoList = new TodoTableTag(fileUrl, TodoTask.FindAllTodos().OrderBy(x => x.File).ThenBy(x => x.Line)) }); }
public HomeModel Index() { var tags = _repository.All <Album>().ToList().Select(album => { return(new LinkTag(album.Artist + " - " + album.Name, _urls.UrlFor(album, "GET"))); }); // You'll probably want to do more than this... return(new HomeModel { Albums = new TagList(tags) }); }
private void addQueueRow(TableRowTag row, IQueueManager queueManager, string queueName, IUrlRegistry urls, string displayForCount = null) { var url = urls.UrlFor(new MessagesInputModel { Port = queueManager.Endpoint.Port, QueueName = queueName }); row.Cell().Add("a") .Attr("href", url) .Text(queueName); row.Cell(displayForCount ?? queueManager.GetNumberOfMessages(queueName).ToString(CultureInfo.InvariantCulture)); }
public RequestLog BuildForCurrentRequest() { var report = new ValueReport(); _requestData.WriteReport(report); var chainId = _currentChain.OriginatingChain == null ? Guid.Empty : _currentChain.OriginatingChain.UniqueId; var log = new RequestLog { ChainId = chainId, Time = _systemTime.UtcNow(), RequestData = report, ChainUrl = _urls.UrlFor(new ChainRequest { Id = chainId }), DetailsUrl = _urls.UrlFor(new ChainDetailsRequest { Id = chainId }) }; if (_currentChain.OriginatingChain.Route != null) { log.HttpMethod = _request.HttpMethod(); log.Endpoint = _request.RelativeUrl(); } else if (_currentChain.OriginatingChain.InputType() != null) { log.Endpoint = _currentChain.OriginatingChain.InputType().FullName; log.HttpMethod = "n/a"; } else { log.Endpoint = ChainVisualization.TitleForChain(_currentChain.OriginatingChain); log.HttpMethod = "n/a"; } log.ReportUrl = _urls.UrlFor(log); return(log); }
private void writeChildNodes(TopicNode node, HtmlTag tag) { node.ChildNodes.Each(childTopic => { var li = tag.Add("li"); li.Add("a").Attr("href", _urls.UrlFor(childTopic.TopicType)).Text(childTopic.Title); if (childTopic.ChildNodes.Any()) { var ul = li.Add("ul"); writeChildNodes(childTopic, ul); } }); }
public FubuContinuation Execute(SignInModel model) { var loggedin = _authenticationService.SignIn(model.UserName, model.Password, true); if (loggedin) { return(FubuContinuation.RedirectTo(model.ReturnUrl.IsEmpty() ? _urlRegistry.UrlFor <HomeRequest>() : model.ReturnUrl)); } return(FubuContinuation.TransferTo(new SignInRequest { ReturnUrl = model.ReturnUrl, LoginFailed = true })); }
private void writeLog(RequestLog log, IUrlRegistry urls) { AddBodyRow(row => { var chainUrl = urls.UrlFor(log); row.Cell().Add("a").Text(log.LocalTime).Attr("href", chainUrl); row.Cell(log.Endpoint); row.Cell(log.HttpMethod); var statusCell = row.Cell(); statusCell.Add("span").AddClass("http-status-code").Text(log.HttpStatus.Status.ToString()); statusCell.Add("span").AddClass("http-status-description").Text(log.HttpStatus.Description); row.Cell(log.ContentType); row.Cell(Math.Ceiling(log.ExecutionTime).ToString()).AddClass("number"); }); }
public static HtmlDocument BuildDocument(IUrlRegistry urls, string title, params HtmlTag[] tags) { var css = GetResourceText(typeof(BehaviorGraphWriter), "diagnostics.css"); var realTitle = "FubuMVC: " + title; var document = new HtmlDocument(); document.Title = realTitle; var mainDiv = new HtmlTag("div").AddClass("main"); mainDiv.Add("h2").Text("FubuMVC Diagnostics").Child(buildVersionTag()); var navBar = mainDiv.Add("div").AddClass("homelink"); navBar.AddChildren(new LinkTag("Home", urls.UrlFor<BehaviorGraphWriter>(w => w.Index()))); navBar.Add("span").Text(" > " + title); document.Add(mainDiv); mainDiv.AddChildren(tags); document.AddStyle(css); return document; }
public static HtmlDocument BuildDocument(IUrlRegistry urls, string title, params HtmlTag[] tags) { string css = GetDiagnosticCss(); var realTitle = "FubuMVC: " + title; var document = new HtmlDocument(); document.Title = realTitle; var mainDiv = new HtmlTag("div").AddClass("main"); mainDiv.Add("h2").Text("FubuMVC Diagnostics").Append(buildVersionTag()); var navBar = mainDiv.Add("div").AddClass("homelink"); if (urls != null) navBar.Append(new LinkTag("Home", urls.UrlFor<BehaviorGraphWriter>(w => w.Index(), null))); navBar.Add("span").Text(" > " + title); document.Add(mainDiv); mainDiv.Append(tags); document.AddStyle(css); return document; }
private void addJobRow(TableRowTag row, JobStatusDTO job, IUrlRegistry urls) { row.Cell().Add("a").Text(job.JobKey).Attr("href", urls.UrlFor(new ScheduledJobRequest{Job = job.JobKey})); row.Cell(job.NextTime.HasValue ? job.NextTime.Value.ToLocalTime().ToString() : "Not scheduled"); row.Cell(job.GetStatusDescription()); row.Cell(job.GetLastExecutionDescription()); var url = urls.UrlFor(new RunJobRequest {Name = job.JobKey}); row.Cell().Add("button").Text("Execute").Attr("data-url", url).AddClass("button").AddClass("executor").Attr("onclick", "if (window.confirm('Ok to run this job?')) window.location='" + url + "'"); }
private void addQueueRow(TableRowTag row, IQueueManager queueManager, string queueName, IUrlRegistry urls, string displayForCount = null) { var url = urls.UrlFor(new MessagesInputModel {Port = queueManager.Endpoint.Port, QueueName = queueName}); row.Cell().Add("a") .Attr("href", url) .Text(queueName); row.Cell(displayForCount ?? queueManager.GetNumberOfMessages(queueName).ToString(CultureInfo.InvariantCulture)); }
public static RouteReport ForChain(BehaviorChain chain, IUrlRegistry urls) { return new RouteReport(chain, urls.UrlFor(new ChainRequest{Id = chain.UniqueId}), urls.UrlFor(new ChainDetailsRequest{Id = chain.UniqueId})); }