Monday, June 27, 2005

Forrest (Publishing framework)

ช่วงนี้นั่งทำเอกสาร tutorial อยู่
ก็เลยมองหา tool มาช่วยเขียน
จำได้ว่าพวก Apache ใช้มาตรฐาน xdoc
ในการทำเอกสาร ก็เลยตามเข้าไปดู

ไปเจอโปรเจค Forrest เข้า
Apache Forrest is a publishing framework that
transforms input from various sources
into a unified presentation
in one or more output formats

ก็เลย load มาทดลองใช้ดู

การใช้งาน ก็ง่ายดี
เริ่มต้นด้วยการสร้าง project ใหม่
ด้วยคำสั่ง forrest seed
โดยเจ้า forrest จะสร้าง directory, template file
ต่างๆให้



จากนั้นเราก็เข้าไป edit เอกสาร
ซึ่งใช้ format xdoc
และถ้าต้องการ generate web site ก็เพียงแต่สั่ง
forrest run เจ้า forrest ก็จะจัดการ
generate ให้เรียบร้อย

นอกจากนี้ยังสามารถ start เป็น web application ได้ด้วย
โดยสั่ง forrest run
เจ้า forrest ก็จะทำการ start jetty ให้
บน port 8888 ทำให้เราสามารถแก้ไขเอกสาร
พร้อมกับดูผลลัพท์ได้ทันที

หลังจากลองใช้สักพัก ก็เริ่มโลภมาก
อยากได้ feature source highlight
โดยกะว่าจะเพิ่ม tag พิเศษที่ชื่อ <javacode>
จะได้เอาไว้ render source code ให้มีสีสรรสวยงาม
ก็เลยค้นเอกสาร forrest
จึงรู้ว่า เจ้า forrest ใช้ cocoon เป็นฐานราก
Cocoon implements these concepts around
the notion of 'component pipelines',
each component on the pipeline
specializing on a particular operation.
This makes it possible to use a Lego(tm)-like approach
in building web solutions,
hooking together components into pipelines
without any required programming.

ใน pipeline ของ cocoon จะมี component
อยู่ 3 แบบก็คือ
  • generator ทำหน้าที่สร้าง xml sax event
    ขึ้นจาก source ต่างๆ ไม่ว่าจะเป็น file system
    ,jdbc, xml database, etc..
  • transformer ทำหน้าที่ตามชื่อ
    โดยรับ input เป็น sax event
    และให้ output เป็น sax event
  • Serializer ทำหน้าที่แปลง
    sax event ออกเป็น final format
    ซึ่งอาจจะเป็น html, pdf, svg, office document, etc..

forrests เปิดโอกาสให้เรา customize pipeline ได้
ก็เลยกะว่าจะ implements เจ้า Java2HtmlTransformer
ขึ้นมาเอง และก็ add เข้าไปใน pipeline ของ forrest เสีย
โดยเอา library java2html มาใช้

Related link from Roti

No comments: