Mercurial > hgrepos > hgweb.cgi > after5
comparison after5.rb @ 8:55548317a101 draft
RCS-revision 1.9
date: 2004/01/16 14:45:49; author: yuuji; state: Exp; lines: +16 -6
Use parameter sub_nt* instead of nt* at actual submission.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 16 Jan 2004 14:45:49 +0859 |
parents | 51440ee77ae4 |
children | fbe1de450bd7 |
comparison
equal
deleted
inserted
replaced
7:51440ee77ae4 | 8:55548317a101 |
---|---|
1 #!/usr/local/bin/ruby | 1 #!/usr/local/bin/ruby |
2 # | 2 # |
3 # Associative Scheduling Table - after5 | 3 # Associative Scheduling Table - after5 |
4 # (C)2003, 2004 by HIROSE Yuuji [yuuji@gentei.org] | 4 # (C)2003, 2004 by HIROSE Yuuji [yuuji@gentei.org] |
5 # $Id: after5.rb,v 1.8 2004/01/16 04:28:06 yuuji Exp $ | 5 # $Id: after5.rb,v 1.9 2004/01/16 14:45:49 yuuji Exp $ |
6 # Last modified Fri Jan 16 13:10:10 2004 on firestorm | 6 # Last modified Fri Jan 16 23:25:14 2004 on firestorm |
7 # See http://www.gentei.org/~yuuji/software/after5/ | 7 # See http://www.gentei.org/~yuuji/software/after5/ |
8 # このスクリプトはEUCで保存してください。 | 8 # このスクリプトはEUCで保存してください。 |
9 | 9 |
10 require 'kconv' | 10 require 'kconv' |
11 | 11 |
929 'logfile' => @mybase+".log", | 929 'logfile' => @mybase+".log", |
930 "sendmail" => "/usr/sbin/sendmail", | 930 "sendmail" => "/usr/sbin/sendmail", |
931 'hostcmd' => '/usr/bin/host', | 931 'hostcmd' => '/usr/bin/host', |
932 'nslookup' => '/usr/sbin/nsookup', | 932 'nslookup' => '/usr/sbin/nsookup', |
933 'bg' => 'ivory', | 933 'bg' => 'ivory', |
934 'name' => nil, | |
934 'at_bsd' => '%H:%M %b %d %Y', | 935 'at_bsd' => '%H:%M %b %d %Y', |
935 'at_solaris' => '%H:%M %b %d,%Y', | 936 'at_solaris' => '%H:%M %b %d,%Y', |
936 'schedir' => 's', | 937 'schedir' => 's', |
937 'tdskip' => '<br>', | 938 'tdskip' => '<br>', |
938 'forgot' => 'wasureta', | 939 'forgot' => 'wasureta', |
992 end | 993 end |
993 end | 994 end |
994 @params['user'] = safecopy(@params['user']) | 995 @params['user'] = safecopy(@params['user']) |
995 | 996 |
996 eval @job | 997 eval @job |
998 a5name = if @opt['name'] && @opt['name'] > '' | |
999 sprintf("(%s)", @opt['name']) | |
1000 else | |
1001 "" | |
1002 end | |
997 @O.append(@H.contenttype() + | 1003 @O.append(@H.contenttype() + |
998 @H.head("After 5"+@job.sub(/\s*/, ' '), @opt['css'])) | 1004 @H.head(a5name+"After 5"+@job.sub(/\s*/, ' '), @opt['css'])) |
999 # @job is here | 1005 # @job is here |
1000 @O.print @H.startelement("body", bodyclass, true) | 1006 @O.print @H.startelement("body", bodyclass, true) |
1001 @O.print @H.endelement(nil, true) # body | 1007 @O.print @H.endelement(nil, true) # body |
1002 @O.print "</html>\n" # html | 1008 @O.print "</html>\n" # html |
1003 setcookie() | 1009 setcookie() |
1016 'passwd' => ['パスワード<br>(初回時は空欄)', | 1022 'passwd' => ['パスワード<br>(初回時は空欄)', |
1017 'Passowrd<br>Left blank, first time'], | 1023 'Passowrd<br>Left blank, first time'], |
1018 'error' => ['エラー:', 'Error: '], | 1024 'error' => ['エラー:', 'Error: '], |
1019 'mailerror' => ['メイルアドレスが違います', 'Invalid email address'], | 1025 'mailerror' => ['メイルアドレスが違います', 'Invalid email address'], |
1020 'pswderror' => ['パスワードが違います', 'Password incorrect'], | 1026 'pswderror' => ['パスワードが違います', 'Password incorrect'], |
1021 'fmtdaysschedule'=> ['%sの予定', 'Schedule on %s'], | 1027 'fmtdaysschedule'=> ['%s〜の予定', 'Schedule from %s'], |
1022 'noplan' => ['登録されている予定はありません', 'No plans'], | 1028 'noplan' => ['登録されている予定はありません', 'No plans'], |
1023 'allday' => ['全日', 'whole day'], | 1029 'allday' => ['全日', 'whole day'], |
1024 'addsched' => ['新規予定項目の登録', 'Register new schedule'], | 1030 'addsched' => ['新規予定項目の登録', 'Register new schedule'], |
1025 'defthisday' => ['デフォルトの日付はこの日になってま', ''], | 1031 'defthisday' => ['デフォルトの日付はこの日になってま', ''], |
1026 '24hour' => ['24時間制4桁でね<br>(0000〜2359)<br>%sは時刻指定なし', 'in 24-hour<br>(0000-2359)<br>%s for whole day'], | 1032 '24hour' => ['24時間制4桁でね<br>(0000〜2359)<br>%sは時刻指定なし', 'in 24-hour<br>(0000-2359)<br>%s for whole day'], |
1476 last = daysofmonth(day.year, day.month) | 1482 last = daysofmonth(day.year, day.month) |
1477 wday1 = first.wday | 1483 wday1 = first.wday |
1478 start = 1-wday1 | 1484 start = 1-wday1 |
1479 wname = @wnames | 1485 wname = @wnames |
1480 today = Time.now | 1486 today = Time.now |
1487 todayy = today.year | |
1481 todaym = today.month | 1488 todaym = today.month |
1482 todayd = today.day | 1489 todayd = today.day |
1483 tdclass = {} | 1490 tdclass = {} |
1484 tdclass["width"] = "64px" if @oldagent # workaround for NN4 | 1491 tdclass["width"] = "64px" if @oldagent # workaround for NN4 |
1485 personal = /personal/ =~ @params['displaymode'] | 1492 personal = /personal/ =~ @params['displaymode'] |
1509 column = start | 1516 column = start |
1510 ## p day, last | 1517 ## p day, last |
1511 while column <= last | 1518 while column <= last |
1512 @O.print @H.elementln("tr", nil){ | 1519 @O.print @H.elementln("tr", nil){ |
1513 (column..column+6).collect{|d| | 1520 (column..column+6).collect{|d| |
1514 todayp = (day.month==todaym && d==todayd) | 1521 todayp = (day.year==todayy && day.month==todaym && d==todayd) |
1515 wd=d-column | 1522 wd=d-column |
1516 hd = holiday.isHoliday(day.year, day.month, d, wd) | 1523 hd = holiday.isHoliday(day.year, day.month, d, wd) |
1517 tdclass['class'] = (hd ? 'holiday' : wname[wd]) | 1524 tdclass['class'] = (hd ? 'holiday' : wname[wd]) |
1518 @H.element("td", tdclass){ | 1525 @H.element("td", tdclass){ |
1519 if d>0 && d <= last | 1526 if d>0 && d <= last |
1806 ## table | 1813 ## table |
1807 } + \ | 1814 } + \ |
1808 @H.elementln("p"){ # put notify mail checkbox | 1815 @H.elementln("p"){ # put notify mail checkbox |
1809 msg('reqnotify') + '<br>' + \ | 1816 msg('reqnotify') + '<br>' + \ |
1810 @ntlist.collect{|n, v| | 1817 @ntlist.collect{|n, v| |
1811 @H.checkbox(n, 'yes', v, @params[n]) | 1818 # Actual variables of notifylist for submitting is "sub_"+n |
1819 @H.checkbox("sub_"+n, 'yes', v, @params[n]) | |
1812 }.join("\n") + \ | 1820 }.join("\n") + \ |
1813 " " + @H.checkbox('rightnow', 'yes', msg('rightnow'), true) + \ | 1821 " " + @H.checkbox('rightnow', 'yes', msg('rightnow'), true) + \ |
1814 "\n" | 1822 "\n" |
1815 } + \ | 1823 } + \ |
1816 if mygroup[0] | 1824 if mygroup[0] |
1927 end | 1935 end |
1928 now = Time.now | 1936 now = Time.now |
1929 | 1937 |
1930 filearg = [user, year, month, day, t] | 1938 filearg = [user, year, month, day, t] |
1931 @ntlist.each{|k, v| | 1939 @ntlist.each{|k, v| |
1940 # @params[k]s are always defined in cookies, so we use @params["sub_"+k] | |
1941 @params[k] = @params["sub_"+k] | |
1932 nt_time = notify_time(year, month, day, t, k) | 1942 nt_time = notify_time(year, month, day, t, k) |
1933 if !nt_time | 1943 if !nt_time |
1934 # do nothing for allday schedule's notification before some minutes | 1944 # do nothing for allday schedule's notification before some minutes |
1935 elsif cancelall || nt_time < now+threshold || | 1945 elsif cancelall || nt_time < now+threshold || |
1936 /yes|on|true|1/ !~ @params[k] || !@params[k] | 1946 /yes|on|true|1/ !~ @params[k] || !@params[k] |