TagCloud with xml
来源:互联网 发布:淘宝有开刃的剑么? 编辑:程序博客网 时间:2024/05/14 06:29
Django后台开发 加了个3D标签云的插件
3DTagCloudwithXML 中使用的是xml生成方式 为了xml自动化生成 而不需要去手工修改xml 特地写了个xmlgenerator 比较粗糙 主要还是上一篇将的库导入以及环境变量的问题
具体代码如下:
#!/usr/bin/python
from xml.etree import ElementTree
from xml.etree.ElementTree import Element,SubElement,tostring
from xml.dom import minidom
import random
#from django.conf import settings
from sys import path
path.extend(['/home/zoueswebsite', '/home/zoueswebsite/blog', '/home/zoueswebsite/zoueswebsite'])
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'zoueswebsite.settings'
from blog.models import *
def prettify(elem):
rough_string = ElementTree.tostring(elem, 'utf-8')
parse_string = minidom.parseString(rough_string)
return parse_string.toprettyxml(indent=" ")
root = Element('tag')
for num, value in enumerate(Category.objects.all()):
SubElement(root, 'a',{'href': '/category/'+value.alias,
'class': "tag-link-" + str(Category.objects.count()),
'title': "2 topics",
'rel': "tag",
'style': "font-size:"+ str(random.uniform(10, 20))+"pt;",
'color': "0xff0099",
})
with open('category.xml','w') as f:
f.write(prettify(root))
- TagCloud with xml
- Flash TagCloud中文版.
- tagcloud标签云
- Getting Groovy with XML
- Working with XML nodes
- Working with XML nodes
- System Architecture with XML
- XML with C#
- XML with C# 2
- Write jsp with xml
- Displaying XML with XSLT
- XML Processing with Python
- Displaying XML with CSS
- Displaying XML with XSLT
- Read XML with namespace
- Loading XML with Javascript
- Easier XML With Boost
- Displaying XML with XSLT
- HDU 1885 Key Task 状态压缩+搜索
- 数据结构与算法问题 二叉树
- java (4) - break和continue用法详解 -万万没想到系列(2)
- 图像处理和图像识别中常用的OpenCV函数
- Cookies揭秘 [Asp.Net, Javascript]
- TagCloud with xml
- ViewPager嵌套GridView引发的一系列UI卡顿不顺畅的问题
- 少年程序员的奇幻漂流(一)柳少侠前传
- 排序总结
- ny 532 不吉利的数字 no
- 都回去无考核的空间哈的空间去外地
- 20-网页设计Android界面
- 回文数算法
- bzoj1112 [POI2008]砖块Klo