2007-08
23

Wordpress首页摘要输出而RSS全文输出的解决方案

从一开始,我的 blog 就采用首页输出文章摘要而 RSS feed 输出全文的办法。由于文章的长短参差不齐,贴有代码的文章会显得很长,而且还有很多文章中插有图片和视频,所以如果首页输出全文,会影响页面的整体美观和载入速度。但是在 RSS 中,我认为应该输出全文,否则读者阅读起来不是很方便。

我们从 Wordpress 的输出设置中可以了解,在文章中使用 <!–more–> 标记能够把首页显示的文章截断,达到输出摘要的目的,但是这样做会把 RSS 的文章也给截断,这样就不能达到两者兼顾的目的了。

之前我一直使用中文 WordPress 工具箱这个插件来实现截断首页文章的效果,它不会把 RSS 的输出截断。其实这个功能就是调用了 wordpress 本身的一个函数,但是它有一个缺点就是会过滤掉所有的超文本标记,比如标题、链接、图片等,造成的结果就是首页显示的摘要完全是纯文本的,而且如果文章很短,在首页可以完全显示,后面还会是多一个“继续阅读其他部分”。所以还是不用 wp 自带的摘要功能了,重新找一个办法。

经过查找,终于找到了这个问题的解决方法如下: 还没有完呢,请继续阅读……

2007-08
17

我的Wordpress支持手机WAP浏览了

昨天闲着无聊的时候用手机上了一下网,用 opera 浏览了一下我的blog,速度虽然可以,但是我发现流量还是挺大的,在页面还没有完全载入的情况下已经达到了80多kb,在高额的 GPRS 收费标准下,这种流量难以接受,毕竟现在武汉没有不限流量的包月套餐。

于是考虑为 blog 创建一个 WAP 版,然后就发现了 WP-WAP 这个插件。其实这也不算是一个插件,因为它不需要放在 plugins 目录下,而是直接放在网站的根目录下。使用也很简单,解压后只有 wp-wap.php 和 wp-wap-comments.php 两个文件,放在根目录下即可,然后就可以用手机通过这个地址 http://www.helloxudan.net/wp-wap.php 来访问了,在电脑上也可以用 opera 浏览器访问这个地址,看起来非常简洁,可以节省很多流量。暂时还不知道怎么绑定二级域名,如果有哪位朋友知道请指点一下。

虽然现在很有可能只有我一个人使用手机访问我的blog,但是不论用户怎么样,作为站长,该做的工作是不能含糊的。

2007-08
12

活动宣传:首届WordPress主题设计大赛

简介:

作为网上最好的开源博客工具与平台,WordPress 发展到今天已经是是第四个年头, 并且得到了Bloggers的广泛支持,国内外众多 WordPress 爱好者已经设计了成千上万的精致主题。为了激励国内WordPress爱好者的创作热情,WordPress中文论坛携手盘古网络于2007年8月至10月举办首届WordPress主题设计大赛,为国内WordPress 使用者提供一个一展身手、展示自己的平台,同时为广大 WordPress 使用者提供更多更好的主题。

活动时间:8月至10月底

活动主办:WordPress中文论坛

活动协办:网帆互动 蓝色理想

赞 助 商:盘古网络

参与方式:

您可以选择以下方式参赛:

  1. 比赛截止日期前将参赛作品邮件发送到指定邮箱 wordpress.org.cn@gmail.com
  2. 比赛截止日期前将参赛作品通过发帖形式上传至WordPress中文论坛专门板块。

您也可以通过为参赛者投票的方式参与此次活动。对您的支持,我们表示诚挚的谢意!

