小编bio*_*tal的帖子

禁用/启用按钮和链接的最简单方法是什么(jQuery + Bootstrap)

有时我使用锚作为按钮,有时我只使用按钮.我想禁用特定的clicky-things,以便:

  • 他们看起来残疾
  • 他们不再被点击了

我怎样才能做到这一点?

html css jquery twitter-bootstrap

354
推荐指数
10
解决办法
61万
查看次数

如何让后退按钮与AngularJS ui-router状态机一起使用?

我已经使用ui-router实现了angularjs单页面应用程序.

最初我使用一个不同的URL来识别每个州,但这是为了不友好的GUID打包网址.

所以我现在将我的网站定义为一个更简单的状态机.状态不是由URL标识的,而是根据需要简单地转换为,如下所示:

定义嵌套状态

angular
.module 'app', ['ui.router']
.config ($stateProvider) ->
    $stateProvider
    .state 'main', 
        templateUrl: 'main.html'
        controller: 'mainCtrl'
        params: ['locationId']

    .state 'folder', 
        templateUrl: 'folder.html'
        parent: 'main'
        controller: 'folderCtrl'
        resolve:
            folder:(apiService) -> apiService.get '#base/folder/#locationId'
Run Code Online (Sandbox Code Playgroud)

过渡到定义的国家

#The ui-sref attrib transitions to the 'folder' state

a(ui-sref="folder({locationId:'{{folder.Id}}'})")
    | {{ folder.Name }}
Run Code Online (Sandbox Code Playgroud)

这个系统工作得很好,我喜欢它干净的语法.但是,由于我没有使用URL,后退按钮不起作用.

如何保持我的整洁的ui-router状态机,但启用后退按钮功能?

javascript coffeescript angularjs angular-ui-router

85
推荐指数
4
解决办法
14万
查看次数

为什么我的AngularJS,Karma/Jasmine测试运行得如此之慢?

我有一些简单的业力/茉莉花单元测试针对angularjs app运行.我使用最新版本的Chrome并在WebStorm IDE中运行我的测试.

有时候测试套件运行得非常快(0.24秒)

对于完全相同的代码,有时完全相同的测试套件运行速度非常慢(120秒)

我尝试过每一个常识修复.我在网上搜索,试图发现我做错了什么.

为什么我的测试运行得这么慢?

jasmine angularjs karma-runner

50
推荐指数
1
解决办法
7812
查看次数

在编写CoffeeScript时如何为AngularJS启用Webstorm intellisense

我已经设置了Webstorm来识别和编译我的coffeescript文件.

我已经安装了AngularJS插件,并且可以在普通的旧javascript中成功编写我的控制器等.

当我尝试在CoffeeScript中编写我的角度相关代码但是我没有得到任何IDE支持:代码完成,智能感知等.

作为一切都不好的标志,angular变量本身无法识别,如下图所示.

在此输入图像描述

问题:如何在CoffeeScript文件中启用对AngularJS的支持?

谢谢

coffeescript webstorm angularjs

28
推荐指数
2
解决办法
3万
查看次数

RavenDb:强制索引等到单元测试时不会陈旧

使用RavenDb进行单元测试时,通常会检索或以其他方式处理新添加的数据.这可能导致"陈旧索引"例外,例如

Bulk operation cancelled because the index is stale and allowStale is false
Run Code Online (Sandbox Code Playgroud)

根据一些答案

强制数据库(IDocumentStore实例)在处理查询或批处理操作之前等待其索引未过时的方法是DefaultQueryingConsistency = ConsistencyOptions.QueryYourWritesIDocumentStore初始化期间使用,如下所示:

public class InMemoryRavenSessionProvider : IRavenSessionProvider
{
    private static IDocumentStore documentStore;

    public static IDocumentStore DocumentStore
    {
        get { return (documentStore ?? (documentStore = CreateDocumentStore())); }
    }

