流行的火焰图标未在CKAN中显示

时间:2018-10-31 17:13:58

标签: python css less jinja2 ckan

场景:

我在helpers.py中使用默认的常用功能。但是,在具有10个以上视图的包/资源之后,它将不会显示该图标。如何在resource_item.html模板中设置常用功能,如下所示:

{{ h.popular('views', res.tracking_summary.total, min=10) }}

我还检查了将由h.popular呈现的代码段:

{% if number >= min %}
<span class="popular ckan-icon ckan-icon-flame" title="{{ title.format(number=number) }}" xmlns="http://www.w3.org/1999/xhtml">{{ _('Popular') }}</span>
{% endif %}

它只能呈现“流行”文本。我试图删除该文本,似乎CKAN无法获得ckan-icon-flame。然后,我检查了icons.less,并定义了ckan-icon-flame

其他信息:

我实施了自定义的跟踪工具。因此,我没有在ckan.tracking_enabled文件中启用ckan.ini。我想知道此更改是否与正确加载图标有关。但是根据对代码的阅读,我发现没有任何与图标渲染有关的条件。

更多信息:

variable.less:

@imagePath: "../../../base/images";
@spritePath: "@{imagePath}/sprite-ckan-icons.png";

icons.less:

.ckan-icon {
    //.ie7-restore-right-whitespace;
    display: inline-block;
    vertical-align: text-bottom;
    position: relative;
    top: 2px;
    width: 16px;
    height: 16px;
    background-image: url("@{imagePath}/sprite-ckan-icons.png");
    background-repeat: no-repeat;
    background-position: 16px 16px;
}

.ckan-icon-background-position(@offset,
@size) {
    @w: "@{size}X";
    @h: "@{size}Y";
    @x: "@{size}OffsetX";
    @y: "@{size}OffsetY";
    width: @@w;
    height: @@h;
    background-position: (@@x * @offset) @@y;
}

.ckan-icon-flame {
    .ckan-icon-background-position(2,
    "medium")
}

1 个答案:

答案 0 :(得分:1)

CKAN具有默认的CSS。它还允许开发人员自定义默认的CSS。我的问题是由覆盖引起的。我的新样式表将完全覆盖默认的CSS,而不是将它们添加到默认文件中。有关更详细的讨论,您可以在此处参考问题:https://github.com/ckan/ckan/issues/4542