这个东西是模仿国外 pastie.org 做的,当然CSS和UI都是复制的。
使用 Ruby on Rails 开发,方便写博客要贴代码的时候可以有更好的显示样式。
当然,除了用于贴代码,这个项目还有一个作用就是记录自已的一些代码片段,你将会有自已的个人主页,会列出分开的代码(代码可设置不公开)。
接下来我将会开放API,如果你愿意,可以通过API完整的导出或导入你的代码。
小小广告一下
http://pasite.orgPasite 上关于 C# 的代码:
http://pasite.org/lang/csharp演示例子(博客园的HTML会把代码的空格去掉,如果你要实现正常的显示,请直接复制代码查看页的内空,然后在博客园后台编辑器的 Normal 视图下面粘贴,否则格式将会有错乱):
# 运行 script/generate mailer Mailer 在 models 里面生成 mailer.rb
# template 放 views 跟 controllers 的用法一样
class Mailer < ActionMailer::Base
layout "mailer"
def regist_successed(user,passwd_unencoded)
subject "欢迎加入 Pasite.org"
recipients user.email
from 'No Reply Pasite.org<no-reply@pasite.org>'
sent_on Time.now
body_array = {:user => user, :passwd => passwd_unencoded}
body body_array
template "regist_successed"
end
def snippet_got_comment(comment,snippet)
subject "Pasite.org 评论提醒"
recipients snippet.user.email
from 'No Reply Pasite.org<no-reply@pasite.org>'
sent_on Time.now
body_array = {:comment => comment, :snippet => snippet}
body body_array
template "snippet_got_comment"
end
# register successed message
def self.regist_successed(user,passwd)
Thread.new {
Mailer.deliver_regist_successed(user,passwd)
}
end
# snippet got comment tip
def self.snippet_got_comment(comment,snippet)
Thread.new {
Mailer.deliver_snippet_got_comment(comment,snippet)
}
end
end