Apr 08 2008

typo的title调用

Posted by admin

Tags:

在typo里每个theme的layout/default.html.erb是这样来调用标题(title)的
<%=h page_title %>
而Page_title是一个helper方法,它在content_helper方法里定义如下:

def page_title
blog_name = this_blog.blog_name || "Typo"
if @page_title
# this is where the page title prefix (string) should go
(this_blog.title_prefix == 1 ? blog_name + " : " : '') + @page_title + (this_blog.title_prefix == 2 ? " : " + blog_name : '')
else
blog_name
end
end

是不是很奇怪Article控制器里使用
layout :theme_layout, :except => [:comment_preview, :trackback]
来指定模版,但调用Article_controller时却能使用Content_controller器的辅助方法呢?
是这样的,ContentController是Article_controller父类。你细心的话可以在Article_controller顶端看到这样一行代码

class ArticlesController < ContentController

还有两种调用title的基本方法
1、 实例变量
<%= @title || 'welcome' %>
2、 Content_for方法
在helper定义

def set_html_title(str="")
unless str.blank?
content_for :html_title do
"— #{str} "
end
end
end

layout里这样调用
<% set_html_title(@article.name) -%>

Filed under : technology | No Comments »
Mar 26 2008

Typo5.0.3利用Migrator.migrate进行初始化表

Posted by admin

Tags:


if RAILS_ENV != 'test'
begin
ActiveRecord::Base.connection.select_all("select * from sessions")
rescue
Migrator.migrate
end
end

config下的environment.rb文件里增加了上面这代码来实现第一次运行project创建表,不需要像以前安装要rake db:migrate。
配置数据库->script/server就完成了安装,有利于typo的大众化使用。

不过 robinlu提醒说这样启动多个project时可能会有问题。

Filed under : technology | No Comments »
Mar 22 2008

“Couldn’t find Article with ID=orderpublished_at DESC“解决办法

Posted by admin

Tags:

typo的Dirtylicious主题,如果你试图点击左上方的”articles”链接来看历史的文章,你会惊讶的发现会弹出一个错误“”Couldn’t find Article with ID=orderpublished_at DESC”,这是因为articles控制器下的archives方法里没有了:all选项造成查询不了ID。
解决办法:
将\typo\app\controllers目录的articles_controller.rb文件下

def archives
@articles = Article.find_published(:order => 'published_at DESC')
@page_title = "Archives"
end

改为

def archives
@articles = Article.find_published(:all, :order => ‘published_at DESC’)
@page_title = “Archives”
end

Filed under : technology | No Comments »
Mar 22 2008

Typo5.0.3释出

Posted by admin

Tags:

对于一个普通用户来说,与旧版相比,最大的改进莫过于是rich editor用上FCKEditor,试想一下在textile下发个链接要用的’ “” ‘,加个图片要用’ !! ‘ ,可不好受!

默认theme改得有点像mephisto的默认theme的样子。

添加了feedback:
用Jabber account来发邮件通知。

cache的缓存,二种选择:
HTML page caching
use semi static caching (default)

title的优化,可选择三种方案:
At the beginning of page title
At the end of page title
Don’t show blog name in page title

span也弄得有点像wordpress,可选择Akismet Key。 Read more »

Filed under : technology | No Comments »