存档

文章标签 ‘bug’

wordpress不显示分类列表title的bug

2009年10月28日 1 条评论

刚才把菜单栏清理了一下,就剩下about页面。于是把inove的分类列表提到menu栏,右边的sidebar也缩短了不少。
但是立马出现了一个新问题,菜单中鼠标移过去会有title信息遮住二级菜单,按照文档说明修改后却没有生效,如图:

has category title

has category title


首先,查了一下wp_list_categories函数的用法:http://codex.wordpress.org/Template_Tags/wp_list_categories,按照文档里描述的,把use_desc_for_title参数设置为0就行:
wp_list_categories('title_li=0&orderby=name&show_count=0&use_desc_for_title=1');

use_desc_for_title
(boolean) Sets whether a category’s description is inserted into the title attribute of the links created (i.e. <a title=”<em>Category Description</em>” href=”…). The default is true (category descriptions will be inserted). Valid values:
1 (True) – Default
0 (False)

查看wp-includes/classes.php中wp_list_categories函数定义才发现有bug:

1331 if ( $use_desc_for_title == 0 || empty($category->description) )
1332 $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
1333 else
1334 $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description',
$category->description, $category ) ) ) . '"';

很显然,不管use_desc_for_title参数是0还是1都会显示title信息,无语了,稍微改动一下:

1331 if ( $use_desc_for_title == 1 && empty($category->description) )
1332 $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
1333 else if($use_desc_for_title == 1 && !empty($category->description))
1334 $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';

总算隐藏掉了分类列表的title信息了,如图

no category title

no category title

百度搜索结果页UTF-8字符显示乱码的Bug

2009年10月7日 没有评论

搜索”site:zealot.hitidea.org”时出现的。(http://blog.losthit.com还没被收录,不然就直接搜“site:losthit.com”了-_-|||)

baidu搜索结果也url乱码,UTF8没处理

baidu搜索结果也url乱码,UTF8没处理

而Google正确处理了这个UTF8编码,如图所示

Google的URL没有问题

Google的URL没有问题

对比图

对比图

对比图

不过上述对比不严谨,http://zealot.hitidea.org是UTF-8编码,Baidu页面是gb2312编码,而Google页面恰好是UTF-8编码的。一时找不着gbk编码的网站url,只好这样了。不过无论如何,显示乱码是难以容忍的。

C++解析json的parser,tinyjson问题的解决办法

2009年4月26日 没有评论

前不久需要解析一个json的接口,上json官网(http://www.json.org/json-zh.html)上找找C++parser。结果发现长长的list,支持各种语言的各种版本。上第一个官网看看(http://blog.beef.de/projects/tinyjson/),对tiny**的东西还是比较感兴趣的,比如tinyxml。。。

果然够tiny,下载下来一看发现只有一个.hpp文件就行了。接下来就开始ft了,按照官网上的sample调用了一下,编译都不过:

../include/tinyjson/tinyjson.hpp: In function ‘typename json::grammar<typename Iterator::value_type>::variant json::parse(const Iterator&, const Iterator&)’:

../include/tinyjson/tinyjson.hpp:549: error: expected `;’ before ‘st’

../include/tinyjson/tinyjson.hpp:550: error: ‘st’ was not declared in this scope

../include/tinyjson/tinyjson.hpp: In function ‘typename json::grammar<typename Iterator::value_type>::variant json::parse(const Iterator&, const Iterator&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]‘:

test.cpp:45: instantiated from here

../include/tinyjson/tinyjson.hpp:549: error: dependent-name ‘json::grammar<typename Iterator::value_type>::stack’ is parsed as a non-type, but instantiation yields a type

../include/tinyjson/tinyjson.hpp:549: note: say ‘typename json::grammar<typename Iterator::value_type>::stack’ if a type is meant

……

google了一下,相关资料真少,难道用c++解析json很发指么,最后硬着头皮在这个日文的bloghttp://d.hatena.ne.jp/S_Nakayama/20081207/1228592806)上找到了答案。修改记录如下:

549c549

< json::grammar< typename Iterator::value_type >::stack st;

> typename json::grammar< typename Iterator::value_type >::stack st;

565c565

< return json::grammar< typename Iterator::value_type >::variant(new boost::any());

> return typename json::grammar< typename Iterator::value_type >::variant(new boost::any());

相应的加上typename就行了。

最后,还想说一句,tinyjson官网的sample里遍历的方法也没编译过,最后改了一下遍历函数的参数,函数原型是void Traverse(json::grammar<char>::variant const v, const string& name, int level)。name表示上级节点名称,level表示当前内容的深度。虽然看着还是不爽,但好歹能工作了。