参赛作品要求:

  1. 要求原创作品,不接受对其他主题的简单修改版本,包括对其进行汉化、简单修改外观、更改代码等处理后重新发布的版本。
  2. 完整的 WordPress 主题代码,至少包括 index.php header.php footer.php single.php 404.php archive.php search.php 等文件。
  3. 参赛作品必须遵循 GNU General Public License 版权规则或其的兼容版本。
  4. 不能包含主题无关的内容与链接,特别是赞助商链接。
  5. 建议代码至少通过 XHTML 1.0 Transitional 验证。(通过XHTML严格验证可以得到额外加分)
  6. 主题应尽量保持在IE6、IE7、FF2、Opera,Safari3等浏览器下显示基本一致,即有一定的浏览器兼容性。

说明:以WordPress默认主题代码框架进行设计是完全允许的,同时还可以选择Sandbox或者K2作为代码框架。
还没有完呢,请继续阅读……

2007-08
09

更新至WordPress2.2.2

这次升级并没有改变数据库的结构,也没有功能上的改变,只是修复了几处 bug ,所以可以放心、安全地升级。

为方便大家,提供wordpress 2.2.2 下载:

  • wordpress 2.2.1 到 2.2.2 升级包(直接覆盖即可):下载
  • wordpress 2.2.2 简体中文完整安装包:下载
2007-07
31

在Wordpress中加入Google AJAX Search

这两天在为博客添加 Google 搜索功能的时候了解到了 Google AJAX Search ,听闻其功能很强大,于是马上 google 了一下,学习怎样加入到 wordpress 中。

在使用过程中参考了徘徊在玻璃之城的文章Google AJAX Search 使用简介,成功地将 Google AJAX Search加入到了我的 blog 中。下面给大家共享一下具体怎样做:(更新:由于 Google Ajax 搜索代码很多,比较拖速度,故本站暂停使用。本文介绍的方法仍然有效。)

首先你要做的是去 Google 的网站申请一个 Google AJAX Search API ,点击左下角的确认框,并且输入你的 blog 地址后,你会得到一个长长的 Key 。

然后把如下代码加入到你的 header.php 的 <head> 和 </head> 之间。

<script src=http://www.google.com/uds/api?file=uds.js&v=1.0&key=请在此处填写你的key type=text/javascript></script>
<script language=Javascript type=text/javascript>//<![CDATA[
function OnLoad() {
//
create a search control
var searchControl = new GSearchControl();
searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF); //可选项,如果删除此行,搜索结果将在新页中打开
searchControl.setResultSetSize(GSearch.LARGE_RESULTSET); //可选项,如果删除此行,搜索结果将从10条变为4

// create a draw options object so that we
//
can position the search form root
var options = new GdrawOptions();
options.setSearchFormRoot(document.getElementById(searchForm));
options.setDrawMode(GSearchControl.DRAW_MODE_TABBED);

var siteSearch = new GwebSearch();
siteSearch.setUserDefinedLabel(填入你的网站标签);
siteSearch.setUserDefinedClassSuffix(siteSearch);
siteSearch.setSiteRestriction(填入你的blog网址);
searchControl.addSearcher(siteSearch);

// standard, unrestricted web search
searchControl.addSearcher(new GwebSearch());

searchControl.draw(document.getElementById(searchResults), options);
}
GSearch.setOnLoadCallback(OnLoad);
//]]
>
</script>

几个需要修改的地方已经在代码中说明。

接下来就看你需要什么样的显示方式了,你可以选择把搜索栏和搜索结果分开显示(就像我的一样),或者在一起显示。

  • 分开显示:

在你需要显示搜索结果的地方(如 index.php 或 single.php 中)加入如下代码(我放在了 <div id=”content”> 之后):

<div id=searchResults/></div>

然后在你需要显示搜索栏的地方加入如下代码(我放在了 sidebar.php 中):

<div id=searchForm></div>

  • 一起显示:

在你需要显示搜索栏和结果的地方加入如下代码:

<div id=searchResults/></div>

注意:经过我的测试,把搜索栏和搜索结果一起显示不需要 <div id=”searchForm”></div> ,在 <div id=”searchResults”/></div> 处会显示搜索栏和搜索结果。

最后,再把搜索栏和搜索结果的 CSS 样式加入你的 style.css 中,然后按照你自己的风格修改一下,就大功告成了。CSS 代码如下(需要修改的地方已经在代码中说明):

/** Copyright 2005 Google Inc. All rights reserved. */

/* the GSearchControl CSS Classes
* .gsc-control :主显示框
*/
.gsc-control {
width: 98%;
}

.gsc-control div {
position: static;
}

/* control inputs
* .gsc-search-box : 搜索栏大小
* .gsc-input : the text input area
* .gsc-keeper : the save link below savable results
*/
form.gsc-search-box {
width: 96%;
}

/*
* This table contains the input element as well as the search button
* Note that the search button column is fixed width, designed to hold the
* button divs background image
*/
table.gsc-search-box {
width : 100%;
margin-bottom : 2px;
margin-top : 5px;
margin-left: -6px;
}

td.gsc-search-button {
width : 1%;
}

td.gsc-clear-button {
width : 14px;
}

/**
* undo common generic table rules
* that tend to impact branding
*/
table.gsc-branding td,
table.gsc-branding {
margin: 0 0 0 0;
padding: 0 0 0 0;
border : none;
}

table.gsc-branding {
border-style : none;
border-width : 0px;
border-spacing : 0px 0px;
width : 100%;
}

td.gsc-branding-text {
vertical-align : top;
}

td.gsc-branding-text div.gsc-branding-text {
padding-bottom : 2px;
text-align : right;
color : #676767;
font-size : 11px;
margin-right : 2px;
}

td.gsc-branding-img-noclear {
width : 51px;
vertical-align : bottom;
}

td.gsc-branding-img {
width : 60px;
vertical-align : bottom;
}

input.gsc-search-button {
margin-left : 4px;
}

