Skip to content

Instantly share code, notes, and snippets.

@masao
Last active May 5, 2021 12:07
Show Gist options
  • Save masao/4d408af7ad4d9bf4e5d3 to your computer and use it in GitHub Desktop.
Save masao/4d408af7ad4d9bf4e5d3 to your computer and use it in GitHub Desktop.
source "https://rubygems.org"
gem "roo"
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require "cgi"
require "date"
require "roo"
print <<EOF
<tr>
<th>学籍番号</th>
<th style="width:5.5em;">氏名</th>
<th>論題</th>
<th style="width:2.5em"></th>
<th style="width:2.5em"></th>
</tr>
EOF
xlsx = Roo::Excelx.new(ARGV[0])
# skip header line.
xlsx.each_row_streaming(pad_cells: true, offset: 1) do |row|
#以下の順で並べる:
number, name, title, file_abstract, file_fulltext, embargo, = row.to_a.map{|e| e.value }
title = title.gsub(/\s+/, " ")
title = title.gsub(/\A\"(.+)\"\z/){ $1 }.strip
year = Date.today.year - 1
fulltext_link = if embargo.nil? or embargo.to_s.empty?
%Q[<a href="http://ronbun.klis.tsukuba.ac.jp/archives/#{ year }/#{ file_fulltext }">本文</a>]
else
"(公開猶予)"
end
print <<EOF
<tr>
<td>#{ number }</td>
<td>#{ name }</td>
<td>#{ CGI.escapeHTML title }</td>
<td><a href="archives/#{ year }/#{ file_abstract }">抄録</a></td>
<td>#{ fulltext_link }</td>
</tr>
EOF
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment