Skip to content

Commit

Permalink
* chalow, cl.conf: $descending_order_items を新設。
Browse files Browse the repository at this point in the history
0 の時、日ページ、月ページ、カテゴリページで、アイテムを降順 (新し
いアイテムが上) で表示する。デフォルトは 1 (今までと同じ動作)
  • Loading branch information
masutaka committed Jul 6, 2011
1 parent faf6848 commit 7480bc8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2011-07-06 Takashi Masuda <masutaka@nifty.com>

* chalow, cl.conf: $descending_order_items を新設。
0 の時、日ページ、月ページ、カテゴリページで、アイテムを降順 (新し
いアイテムが上) で表示する。デフォルトは 1 (今までと同じ動作)

* chalow, cl.conf: $ignore_case_sorting_by_cat_in_sidemenu を新設。
1 の時、サイドメニューのカテゴリを大文字小文字無視でソートする。
デフォルトは 0 (今までと同じ動作)
Expand Down
18 changes: 16 additions & 2 deletions chalow
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ my $opt_topn = 5;
my $show_day_of_week = 1;
# 月ページで、日付を降順 (新しい日付が上) で表示するか (1:yes or 0:no)
my $reverse_order_days = 0;
# 日ページ、月ページ、カテゴリページで、アイテムを降順 (新しいアイテム
# が上) で表示するか (1:yes or 0:no)
my $descending_order_items = 1;

# インデックスページのテンプレート
my $index_page_template = << "___INDEX_PAGE_TEMPLATE"
Expand Down Expand Up @@ -391,6 +394,7 @@ $clog_url_pref .= "/" unless ($clog_url_pref =~ m!/$!);
# http://chalow.net -> http://chalow.net/

my %month_page; # 月別のページ
my %month_page_for_index; # 月別のページ for index.html
my %category_item; # カテゴリ別ページ用 item
my %inside_ref; # 日付リンクによるリファラー

Expand Down Expand Up @@ -442,8 +446,13 @@ foreach my $ymd (sort keys %{$cl->{all}}) {
next if ($i !~ /^\d/);
push @items, make_item_html($e, $ymd, $i);
}
my @items_for_index = @items;
unless ($descending_order_items) {
@items = reverse @items; # 昇順: 古いアイテムが上
}
my ($y, $m, $d) = ($ymd =~ /^(\d{4})-(\d\d)-(\d\d)$/);
$month_page{"$y-$m"}{$ymd}{str} = make_entry_html($e, $ymd, \@items);
$month_page_for_index{"$y-$m"}{$ymd}{str} = make_entry_html($e, $ymd, \@items_for_index);
}

### 生成(2) HTML ファイルの出力
Expand Down Expand Up @@ -662,7 +671,12 @@ sub write_category_page {

foreach my $catname (@cat_list) {

my @ents = sort {$b->{eh} cmp $a->{eh}} @{$category_item{$catname}};
my @ents;
if ($descending_order_items) { # 降順: 新しいアイテムが上
@ents = sort {$b->{eh} cmp $a->{eh}} @{$category_item{$catname}};
} else { # 昇順: 古いアイテムが上
@ents = reverse sort {$b->{eh} cmp $a->{eh}} @{$category_item{$catname}};
}

my $n = $cat_page_entry_max;
my $num_of_old_pages = int(@ents / $n);
Expand Down Expand Up @@ -914,7 +928,7 @@ sub write_index_page {
my $ymd = $recent[$i];
my ($ym, $d) = ($ymd =~ /^(\d{4}-\d\d)-(\d\d)$/);
# $top_n_str .= $month_page{$ym}{$ymd}{str};
push @top_n_entries, {content => $month_page{$ym}{$ymd}{str}};
push @top_n_entries, {content => $month_page_for_index{$ym}{$ymd}{str}};
}
my ($ymd, $ym, $d) = ($recent[0] =~ /^((\d{4}-\d\d)-(\d\d))$/);

Expand Down
5 changes: 5 additions & 0 deletions cl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ $show_day_of_week = 1;
# 月ページで、日付を降順 (新しい日付が上) で表示するか (1:yes or 0:no)
$reverse_order_days = 1;

# --------------------------------------------------------------------
# 日ページ、月ページ、カテゴリページで、アイテムを降順 (新しいアイテム
# が上) で表示するか (1:yes or 0:no)
$descending_order_items = 1;

# --------------------------------------------------------------------
# アイテムヘッダーのフォーマットをどうするか
# (0:"* HOGE:", 1:"* HOGE", 2:"HOGE:",3:"HOGE")
Expand Down

0 comments on commit 7480bc8

Please sign in to comment.