免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2664 | 回复: 3
打印 上一主题 下一主题

使用 Soxer 创建第一个网页 Hello World [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-16 18:27 |只看该作者 |倒序浏览
Soxer 是一个适合懒人的程序员和设计师使用的网页发布工具,可使用它来创建和维护基于文档的网站,例如公司网站、博客和项目网站;同时它也非常适合用来创建数据库应用的版面编排。使用 YAML 文件而不是数据库来进行数据传输。



[代码] 安装并创建应用目录
01 # Create all needed directories  

02 mkdir myapp myapp/lib myapp/public myapp/views myapp/content  

03   

04 # Download and untar the Soxer source.  

05 cd myapp/lib  

06 wget http://soxer.mutsu.org/downloads/latest.tar.bz2  

07 tar xvjf latest.tar.bz2  

08 rm latest.tar.bz2  

09   

10 # Create main application file and our index file for content.  

11 cd ../  

12 touch app.rb content/index.yaml

[代码] index.yaml
1 # << /content/index.yaml  

2 # ---------------------------------------------------------------------  

3 content: Hello World!

[代码] app.rb
01 # << /app.rb  

02 # ---------------------------------------------------------------------  

03 require "rubygems"

04 require "sinatra"

05 require "lib/soxer.rb"

06   

07 # This will set the origin or "base directory" of your web site.  

08 # This is not the base directory of your application. This is usualy  

09 # a subdirectory under you application directory  

10 set rigin, "content"

11   

12 get '*/?' do

13   # The magic begins: first soxer's get_page loads the proper file  

14   page = get_page  

15   # Then the page is displayed  

16   page['content']  

17 end

[代码] 运行
1 toni@doug:~/Documents/myapp$ ruby app.rb   

2 == Sinatra/1.0 has taken the stage on 4567 for development with backup from Thin  

3 >> Thin web server (v1.2.7 codename No Hup)  

4 >> Maximum connections set to 1024  

5 >> Listening on 0.0.0.0:4567, CTRL+C to stop

[图片] 运行结果

论坛徽章:
0
2 [报告]
发表于 2011-01-25 12:25 |只看该作者
挺好的 学习一下

论坛徽章:
0
3 [报告]
发表于 2011-01-25 13:43 |只看该作者
这个有空试试看。

论坛徽章:
0
4 [报告]
发表于 2011-01-31 21:22 |只看该作者
本帖最后由 laohuanggua 于 2011-01-31 21:24 编辑

基于rails的么???


http://www.oschina.net/code/snippet_12_1218

是国内的兄弟搞的???
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP