changeset 6:f4b10ab5479f draft

RCS-revision 1.7 date: 2004/01/10 06:57:44; author: yuuji; state: Exp; lines: +26 -11 headlinehighlight
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 10 Jan 2004 06:57:44 +0859
parents e26bc5d3563b
children 51440ee77ae4
files after5.rb
diffstat 1 files changed, 26 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/after5.rb	Sat Jan 03 02:45:14 2004 +0859
+++ b/after5.rb	Sat Jan 10 06:57:44 2004 +0859
@@ -2,8 +2,8 @@
 #
 # Associative Scheduling Table - after5
 # (C)2003, 2004 by HIROSE Yuuji [yuuji@gentei.org]
-# $Id: after5.rb,v 1.6 2004/01/03 02:45:14 yuuji Exp $
-# Last modified Sat Jan  3 01:06:04 2004 on firestorm
+# $Id: after5.rb,v 1.7 2004/01/10 06:57:44 yuuji Exp $
+# Last modified Sat Jan 10 15:48:17 2004 on firestorm
 # See http://www.gentei.org/~yuuji/software/after5/
 # このスクリプトはEUCで保存してください。
 
@@ -189,7 +189,7 @@
       next if /^\./ =~ u
       newu = ''
       u.split('').each{|c|	# for security wrapping
-	newu << c[0].chr if /[-A-Z_.@]/i =~ c
+	newu << c[0].chr if %r,[-A-Z/+_.@],i =~ c
       }
       u = newu
       map[u] = {}
@@ -411,6 +411,7 @@
     end
   end
   def rm_rf(path)
+    path.untaint
     if (list = Dir.glob(path))[0]
       for p in list
 	p.untaint
@@ -490,6 +491,7 @@
 	  file = File.join(dir, @schedulefile)
 	  if test(?s, file) && test(?r, file) && test(?s, file)
 	    sched[time][who]['sched'] = IO.readlines(file).join().chomp!
+	    sched[time][who]['regtime'] = File.stat(file).mtime
 	  end
 	  sched[time][who]['pub'] = visible
 	end
@@ -938,8 +940,9 @@
       'night'		=> '22',
       'alldaydir'	=> '3000',
       'pswdlen'		=> 4,
-      'pswddb'		=> 'a5pswd',
+      'pswddb'		=> 's/a5pswd',
       'lang'		=> 'j',
+      'notifymail'	=> true,
     }
     @ntlist = [
       ['nt10m', "10"+msg('minutes', 'before')],
@@ -1109,6 +1112,7 @@
 	'head5char'	=> ['先頭5文字', 'Head 5 chars'],
 	'headline'	=> ['先頭1行', 'Headline only'],
 	'whole'		=> ['長くても全部', 'Whole text'],
+	'hldays'	=> ['最新X日分強調', 'Hilight Recent X-days'],
 	'addedtogroup'	=> ['をグループに追加 →', 'added to the group:'],
 	'removedfromgp'	=> ['をグループから削除:', 'removed from the group:'],
 	'soleadmin'	=> ['%s は %s の唯一の管理者なのでやめられないのだ',
@@ -1159,7 +1163,7 @@
   def setcookie()
     p = {}
     @params.keys.grep(@savecookieregexp){|v|
-      p[v] = @params[v].to_s.strip
+      p[v] = @params[v].to_s.strip if @params[v] && @params[v] > ''
     }
     c = gencookie(p, 3600*6*1)
     printf "Set-Cookie: %s\n", c if c
@@ -1464,6 +1468,9 @@
     tdclass["width"] = "64px" if @oldagent # workaround for NN4
     personal = /personal/ =~ @params['displaymode']
     headline = @params['headline']
+    headlinehl = @params['headlinehl']
+    hldays = headlinehl.to_i * 3600*24
+    recent = {'class'=>'recent'}
     monthstr = sprintf "%d/%d", day.year, day.month
     
     holiday = Holiday.new
@@ -1508,7 +1515,7 @@
 		  s.keys.sort.collect{|time|
 		    s[time].keys.sort.collect{|who|
 		      text = s[time][who]['sched']
-		      sprintf "%s%s",
+		      topic = sprintf "%s%s",
 			time == @opt['alldaydir'] ? '' : time+":",
 			if personal
 			  text.split("\n")  ##[0]
@@ -1522,6 +1529,11 @@
 			      '=' + text.split("\n")[0]
 			    end.to_s
 			end
+		      if hldays > 0 &&
+			  (today - s[time][who]['regtime']) < hldays
+			topic = @H.element("span", recent){topic}
+		      end
+		      topic
 		    }.join("<br>")
 		  }.join("<br>\n")
 		else
@@ -1566,7 +1578,9 @@
 	[msg('headline'), 'headline'],
 	[msg('whole'), 'whole']]
       msg('display') + \
-      @H.select('headline', choice, headline) + \
+      @H.select('headline', choice, headline) + "/" + \
+      msg('hldays') + \
+      @H.select('headlinehl', 0..30, headlinehl) + \
       @H.submit("GO", "GO")
     }
     @O.print footer
@@ -1613,7 +1627,7 @@
 	@H.element("th", {'class'=>'time'}){'TIME'} + \
 	@H.element("th", nil){'Who - '+datewn+' - What'}
       }
-      for time in s.keys
+      for time in s.keys.sort
 	tstr = case time
 	       when @opt['alldaydir']
 		 msg('allday')
@@ -1820,7 +1834,7 @@
     ## @O.print @H.p()
     @O.print @H.elementln("form", {'action'=>@myname+"?-show+#{date}", 'method'=>'POST'}){
       @H.elementln("p"){
-	msg(personal ? 'personalmode' : 'normalmode') + " " + \
+	msg(personal ? 'personalmode' : 'normalmode') + "<br>" + \
 	@H.select("displaydays", 1..30, days) + msg('daystodisplay') + \
 	@H.submit("GO", "GO")
       }
@@ -1884,6 +1898,7 @@
     end
   end
   def reg_notify(user, year, month, day, time, text, cancelall = nil)
+    return nil unless @opt['notifymail']
     threshold = 5*60		# Omit notifycation within 30min future
 
     y, m, d, t, = year.to_i, month.to_i, day.to_i, time.to_i
@@ -2845,7 +2860,7 @@
 	when /^([a-z]+)=(.*)/oi
 	  key, value = $1, $2
 	  case value
-	  when /^(no|none|null|nil)$/io
+	  when /^(no|none|null|nil|false|0|off)$/io
 	    @opt[key] = nil
 	  else
 	    @opt[key] = value
@@ -2936,7 +2951,7 @@
 	@job = 'newgroupsub'
       when "-delusersub"
 	ARGV.shift
-	usr = users().grep(ARGV[0])[0]
+	usr = safecopy(users().grep(ARGV[0])[0])
 	@job = 'delusersub "'+usr+'"'
       when "-delgroupsub"
 	ARGV.shift

yatex.org