in response to
geisha_doll's
s2smoothsailing post. uses TagCloud as example for "special page."
function TagsPage::view_title : string {
# get special page type
var string page = $.args{"page"};
# set special page titles
var string{} pages = {
"one" => "One", # "one" page title
"two" => "Two", # "two" page title
"tagcloud" => "TagCloud", # "tagcloud" page title
};
# if we are doing a special page, get special page title
# else, return normal page title
# change this to "Tags Page" if not using Smooth Sailing
return $pages{$page} != "" ? $pages{$page} : $*text_tags_pagetitle;
}
function TagsPage::print_body() {
# get special page type
var string page = $.args{"page"};
# "one" page content
if($page == "one") {
#
"one";
#
# "two" page content
} elseif ($page == "two") {
#
"two";
#
# "tagcloud" page content
} elseif ($page == "tagcloud") {
#
var string header = $this->view_title();
var string datetime = $.time->date_format($*text_format_entry_date_and_time);
var string content = "";
var int int_groups = 5; # number of groups
var int int_percent = 20; # perecentage difference for each interval
var int adjust = 0; # font size adjustment
var int factor = 0; # factor of font size adjustment
var int interval = 0; # tag use count interval per group
var int max = 1; # max number of tag uses
var TagDetail[] my_tags = $this->visible_tag_list(); # list of visible tags
# implement cloudstyle ala delicious, etc
if ($my_tags) {
$content = $content + """
""";
# get max
foreach var TagDetail t ($my_tags) {
if($t.use_count > $max) {
$max = $t.use_count;
}
}
# now we get tag use count interval per group
$interval = $max / $int_groups;
# now print each item, and adjust its
# fontsize as a function of where in the
# continuum of $int_groups intervals it is
foreach var TagDetail t ($my_tags) {
# if we're not going to divide by 0
if($interval > 0) {
# get the proportion based on use_count and interval
$factor = $t.use_count / $interval;
} else {
# if we're dividing by 0, set factor to 0
$factor = 0;
}
$adjust = ($factor * $int_percent) + 100;
$content = $content + """
$t.name """;
}
$content = $content + """
""";
} else {
$content = $content + """
There are currently no tags or categories for this journal.
""";
}
"""
$datetime - $header
""";
if ($*layout_position_userinfo_entry == "left" or $*layout_wrapping_userinfo_entry) {
if(defined $.journal.default_pic) {
"""
""";
if (not $*layout_wrapping_userinfo_entry) {
"""
""";
}
}
}
"""
$content
""";
if ($*layout_position_userinfo_entry == "right" and not $*layout_wrapping_userinfo_entry) {
if(defined $.journal.default_pic) {
"""
""";
}
}
"""
""";
#
# no special page
# print as normal
# existing TagsPage::print_body() goes here
} else {
#
if(size $.tags > 0) {
if ($*layout_tagspage == "table") {
$this->lay_print_tagstable();
} elseif($*layout_tagspage == "list") {
$this->lay_print_tagslist();
}
} else {
"""$*text_tags_none""";
}
#
}
}