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());
        }
Ejemplo n.º 5
0
        //[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()
            });
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 10
0
        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
            });
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 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>());
     }));
 }
Ejemplo n.º 14
0
        /// <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));
        }
Ejemplo n.º 15
0
        /// <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));
        }
Ejemplo n.º 16
0
 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>());
     }));
 }
Ejemplo n.º 17
0
 public DeleteCommandModel Query(DeleteProductRequest model)
 {
     return(new DeleteCommandModel
     {
         Id = model.Id,
         Name = _productService.GetById(model.Id).Name,
         HomeUrl = _urlRegistry.UrlFor <HomeQueryModel>()
     });
 }
Ejemplo n.º 18
0
        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
            });
        }
Ejemplo n.º 19
0
        public AjaxContinuation BuildAjaxContinuation()
        {
            var url          = _urls.UrlFor(new LoginRequest(), "GET");
            var continuation = new AjaxContinuation {
                Success = false, NavigatePage = url
            };

            return(continuation);
        }
Ejemplo n.º 20
0
 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);
     });
 }
Ejemplo n.º 21
0
        // 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));
        }
Ejemplo n.º 22
0
        // 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);
        }
Ejemplo n.º 23
0
        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));
        }
Ejemplo n.º 24
0
        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
            });
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 27
0
        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))
            });
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 31
0
        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");
     });
 }
Ejemplo n.º 34
0
        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;
        }
Ejemplo n.º 35
0
        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));
        }
Ejemplo n.º 38
0
 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}));
 }