lilalo
diff l3-frontend @ 90:1d97bb13da20
После того как я нечаянно грохнул CSS
я решил перенести его в CVS
Итак, встречайте!
l3.css - таблица стилей журнала LiLaLo
я решил перенести его в CVS
Итак, встречайте!
l3.css - таблица стилей журнала LiLaLo
author | devi |
---|---|
date | Sat Mar 04 00:12:54 2006 +0200 (2006-03-04) |
parents | 385499ec544a |
children | d3182b751893 |
line diff
1.1 --- a/l3-frontend Thu Mar 02 00:06:54 2006 +0200 1.2 +++ b/l3-frontend Sat Mar 04 00:12:54 2006 +0200 1.3 @@ -11,7 +11,10 @@ 1.4 our %Args_Description; 1.5 our $Mywi_Socket; 1.6 our %Sessions; 1.7 + 1.8 our %filter; 1.9 +our $filter_url; 1.10 +sub init_filter; 1.11 1.12 our %Files; 1.13 1.14 @@ -43,7 +46,9 @@ 1.15 1.16 sub print_all_txt; 1.17 sub print_all_html; 1.18 +sub print_edit_all_html; 1.19 sub print_command_lines_html; 1.20 +sub print_command_lines_txt; 1.21 sub print_files_html; 1.22 sub print_stat_html; 1.23 sub print_header_html; 1.24 @@ -59,16 +64,34 @@ 1.25 init_config(); 1.26 $Config{frontend_ico_path}=$Config{frontend_css}; 1.27 $Config{frontend_ico_path}=~s@/[^/]*$@@; 1.28 + init_filter(); 1.29 1.30 open_mywi_socket(); 1.31 load_command_lines_from_xml($Config{"backend_datafile"}); 1.32 load_sessions_from_xml($Config{"backend_datafile"}); 1.33 sort_command_lines; 1.34 process_command_lines; 1.35 - print_all_txt($Config{"output"}); 1.36 + if (defined($filter{action}) && $filter{action} eq "edit") { 1.37 + print_edit_all_html($Config{"output"}); 1.38 + } 1.39 + else { 1.40 + print_all_html($Config{"output"}); 1.41 + } 1.42 close_mywi_socket; 1.43 } 1.44 1.45 +sub init_filter 1.46 +{ 1.47 + if ($Config{filter}) { 1.48 + # Инициализация фильтра 1.49 + for (split /&/,$Config{filter}) { 1.50 + my ($var, $val) = split /=/; 1.51 + $filter{$var} = $val || ""; 1.52 + } 1.53 + } 1.54 + $filter_url = join ("&", map("$_=$filter{$_}", keys %filter)); 1.55 +} 1.56 + 1.57 # extract_from_cline 1.58 1.59 # In: $what = commands | args 1.60 @@ -237,6 +260,7 @@ 1.61 open (CLASS, $datafile) 1.62 or die "Can't open file with xml lablog ",$datafile,"\n"; 1.63 local $/; 1.64 + binmode CLASS, ":utf8"; 1.65 $data = <CLASS>; 1.66 close(CLASS); 1.67 1.68 @@ -253,9 +277,10 @@ 1.69 { 1.70 my $datafile = $_[0]; 1.71 1.72 - open (CLASS, $datafile) 1.73 + open (CLASS, $datafile) 1.74 or die "Can't open file with xml lablog ",$datafile,"\n"; 1.75 local $/; 1.76 + binmode CLASS, ":utf8"; 1.77 my $data = <CLASS>; 1.78 close(CLASS); 1.79 1.80 @@ -301,11 +326,20 @@ 1.81 1.82 sub process_command_lines 1.83 { 1.84 + 1.85 +COMMAND_LINE_PROCESSING: 1.86 for my $i (@Command_Lines_Index) { 1.87 my $cl = \$Command_Lines[$i]; 1.88 1.89 next if !$cl; 1.90 1.91 + for my $filter_key (keys %filter) { 1.92 + next COMMAND_LINE_PROCESSING 1.93 + if defined($$cl->{local_session_id}) 1.94 + && defined($Sessions{$$cl->{local_session_id}}->{$filter_key}) 1.95 + && $Sessions{$$cl->{local_session_id}}->{$filter_key} ne $filter{$filter_key}; 1.96 + } 1.97 + 1.98 $$cl->{id} = $$cl->{"time"}; 1.99 1.100 $$cl->{err} ||=0; 1.101 @@ -461,13 +495,6 @@ 1.102 my @known_commands; 1.103 1.104 1.105 - if ($Config{filter}) { 1.106 - # Инициализация фильтра 1.107 - for (split /&/,$Config{filter}) { 1.108 - my ($var, $val) = split /=/; 1.109 - $filter{$var} = $val || ""; 1.110 - } 1.111 - } 1.112 1.113 $Stat{LastCommand} ||= 0; 1.114 $Stat{TotalCommands} ||= 0; 1.115 @@ -615,10 +642,12 @@ 1.116 1.117 # Session change 1.118 if ( $last_session ne $cl->{"local_session_id"}) { 1.119 - my $tty = $cl->{"tty"}; 1.120 - $this_day_result .= "<div class='ttychange'><a href='?local_session_id=".$cl->{"local_session_id"}."'>" 1.121 + my $tty; 1.122 + if (defined $Sessions{$cl->{"local_session_id"}}->{"tty"}) { 1.123 + $this_day_result .= "<div class='ttychange'><a href='?local_session_id=".$cl->{"local_session_id"}."'>" 1.124 . $Sessions{$cl->{"local_session_id"}}->{"tty"} 1.125 ."</a></div>"; 1.126 + } 1.127 $last_session=$cl->{"local_session_id"}; 1.128 } 1.129 1.130 @@ -817,7 +846,7 @@ 1.131 # In: $_[0] output_filename 1.132 # Out: 1.133 1.134 -sub print_all_txt 1.135 +sub print_command_lines_txt 1.136 { 1.137 1.138 my $output_filename=$_[0]; 1.139 @@ -985,40 +1014,86 @@ 1.140 $result .= $this_day_result; 1.141 } 1.142 1.143 + return $result; 1.144 1.145 1.146 1.147 - my $SetCursorPosition_JS = <<JS; 1.148 -function setCursorPosition(oInput,oStart,oEnd) { 1.149 - oInput.focus(); 1.150 - if( oInput.setSelectionRange ) { 1.151 - oInput.setSelectionRange(oStart,oEnd); 1.152 - } else if( oInput.createTextRange ) { 1.153 - var range = oInput.createTextRange(); 1.154 - range.collapse(true); 1.155 - range.moveEnd('character',oEnd); 1.156 - range.moveStart('character',oStart); 1.157 - range.select(); 1.158 - } 1.159 } 1.160 -JS 1.161 1.162 - if ($output_filename eq "-") { 1.163 - print 1.164 +############# 1.165 +# print_edit_all_html 1.166 +# 1.167 +# Вывести страницу с текстовым представлением журнала для редактирования 1.168 +# 1.169 +# In: $_[0] output_filename 1.170 +# Out: 1.171 + 1.172 +sub print_edit_all_html 1.173 +{ 1.174 + my $output_filename= shift; 1.175 + my $result; 1.176 + my $cursor_position = 0; 1.177 + 1.178 + $result = print_command_lines_txt; 1.179 + 1.180 + $result = 1.181 "<html>" 1.182 + ."<head>" 1.183 + ."<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />" 1.184 + ."<link rel='stylesheet' href='$Config{frontend_css}' type='text/css'/>" 1.185 + ."<title>$title</title>" 1.186 + ."</head>" 1.187 ."<script>" 1.188 .$SetCursorPosition_JS 1.189 ."</script>" 1.190 ."<body onLoad='setCursorPosition(document.all.mytextarea, $cursor_position, $cursor_position+10)'>" 1.191 + ."<h1>Журнал лабораторных работ. Правка</h1>" 1.192 + ."<form>" 1.193 ."<textarea rows='30' cols='100' wrap='off' id='mytextarea'>$result</textarea>" 1.194 + ."<br/><input type='submit' value='Сохранить' label='label'/>" 1.195 + ."</form>" 1.196 + ."<p>Внимательно правим, потом сохраняем</p>" 1.197 + ."<p>Строки, начинающиеся символами #l3: можно трогать, только если точно знаешь, что делаешь</p>" 1.198 ."</body>" 1.199 - ."</html>" 1.200 - ; 1.201 + ."</html>"; 1.202 + 1.203 + if ($output_filename eq "-") { 1.204 + print $result; 1.205 } 1.206 else { 1.207 open(OUT, ">", $output_filename) 1.208 or die "Can't open $output_filename for writing\n"; 1.209 - print OUT "<pre>$result</pre>"; 1.210 + binmode ":utf8"; 1.211 + print OUT "$result"; 1.212 + close(OUT); 1.213 + } 1.214 +} 1.215 + 1.216 +############# 1.217 +# print_all_txt 1.218 +# 1.219 +# Вывести страницу с текстовым представлением журнала для редактирования 1.220 +# 1.221 +# In: $_[0] output_filename 1.222 +# Out: 1.223 + 1.224 +sub print_all_txt 1.225 +{ 1.226 + my $result; 1.227 + 1.228 + $result = print_command_lines_txt; 1.229 + 1.230 + $result =~ s/>/>/g; 1.231 + $result =~ s/</</g; 1.232 + $result =~ s/&/&/g; 1.233 + 1.234 + if ($output_filename eq "-") { 1.235 + print $result; 1.236 + } 1.237 + else { 1.238 + open(OUT, ">:utf8", $output_filename) 1.239 + or die "Can't open $output_filename for writing\n"; 1.240 + print OUT "$result"; 1.241 close(OUT); 1.242 } 1.243 } 1.244 @@ -1052,16 +1127,17 @@ 1.245 1.246 $result.= "<h2 id='log'>Журнал</h2>" . $command_lines; 1.247 $result.= "<h2 id='files'>Файлы</h2>" . $files_section if $files_section; 1.248 - $result.= "<h2 id='stat'>Статистика</h2>" . print_stat; 1.249 + $result.= "<h2 id='stat'>Статистика</h2>" . print_stat_html; 1.250 $result.= "<h2 id='help'>Справка</h2>" . $Html_Help . "<br/>"; 1.251 $result.= "<h2 id='about'>О программе</h2>". $Html_About. "<br/>"; 1.252 $result.= print_footer_html; 1.253 1.254 if ($output_filename eq "-") { 1.255 + binmode STDOUT, ":utf8"; 1.256 print $result; 1.257 } 1.258 else { 1.259 - open(OUT, ">", $output_filename) 1.260 + open(OUT, ">:utf8", $output_filename) 1.261 or die "Can't open $output_filename for writing\n"; 1.262 print OUT $result; 1.263 close(OUT); 1.264 @@ -1140,7 +1216,10 @@ 1.265 <!-- ^^^ Tigra Hints ^^^ --> 1.266 1.267 1.268 - <h1 onmouseover="myHint.show('1')" onmouseout="myHint.hide()">Журнал лабораторных работ</h1> 1.269 + <div class='edit_link'> 1.270 + [ <a href='?action=edit&$filter_url'>править</a> ] 1.271 + </div> 1.272 + <h1 onmouseover="myHint.show('1')" onmouseout="myHint.hide()" class='lined_header'>Журнал лабораторных работ</h1> 1.273 HEADER 1.274 if ( $course_student 1.275 || $course_trainer 1.276 @@ -1334,7 +1413,12 @@ 1.277 . "<div class='file_navigation'><a href='#command:".$Files{$file}->{source_command_id}."'>".">"."</a></div>" 1.278 . "<div class='filedata'><pre>".$Files{$file}->{content}."</pre></div>"; 1.279 } 1.280 - return "<div class='files_toc'>".collapse_list(\@toc)."</div>".$result; 1.281 + if ($result) { 1.282 + return "<div class='files_toc'>".collapse_list(\@toc)."</div>".$result; 1.283 + } 1.284 + else { 1.285 + return ""; 1.286 + } 1.287 } 1.288 1.289 1.290 @@ -1665,6 +1749,21 @@ 1.291 } 1.292 JS 1.293 1.294 +$SetCursorPosition_JS = <<JS; 1.295 +function setCursorPosition(oInput,oStart,oEnd) { 1.296 + oInput.focus(); 1.297 + if( oInput.setSelectionRange ) { 1.298 + oInput.setSelectionRange(oStart,oEnd); 1.299 + } else if( oInput.createTextRange ) { 1.300 + var range = oInput.createTextRange(); 1.301 + range.collapse(true); 1.302 + range.moveEnd('character',oEnd); 1.303 + range.moveStart('character',oStart); 1.304 + range.select(); 1.305 + } 1.306 +} 1.307 +JS 1.308 + 1.309 %Search_Machines = ( 1.310 "google" => { "query" => "http://www.google.com/search?q=" , 1.311 "icon" => "$Config{frontend_google_ico}" },