boy11-2 发表于 2011-01-16 18:27

使用 Soxer 创建第一个网页 Hello World

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 :origin, "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

[图片] 运行结果
http://www.oschina.net/uploads/code/201010/31231720_6SNG.jpg

Superman2468 发表于 2011-01-25 12:25

挺好的 学习一下

2gua 发表于 2011-01-25 13:43

这个有空试试看。

laohuanggua 发表于 2011-01-31 21:22

本帖最后由 laohuanggua 于 2011-01-31 21:24 编辑

基于rails的么???


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

是国内的兄弟搞的???
页: [1]
查看完整版本: 使用 Soxer 创建第一个网页 Hello World