summaryrefslogtreecommitdiff
path: root/fml/doc/en/tutorial/module/create.sgml
blob: 688b46741217829f30dd5ccd466b86fa91cf396d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!--
   $FML: create.sgml,v 1.1 2003/07/28 15:20:18 fukachan Exp $
   $jaFML: create.sgml,v 1.2 2003/04/15 14:51:42 fukachan Exp $
-->

<chapter id="module.create">
	<title>
	Execise: create a new program
	</title>


<para>
Consider creation of a simple scheduler listing tool in the &fml8;
framework. Here the program name is "fmlsch" and the cgi is
"fmlsch.cgi".
</para>


<sect1>
	<title>
	Case study: create a fmlsch
	</title>


<sect2>
	<title>
	Step 1: add fmlsch into installer configuration
	</title>

<para>
Add fmlsch into $bin_programs in fml/etc/install.cf.in.
Run configreu to re-create fml/etc/install.cf.
</para>

</sect2>


<sect2>
	<title>
	Step 2: build a module
	</title>


<para>
Write fml/lib/Calender/Lite.pm as the main library of fmlsch.
</para>

<para>
Import other libraries if needed. 
For fmlsch we import
HTML-CalendarMonthSimple-1.02.tar.gz
from CPAN.
</para>

<para>
Also, install Date-Calc if your system has not it.
</para>

</sect2>


<sect2>
	<title>
	Step 3: modify FML::Process:: class
	</title>

<para>
Calender::Lite works mainly but we build the machanism how &fml8;
loads and runs it. We modify FML::Process class for &fml8; bootloader
to call Calender::Lite.
</para>

<para>
Firstly, write mandatory methods for fmlsch process in
fml/lib/FML/Process/Calender.pm. You need to create this file.
</para>

<para>
Secondly, set up boot loader configuration. In the case of fmlsch, the
bootloader loads FML::Process::Calender. Define it in fml/etc/modules. 
Set up fml/etc/command_line_options properly. This
"command_line_options" file has a map between a command and the
command line options parsed by Getopt::Long().
</para>


<para>
Create FML::Process::Calender module by copy-and-pasting other
FML::Process:: modules :-) However fmlsch has only to contain least
functions, you need to write FML::Process::Calender::run() method.
For undefined methods, fml loads FML::Process::Kernel functions
(inheritence).
</para>

</sect2>

</sect1>


<sect1>
	<title>
	Case study: fmlsch.cgi
	</title>


<para>
The way of hacking is similar to fmlsch. The differnce is that the
target to modify is FML::CGI:: class. FML::CGI::Calender is a
sub-class of FML::Process::CGI.
</para>

<para>
If undefined method is called, fml loads it from FML::Process::CGI or
FML::Process::Kernel. FML::Process::CGI uses CGI.pm to create a http
header et.al. If FML::Process::CGI functions are not enough, FML::CGI
class module should support the lack.
</para>

</sect1>


</chapter>