root/trunk/TEMPLATE_SYNTAX

Revision 405, 4.7 kB (checked in by uncle_fungus, 3 years ago)

Added client type and core versions

Line 
1 This file descibes the syntax used for creating templates for the web output
2 system.
3
4 Template pages can be written in whatever language you like, provided that the
5 keywords used in the template definition are not reserved in that language.
6
7 Throughout this document quotation marks "" are used to surround blocks of code.
8 These are not part of the actual definitions.
9
10 Defining Template Blocks
11 ========================
12
13 Template blocks are opened and closed using modified html comments.
14 To open a template block, use the following code:
15
16 "<!--tpl_TYPE "
17
18 To close a template block, use the following code:
19
20 " tpl//-->"
21
22 The leading and trailing spaces in the above two blocks of code are important
23 and must be included.
24
25 Template blocks can contain any text, in addition to a number of predefined
26 variables which are demarkated by @ symbols, which are the only characters you
27 can't include within the template blocks.
28
29 There are two values that "TYPE" can take, these are "static" and "loop".
30 A static template means that it is only processed once while reading the file.
31 A loop template is processed for each monitored client whilst the file is read.
32
33 For example the following template block will be transformed into a single line
34 when the template file is processed. This is useful for showing data like total
35 PPD or update time.
36
37 "<!--tpl_static Total PPD: @TOTAL_PPD@ //-->"
38
39 The output of this template would be:
40
41 "Total PPD: 123.45"
42
43 The following looped template block will be processed for all the clients being
44 monitored by FahMon. This is used to list client data.
45
46 "<!--tpl_loop @NAME@ - @ETA@ - @PPD@ tpl//->"
47
48 The output of this template would be:
49
50 "Client1 - 01/01/01 00:00 - 123.45"
51 "Client2 - 02/01/01 03:45 - 246.80"
52 "Client3 - 03/01/01 16:20 - 987.65"
53
54 Template blocks can span multiple lines, however only one template block can
55 appear on any one line.
56
57 This is valid:
58
59 "<!--tpl_loop <td>@NAME@</td>
60 <td>@PPD@</td> tpl//-->"
61
62 This is not valid:
63
64 "<!--tpl_static @TOTAL_PPD@ tpl//-->Some text<!--tpl_static @UPDATE_TIME@
65  tpl//-->"
66
67 Template Variables
68 ==================
69
70 A number of template variables are defined to access data provided by FahMon:
71 "@PERCENTAGE@"          Returns the progress of a client
72 "@NAME@"                        Returns the client name
73 "@ETA@"                         Returns the client ETA
74 "@PPD@"                         Returns the client PPD
75 "@CORE@"                        Returns the core of the project the client is working on
76 "@PRCG@"                        Returns the PRCG of the project the client is working on
77 "@POINTS@"                      Returns the points of the project the client is working on
78 "@USER_TEAM@"           Returns the username and team of the client
79 "@USERNAME@"            Returns just the username of the client
80 "@TEAMNUMBER@"          Returns just the team number of the client
81 "@DOWNLOAD_DATE@"       Returns the download date for the client
82 "@PREFERRED_DATE@"      Returns the preferred deadline for the client
83 "@FINAL_DATE@"          Returns the final deadline for the client
84 "@STATE_COLOR@"         Returns the hex color related to the clients state
85 "@STATE@"                       Returns a string related to the clients state
86 "@FAHMON_VERSION@"      Returns the FahMon title bar string
87 "@UPDATE_TIME@"         Returns the time of the last page update
88 "@TOTAL_PPD@"           Returns the total PPD of all clients being monitored
89 "@STATE_IMAGE@"         Returns the location of the client state image
90 "@CLIENT_ID@"           Returns the ID of the current client
91 "@CLIENT_TYPE@"         Returns the type of client (CPU/SMP/GPU)
92 "@CORE_VERSION"         Returns the core version number
93
94 Each template variable can also contain an optional string that will allow the
95 output to be padded or truncated to a specific length. This is implemented so
96 that the default simple text output is formatted correctly.
97 To use this option, enclose the desired length in "{}" and put it directly
98 preceding the closing "@".
99 For example, to truncate the state string to only 5 characters:
100
101 "@STATE{5}@"
102
103 For more examples, examine the templates provided with FahMon.
104
105 The following template variable strings are automatically translated to your
106 native language if possible.
107 "@_State@"
108 "@_PRCG@"
109 "@_Credit@"
110 "@_Downloaded@"
111 "@_Progress@"
112 "@_Name@"
113 "@_ETA@"
114 "@_PPD@"
115 "@_Work_Unit_Information@"
116 "@_Core:@"
117 "@_Project:@"
118 "@_Credit:@"
119 "@_Username:@"
120 "@_Preferred_Deadline:@"
121 "@_Final_Deadline:@"
122 "@_Total_PPD:@"
123 "@_Web_View@"
124 "@_FahMon_Client_Monitoring@"
125 "@_Simple_Text_Output@"
126 "@_Last_updated:@"
127 "@_Downloaded:@"
128 "@_Client_Type@"
129 "@_Core_Version@"
130
131 Custom Variables
132 ================
133
134 Custom static variables can now be used in templates, such as for your username
135 etc. To do this you need to create a new file in your config folder called
136 custom.dat. Inside this file you can define all your custom variables in the
137 following format (the quotes are necessary):
138 "@VARIABLE_NAME@" "VARIABLE_VALUE"
139 Then, in your template you can use your custom variables just as you would any
140 other.
Note: See TracBrowser for help on using the browser.