Mercurial > hg > Members > shoshi > TreeCMS > TreeCMSPrototype1
view src/treecms/demo/ContentsTreeBuilder.java @ 50:a72718a0bccf
added demo tree builder
author | shoshi |
---|---|
date | Tue, 01 Feb 2011 16:28:49 +0900 |
parents | |
children | 1b78f1f3add3 |
line wrap: on
line source
package treecms.demo; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.nio.ByteBuffer; import java.util.Calendar; import org.apache.commons.codec.binary.Base64; import treecms.proto.api.Node; import treecms.proto.simple.SimpleBrowser; public class ContentsTreeBuilder { public static Node blogSite() throws Exception { Node root = SimpleBrowser.getSingleton().useContents(); root.setTitle("ブログ形式サイト"); //contents Node contents = root.createNode(); root.addChild(contents); contents.setTitle("contents"); //contents - 2009年12月 Node y09m12 = root.createNode(); contents.addChild(y09m12); y09m12.setTitle("2009年12月"); //contents - 2009年12月 - 今日はレクチャの日です Node lecture = root.createNode(); y09m12.addChild(lecture); lecture.setTitle("今日はレクチャの日です"); lecture.setAttribute("layout","Blog/Main/BlogPage"); lecture.setAttribute("publish_date","2009-12-22-00-00-00"); //contents - 2009年12月 - 今日はレクチャの日です - 本文 Node body = root.createNode(); lecture.addChild(body); body.setTitle("本文"); body.setAttribute("data","今日は二子玉川のオフィスでレイアウトの練習をしています。\n難しそうです。\nたいへんです。\n困ったです。"); //contents - 2009年12月 - 今日はレクチャの日です - 画像 File picFile = new File("contents/cat.jpeg"); byte buf[] = new byte[(int)picFile.length()]; FileInputStream in = new FileInputStream(picFile); in.read(buf); in.close(); String base64 = new String(Base64.encodeBase64(buf)); Node pic = root.createNode(); lecture.addChild(pic); pic.setTitle("画像"); pic.setAttribute("data",base64); //contents - 2010年01月 Node y10m01 = root.createNode(); contents.addChild(y10m01); y10m01.setTitle("2010年1月"); //contents - 2010年01月 - 整体 Node seitai = root.createNode(); y10m01.addChild(seitai); seitai.setTitle("整体"); seitai.setAttribute("layout","Blog/Main/BlogPage"); seitai.setAttribute("publish_date","2009-01-05-00-00-00"); //contents - 2010年01月 - 整体 - 本文 Node bSeitai = root.createNode(); seitai.addChild(bSeitai); bSeitai.setTitle("本文"); bSeitai.setAttribute("data","今日は整体の先生のところへ行きました。昨年 11 月に腰を痛めてから、ずっと通っています。歩けなくなったのが 3 日で一応歩けるようになりました。でも朝とか痛いし、重い物もてないし、台所にずっと立ってるのがつらいんです。"); //contents - 2010年01月 - 仕事始め Node hajime = root.createNode(); y10m01.addChild(hajime); hajime.setTitle("仕事始め"); hajime.setAttribute("layout","Blog/Main/BlogPage"); lecture.setAttribute("publish_date","2009-01-07-00-00-00"); //contents - 2010年01月 - 仕事始め - 本文 Node bHajime = root.createNode(); hajime.addChild(bHajime); bHajime.setTitle("本文"); bHajime.setAttribute("data","なんかひどい一日でした。\n佐野厄除け大師の電車広告によると、今年はなんとか厄みたいなんで、ちょっといやだなぁ。"); //comments Node comments = root.createNode(); root.addChild(comments); comments.setTitle("comments"); //application Node application = root.createNode(); root.addChild(application); application.setTitle("#APPLICATION"); //application - css Node css = root.createNode(); application.addChild(css); css.setTitle("css"); css.setAttribute("data","#header {background-image: url(/cgi-bin/WebObjects/Atropos_TRAIN.woa/wa/imageP/12606f53c0b);}"); return root; } }