-
Notifications
You must be signed in to change notification settings - Fork 0
/
output_www.def
126 lines (101 loc) · 2.79 KB
/
output_www.def
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
123
124
125
include: output.def
include: macros_www/html.def
include: macros_www/tags.def
# include: macros_www/php.def
# include: macros_www/field.def
page: output_www, output_main
type: pm
output_dir: lib/MyDef
ext: html
init_mode: html
package: MyDef::output_www
subcode:: package_globals
use Term::ANSIColor qw(:constants);
subcode:: init_page
$global $style, @style_key_list
$style={};
@style_key_list=()
$global $style_sheets
$style_sheets=[]
subcode: modeswitch
# stackable mode : html -> js -> php
$global @mode_stack
$global $cur_mode="html"
# print "modeswitch $cur_mode-> $mode\n"
$if $mode eq $cur_mode or $mode eq "sub"
goto modeswitch_done
$if $cur_mode eq "php"
$call exit_php
$call popmode
$if $mode eq "php"
$call enter_php
$call pushmode
$if $cur_mode eq "js"
$call exit_js
$call popmode
$if $mode eq "js"
$call enter_js
$call pushmode
modeswitch_done:
# --
subcode: enter_js
MyDef::compileutil::push_interface("js")
push @$out, "<script type=\"text/javascript\">\n";
$global $enter_js_count
$enter_js_count++
subcode: exit_js
push @$out, "<\/script>\n"
MyDef::compileutil::pop_interface()
# --
subcode: enter_php
MyDef::compileutil::push_interface("php")
push @$out, "<?php\n"
subcode: exit_php
push @$out, "?>\n";
MyDef::compileutil::pop_interface()
# --
subcode: pushmode
push @mode_stack, $cur_mode
$cur_mode=$mode
goto modeswitch_done
subcode: popmode
$cur_mode=pop @mode_stack
$if $mode eq $cur_mode
goto modeswitch_done
# ------------------------
subcode:: dumpout
$if $enter_js_count>0
MyDef::output_js::dump_js_globals()
subcode: parsecode
$call parsecode_common
subcode: parsecode_special
$case $l=~/^CSS:\s*(.*)/
return parse_css($1)
fncode: parse_css($t)
$if $t=~/(.*?)\s*\{(.*)\}/
$if $style->{$1}
$style->{$1}.=";$2";
$else
$style->{$1}=$2;
push @style_key_list, $1;
$elif $t=~/(\S*\.css)/
push @$style_sheets, $1
subcode: parsecode_func_param
subcode: parsecode_func
$call parsecode_html_tag, -
$if $func eq "echo"
push @$out, $param
return
$elif $func eq "script"
MyDef::compileutil::modepush("js")
&call return_newblock, script
$call push_indented_block
push @src, "PARSE:MODEPOP"
$elif $func=~/^(title|charset)/
$page->{$1}=$2
return
$elif $func eq "include"
$call include_html_template
subcode: parsecode_other
$if $page->{type} eq "php"
$l=~s/(\$\w+)/<?php echo $1 ?>/g