跳转到主要内容

用于管理“新功能”界面的简单应用程序。

项目描述

Django What's New
==================


基于包版本管理的“新功能”欢迎界面简单应用程序。

.. note:: 包必须包含在主模块的 __init__ 中的有效PEP386条目。


如何使用
----------

- 在您的 INSTALLED_APPS 中添加 ``whatsnew``:

INSTALLED_APPS=(
...
'whatsnew'
)


- 修改您的基模板如下

.. code-block:: html
<link href="{% static 'whatsnew/whatsnew.min.css' %}" rel="stylesheet" media="screen">
<script language="JavaScript" src="{% static 'whatsnew/js/whatsnew.min.js' %}"></script>

{% load whatsnew %}

<body>
{% whatsnew '<your_main_package_name>' %}

- 创建您的 :file:`whatsnew/whatsnew.html` 如下

.. code-block:: html
<style>
#django-whatsnew .button.b-close {
background-color: #2B91AF;
border-radius: 7px;
box-shadow: none;
font: bold 131% sans-serif;
cursor: pointer;
padding: 0 6px 2px;
position: absolute;
right: -7px;
top: -7px;
text-align: center;
text-decoration: none;
}

#django-whatsnew {
font-size: 200%;
background-color: #FFFFFF;
border-radius: 10px;
box-shadow: 0 0 25px 5px #999999;
color: #111111;
display: none;
min-width: 450px;
padding: 0px 5px 5px 15px;
}
</style>
<script>
{% if display %}

function setCookie(name, value, days) {
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
} else {
expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/";
}
setCookie('{{ name }}', '{{ news.version }}');
You can't use 'macro parameter character #' in math mode('.b-close').click(function () {
window.history.go(-1);
})

</script>
{% endblock body %}
{% block jira %}{% endblock jira %}


如何检查版本
------------------------

- 尝试使用setuptools获取版本号
- 检查主包名中的'version'、'VERSION'或'__version__'
- 尝试调用package.get_version()
- 抛出DistributionNotFound异常