小编zlo*_*log的帖子

如何在玉石中添加html标签条件?

,我要放在一个html标记条件按照这种方法,这使在

<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)

在html文件的顶部.

我试过了

//[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]
//[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]
//[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]
//[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]
  head …
Run Code Online (Sandbox Code Playgroud)

html internet-explorer node.js pug

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

如何在生成的d3 html中使用angularjs指令?

我正在尝试在我的d3可视化中使用angularjs 工具提示指令,所以我有类似的东西

var node = svg.selectAll(".node")
    .data(nodes)
    .enter().append("circle")
        .attr("tooltip-append-to-body", true)
        .attr("tooltip", function(d) {
            return d.name;
        })
// ... attributes
Run Code Online (Sandbox Code Playgroud)

但是,工具提示未显示.我需要$compile什么?我也试过把它包裹起来$timeout,但那不起作用.

d3.js angularjs angular-ui angularjs-directive

25
推荐指数
2
解决办法
9621
查看次数

如何使用rspec在sinatra中测试重定向?

我试图在我的sinatra应用程序(更具体地说,一个padrino应用程序)的主页上测试重定向,在rspec中.我发现redirect_to,但它似乎只在rspec-rails中.你如何在sinatra中测试它?

所以基本上,我喜欢这样的东西:

  it "Homepage should redirect to locations#index" do
    get "/"
    last_response.should be_redirect   # This works, but I want it to be more specific
    # last_response.should redirect_to('/locations') # Only works for rspec-rails
  end
Run Code Online (Sandbox Code Playgroud)

ruby rspec sinatra padrino

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

是否可以将哈希标记发送到UIWebView中的文件URL?

我想从文件加载一个html页面,并为其添加一个哈希标记.这可能吗?

我试过了

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someFile" ofType:@"html"];  
NSURL *fileUrl = [NSURL fileURLWithPath:[filePath stringByAppendingFormat:@"#hashtag"]];
[self.webView loadRequest:[NSURLRequest requestWithURL:fileUrl]];    
NSLog(@"fileUrl = %@, reachable? %d", fileUrl, [fileUrl checkResourceIsReachableAndReturnError:nil]);
Run Code Online (Sandbox Code Playgroud)

但这会尝试查找someFile.html%23hashtag无法找到的文件.有没有办法在NSURL创建对象后添加哈希?

我也尝试将文件加载到字符串中并使用loadHTMLString:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someFile" ofType:@"html"];
NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://someFile.html#hashtag"]];
Run Code Online (Sandbox Code Playgroud)

这里的哈希标签确实有效,但我在html中的javascript引用不起作用.这个方法的后续问题是,如何从UIWebView中作为字符串加载的html引用javascript文件,即什么是基本URL?

我能想到的一个黑客就是将我的所有javascript文件内联到html中并将其加载为字符串,但我认为必须有更好的方法!

iphone uiwebview ios

13
推荐指数
2
解决办法
5562
查看次数

Backbone.js创建方法不向sinatra发送参数

我是骨干的新手,并试图在Sinatra中设置它,但我似乎无法让简单的创建工作.

我已经设置了我的模型/集合:

