- 论坛徽章:
- 0
|
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
[图片] 运行结果
![]() |
|