div.gsc-clear-button {
display : inline;
text-align : right;
margin-left : 4px;
margin-right : 4px;
padding-left : 10px;
background-repeat: no-repeat;
background-position: center center;
background-image: url(’http://www.google.com/uds/css/clear.gif’);
cursor : pointer;
}

/*
* Given that this is sitting in a variable width tabel cell, the idea is
* for it to consume the entire cell. The adjacent cell contains the search
* button and that is a fixed width cell.
*/
input.gsc-input {
padding-left : 2px;
border-style : solid;
border-width : 1px;
border-color : #BCCDF0;
width : 99%;
}

/* tabbed mode of search control
* .gsc-tabsArea : the box containing all of the tabs
* .gsc-tabsAreaInvisible : same as above, but this is the state when search has been cleared
* .gsc-tabHeader : an individual tab
* .gsc-tabHeader.gsc-tabhActive : the active tab
* .gsc-tabHeader.gsc-tabhInactive : an inactive tab
* .gsc-tabData : the data area/box containg results and header data for each tab
* .gsc-tabData.gsc-tabdActive : the data area for the active tab
* .gsc-tabData.gsc-tabdInactive : the data area for inactive tabs
*/
.gsc-tabsArea {
clear: both;
margin-top: 6px;
}

.gsc-tabsAreaInvisible {
display : none;
}

.gsc-tabHeader {
display: inline;
cursor: pointer;
display: inline;
padding: 2px 10px !important;
border: 1px solid #999; /*可修改搜索结果标题栏的边框颜色*/
border-bottom: none;
margin-bottom: 0;
margin-right: -6px; /*不要修改*/
margin-left: 10px; /*不要修改*/
}

.gsc-tabHeader.gsc-tabhActive {
background: #f3fce6; /*正在显示的搜索结果标题栏的背景*/
color: #0C72A2; /*正在显示的搜索结果标题栏的字体颜色*/

}

.gsc-tabHeader.gsc-tabhInactive {

}

.gsc-tabData.gsc-tabdActive {
display: block;
border: 1px solid #999; /*搜索结果显示栏的边框颜色*/
padding:10px;
background: #f3fce6; /*搜索结果显示栏的背景颜色*/
margin-bottom:10px; /*搜索结果显示栏内文字字体*/
font-size:14px;
}

/*此代码只对IE6适用*/
* html .gsc-tabData.gsc-tabdActive {
display: block;
border: 1px solid #999; /*搜索结果显示栏的边框颜色*/
padding:10px;
background: #f3fce6; /*搜索结果显示栏的背景颜色*/
margin-bottom:10px; /*搜索结果显示栏内文字字体*/
font-size:14px;
margin-top:1px; /*不要更改,保证tab显示效果和firefox一致*/
}

/*此代码只对IE7适用*/
*+ html .gsc-tabData.gsc-tabdActive {
display: block;
border: 1px solid #999; /*搜索结果显示栏的边框颜色*/
padding:10px;
background: #f3fce6; /*搜索结果显示栏的背景颜色*/
margin-bottom:10px; /*搜索结果显示栏内文字字体*/
font-size:14px;
margin-top:1px; /*不要更改,保证tab显示效果和firefox一致*/
}

.gsc-tabData.gsc-tabdInactive {
display: none;
}

/* tab specific results header supression
* - no twiddle, tabbed mode runs in full expand mode
* - no title
* - no stats
*/
.gsc-tabData .gsc-resultsHeader .gsc-title {
display: none;
}

.gsc-tabData .gsc-resultsHeader .gsc-stats {
display: none;
}

.gsc-tabData .gsc-resultsHeader .gsc-results-selector {
display : none;
}

/* the results for each section
* .gsc-resultsbox-{visible,invisible} : a complete-collection of results including headers
* .gsc-results : the collection of results for a given searcher
* .gsc-result : a generic result within the control. each result has this class, as well as .gsc-xxxResult where xxx is web, image, local, blog, etc.
*/

.gsc-resultsbox-visible {
display : block;
}

.gsc-resultsbox-invisible {
display : none;
}

.gsc-results {
clear: both;
padding-bottom: 2px;
}

.gsc-result {
margin-bottom: 10px;
}

.gsc-result .gs-title {
height: 1.4em;
overflow: hidden;
}

/* specialized, result type specific, fine grained controls */
.gsc-result div.gs-watermark {
display: none;
}

/* Ads
*/
.gsc-results .gsc-result img.gs-ad-marker {
display: none;
}

/*** End of Control, Begin Results ***/

/* generic, cross cutting result style
* - in the form of .gs-result .gs-xxx where xxx is the generic style
* .gs-title : typically the first line of a result, typically a link, image results over ride this, since for image results, the image is the link
* .gs-divider : typically seperates results from ads
* .gs-visibleUrl : typically the last line of a result, displayed in green. sometimes a link (like in blog search)
* .gs-clusterUrl : for news, and other similar services, this is a cluster of additional results
* img.gs-image : an actial image in a result
* .gs-phone : a phone number
* .gs-address : an address (includes street, city, region, country)
* .gs-streetAddress : a street (including #)
* .gs-city : a city
* .gs-region : a region (zip code, area, etc.)
* .gs-country : a country
* .gs-snippet : snippetized content
* .gs-watermark : indicator that user selected this result
* .gs-metadata : generic metadata, e.g.,
* .gs-image-box : generic container for a results image (within a table)
* .gs-text-box : generic container for a results text content (within a table). Note that this class, and image-box are only used in video
*/
.gs-result .gs-title,
.gs-result .gs-title * {
color: #0C72A2; /*搜索结果内容标题栏颜色 */
font-weight: bold;
text-decoration: underline;
padding-bottom:5px;
}

.gs-divider {
padding-bottom: 8px;
text-align: center;
color: #676767;
}

.gs-result a.gs-visibleUrl,
.gs-result .gs-visibleUrl {
color: #789d47; /*搜索结果来源网站的颜色 */
text-decoration: none;
}

.gs-webResult div.gs-visibleUrl-long {
width : 100%;
overflow : hidden;
display : none;
}