changeset 3242:2a1a5a1e157c

rename
author HIROSE Yuuji <yuuji@koeki-u.ac.jp>
date Thu, 14 Jul 2016 22:50:17 +0900
parents b56bf1659fd5
children 4d5b4c0e2a86
files event/oasis2016/sea/.htaccess event/oasis2016/sea/ans.jpg event/oasis2016/sea/boat-0.png event/oasis2016/sea/boat-1.png event/oasis2016/sea/boat-2.png event/oasis2016/sea/ckgame.html event/oasis2016/sea/ckgame.rb event/oasis2016/sea/dbinit.cgi event/oasis2016/sea/index.jpeg event/oasis2016/sea/matigai.png event/oasis2016/sea/point.yaml event/oasis2016/sea/qrpanel.rb event/oasis2016/sea/rogo.png
diffstat 13 files changed, 514 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/event/oasis2016/sea/.htaccess	Thu Jul 14 22:50:17 2016 +0900
@@ -0,0 +1,5 @@
+AddHandler      cgi-script			.rb .sh
+Options 	+ExecCGI
+AddType 	"text/html; charset=utf-8"		.html
+# AddDefaultCharset	    		UTF-8
+# AddCharset				UTF-8	.rb	.html
Binary file event/oasis2016/sea/ans.jpg has changed
Binary file event/oasis2016/sea/boat-0.png has changed
Binary file event/oasis2016/sea/boat-1.png has changed
Binary file event/oasis2016/sea/boat-2.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/event/oasis2016/sea/ckgame.html	Thu Jul 14 22:50:17 2016 +0900
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="ja">
+<head><title>まちがいみつけでみっちゃ</title></head>
+<style type="text/css">
+<!--
+div.don {
+    position: relative; width: 450px; height: 450px;
+    border: 1px solid #f9f5a9; margin: 1em auto;
+}
+div.don div {width: 150px; height: 150px; margin: 0px;}
+div.don div:first-child {left: 0px; top: 0px}
+div.don div:nth-child(2) {position: absolute; left: 150px; top: 0px;}
+div.don div:nth-child(3) {position: absolute; left: 300px; top: 0px;}
+body{text-align:center;
+background:#f9f5a9;}
+-->
+</style>
+</head>
+<body>
+<img src="rogo.png" width="900px" height="100px">
+<h1>もっけ さんのホーム</h1>
+<p></p>
+<p>当てたキーワード(4/4): 「もっけ」, 「げっぱ」, 「はっこ」, 「やばち」
+</p>
+<form action="./ckgame.rb" method="POST">
+<p>キーワードを入れてください: <input name="keyword"><br>
+<input type="submit" value="送信">
+<input type="reset" value="リセット"></p>
+</form>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/event/oasis2016/sea/ckgame.rb	Thu Jul 14 22:50:17 2016 +0900
@@ -0,0 +1,119 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+require 'yaml/store'
+file = "db/point2.yaml"
+bingoword = %w(かもめ とびうお ひとで) # 正解キーワード3つ
+
+require 'cgi'
+c = CGI.new(:accept_charset => "UTF-8")
+
+# 前回のアクセスで既にcookieが定義されていたら取得
+# ブラウザからのcookieは、c.cookies[変数名][0] で受け取る
+cookie_id=c.cookies["id"][0]
+
+# 前回のアクセスで入力された値を取得
+form_name=c["playname"]        # nameをフォームから取得(もしあれば)
+form_kwd=c["keyword"]          # keywordも取得(もしあれば)
+
+if cookie_id == nil             # (1)もしcookieからのidがなければ新規生成
+  # 新規idは、現在時刻を秒(to_i)にした文字列(to_s)と乱数の組み合わせ
+  newid = Time.now.to_i.to_s + "/" + rand(99999).to_s
+  id=newid                      # 新規idをidとする
+else                            # (2)cookieからのidがあればそれをidとする
+  id=cookie_id
+end
+
+# idをすぐcookieで相手ブラウザに送る
+# 変数の期限を24時間に設定し、expire変数に入れる
+expire = (Time.now+24*3600).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT")
+printf("Content-type: text/html; charset=UTF-8\n")
+printf("Set-Cookie: id=%s; expires=%s\n\n", id, expire)
+
+db = YAML::Store.new(file)
+db.transaction do
+  info = db["info"] = db.fetch("info", Hash.new)
+  if !info[id]              # もしそのユーザ情報が未登録(空)なら
+    info[id] = Hash.new     # 新規ハッシュを割り当てる
+  end
+  if form_name > ""             # formからの名前設定がもしあれば
+    info[id]["name"] = form_name # それをユーザ情報に記録
+    info[id]["bingo"] = Hash.new # 正解した単語保存用のハッシュも作成
+  end
+  point = 0# 開始直後は0点
+  if !info[id]["name"]      # もしユーザのプレイ名が未設定なら
+    title = "ようこそ!"
+    hello = "まちがいさがしスタート"
+    guide = "あなたのプレイ名を決めます"
+    input = '<input name="playname">'
+  else                          # プレイ名設定済みならキーワード入力
+    title = sprintf("%s さんのホーム", info[id]["name"])
+    setumei = "絵から間違いを3個見つけよう!"
+    setumei2 = "間違っている絵のパネルは全部で3個あるよ♪"
+    guide = "キーワードを入れてください"
+    input = '<input name="keyword">'
+    seikai = '<img src="ans.jpg" width="450px" height="450px">'
+    # プレイ名設定済みで、さらにキーワードが入力されていたら
+    if form_kwd > ""
+      index = bingoword.index(form_kwd) # 配列から入力単語(form_kwd)を探索
+      hello = sprintf("現在のポイントは %dpt です。", 25*point)
+      if index
+        # 見付かった! その単語をハッシュのキーとして適当に値(true)を入れておく
+        info[id]["bingo"][bingoword[index]] = true
+      end
+    end
+    point = info[id]["bingo"].length # ハッシュの長さで正解数が分かる
+    bingos = info[id]["bingo"].keys.collect do |x|
+      "「" + x + "」"# collectメソッドで 「 」 で括った単語を集めて
+    end.join(", ")# joinメソッドで ,(カンマ) 区切りでつなげる
+    boat = ""; boat2 = ""; boat3 = "";
+    info[id]["bingo"].keys.each do |f|
+      if /かもめ/ =~ f
+        boat = '<img src="boat-0.png" width="450px" height="151px">'
+      elsif /とびうお/ =~ f
+        boat2 = '<img src="boat-1.png" width="450px" height="147px">'
+      elsif /ひとで/ =~ f
+        boat3 = '<img src="boat-2.png" width="450px" height="152px">'
+      end
+    end
+  end
+printf(<<-EOF,
+<!DOCTYPE html>
+<html lang="ja">
+<head><title>まちがいみつけでみっちゃ</title>
+<style type="text/css">
+<!--
+div.don {
+    position: relative; width: 900px; height: 900px;
+    border: 1px solid #f9f5a9; margin: 1em auto;
+}
+div.don div {width: 150px; height: 150px; margin: 0px;}
+div.don div:first-child {position: absolute; left: 175px; top: 0px}
+div.don div:nth-child(2) {position: absolute; left: 175px; top: 151px;}
+div.don div:nth-child(3) {position: absolute; left: 175px; top: 298px;}
+body{text-align:center;
+background:#f9f5a9;}
+-->
+</style>
+</head>
+<body>
+<img src="rogo.png" width="900px" height="100px">
+<h1>%s</h1>
+<h2>%s</h2>
+<h2>%s</h2>
+<p>%s</p>
+<p>開けたパネル(%d/%d): %s</p>
+<form action="?" method="GET">
+<p>%s: %s<br>
+<input type="submit" value="送信">
+<input type="reset" value="リセット"></p>
+</form>
+<p>%s</p>
+<div class="don">
+<div>%s</div>
+<div>%s</div>
+<div>%s</div>
+</div>
+</body></html>
+EOF
+         title, setumei, setumei2, hello, point, bingoword.length, bingos, guide, input, seikai, boat, boat2, boat3 )
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/event/oasis2016/sea/dbinit.cgi	Thu Jul 14 22:50:17 2016 +0900
@@ -0,0 +1,1 @@
+../don/dbinit.cgi
\ No newline at end of file
Binary file event/oasis2016/sea/index.jpeg has changed
Binary file event/oasis2016/sea/matigai.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/event/oasis2016/sea/point.yaml	Thu Jul 14 22:50:17 2016 +0900
@@ -0,0 +1,295 @@
+---
+info:
+  1467004899/57021: {}
+  1467032118/62831:
+    name: i
+    bingo:
+      a: true
+      b: true
+      c: true
+  1467117318/92953:
+    name: a
+    bingo: {}
+  1467117911/42150:
+    name: a
+    bingo:
+      a: true
+  1467118488/93735:
+    name: "あ"
+    bingo:
+      a: true
+  1467119115/96970:
+    name: "h"
+    bingo:
+      a: true
+  1467119305/72833:
+    name: a
+    bingo:
+      a: true
+  1467119459/65450:
+    name: "いつき"
+    bingo:
+      a: true
+      b: true
+  1467119700/40304:
+    name: a
+    bingo:
+      a: true
+  1467120001/16537:
+    name: "あ"
+    bingo:
+      b: true
+  1467120057/67247:
+    name: k
+    bingo:
+      b: true
+  1467120344/33686:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467120651/18406:
+    name: a
+    bingo: {}
+  1467120682/52935:
+    name: a
+    bingo: {}
+  1467120850/2161:
+    name: j
+    bingo:
+      a: true
+      b: true
+  1467121204/45943:
+    name: j
+    bingo:
+      b: true
+  1467121526/7362:
+    name: a
+    bingo:
+      a: true
+  1467121606/31914:
+    name: a
+    bingo:
+      a: true
+  1467121704/50650:
+    name: a
+    bingo:
+      b: true
+  1467121974/97264:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467122622/50115:
+    name: h
+    bingo: {}
+  1467122728/43950:
+    name: j
+    bingo: {}
+  1467122767/39079:
+    name: j
+    bingo:
+      a: true
+      b: true
+  1467124887/97240:
+    name: "h"
+    bingo:
+      a: true
+      b: true
+  1467124942/23020:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467165318/97088:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467166009/28556: {}
+  1467166801/79139:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467166948/64537:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467167057/90348:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467167123/53040:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467167767/49453: {}
+  1467167981/41879:
+    name: a
+    bingo:
+      a: true
+  1467168215/59909:
+    name: "いつき"
+    bingo:
+      a: true
+      b: true
+  1467168390/69369: {}
+  1467168688/57108:
+    name: a
+    bingo: {}
+  1467168846/69155:
+    name: a
+    bingo: {}
+  1467169038/59209:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467169490/16081:
+    name: "いつき"
+    bingo:
+      a: true
+  1467169730/37759:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467170157/94600:
+    name: a
+    bingo:
+      a: true
+      b: true
+  1467209489/32797:
+    name: "いつき"
+    bingo: {}
+  1467210107/32355:
+    name: k
+    bingo: {}
+  1467210208/28511:
+    name: k
+    bingo:
+      a: true
+      b: true
+  1467210231/85135:
+    name: "いつき"
+    bingo:
+      a: true
+      b: true
+      c: true
+      f: true
+      i: true
+      g: true
+      e: true
+      h: true
+      d: true
+  1467210400/60766:
+    name: a
+    bingo: {}
+  1467210690/86800:
+    name: a
+    bingo: {}
+  1467346224/88139:
+    name: "ほーじょー"
+    bingo:
+      a: true
+      d: true
+      i: true
+      b: true
+      c: true
+      e: true
+      f: true
+      g: true
+      h: true
+  1467346315/22993:
+    name: yuuji
+    bingo:
+      a: true
+      d: true
+      i: true
+  1467346346/47890:
+    name: tst
+    bingo:
+      a: true
+      d: true
+      i: true
+      b: true
+      f: true
+      h: true
+  1467346350/1182:
+    name: moi
+    bingo:
+      a: true
+      d: true
+      i: true
+      b: true
+      c: true
+      e: true
+      f: true
+      g: true
+      h: true
+  1467346610/87685:
+    name: a
+    bingo:
+      a: true
+  1467346676/29771:
+    name: a
+    bingo: {}
+  1467348537/15249:
+    name: ituki
+    bingo:
+      a: true
+      b: true
+      c: true
+      d: true
+      e: true
+      f: true
+      g: true
+      h: true
+      i: true
+  1467348899/52734:
+    name: "ゆうき"
+    bingo:
+      "あ": true
+      b: true
+      c: true
+      d: true
+      e: true
+      f: true
+      g: true
+      h: true
+      i: true
+  1467349308/70804:
+    name: "いつき"
+    bingo:
+      "きゅうり": true
+      "うに": true
+  1467349375/17261: {}
+  1467349492/94530:
+    name: "いつき"
+    bingo:
+      "ほし": true
+      "どんぶり": true
+      "いくら": true
+  1467349578/40580:
+    name: "い"
+    bingo:
+      "えび": true
+      "たまご": true
+      "まぐろ": true
+      "きゅうり": true
+      "さーもん": true
+      "わさび": true
+      "どんぶり": true
+      "ほし": true
+      "まる": true
+  1467544363/33633: {}
+  1467606095/21541: {}
+  1467853110/52265: {}
+  1467884315/8342:
+    name: a
+    bingo: {}
+  1467884891/68742: {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/event/oasis2016/sea/qrpanel.rb	Thu Jul 14 22:50:17 2016 +0900
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+require 'yaml/store'
+
+player = ARGV[0]
+place  = ARGV[1]
+
+if player == nil then
+  STDERR.puts "#{$0} Player Place"
+  exit 1
+end
+
+class PanelQR
+  def initialize(dbfile = "paneldb.yaml")
+    @db = YAML::Store.new(dbfile)
+  end
+  def regist(player, place)
+    @db.transaction do
+      # pn変数にファイルに記録されているパネル情報を取得
+      pn = @db["panel"] = @db.fetch("panel", Hash.new)
+      # 登録者(player)が空なら新規Hashを代入
+      if pn[player] == nil
+        pn[player] = Hash.new
+      end
+      # playerがplaceのQRコードを取得
+      if pn[player][place] == nil then
+        pn[player][place] = 0# Hash.new(0)が使えないため
+      end
+      pn[player][place] += 1
+    end
+  end
+  def list(player)
+    @db.transaction do
+      pn = @db["panel"]
+      # パネル情報が空でなければ出力する
+      if pn && pn[player] then
+        pn[player].each do |place, count|
+          printf("%s さんは %s に%d回行きました\n", player, place, count)
+        end
+      end
+    end
+  end
+  def listall()
+    @db.transaction do
+      if @db["panel"] then
+        @db["panel"].each do |who, phash|
+          phash.each do |place, count|
+            printf("%s さんは %s に%d回行きました\n", who, place, count)
+          end
+        end
+      end
+    end
+  end
+end
+pq = PanelQR.new
+
+if player == "-l" then
+  pq.listall
+else
+  pq.regist(player, place)
+  pq.list(player)
+end
Binary file event/oasis2016/sea/rogo.png has changed

yatex.org