标签:
在前面的文章“Scopes 关键词 (keyword)及departments探讨(英文视频)”中,我们已经对Scope中的keyword做了一些基本的介绍。但是我们没有相应的教程。在这篇文章中,我们将通过youku Scope来介绍如何使用keyword从而使得一个Scope在不同的聚合Scope中来得到不同的呈现。
如果大家对如何开发Scope还不是很熟的话,请参阅我的教程“在Ubuntu OS上创建一个dianping Scope (Qt JSON)”。如果大家对创建Scope很熟的话,相信要不了一两个小时,你就可以创建一个和我相差不多的一个Scope来。
[ScopeConfig] _DisplayName=Youku Scope _Description=This is a Youku scope Art=screenshot.png Author=Firstname Lastname Icon=icon.png Keywords=video;videos [Appearance] PageHeader.Logo=logo.png
void Query::run(sc::SearchReplyProxy const& reply) {
auto metadata_ = search_metadata();
if (metadata_.is_aggregated()) {
auto keywords = metadata_.aggregated_keywords();
if ( (keywords.find("videos") != keywords.end()) ||
(keywords.find("video") != keywords.end()) ) {
qDebug() << "it is a video scope";
do_videos_search(reply);
}
} else {
qDebug() << "it is a normal video scope";
do_normal_search(reply);
}
}const std::string VIDEOS_TEMPLATE = R"(
{
"schema-version": 1,
"template": {
"category-layout": "grid",
"card-size": "large",
"overlay": true
},
"components": {
"title": "title",
"subtitle": "subtitle",
"art" : {
"field": "art",
"aspect-ratio": 2.0
}
}
}
)";
如何在Scope中利用keyword来使自己的Scope在聚合Scope中展示自己
标签:
原文地址:http://blog.csdn.net/ubuntutouch/article/details/46533519