lilalo
annotate l3config.pm @ 89:62001c1e3295
Доделан вызов окна редактирования журнала.
+ исправлен баг с unicode
+ исправлен баг с unicode
author | devi |
---|---|
date | Thu Mar 02 20:13:31 2006 +0200 (2006-03-02) |
parents | 3f92cd706473 |
children | 93281d002ee4 |
rev | line source |
---|---|
devi@23 | 1 package l3config; |
devi@23 | 2 |
devi@89 | 3 use utf8; |
devi@23 | 4 use Exporter; |
devi@30 | 5 use vars qw(@ISA @EXPORT $VERSION); |
devi@23 | 6 use Getopt::Long; |
devi@23 | 7 |
devi@23 | 8 @ISA = ('Exporter'); |
devi@23 | 9 @EXPORT = qw(%Config &init_config); |
devi@23 | 10 |
devi@32 | 11 our $System_Config_File = "/etc/lilalo.conf"; |
devi@32 | 12 our $User_Config_File = "$ENV{HOME}/.lilalo.conf"; |
devi@32 | 13 $ENV{HOME} ||= "/tmp"; |
devi@32 | 14 |
devi@32 | 15 |
devi@23 | 16 our %Config = ( |
devi@69 | 17 "skip_empty" => "yes", |
devi@69 | 18 "skip_interrupted" => "no", |
devi@69 | 19 "skip_wrong" => "no", |
devi@69 | 20 "editors" => ["vi", "pico", "ee", "vim", "nano"], |
devi@69 | 21 "pagers" => ["more", "less", "zmore", "zless", "info", |
devi@69 | 22 "man", "mc", "trafshow", "screen", "cfdisk", |
devi@69 | 23 "trafshow-bsd", "yes", "lynx", "links", "centericq" |
devi@69 | 24 ], |
devi@69 | 25 "full_output_commands" => ["cat"], |
devi@69 | 26 "terminal" => ["mc"], |
devi@69 | 27 "suppress_editors" => "yes", |
devi@69 | 28 "suppress_pagers" => "yes", |
devi@69 | 29 "suppress_terminal" => "yes", |
devi@23 | 30 |
devi@69 | 31 "terminal_width" => 400, |
devi@81 | 32 "terminal_height" => 300, |
devi@69 | 33 "verbose" => "yes", |
devi@23 | 34 |
devi@82 | 35 "head_lines" => 10, |
devi@82 | 36 "tail_lines" => 10, |
devi@82 | 37 "cache_head_lines" => 250, |
devi@82 | 38 "cache_tail_lines" => 250, |
devi@69 | 39 "skip_text" => "...", |
devi@69 | 40 "show_time" => "yes", |
devi@69 | 41 "show_diffs" => "yes", |
devi@81 | 42 "show_screenshots" => "yes", |
devi@69 | 43 "show_comments" => "yes", |
devi@69 | 44 "show_notes" => "yes", |
devi@23 | 45 |
devi@69 | 46 "input" => "$ENV{HOME}/.lilalo", |
devi@69 | 47 "diffs" => "", |
devi@69 | 48 "input_mask" => "*.script", |
devi@69 | 49 "encoding" => "utf-8", |
devi@23 | 50 |
devi@69 | 51 "cache" => "$ENV{HOME}/.lilalo/report.xml", |
devi@69 | 52 "cache_stat" => "$ENV{HOME}/.lilalo/.report.dat", |
devi@23 | 53 |
devi@69 | 54 "output" => "/tmp/report.html", |
devi@69 | 55 "output_mask" => "INDEX", |
devi@69 | 56 "output_format" => "html", |
devi@69 | 57 "frontend_css" => "/l3/l3.css", |
devi@81 | 58 "l3shot_path" => "/l3shot/", |
devi@81 | 59 "l3shot_suffix" => ".png", |
devi@69 | 60 "frontend_google_ico" => "/l3/google.ico", |
devi@69 | 61 "frontend_linux_ico" => "/l3/linux.ico", |
devi@69 | 62 "frontend_freebsd_ico" => "/l3/freebsd.ico", |
devi@69 | 63 "frontend_opennet_ico" => "/l3/opennet.ico", |
devi@69 | 64 "frontend_local_ico" => "/l3/freebsd.ico", |
devi@23 | 65 |
devi@69 | 66 "mywi_server" => "127.0.0.1", |
devi@69 | 67 "mywi_port" => "19801", |
devi@31 | 68 |
devi@69 | 69 "stat_inactivity_interval" => "1800", |
devi@23 | 70 |
devi@69 | 71 "signature" => "#lm:", |
devi@69 | 72 "from" => "", |
devi@69 | 73 "to" => "", |
devi@69 | 74 "lab" => "", |
devi@69 | 75 "keywords" => "linux command", |
devi@69 | 76 "files_keywords" => "linux file", |
devi@27 | 77 |
devi@69 | 78 comment_width => "300", |
devi@85 | 79 note_width => "500", |
devi@85 | 80 time_width => "6em", |
devi@30 | 81 |
devi@85 | 82 "mode" => "daemon", # daemon | normal |
devi@69 | 83 "daemon_sleep_interval" => "10", |
devi@85 | 84 "detach" => "yes", |
devi@69 | 85 "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid", |
devi@30 | 86 |
devi@79 | 87 "backend_address" => "192.168.15.254", |
devi@69 | 88 "backend_port" => "18030", |
devi@69 | 89 "backend_pidfile" => "/tmp/l3-backend.pid", |
devi@69 | 90 "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml", |
devi@30 | 91 |
devi@85 | 92 "l3-agent" => "l3-agent", |
devi@69 | 93 "l3-backend" => "l3-backend", |
devi@30 | 94 |
devi@69 | 95 "course-name" => "", |
devi@69 | 96 "course-code" => "", |
devi@85 | 97 "course-date" => "", |
devi@69 | 98 "course-center" => "", |
devi@69 | 99 "course-trainer" => "", |
devi@69 | 100 "course-student" => "", |
devi@30 | 101 |
devi@85 | 102 "filter" => "", |
devi@58 | 103 #lm |
devi@69 | 104 "show_host" => "no", |
devi@30 | 105 |
devi@58 | 106 # Вспомогательные программы |
devi@69 | 107 #"l3-report" => "./lm-report", |
devi@85 | 108 "l3-report" => "./l3-report", |
devi@40 | 109 |
devi@58 | 110 # Каталоги |
devi@69 | 111 "path_lilalo" => "/var/lilalo/", |
devi@69 | 112 "path_classes" => "/var/lilalo/classes/", |
devi@69 | 113 "path_lablogs" => "/var/lilalo/lablogs/", |
devi@69 | 114 "courses_path" => "/var/lilalo/courses/", |
devi@85 | 115 "outpath" => "/var/lilalo/out/", |
devi@85 | 116 "path_web" => "/var/www/l3", # Путь к web-отчётам |
devi@69 | 117 "path_share" => "./share/", # Путь к web-отчётам |
devi@48 | 118 |
devi@58 | 119 # Файлы |
devi@85 | 120 "runfile" => "lm.run", |
devi@85 | 121 "logfile" => "lm.log", |
devi@58 | 122 |
devi@85 | 123 "class" => "class", # Имя файла класса |
devi@69 | 124 "class_suffix" => ".xml", # Cуффикс файла класса |
devi@85 | 125 "classfile" => "", |
devi@58 | 126 |
devi@85 | 127 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub", |
devi@85 | 128 "lmssh" => "./lm-ssh", |
devi@85 | 129 "lminstall" => "./lm-install", |
devi@85 | 130 "ssh_user" => "r", |
devi@58 | 131 |
devi@85 | 132 "l3scripts" => "l3scripts", |
devi@58 | 133 |
devi@58 | 134 |
devi@69 | 135 "cgi_path_info" => "", |
devi@85 | 136 "cgi2file" => "", |
devi@58 | 137 |
devi@85 | 138 "year" => "2006", |
devi@58 | 139 ); |
devi@23 | 140 |
devi@23 | 141 sub read_config_file |
devi@23 | 142 { |
devi@23 | 143 my $config = $_[0]; |
devi@23 | 144 my $filename = $_[1]; |
devi@23 | 145 open(CONFIG, "$filename") |
devi@23 | 146 or return; |
devi@23 | 147 while (<CONFIG>) { |
devi@23 | 148 s/#.*//; |
devi@23 | 149 next if /^\s*$/; |
devi@23 | 150 my ($var, $val) = split /\s*=\s*/, $_, 2; |
devi@23 | 151 $var =~ s/\s*//; |
devi@23 | 152 $config->{$var} = $val; |
devi@23 | 153 } |
devi@23 | 154 close(CONFIG); |
devi@23 | 155 } |
devi@23 | 156 |
devi@23 | 157 |
devi@23 | 158 sub init_config |
devi@23 | 159 { |
devi@23 | 160 my %argv_config; |
devi@23 | 161 my %file_config; |
devi@32 | 162 read_config_file(\%file_config, $System_Config_File); |
devi@32 | 163 read_config_file(\%file_config, $User_Config_File); |
devi@23 | 164 GetOptions(\%argv_config, map "$_=s", keys %Config); |
devi@23 | 165 %Config = (%Config, %file_config, %argv_config); |
devi@89 | 166 for my $key (keys %Config) { |
devi@89 | 167 utf8::decode($Config{$key}); |
devi@89 | 168 } |
devi@23 | 169 } |
devi@23 | 170 |