var TEAM_ID = window.location.pathname.split('/')[1]; // From url
$(function () {
  var TeamMember = Backbone.Model.extend({
    defaults: {
      name : ""
    }
  });

  var TeamMembers = Backbone.Collection.extend({
    model: TeamMember,
    url: "/" + TEAM_ID + "/team-members.json"
  });

  var teamMembers = new TeamMembers;

  var TeamMemberView = Backbone.View.extend({
    events: { 
      "click #new-team-member-form .submit-button" : "handleNewTeamMember" 
    },
    handleNewTeamMember: function(data) {
      var inputField = $('input[name=new_team_member_name]');
      console.log("Pre create");

      // This doesn't get sent to the server!!
      var teamMember = teamMembers.create({name: inputField.val());

      console.log("Post create");

      return false; // …
Run Code Online (Sandbox Code Playgroud)

sinatra backbone.js

13
推荐指数
1
解决办法
1629
查看次数

在heroku雪松堆栈上部署sinatra应用程序(使用config.ru)

我正在尝试重构我的sinatra代码,将我的主文件分成单独的文件,使用此响应中的一些提示,我遇到了部署到heroku的麻烦.

以前我没有config.ru文件,只是使用了我的Procfile,这是:

web: bundle exec ruby web.rb -p $PORT
Run Code Online (Sandbox Code Playgroud)

根据这篇文章.

从重构开始,我现在改变了我Procfile的意思

web: bundle exec thin -R config.ru start -p $PORT
Run Code Online (Sandbox Code Playgroud)

随着我的config.ru文件正在

root = ::File.dirname(__FILE__)
require ::File.join( root, 'web' )
run MyApp.new
Run Code Online (Sandbox Code Playgroud)

我的web.rb文件包含在类定义中

class MyApp < Sinatra::Application
  # ...
end
Run Code Online (Sandbox Code Playgroud)

这适用于我的本地开发计算机,但是当我部署到heroku时,我得到了

2011-12-01T11:21:54+00:00 app[web.1]: bundler: command not found: thin
2011-12-01T11:21:54+00:00 app[web.1]: Install missing gem executables with `bundle install`
2011-12-01T11:21:56+00:00 heroku[web.1]: State changed from starting to crashed
2011-12-01T11:22:01+00:00 heroku[router]: …
Run Code Online (Sandbox Code Playgroud)

ruby deployment heroku sinatra

8
推荐指数
1
解决办法
5181
查看次数

缺少UIView的anchorPoint属性

我正在使用来自apple的Touches代码的略微改编的代码(我刚刚将片段的变量名称更改为图像):

- (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
    if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        UIView *image = gestureRecognizer.view;
        CGPoint locationInView = [gestureRecognizer locationInView:image];
        CGPoint locationInSuperview = [gestureRecognizer locationInView:image.superview];

        // Gives error: Property 'anchorPoint' not found on object of type 'CALayer *'
        //image.layer.anchorPoint = CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height);
        // Gives warning: Method '-setAnchorPoint' not found
        [image.layer setAnchorPoint:CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height)];
        image.center = locationInSuperview;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,如注释中所述,image.layer.anchorPoint无法编译,但错误是无法找到'anchorPoint'属性.它在使用消息传递重写行时进行编译,但它仍会发出警告.

直接复制和粘贴Touches代码而不更改名称更改会产生相同的错误.编译Touches代码时也不会出现这些错误.

为什么是这样?

iphone objective-c uiview ios

6
推荐指数
1
解决办法
3257
查看次数

使用omniauth的Sinatra应用程序在ie9中获取Rack :: Protection :: SessionHijacking

我有一个Sinatra应用程序,使用omniauth,不断得到这个错误

attack prevented by Rack::Protection::SessionHijacking
Run Code Online (Sandbox Code Playgroud)

当我尝试登录时(使用谷歌帐户).

它在其他版本的IE和chrome/firefox/safari上运行良好.

我的设置是

rack (1.4.1)
rack-force_domain (0.2.0)
rack-protection (1.2.0)

sinatra (1.3.2)
  rack (~> 1.3, >= 1.3.6)
  rack-protection (~> 1.2)
  tilt (~> 1.3, >= 1.3.3)
omniauth (1.0.3)
  hashie (~> 1.2)
  rack

omniauth-google-oauth2 (0.1.9)
  omniauth (~> 1.0)
  omniauth-oauth2
omniauth-oauth2 (1.0.0)
  oauth2 (~> 0.5.0)
  omniauth (~> 1.0)
Run Code Online (Sandbox Code Playgroud)

谁知道为什么会这样?

internet-explorer rack sinatra omniauth

6
推荐指数
1
解决办法
1853
查看次数

如何在angularjs测试中模拟$ location.host()?

我创建了一个Env包装环境信息的服务,我目前正在使用它$location.host()来确定我所处的环境.如何在我的测试中模拟它?

我已阅读https://groups.google.com/forum/?fromgroups#!topic/angular/F0jFWC4G9hI,但它似乎不起作用,例如:

describe("Env (environment) service", function() {

  var Env;

  beforeEach(module('App'));

  beforeEach(inject(
    ['Env', function(e) {
      Env = e;
    }]
  ));

  describe("for staging", function() {
    beforeEach(inject(function($location, $rootScope) {
      $location.host("http://staging-site.com");
      $rootScope.$apply();
    }));

    it("returns envrionment as staging", function() {
      expect(Env.environment).toEqual("staging");
    });

    it("returns .isStaging() as true", function() {
      expect(Env.isStaging()).toBeTruthy();
    });
  });
});
Run Code Online (Sandbox Code Playgroud)

我也试过了这个$browser变种,但这也行不通.有任何想法吗?

javascript testing mocking angularjs

6
推荐指数
2
解决办法
4523
查看次数

如何修复"Apple目前不接受使用此版本SDK构建的应用程序." 分发iOS SDK 4.2应用程序时出错

这与stackoverflow上的其他几个问题非常相似,但它们似乎都来自去年并且指的是较低的版本号.

我有:

  • xcode版本3.2.5
  • 使用Base SDK =最新iOS(当前设置为iOS 4.2)的分发版本,iOS部署目标= iOS 3.2

没有太多运气,我尝试了以下内容:

  • 部署到设备(不是模拟器)
  • 将iOS部署目标设置为3.0,3.2,4.0,4.1和4.2
  • 清理了我的xcode缓存
  • 通过Application Loader和Organizer部署
  • 做得干净整洁
  • 重新安装xcode < - 结果证明这是问题 - 需要检查它是最终版本(即xcode_3.2.5_and_ios_sdk_4.2_final.dmg)而不是beta版本
  • 试图找到要安装的SDK <4.2的版本,但苹果似乎从他们的开发者网站删除了所有旧版本

我确定iOS 4.2现在应该没有测试版,所以我认为这也不是问题.还有其他想法吗?有没有办法获得有关苹果想要的SDK版本的更多信息?

确实非常令人沮丧!

iphone app-store appstore-approval ios4 ios

5
推荐指数
1
解决办法
2478
查看次数