50
|
1 package treecms.demo;
|
|
2
|
|
3 import java.io.File;
|
|
4 import java.io.FileInputStream;
|
|
5 import java.io.FileReader;
|
|
6 import java.nio.ByteBuffer;
|
|
7 import java.util.Calendar;
|
|
8
|
|
9 import org.apache.commons.codec.binary.Base64;
|
|
10
|
|
11 import treecms.proto.api.Node;
|
|
12 import treecms.proto.simple.SimpleBrowser;
|
|
13
|
|
14 public class ContentsTreeBuilder
|
|
15 {
|
|
16 public static Node blogSite() throws Exception
|
|
17 {
|
|
18 Node root = SimpleBrowser.getSingleton().useContents();
|
|
19 root.setTitle("ブログ形式サイト");
|
|
20
|
|
21 //contents
|
|
22 Node contents = root.createNode();
|
|
23 root.addChild(contents);
|
|
24 contents.setTitle("contents");
|
|
25
|
|
26 //contents - 2009年12月
|
|
27 Node y09m12 = root.createNode();
|
|
28 contents.addChild(y09m12);
|
|
29 y09m12.setTitle("2009年12月");
|
|
30
|
|
31 //contents - 2009年12月 - 今日はレクチャの日です
|
|
32 Node lecture = root.createNode();
|
|
33 y09m12.addChild(lecture);
|
|
34 lecture.setTitle("今日はレクチャの日です");
|
|
35 lecture.setAttribute("layout","Blog/Main/BlogPage");
|
|
36 lecture.setAttribute("publish_date","2009-12-22-00-00-00");
|
|
37
|
|
38 //contents - 2009年12月 - 今日はレクチャの日です - 本文
|
|
39 Node body = root.createNode();
|
|
40 lecture.addChild(body);
|
|
41 body.setTitle("本文");
|
|
42 body.setAttribute("data","今日は二子玉川のオフィスでレイアウトの練習をしています。\n難しそうです。\nたいへんです。\n困ったです。");
|
|
43
|
|
44 //contents - 2009年12月 - 今日はレクチャの日です - 画像
|
|
45 File picFile = new File("contents/cat.jpeg");
|
|
46 byte buf[] = new byte[(int)picFile.length()];
|
|
47 FileInputStream in = new FileInputStream(picFile);
|
|
48 in.read(buf);
|
|
49 in.close();
|
|
50
|
|
51 String base64 = new String(Base64.encodeBase64(buf));
|
|
52
|
|
53 Node pic = root.createNode();
|
|
54 lecture.addChild(pic);
|
|
55 pic.setTitle("画像");
|
|
56 pic.setAttribute("data",base64);
|
|
57
|
|
58 //contents - 2010年01月
|
|
59 Node y10m01 = root.createNode();
|
|
60 contents.addChild(y10m01);
|
|
61 y10m01.setTitle("2010年1月");
|
|
62
|
|
63 //contents - 2010年01月 - 整体
|
|
64 Node seitai = root.createNode();
|
|
65 y10m01.addChild(seitai);
|
|
66 seitai.setTitle("整体");
|
|
67 seitai.setAttribute("layout","Blog/Main/BlogPage");
|
|
68 seitai.setAttribute("publish_date","2009-01-05-00-00-00");
|
|
69
|
|
70 //contents - 2010年01月 - 整体 - 本文
|
|
71 Node bSeitai = root.createNode();
|
|
72 seitai.addChild(bSeitai);
|
|
73 bSeitai.setTitle("本文");
|
|
74 bSeitai.setAttribute("data","今日は整体の先生のところへ行きました。昨年 11 月に腰を痛めてから、ずっと通っています。歩けなくなったのが 3 日で一応歩けるようになりました。でも朝とか痛いし、重い物もてないし、台所にずっと立ってるのがつらいんです。");
|
|
75
|
|
76 //contents - 2010年01月 - 仕事始め
|
|
77 Node hajime = root.createNode();
|
|
78 y10m01.addChild(hajime);
|
|
79 hajime.setTitle("仕事始め");
|
|
80 hajime.setAttribute("layout","Blog/Main/BlogPage");
|
|
81 lecture.setAttribute("publish_date","2009-01-07-00-00-00");
|
|
82
|
|
83 //contents - 2010年01月 - 仕事始め - 本文
|
|
84 Node bHajime = root.createNode();
|
|
85 hajime.addChild(bHajime);
|
|
86 bHajime.setTitle("本文");
|
|
87 bHajime.setAttribute("data","なんかひどい一日でした。\n佐野厄除け大師の電車広告によると、今年はなんとか厄みたいなんで、ちょっといやだなぁ。");
|
|
88
|
|
89
|
|
90 //comments
|
|
91 Node comments = root.createNode();
|
|
92 root.addChild(comments);
|
|
93 comments.setTitle("comments");
|
|
94
|
|
95 //application
|
|
96 Node application = root.createNode();
|
|
97 root.addChild(application);
|
|
98 application.setTitle("#APPLICATION");
|
|
99
|
|
100 //application - css
|
|
101 Node css = root.createNode();
|
|
102 application.addChild(css);
|
|
103 css.setTitle("css");
|
|
104 css.setAttribute("data","#header {background-image: url(/cgi-bin/WebObjects/Atropos_TRAIN.woa/wa/imageP/12606f53c0b);}");
|
|
105
|
|
106 return root;
|
|
107 }
|
|
108 }
|