我尝试在我的角度HTML模板中编写大部分有效的多语言(X)HTML 5.他们看起来像这样:
<div class="some-class">
<input type="checkbox" data-ng-model="variable" />
<foo-directive data-ng-if="variable"></foo-directive>
</div>
Run Code Online (Sandbox Code Playgroud)
有时我会忘记正确关闭标签,这会打破一些浏览器.所以我想在我的工具链中加入验证器.
问题是:我不知道可以处理这种情况的验证器.XML验证器通常需要DTD,HTML验证器会抱怨代码中使用的角度指令.
也许验证者是错误的词,我真的想要一个短信.我想要它做的唯一真实的事情是检查每个开始标记是否具有匹配的结束标记.其他一切都是奖金.
你知道这样的验证器吗?
注意:我主要搜索可以与自动化测试集成的命令行工具.但是,Web服务也可能有所帮助.
我正在使用aiohttp在python 3.4中创建一个简单的HTTP请求,如下所示:
response = yield from aiohttp.get(url)
Run Code Online (Sandbox Code Playgroud)
应用程序一遍又一遍地请求相同的URL,所以我自然想要缓存它.我的第一次尝试是这样的:
@functools.lru_cache(maxsize=128)
def cached_request(url):
return aiohttp.get(url)
Run Code Online (Sandbox Code Playgroud)
第一次调用cached_request工作正常,但在以后的调用中我最终得到None而不是响应对象.
我对asyncio比较新,所以我尝试了很多asyncio.coroutine装饰器的组合,yield from以及其他一些东西,但似乎都没有.
那么缓存协同程序如何工作?
我将一些功能附加到DOM元素,并希望能够在从DOM中删除元素时清除所有引用,以便可以对其进行垃圾回收,
我检测元素removel的初始版本是这样的:
var onremove = function(element, callback) {
var destroy = function() {
callback();
element.removeEventListener('DOMNodeRemovedFromDocument', destroy);
};
element.addEventListener('DOMNodeRemovedFromDocument', destroy);
};
Run Code Online (Sandbox Code Playgroud)
然后我读到变异事件被弃用而支持MutationObserver.所以我试着移植我的代码.这就是我想出的:
var isDescendant = function(desc, root) {
return !!desc && (desc === root || isDecendant(desc.parentNode, root));
};
var onremove = function(element, callback) {
var observer = new MutationObserver(function(mutations) {
_.forEach(mutations, function(mutation) {
_.forEach(mutation.removedNodes, function(removed) {
if (isDescendant(element, removed)) {
callback();
// allow garbage collection
observer.disconnect();
observer = undefined;
}
});
});
});
observer.observe(document, {
childList: true, …Run Code Online (Sandbox Code Playgroud) WCAG 2.0建议还使用:focus何时:hover在链接元素上使用以支持键盘导航.这适用于链接元素,但两者之间存在一些差异.
:hover状态,而只有极少数可以聚焦这个问题严格关于css.有没有办法模拟:hover键盘导航的行为(如上所述)?或者有什么强烈的理由让人不想要那个?
为了使它更清楚这里是一个例子:
HTML:
<div id="box">
foo bar
<a href="#">click me</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#box {
opacity: 0.3;
}
#box:hover {
opacity: 1;
}
#box a:focus {
opacity: 1;
}
Run Code Online (Sandbox Code Playgroud)
使用鼠标时,我会在使用之前将鼠标悬停在link元素上.由于:hover向上传播的状态#box将完全不透明.
使用键盘时,我会在使用前关注链接元素.由于:focus国家并没有向上传播#box将不会是完全不透明.
我正在开发一个系统,该系统大量使用假名来为研究人员提供隐私关键数据.这些假名应具有以下属性:
我的第一个想法是使用UUID4.它们在(1)和(2)上相当不错,但在(3)中却没有那么多.
一种变体是使用更宽的字母表对UUID进行编码,从而产生更短的字符串(例如,参见shortuuid).但我不确定这是否真的提高了可读性.
我目前正在研究的另一种方法是2005年的一篇题为"患者识别符的最佳代码"的论文,旨在解决我的问题.这里描述的算法创建了具有30位熵的8字符假名.我宁愿使用更广泛审查的标准.
然后还有git方法:只显示实际假名的前几个字符.但这意味着化名可能在一段时间后失去其独特性.
所以我的问题是:人类可读的独特ID是否有任何广泛使用的标准?
我对网站的语义有点困惑.我知道每个URI都应该代表一个资源.我假设RDFa在网页内提供的所有信息都描述了该网页的URI所代表的资源.我的问题是:为网站的子页面提供语义数据的最佳做法是什么.
在我的情况下,我想使用带有schema.org和opengraph词汇表的RDFa为一个名为magma的剧院组创建一个网站.假设我有欢迎页面(http://magma.com/),联系页面(http://magma.com/contact/)和各个游戏的页面(http://magma.com/play/<playid>/).
现在我认为欢迎页面和联系页面都代表相同的资源(岩浆),同时提供有关该资源的不同信息.然而,剧本页面代表恰好由岩浆执行的剧本.或者更好地说,游戏页面也代表了岩浆,但提供了由该组执行的游戏信息?我偶然发现的第三个选项是http://schema.org/WebPage.特别是类似的亚型ContactPage似乎是相关的.
在实现方面,我在哪里放置RDFa?
最后:我的选择将如何改变第三方(谷歌,脸谱,...)对待网站的方式?
我意识到这个问题有点模糊.为了使它更具体,我将添加一个你可能会批评的例子:
<html vocab="http://schema.org/" typeof="TheaterGroup">
<head>
<meta charset="UTF-8"/>
<title>Magma - Romeo and Juliet</title>
<!-- magma sematics from a template file -->
<meta property="name" content="Magma"/>
<meta property="logo" content="/static/logo.png"/>
<link rel="home" property="url" content="http://magma.com/"/>
</head>
<body>
<h1>Romeo and Juliet</h1>
<!-- semantics of the play -->
<div typeof="CreativeWork" name="Romeo and Juliet">
...
</div>
<h2>Shows</h2>
<!-- samantics of magma events -->
<ul property="events">
<li typeof="Event"><time property="startDate">...</time></li>
...
</ul>
</body> …Run Code Online (Sandbox Code Playgroud) 我想将 python timedelta 对象格式化为“x 分钟/小时/周/月/年前”。
我知道有一些类似的问题,例如:
但是,我没有找到适合我的情况的答案,因为
timedelta为字符串,而不是相反这是我当前的代码(摘录,抱歉):
delta = babel.dates.format_timedelta(now - dt, format=format,
locale=locale)
if now > dt:
return _(u"%(timedelta)s ago") % {'timedelta': delta}
else:
return _(u"in %(timedelta)s") % {'timedelta': delta}
Run Code Online (Sandbox Code Playgroud)
函数babel见http://babel.pocoo.org/docs/dates/#time-delta-formatting
现在这在英语中效果很好。然而,在德语中,它失败了:上面的代码将转换"2 years ago"为"vor 2 Jahre"而不是"vor 2 Jahren".
我也很高兴有一个不使用"... ago"措辞的解决方案。只要是相似且可翻译的我都可以接受。
所以我正在使用 bootstrap4。我试图将一张卡片放在另外两张堆叠在一起的卡片的左侧,最左边的卡片的固定长度是其他两张卡片的总长度......但我可以'不知道如何做到这一点。
<div class="card w-20">
<blockquote class="blockquote card-body">
<p>This card on the left of the other two cards, with a fixed height and scrolling.</p>
<footer class="blockquote-footer">
<small class="text-muted">
Someone famous in <cite title="Source Title">Source Title</cite>
</small>
</footer>
</blockquote>
</div>
<div class="card w-75">
<div class="card-body">
<h5 class="card-title">How do you want to ask the question?</h5>
<p class="card-text">Enter the information below.</p>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Description</span>
</div>
<textarea class="form-control" aria-label="With textarea"></textarea>
</div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Supplemental Methods</span>
</div>
<button type="button" …Run Code Online (Sandbox Code Playgroud)我想在一个网站上公开一些内容,而其他一些内容仅对经过身份验证的用户可见。因此,身份验证是可能的,但不是必需的。我想知道这是否可能。
一些背景:
首先要告诉客户端身份验证可用,我需要发送一些标头。据我了解RFC 2617,“ WWW-Authenticate”标头字段必须始终是“ 401(未经授权)”响应的一部分。
现在,某些客户端(例如wget)在获得401标头时将停止尝试(wget实际上使用术语“需要授权”而不是“未经授权”)。
那么,这是wget错误还是没有可选的HTTP基本身份验证之类的东西?
angularjs ×1
bootstrap-4 ×1
css ×1
datetime ×1
dom ×1
hover ×1
http ×1
javascript ×1
python ×1
python-3.x ×1
rdfa ×1
semantic-web ×1
standards ×1
uuid ×1
validation ×1
wget ×1
xhtml ×1
xml ×1