Index: openacs-4/packages/lars-blogger/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/index.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/lars-blogger/www/index.tcl 18 Sep 2003 20:07:17 -0000 1.9 +++ openacs-4/packages/lars-blogger/www/index.tcl 29 Sep 2003 08:05:42 -0000 1.10 @@ -4,19 +4,41 @@ @author Lars Pind (lars@pinds.com) @creation-date February 2002 } { - screen_name:optional + {screen_name:optional {}} + {category_short_name:optional {}} year:optional,string_length_range(4|4) month:optional,string_length_range(2|2) day:optional,string_length_range(2|2) } set page_title [lars_blog_name] -if {![exists_and_not_null screen_name]} { - set screen_name "" - set context_bar [ad_context_bar] +set package_id [ad_conn package_id] + +set package_url [ad_conn package_url] +set package_url_with_extras $package_url + +set l_context_bar [list] +set context_base_url [ad_conn package_url] + +if { ![empty_string_p $screen_name] } { + # Show Screen Name in context bar + append context_base_url /user/$screen_name + lappend l_context_bar [list $context_base_url $screen_name] + + append package_url_with_extras user/$screen_name/ +} + +if { ![empty_string_p $category_short_name] } { + if { ![db_0or1row get_category_from_short_name { *SQL* }] } { + ad_return_error "Category doesn't exist" "The specified category wasn't valid." + return + } + # Show Category in context bar + append context_base_url /category/$category_short_name + lappend l_context_bar [list $context_base_url $category_name] } else { - set context_bar [ad_context_bar $screen_name] + set category_id "" } if { ![empty_string_p [parameter::get -parameter "rss_file_name"]] } { @@ -29,14 +51,12 @@ } -set package_id [ad_conn package_id] -set package_url [ad_conn package_url] - set write_p [permission::permission_p -object_id $package_id -privilege write] set admin_p [permission::permission_p -object_id $package_id -privilege admin] set display_users_p [parameter::get -parameter "DisplayUsersP" -default 0] +set display_categories [lars_blog_categories_p -package_id $package_id] if {$display_users_p && ![exists_and_not_null screen_name]} { @@ -75,22 +95,25 @@ ad_script_abort } + # Show Archive, Year and Month i context + append context_base_url /archive + lappend l_context_bar [list $context_base_url Archive] + append context_base_url /$year + lappend l_context_bar [list $context_base_url $year] + append context_base_url /$month + lappend l_context_bar [list $context_base_url $month] + + if { [exists_and_not_null day] } { set interval "day" db_1row archive_date_month_day { *SQL* } - if {[empty_string_p $screen_name]} { - set context_bar [ad_context_bar [list "$package_url/archive/" "Archive"] [list "$package_url/archive/$year/$month/" $archive_month_pretty] $archive_date_pretty] - } else { - set context_bar [ad_context_bar [list "$package_url/user/$screen_name/" "$screen_name"] [list "$package_url/user/$screen_name/archive/" "Archive"] [list "$package_url/user/$screen_name/archive/$year/$month/" $archive_month_pretty] $archive_date_pretty] - } + + # Day in context + append context_base_url /$day + lappend l_context_bar [list $context_base_url $day] } else { set interval "month" db_1row archive_date_month { *SQL* } - if {[empty_string_p $screen_name]} { - set context_bar [ad_context_bar [list "$package_url/archive/" "Archive"] $archive_date_pretty] - } else { - set context_bar [ad_context_bar [list "$package_url/user/$screen_name/" "$screen_name"] [list "$package_url/user/$screen_name/archive/" "Archive"] $archive_date_pretty] - } } append page_title " Archive" @@ -104,4 +127,10 @@ set archive_date "" } +db_multirow categories categories { *SQL* } + +# Cut the URL off the last item in the context bar +set l_context_bar [lreplace $l_context_bar end end [lindex [lindex $l_context_bar end] end]] +eval "set context_bar \[ad_context_bar $l_context_bar\]" + ad_return_template