为Django项目简单集成AddThis社交分享小部件。
项目描述
django-addthis
为AddThis社交分享小部件提供Django项目的简单集成。
由Raymond Wanyoike编写,以及一些优秀的贡献者。
安装
首先安装模块,最好在虚拟环境中安装。可以从PyPI安装
pip install django-addthis
设置
您需要将addthis添加到项目settings.py文件中的INSTALLED_APPS中
INSTALLED_APPS += [
'addthis',
]
配置
addthis_widget模板标记需要一个站点配置文件ID:pub_id。要么将其作为pub_id传递,要么在您的ADDTHIS_SETTINGS设置字典中设置PUB_ID
ADDTHIS_SETTINGS = {
'PUB_ID': 'xx-xxxxxxxxxxxxxxxx',
...
}
可以通过访问其在AddThis上的配置文件选项页面来找到站点配置文件ID(ID:)。
在您的ADDTHIS_SETTINGS设置字典中可以放置一些配置选项用于addthis
选项 |
默认值 |
---|---|
USERNAME |
|
SERVICES_EXCLUDE |
|
SERVICES_COMPACT |
|
SERVICES_EXPANDED |
|
SERVICES_CUSTOM |
|
UI_CLICK |
False |
UI_DELAY |
0 |
UI_HOVER_DIRECTION |
0 |
UI_LANGUAGE |
|
UI_OFFSET_TOP |
0 |
UI_OFFSET_LEFT |
0 |
UI_HEADER_COLOR |
|
UI_HEADER_BACKGROUND |
|
UI_COBRAND |
|
UI_USE_CSS |
True |
UI_USE_ADDRESSBOOK |
False |
UI_508_COMPLIANT |
False |
DATA_TRACK_CLICKBACK |
True |
DATA_GA_TRACKER |
请参阅示例应用程序。该应用程序用于手动测试此软件包的功能。这也是一个好例子。
您需要 Django 1.8 或更高版本才能运行它。它可能在较旧版本上运行,但没有进行测试。
用法
首先,在您想要使用它的每个模板中加载 addthis
{% load addthis %}
然后加载小部件
{% addthis_widget %}
访问 AddThis 获取代码 页面并创建/生成您的社交分享代码,例如
<!-- Go to www.addthis.com/dashboard to customize your tools --> <div class=
"addthis_sharing_toolbox"></div>确保省略
<script type=
"text/javascript"src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xx-xxxxxxxxxxxxxxxx"></script>部分代码,因为 addthis_widget 模板标记会处理这一点。
示例
{% load addthis %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>django-addthis Example</title>
</head>
<body>
<!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_sharing_toolbox"></div>
<p>Well, the way they make shows is, they make one show. That show's
called a pilot. Then they show that show to the people who make shows,
and on the strength of that one show they decide if they're going to
make more shows. Some pilots get picked and become television programs.
Some don't, become nothing. She starred in one of the ones that became
nothing.</p>
<!-- Placed at the end of the document so the page load faster -->
{% addthis_widget %}
</body>
</html
贡献
如果您发现了一个错误,实现了一个功能或自定义了模板,并认为它是有用的,那么请考虑贡献。补丁、拉取请求或仅仅是建议都受欢迎!
许可证
django-addthis 在 GNU GPL v3 许可下发布。
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源分布
构建分布
django-addthis-3.0.2.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 3d6a404ba4debf138a8dd225d3cc5ef4106d2cb9a1fcf9c0ddaaaffaed36ba35 |
|
MD5 | c98852282f1d0e2fc234263002fd57ba |
|
BLAKE2b-256 | bd3dbd96807b58702218c9189588106a917525d9cda28395c058606efdde594a |
django_addthis-3.0.2-py3-none-any.whl 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | fbf631fe7403d486d571ef2c510e3199e8f1920f2a687e04a4954a0935532c84 |
|
MD5 | e65751f7e276a55b856818dacf89c064 |
|
BLAKE2b-256 | 06f09852d09ff70504be7bdc6b787baec95ad91e597f2d983df343ea75868af3 |