    private static IDocumentStore CreateDocumentStore()
    {
        var store = new EmbeddableDocumentStore
        {
            RunInMemory = true,
            Conventions = new DocumentConvention
            {
                DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites,
                IdentityPartsSeparator = "-"
            }
        }; …
Run Code Online (Sandbox Code Playgroud)

unit-testing ravendb

24
推荐指数
2
解决办法
4419
查看次数

SignalR plus NancyFX:一个简单但功能良好的例子

例如,有一些NancyFX与SignalR集成的例子

由于我刚刚开始,我想要一个简单,工作良好的规范示例,我可以从中工作.来自微软的聊天示例的nancy版本可以正常运行.

谢谢

nancy signalr

20
推荐指数
1
解决办法
8854
查看次数

如何使用C#正确准备"HTTP重定向绑定"SAML请求

我需要使用HTTP重定向绑定方法创建SP启动的SAML 2.0身份验证事务.事实证明这很容易.只需获取IdP URI并连接单个查询字符串参数即可 SAMLRequest.param是xml的编码块,用于描述SAML请求.到现在为止还挺好.

将SAML转换为查询字符串参数时出现问题.我相信这个准备过程应该是:

  1. 构建SAML字符串
  2. 压缩此字符串
  3. Base64编码字符串
  4. UrlEncode字符串.

SAML请求

<samlp:AuthnRequest
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
    ID="{0}"
    Version="2.0"
    AssertionConsumerServiceIndex="0"
    AttributeConsumingServiceIndex="0">
    <saml:Issuer>URN:xx-xx-xx</saml:Issuer>
    <samlp:NameIDPolicy
        AllowCreate="true"
        Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"/>
</samlp:AuthnRequest>
Run Code Online (Sandbox Code Playgroud)

代码

private string GetSAMLHttpRedirectUri(string idpUri)
{
    var saml = string.Format(SAMLRequest, Guid.NewGuid());
    var bytes = Encoding.UTF8.GetBytes(saml);
    using (var output = new MemoryStream())
    {
        using (var zip = new DeflaterOutputStream(output))
        {
            zip.Write(bytes, 0, bytes.Length);
        }
        var base64 = Convert.ToBase64String(output.ToArray());
        var urlEncode = HttpUtility.UrlEncode(base64);
        return string.Concat(idpUri, "?SAMLRequest=", urlEncode);
    }
}
Run Code Online (Sandbox Code Playgroud)

我怀疑压缩是某种程度上的责任.我正在使用SharpZipLibDeflaterOutputStream类,它应该实现一个行业标准的deflate算法,所以也许这里有一些设置我错了?

可以使用此SAML2.0调试器(其有用的在线转换工具)测试编码输出.当我使用这个工具解码我的输出时,它是无意义的.

因此,问题是:您是否知道如何将SAML字符串转换为正确放气和编码的SAMLRequest查询参数?

谢谢 …

c# sharpziplib saml-2.0

19
推荐指数
2
解决办法
2万
查看次数

Angularjs自定义过滤器和依赖注入

我是AngularJS的新手,我看到了很多这样的语法:

function someFunc(){
   return function(input){
    return 'hello' + input;
  }
}
Run Code Online (Sandbox Code Playgroud)

上面的函数是一个通用的语法,我倾向于看到很多,但问题是针对自定义过滤器的这个示例:

angular.module('bookFilters', [])
    .filter('newBookFilter', function(){
          return function(input){
        return 'The Book: ' + input.name + 'is new !';
   };
});
Run Code Online (Sandbox Code Playgroud)

我知道用另一个函数包装函数让我有机会使用依赖注入,这是我的问题:

过滤器是否从包装函数返回函数?那么它是否能够使用依赖注入将值注入函数?从理论上说:

这段代码:

{{bookObj | newBookFilter}}
Run Code Online (Sandbox Code Playgroud)

会变成:

{{   bookObj | function(input){return 'The Book: ' + input.name + 'is new !'; }  }}
Run Code Online (Sandbox Code Playgroud)

最后,{{}}将返回函数的最终值.

为什么我不能只注入input第一个函数,如:

angular.module('bookFilters', [])
         .filter('newBookFilter', function(input){
             return 'The Book: ' + input.name + 'is new !';
     });
Run Code Online (Sandbox Code Playgroud)

为什么依赖注入只适用于返回的函数?

我知道我真的很困惑,如果有人能帮助我,我会非常感激,谢谢大家,祝你有个美好的一天.

javascript code-injection angularjs

15
推荐指数
2
解决办法
3万
查看次数

NancyFX:带有查询字符串参数的路由始终返回404 NotFound

我有一个简单的南希模块.我想将查询字符串(qs)参数传递给处理程序.如果我没有任何qs参数,一切都很好.一旦我添加了一个参数,我就会收到一个404状态代码.

NancyModule

public class SimpleModule : NancyModule
{
    public SimpleModule()
    {
        Get["/"] = parameters => HttpStatusCode.OK;
    }
}
Run Code Online (Sandbox Code Playgroud)

单元测试 - 通行证

[Fact]
public void SimpleModule__Should_return_statusOK_when_passing_query_params()
{
    const string uri = "/";
    var response = Fake.Browser().Get(uri, with => with.HttpRequest());
    response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
Run Code Online (Sandbox Code Playgroud)

单元测试 - 失败

[Fact]
public void SimpleModule__Should_return_statusOK_when_passing_query_params()
{
    const string uri = "/?id=1";
    var response = Fake.Browser().Get(uri, with => with.HttpRequest());
    response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
Run Code Online (Sandbox Code Playgroud)

谢谢

.net query-string nancy

11
推荐指数
1
解决办法
4161
查看次数

如何从Razor视图中访问Nancy的CurrentUser属性?

我正在尝试访问该CurrentUser属性NancyContext.如何在Razor视图的html中执行此操作?

如果可能的话,我会很感激代码片段.

谢谢

编辑

我现在扩展Nancy.ViewEngines.Razor.HtmlHelpers为给我带有语法糖的交叉视图数据,使视图代码简洁易读.

这里有一些例子:

public static bool IsRegistered<T>(this HtmlHelpers<T> html)
{
    var user = GetUser(html);
    return user != null && user.IsRegistered;
}

public static bool IsAuthenticated<T>(this HtmlHelpers<T> html)
{
    return GetUser(html) != null;
}

public static User GetUser<T>(this HtmlHelpers<T> html)
{
    return (User)html.RenderContext.Context.CurrentUser;
}
Run Code Online (Sandbox Code Playgroud)

还有一些剃刀代码.这里我决定只在用户当前未经过身份验证的情况下包含用于登录弹出窗口(基础显示)的html - 这是有意义的.

@if (!Html.IsAuthenticated())
{
    Html.Partial("Reveals/SignInReveal");
}  
Run Code Online (Sandbox Code Playgroud)

razor nancy

11
推荐指数
1
解决办法
2851
查看次数