Created
July 15, 2012 15:39
-
-
Save ctyo/3117486 to your computer and use it in GitHub Desktop.
FSWiki上でバグトラックで管理されているバグをTagCloud風に表示するプラグイン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# | |
# <p>BugTrackプラグインで管理されているバグをTagCloud風に表示します。</p> | |
# <p> | |
# 引数としてプロジェクト名および表示するバグの条件を渡します<br/> | |
# 条件がない場合は全件を表示します。 | |
# </p> | |
# <pre> | |
# {{bugtrack プロジェクト名,yet}} | |
# {{bugtrack プロジェクト名,done}} | |
# </pre> | |
# | |
# <p>2012.07.15 A.Tatsukawa http://ctyo.info)</p> | |
# | |
################################################################################ | |
package plugin::bugcloud::BugCloud; | |
use strict; | |
#=============================================================================== | |
# コンストラクタ | |
#=============================================================================== | |
sub new { | |
my $class = shift; | |
my $self = {}; | |
return bless $self,$class; | |
} | |
#=============================================================================== | |
# パラグラフ | |
#=============================================================================== | |
sub paragraph { | |
my $self = shift; | |
my $wiki = shift; | |
my $project = shift; | |
my $option = shift; | |
my $cgi = $wiki->get_CGI(); | |
if($project eq ""){ | |
return &Util::paragraph_error("プロジェクト名が指定されていません。"); | |
} | |
my $template = HTML::Template->new( | |
filename=>$wiki->config('tmpl_dir')."/bugcloud.tmpl" | |
, die_on_bad_params => 0); | |
my $bugs = get_buglist($wiki, $project, $option); | |
$template->param(BUGS => $bugs); | |
return $template->output(); | |
} | |
sub get_buglist() { | |
my $wiki = shift; | |
my $project = shift; | |
my $option = shift; | |
my @pages = $wiki->get_page_list(); | |
my $bugs = []; | |
my $quote = quotemeta($project); | |
foreach(@pages){ | |
if($_ =~ /^BugTrack-$quote\/([0-9]+)$/){ | |
my $pagename = $_; | |
my $count = $1; | |
my $category = ""; | |
my $status = ""; | |
my $priority = ""; | |
my $subject = ""; | |
my $page = $wiki->get_page($pagename); | |
my @lines = split(/\n/,$page); | |
my $first = 0; | |
foreach(@lines){ | |
$_ =~ s/\r//; | |
if($first==0 && $_ =~ /^!!!(.*)/){ | |
$subject = $1; | |
$first = 1; | |
} elsif($_ =~ /^\*優先度:\s*(.*)/){ | |
$priority = $1; | |
} elsif($_ =~ /^\*状態:\s*(.*)/){ | |
$status = $1; | |
} | |
} | |
my $bug = {page =>$pagename, | |
count =>$count, | |
category =>$category, | |
status =>$status, | |
priority =>$priority, | |
subject =>$subject, | |
url =>$wiki->create_page_url($pagename), | |
level =>priority2level($priority, $status), | |
}; | |
$bug->{'option'} = $option; | |
if ($option eq 'yet') { | |
if ($status eq '提案' || $status eq '着手') { | |
$bug->{'option'} = 'yet'; | |
push(@$bugs, $bug); | |
} | |
} elsif ($option eq 'done') { | |
if ($status eq '完了' || $status eq 'リリース済' | |
|| $status eq '保留' || $status eq '却下') { | |
push(@$bugs, $bug); | |
} | |
} else { | |
push(@$bugs, $bug); | |
} | |
} | |
} | |
return $bugs; | |
} | |
sub priority2level { | |
my $priority = shift; | |
my $status = shift; | |
my $level_num; | |
$level_num = 1 if $priority eq '緊急'; | |
$level_num = 2 if $priority eq '重要'; | |
$level_num = 3 if $priority eq '普通'; | |
$level_num = 4 if $priority eq '低'; | |
$level_num = 3 if !$level_num; | |
return 'level'.$level_num; | |
} | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
/*-------------------------------------- | |
BugCloud | |
---------------------------------------*/ | |
ul.bugCloud { | |
margin: 10px; | |
padding: 0.5em 10px; | |
border: gray 2px dotted; | |
line-height: 1; | |
font-family: Arial, Helvetica, sans-serif; | |
font-size: 13px; | |
} | |
ul.bugCloud li { | |
margin: 0; | |
padding: 0; | |
display: inline; | |
font-size: 100%; /* ここで相対的に文字サイズを変更 */ | |
} | |
ul.bugCloud li a { | |
text-decoration: none; | |
background: #F0FFF0; | |
margin-right: 5px; | |
margin-bottom: 5px; | |
} | |
/* タグレベル1~6 */ | |
ul.bugCloud li.level1 a { | |
font-size: 167%; | |
font-weight: bold; | |
color: #424242; | |
} | |
ul.bugCloud li.level2 a { | |
font-size: 136%; | |
font-weight: bold; | |
color: #5e5e5e; | |
} | |
ul.bugCloud li.level3 a { | |
font-size: 122%; | |
font-weight: bold; | |
color: #7a7a7a; | |
} | |
ul.bugCloud li.level4 a { | |
font-size: 114%; | |
color: #979797; | |
} | |
ul.bugCloud li.level5 a { | |
font-size: 92%; | |
color: #b3b3b3; | |
} | |
ul.bugCloud li.level6 a { | |
font-size: 90%; | |
color: #cfcfcf; | |
} | |
/* オンマウス */ | |
ul.bugCloud li a:hover { | |
color: #000; | |
} | |
</style> | |
<ul class="bugcloud"> | |
<!--TMPL_LOOP NAME="BUGS"--> | |
<li class="<!--TMPL_VAR NAME="LEVEL"-->"><a href="<!--TMPL_VAR NAME="URL"-->"><!--TMPL_VAR ESCAPE="HTML" NAME="SUBJECT"--></a></li> | |
<!--/TMPL_LOOP--> | |
<!-- <li class="bc_add"><a href="<!--TMPL_VAR NAME="ADD_URL"-->">追加</a></li> --> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# | |
# バグトラックで管理されているバグをTagCloud風に表示します。 | |
# | |
################################################################################ | |
package plugin::bugcloud::Install; | |
use strict; | |
sub install { | |
my $wiki = shift; | |
$wiki->add_paragraph_plugin("bugcloud","plugin::bugcloud::BugCloud","HTML"); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment