Committer: gprochaev
LJSUP-7052. Landing Page.U trunk/bin/upgrading/update-db-general.pl U trunk/cgi-bin/LJ/Browse.pm U trunk/cgi-bin/LJ/URI.pm U trunk/cgi-bin/LJ/Vertical.pm U trunk/cgi-bin/LJ/Widget/Browse.pm U trunk/cgi-bin/ljlib.pl U trunk/htdocs/admin/browse/add_category.bml A trunk/htdocs/admin/browse/edit_verticals.bml U trunk/htdocs/admin/browse/index.bml U trunk/htdocs/browse/index.bml A trunk/templates/Browse/browse.tmpl U trunk/templates/Browse/index.tmpl A trunk/templates/Browse/recent_posts.tmpl
Modified: trunk/bin/upgrading/update-db-general.pl =================================================================== --- trunk/bin/upgrading/update-db-general.pl 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/bin/upgrading/update-db-general.pl 2010-10-26 05:23:19 UTC (rev 17601) @@ -3036,6 +3036,18 @@ ) EOC +# global table for verticals 2 +register_tablecreate("vertical2", <<'EOC'); +CREATE TABLE `vertical2` ( + `vert_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `url` VARCHAR(20) NOT NULL, + `name` VARCHAR(50) NOT NULL, + `createtime` INT(10) UNSIGNED NOT NULL DEFAULT '0', + `journal` VARCHAR(16) DEFAULT '', + PRIMARY KEY (`vert_id`) +) +EOC + # global table for verticals register_tablecreate("vertical", <<'EOC'); CREATE TABLE vertical ( Modified: trunk/cgi-bin/LJ/Browse.pm =================================================================== --- trunk/cgi-bin/LJ/Browse.pm 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/cgi-bin/LJ/Browse.pm 2010-10-26 05:23:19 UTC (rev 17601) @@ -7,7 +7,7 @@ use Carp qw/ croak cluck /; my %singletons = (); # catid => singleton -my @cat_cols = qw( catid pretty_name url_path parentcatid ); +my @cat_cols = qw( catid pretty_name url_path parentcatid vert_id ); my @prop_cols = qw( children top_children in_nav featured ); # @@ -238,13 +238,18 @@ } sub load_all { - my $class = shift; + my $class = shift; + my $vertical = shift; my $dbh = LJ::get_db_reader() or die "unable to contact global db slave to load categories"; - my $sth = $dbh->prepare("SELECT * FROM category"); - $sth->execute; + my $vert_id = $vertical ? $vertical->vert_id : undef; + my $where = ''; + $where = ' WHERE vert_id = ? ' if $vert_id; + + my $sth = $dbh->prepare("SELECT * FROM category" . $where); + $sth->execute($vert_id); die $dbh->errstr if $dbh->err; my @categories; @@ -353,14 +358,24 @@ $path =~ s/\/?(?:\?.*)?$//; # remove trailing slash and any get args $path =~ s/\/index\.bml$//; # remove bml page - # 3 possibilities: + # 4 possibilities: # /browse - # /browse/topcategory/ - # /browse/topcategory/subcategory/[subcategory] - if ($path =~ /^\/browse\/(.+)$/) { + # /browse/vertical/ + # /browse/vertical/topcategory/ + # /browse/vertical/topcategory/subcategory/[subcategory] + if ($path =~ /^(\/browse.+)$/) { my $p = $1; my $category; + $p =~ s#^(/browse/(?:[\w\-]|[^/])+)/?##; + my $v_uri = $1; + + ## Vertical is not set + return undef unless $v_uri; + + my $vertical = LJ::Vertical->load_by_url ($v_uri); + #return $vertical; + # check cache now for full URI my $c = $class->load_from_uri_cache("/" . $p); return $c if $c; @@ -763,11 +778,13 @@ # returns full URL for a category sub url { - my $self = shift; + my $self = shift; + my $vertical = shift; - my $base = "$LJ::SITEROOT/browse"; - my $parent = ""; + return undef unless $vertical; + my $base = "$LJ::SITEROOT/browse".$vertical->uri; + return $base . $self->uri . "/"; } @@ -794,6 +811,19 @@ return $ret; } +sub recent_posts { + my $class = shift; + my $comms = shift; + my $limit = shift; + + my $comm_list = join ",", @$comms; + my $dbh = LJ::get_db_reader(); + my $post_ids = $dbh->selectall_arrayref ("SELECT * FROM category_recent_posts WHERE journalid IN ($comm_list) AND is_deleted = 0 ORDER BY timecreate DESC LIMIT $limit", { Slice => {} }); + my @entries = map { LJ::Entry->new ($_->{journalid}, jitemid => $_->{jitemid}) } @$post_ids; + return @entries; + +} + # Return a list of communities found in a category # Returns User objects sub communities { Modified: trunk/cgi-bin/LJ/URI.pm =================================================================== --- trunk/cgi-bin/LJ/URI.pm 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/cgi-bin/LJ/URI.pm 2010-10-26 05:23:19 UTC (rev 17601) @@ -39,10 +39,17 @@ return Apache::LiveJournal::redir($url, LJ::Request::HTTP_MOVED_TEMPORARILY); } - # handle vertical URLs my $args = LJ::Request->args; my $full_uri = $uri; $full_uri .= "?$args" if $args; + + ######## + # + # Now we handle verticals as subproject of community directory via LJ::Browse + # + ######## +=head + # handle vertical URLs if (my $v = LJ::Vertical->load_by_url($full_uri)) { if ($v->is_canonical_url($full_uri)) { my $args_for_redir = $args ? "?$args" : ''; @@ -51,8 +58,9 @@ return LJ::URI->bml_handler("explore/index.bml"); } } +=cut - if (my $c = LJ::Browse->load_by_url($full_uri)) { + if (my $c = LJ::Vertical->load_by_url($full_uri)) { return LJ::URI->bml_handler("browse/index.bml"); } Modified: trunk/cgi-bin/LJ/Vertical.pm =================================================================== --- trunk/cgi-bin/LJ/Vertical.pm 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/cgi-bin/LJ/Vertical.pm 2010-10-26 05:23:19 UTC (rev 17601) @@ -42,7 +42,7 @@ # my %singletons = (); # vertid => singleton -my @vert_cols = qw( vertid name createtime lastfetch ); +my @vert_cols = qw( vert_id url journal name createtime lastfetch ); sub min_age_of_poster_account { my $class = shift; @@ -278,7 +278,7 @@ my $self = bless { # arguments - vertid => delete $opts{vertid}, + vert_id => delete $opts{vert_id}, # initialization name => undef, @@ -298,18 +298,18 @@ _loaded_rules => 0, }; - croak("need to supply vertid") unless defined $self->{vertid}; + croak("need to supply vert_id") unless defined $self->{vert_id}; croak("unknown parameters: " . join(", ", keys %opts)) if %opts; # do we have a singleton for this vertical? { - my $vertid = $self->{vertid}; - return $singletons{$vertid} if exists $singletons{$vertid}; + my $vert_id = $self->{vert_id}; + return $singletons{$vert_id} if exists $singletons{$vert_id}; # save the singleton if it doesn't exist - $singletons{$vertid} = $self; + $singletons{$vert_id} = $self; } return $self; @@ -327,6 +327,7 @@ my %opts = @_; $self->{name} = delete $opts{name}; + $self->{url} = delete $opts{url}; croak("need to supply name") unless defined $self->{name}; @@ -336,17 +337,27 @@ my $dbh = LJ::get_db_writer() or die "unable to contact global db master to create vertical"; - $dbh->do("INSERT INTO vertical SET name=?, createtime=UNIX_TIMESTAMP()", - undef, $self->{name}); + $dbh->do("INSERT INTO vertical2 SET name=?, createtime=UNIX_TIMESTAMP(), url = ?", + undef, $self->{name}, $self->{url}); die $dbh->errstr if $dbh->err; return $class->new( vertid => $dbh->{mysql_insertid} ); } +sub get_categories { + my $self = shift; + + my $dbh = LJ::get_db_reader(); + + my $cats = $dbh->selectall_arrayref("SELECT * FROM category WHERE vert_id = ?", { Slice => {} }, $self->vert_id); + + return $cats; +} + sub load_by_id { my $class = shift; - my $v = $class->new( vertid => shift ); + my $v = $class->new( vert_id => shift ); $v->preload_rows; return $v; @@ -405,13 +416,13 @@ my $dbh = LJ::get_db_writer() or die "unable to contact global db master to load vertical"; - my $sth = $dbh->prepare("SELECT * FROM vertical"); + my $sth = $dbh->prepare("SELECT * FROM vertical2"); $sth->execute; die $dbh->errstr if $dbh->err; my @verticals; while (my $row = $sth->fetchrow_hashref) { - my $v = $class->new( vertid => $row->{vertid} ); + my $v = $class->new( vert_id => $row->{vert_id} ); $v->absorb_row($row); $v->set_memcache; @@ -475,17 +486,52 @@ my $class = shift; my $url = shift; - $url =~ /^(?:$LJ::SITEROOT)?(\/.+)$/; - my $path = $1; - $path =~ s/\/?(?:\?.*)?$//; # remove trailing slash and any get args + return undef unless $url; - my $map = $class->uri_map; - if (my $vertname = $map->{$path}) { - return $class->load_by_name($vertname); - } elsif ($path =~ /^\/explore\/(.+)$/) { - return $class->load_by_name($1); + $url =~ s/^(?:$LJ::SITEROOT)?(\/.+)$//; ## + $url = $1; + $url =~ s#(?:\?.*)?$##; ## remove trailing slash and any get args + $url =~ m#^/browse(/[^/]*)#; ## + $url = $1; + + ## Something wrong with url + return undef unless $url; + + my $reqcache = $LJ::REQ_GLOBAL{verturl}->{$url}; + if ($reqcache) { + my $v = $class->new( vert_id => $reqcache->{vert_id} ); + $v->absorb_row($reqcache); + + return $v; } + # check memcache for data + my $memval = LJ::MemCache::get($class->memkey_verturl($url)); + if ($memval) { + my $v = $class->new( vert_id => $memval->{vert_id} ); + $v->absorb_row($memval); + $LJ::REQ_GLOBAL{verturl}->{$url} = $memval; + + return $v; + } + + my $dbh = LJ::get_db_writer() + or die "unable to contact global db master to load vertical"; + + # not in memcache; load from db + my $sth = $dbh->prepare("SELECT * FROM vertical2 WHERE url = ?"); + $sth->execute($url); + die $dbh->errstr if $dbh->err; + + if (my $row = $sth->fetchrow_hashref) { + my $v = $class->new( vert_id => $row->{vert_id} ); + $v->absorb_row($row); + $v->set_memcache; + $LJ::REQ_GLOBAL{verturl}->{$url} = $row; + + return $v; + } + return undef; } @@ -533,7 +579,7 @@ my $id = shift; return [ $id, "vert:$id" ] if $id; - return [ $self->{vertid}, "vert:$self->{vertid}" ]; + return [ $self->{vert_id}, "vert:$self->{vert_id}" ]; } sub memkey_vertname { @@ -544,6 +590,14 @@ return "vertname:$self->{name}"; } +sub memkey_verturl { + my $self = shift; + my $url = shift; + + return "vertname:$url" if $url; + return "vertname:$self->{url}"; +} + sub memkey_rules { my $self = shift; my $id = shift; @@ -648,18 +702,18 @@ return 1 if $self->{_loaded_row}; my @to_load = $self->unloaded_singletons; - my %need = map { $_->{vertid} => $_ } @to_load; + my %need = map { $_->{vert_id} => $_ } @to_load; my @mem_keys = map { $_->memkey_vertid } @to_load; my $memc = LJ::MemCache::get_multi(@mem_keys); # now which of the objects to load did we get a memcache key for? foreach my $obj (@to_load) { - my $row = $memc->{"vert:$obj->{vertid}"}; + my $row = $memc->{"vert:$obj->{vert_id}"}; next unless $row; $obj->absorb_row($row); - delete $need{$obj->{vertid}}; + delete $need{$obj->{vert_id}}; } # now hit the db for what was left @@ -668,13 +722,13 @@ my @vals = keys %need; my $bind = LJ::bindstr(@vals); - my $sth = $dbh->prepare("SELECT * FROM vertical WHERE vertid IN ($bind)"); + my $sth = $dbh->prepare("SELECT * FROM vertical WHERE vert_id IN ($bind)"); $sth->execute(@vals); while (my $row = $sth->fetchrow_hashref) { # what singleton does this DB row represent? - my $obj = $need{$row->{vertid}}; + my $obj = $need{$row->{vert_id}}; # and update singleton (request cache) $obj->absorb_row($row); @@ -683,7 +737,7 @@ $obj->set_memcache; # and delete from %need for error reporting - delete $need{$obj->{vertid}}; + delete $need{$obj->{vert_id}}; } @@ -915,17 +969,20 @@ my $dbh = LJ::get_db_writer() or die "unable to contact global db master to load vertical"; - foreach my $table (qw(vertical vertical_entries)) { - $dbh->do("DELETE FROM $table WHERE vertid=?", undef, $self->{vertid}); + my $res = $dbh->do("SELECT vert_id FROM category WHERE vert_id = ?", undef, $self->{vert_id}); + return $res if $res; + + foreach my $table (qw(vertical2)) {# vertical_entries)) { + $dbh->do("DELETE FROM $table WHERE vert_id=?", undef, $self->{vert_id}); die $dbh->errstr if $dbh->err; } $self->clear_memcache; $self->clear_entries_memcache; - delete $singletons{$self->{vertid}}; + delete $singletons{$self->{vert_id}}; - return; + return undef; } # @@ -1200,11 +1257,7 @@ sub url { my $self = shift; - if ($LJ::VERTICAL_TREE{$self->name}->{url_path}) { - return "$LJ::SITEROOT" . $LJ::VERTICAL_TREE{$self->name}->{url_path} . "/"; - } else { - return "$LJ::SITEROOT/explore/" . $self->name . "/"; - } + return "$LJ::SITEROOT/browse" . $self->uri . "/"; } # checks to see if the given URL is the canonical URL so that we can redirect if it's not @@ -1322,8 +1375,8 @@ my $dbh = LJ::get_db_writer() or die "unable to contact global db master to load vertical"; - $dbh->do("UPDATE vertical SET $key=? WHERE vertid=?", - undef, $self->{vertid}, $val); + $dbh->do("UPDATE vertical2 SET $key=? WHERE vert_id=?", + undef, $val, $self->{vert_id}); die $dbh->errstr if $dbh->err; $self->clear_memcache; @@ -1337,12 +1390,16 @@ return $self->{$key}; } -sub vertid { shift->_get_set('vertid') } -sub name { shift->_get_set('name') } -sub set_name { shift->_get_set('name' => $_[0]) } -sub createtime { shift->_get_set('createtime') } -sub set_createtime { shift->_get_set('createtime' => $_[0]) } -sub lastfetch { shift->_get_set('lastfetch') } -sub set_lastfetch { shift->_get_set('lastfetch' => $_[0]) } +sub vert_id { shift->_get_set('vert_id') } +sub name { shift->_get_set('name') } +sub set_name { shift->_get_set('name' => $_[0]) } +sub uri { shift->_get_set('url') } +sub set_uri { shift->_get_set('url' => $_[0]) } +sub journal { shift->_get_set('journal') } +sub set_journal { shift->_get_set('journal' => $_[0]) } +sub createtime { shift->_get_set('createtime') } +sub set_createtime { shift->_get_set('createtime' => $_[0]) } +sub lastfetch { shift->_get_set('lastfetch') } +sub set_lastfetch { shift->_get_set('lastfetch' => $_[0]) } 1; Modified: trunk/cgi-bin/LJ/Widget/Browse.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/Browse.pm 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/cgi-bin/LJ/Widget/Browse.pm 2010-10-26 05:23:19 UTC (rev 17601) @@ -9,23 +9,27 @@ #sub need_res { qw( stc/widgets/browse.css stc/pagemodules.css ) } sub _build_tree { - my ($parent, $level, $test_uri, @categories) = @_; + my ($parent, $level, $test_uri, $vertical, @categories) = @_; my @tree = (); + foreach my $c (grep { (!$parent && !$_->parent) || ($_->parent == $parent) } grep { $_ } @categories) { + #(grep { $_->parent == $parent } @categories) { my $c_uri = $c->uri; + my $is_current = ($test_uri =~ m/^\Q$c_uri\E/); + ++$level; push @tree, { name => $c->display_name(), title => $c->title_html(), - url => $c->url(), + url => $c->url($vertical), summary => LJ::Widget::CategorySummary->render( category => $c ), level => $level, is_expanded => $is_current, is_current => $is_current, - "level$level" => [ _build_tree($c, $level, $test_uri, @categories) ], + "level$level" => [ _build_tree($c, $level, $test_uri, $vertical, @categories) ], }; --$level; } @@ -82,7 +86,7 @@ return $class->render_body_old(%opts) unless exists $opts{browse}; - my ($title, $windowtitle, $remote, $uri, $page) = @opts{qw(title windowtitle remote uri page)}; + my ($title, $windowtitle, $remote, $uri, $page, $post_page) = @opts{qw(title windowtitle remote uri page post_page)}; my $template = LJ::HTML::Template->new( { use_expr => 1 }, # force HTML::Template::Pro with Expr support @@ -91,17 +95,19 @@ strict => 0, ) or die "Can't open template: $!"; - $$windowtitle = $class->ml('widget.browse.windowtitle'); + my $vertical = LJ::Vertical->load_by_url($uri); + + $$windowtitle = $vertical->name; #$class->ml('widget.browse.windowtitle'); my $cat = LJ::Browse->load_by_url($uri); # Currently selected category - my @categories = sort { lc $a->display_name cmp lc $b->display_name } LJ::Browse->load_all(); + my @categories = sort { lc $a->display_name cmp lc $b->display_name } LJ::Browse->load_all($vertical); my $test_uri = $uri; $test_uri =~ s/^\/browse//; $test_uri =~ s/\/$//; - my @tmpl_categories = _build_tree(undef, 0, $test_uri, @categories); + my @tmpl_categories = _build_tree(undef, 0, $test_uri, $vertical, @categories); # Spotlight categories: # if it found, move it to the top, add 'suggest' link to this list and @@ -138,17 +144,22 @@ my ($ad, $nav_line) = 2 x ''; my @tmpl_communities = (); + my @tmpl_posts = (); - my $page_size = 10; # const + my $page_size = 6; + my $post_page_size = 10; my $count = 0; + my $post_count = 0; my @comms = (); $page ||= 1; my $skip = ($page-1) * $page_size; my $last = $skip + $page_size; - + $post_page ||= 1; + my $post_skip = ($post_page-1) * $post_page_size; + my $post_last = $post_skip + $post_page_size; if ($cat) { # we're looking at a lower-level category my @cat_title = split(/>/, $cat->title_html()); @@ -175,6 +186,35 @@ $$title = "$$windowtitle"; + my @posts = LJ::Browse->recent_posts ( [ map { $_->{userid} } @comms ], '10, 10' ); + + foreach my $entry (@posts) { + next unless $entry; + + next unless 1;## This entry is inappropriate language in the subject or body + + $post_count++; + next if $post_count <= $post_skip || $post_count > $post_last; + + my $poster = $entry->poster; + my $userpic = $entry->userpic; + my @tags = $entry->tags; + push @tmpl_posts, { + subject => $entry->subject_text, + userpic => $userpic ? $userpic->url : '', + posted_ago => LJ::TimeUtil->ago_text($entry->logtime_unix), + poster => $poster ? LJ::ljuser($poster) : '?', + tags => scalar @tags ? [ map { { tag => $_ } } @tags ] : '', + mood => $entry->prop('current_mood') || LJ::mood_name($entry->prop('current_moodid')) || '', + music => $entry->prop('current_music'), + location => $entry->prop('current_location'), + post_text => $entry->event_html, + url_to_post => $entry->url, + comments_count => $entry->reply_count, + is_need_more => bytes::length($entry->event_text) > 800 ? 1 : 0, + }; + } + foreach my $comm (@comms) { next unless LJ::isu($comm); @@ -200,6 +240,21 @@ }; } + # post paging: first, previouse, next, last pages. + my ($post_page_first, $post_page_prev, $post_page_next, $post_page_last) = 4 x 0; + my $post_pages = int($post_count / $post_page_size) + 1; + $post_page = 1 unless $post_page; + if($post_page > 1) { + $post_page_first = 1; + $post_page_prev = $post_page - 1; + } + + if ($post_page < $post_pages) { + $post_page_next = $post_page + 1; + $post_page_last = $post_pages; + $post_page_next = $post_page_last if $post_page_next > $post_page_last; + } + # paging: first, previouse, next, last pages. my ($page_first, $page_prev, $page_next, $page_last) = 4 x 0; my $pages = int($count / $page_size) + 1; @@ -217,7 +272,7 @@ my $args = ''; ($uri, $args) = split(/\?/, $uri); - $args =~ s/&?page=[^&]*//; # cut off page= parameter + $args =~ s/&?(post_)?page=[^&]*//g; # cut off page= parameter $args =~ s/^&//; # make page_* urls @@ -225,11 +280,17 @@ $_ ? $LJ::SITEROOT . $uri . ($args ? "?$args&page=$_" : "?page=$_") : '' } ($page_first, $page_prev, $page_next, $page_last); + # make post_page_* urls + ($post_page_first, $post_page_prev, $post_page_next, $post_page_last) = map { + $_ ? $LJ::SITEROOT . $uri . ($args ? "?$args&post_page=$_" : "?post_page=$_") : '' + } ($post_page_first, $post_page_prev, $post_page_next, $post_page_last); + # merge args to uri. $uri .= '?' . $args if $args; $template->param( communities => \@tmpl_communities, + posts => \@tmpl_posts, uri => $uri, page => $page, pages => $pages, @@ -237,6 +298,12 @@ page_prev => $page_prev, page_next => $page_next, page_last => $page_last, + post_page => $post_page, + post_pages => $post_pages, + post_page_first => $post_page_first, + post_page_prev => $post_page_prev, + post_page_next => $post_page_next, + post_page_last => $post_page_last, title => $$title, categories => \@tmpl_categories, ad => $ad, Modified: trunk/cgi-bin/ljlib.pl =================================================================== --- trunk/cgi-bin/ljlib.pl 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/cgi-bin/ljlib.pl 2010-10-26 05:23:19 UTC (rev 17601) @@ -977,6 +977,7 @@ # -- friendsview: if true, sorts by logtime, not eventtime # -- notafter: upper bound inclusive for rlogtime/revttime (depending on sort mode), # defaults to no limit +# -- afterid: upper bound inclusive for jitemid. defaults to not use # -- skip: items to skip # -- itemshow: items to show # -- viewall: if set, no security is used. @@ -1174,6 +1175,11 @@ $sql_select = "AND $sort_key <= $notafter"; } + my $after_sql = ''; + my $afterid = $opts->{'afterid'} + 0; + if ($afterid) { + $after_sql = "AND jitemid >= $afterid"; + } my $posterwhere; if ($opts->{'posterid'} && $opts->{'posterid'} =~ /^(\d+)$/) { Modified: trunk/htdocs/admin/browse/add_category.bml =================================================================== --- trunk/htdocs/admin/browse/add_category.bml 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/htdocs/admin/browse/add_category.bml 2010-10-26 05:23:19 UTC (rev 17601) @@ -76,9 +76,10 @@ # Get the full list of categories my @categories = LJ::Browse->load_all; # Get the unique URI for each - my @caturls = map { $_->uri, $_->uri } @categories; - @caturls = sort { $a cmp $b } @caturls; + my @caturls = map { { text => $_->{pretty_name}, value => $_->uri } } @categories; + #@caturls = sort { $a cmp $b } @caturls; + $ret .= "<p>Add to Category:<br />"; $ret .= LJ::html_select({ name => 'parentcaturl', Added: trunk/htdocs/admin/browse/edit_verticals.bml =================================================================== --- trunk/htdocs/admin/browse/edit_verticals.bml (rev 0) +++ trunk/htdocs/admin/browse/edit_verticals.bml 2010-10-26 05:23:19 UTC (rev 17601) @@ -0,0 +1,64 @@ +<?page +body<= +<?_code +{ + use strict; + use vars qw(%GET %POST $title $headextra @errors @warnings); + use Class::Autouse qw( LJ::Browse ); + + my $remote = LJ::get_remote(); + + return "<?needlogin?>" + unless $remote; + + return "You are not allowed to view this page" + unless LJ::check_priv($remote, 'siteadmin', 'community_directory') || $LJ::IS_DEV_SERVER; + + $title = "Edit verticals"; + my $ret = ""; + + if (LJ::did_post()) { + my @keys = keys %POST; + foreach (@keys) { + next unless $_ =~ /^(\d+)-name$/; + my $vert_id = $1; + my $vert = LJ::Vertical->load_by_id ($vert_id); + $vert->set_name($POST{"$vert_id-name"}); + $vert->set_uri($POST{"$vert_id-url"}); + $vert->set_journal($POST{"$vert_id-journal"}); + } + } + + my @verticals = LJ::Vertical->load_all(); + + $ret .= "<form method='POST'>\n"; + $ret .= LJ::form_auth(); + + $ret .= "<table border='1' cellspacing='0' cellpadding='2'>"; + $ret .= "<tr><th>Vertical name</th><th>Vertical Url</th><th>Vertical Journal</th></tr>"; + foreach my $vert (@verticals) { + my $vert_name = $vert->{name}; + my $vert_url = $vert->{url}; + my $vert_id = $vert->{vert_id}; + my $vert_journal = $vert->{journal}; + $ret .= "<tr> + <td><input type='text' name='$vert_id-name' value='$vert_name'></td> + <td><input type='text' name='$vert_id-url' value='$vert_url'></td> + <td><input type='text' name='$vert_id-journal' value='$vert_journal'></td> + </tr>"; + } + $ret .= "</table>"; + $ret .= "<br/><input type='submit' value='Save'>"; + + $ret .= "</form>"; + + + return "<body>$ret</body>"; +} +_code?> +<=body +title=><?_code return $title; _code?> +head<= +<?_code return $headextra; _code?> +<=head +page?> Modified: trunk/htdocs/admin/browse/index.bml =================================================================== --- trunk/htdocs/admin/browse/index.bml 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/htdocs/admin/browse/index.bml 2010-10-26 05:23:19 UTC (rev 17601) @@ -14,9 +14,17 @@ return "You are not allowed to view this page" unless LJ::check_priv($remote, 'siteadmin', 'community_directory') || $LJ::IS_DEV_SERVER; - $title = "Community Directory Admin"; + $title = "Verticals And Community Directory Admin"; my $ret = ""; + $ret .= "<h2>Manage Verticals</h2><blockquote>"; + $ret .= "<p><a href='./add_verticals.bml'>Add Verticals</a></p>"; + $ret .= "<p><a href='./edit_verticals.bml'>Edit Verticals</a></p>"; + $ret .= "<p><a href='./remove_verticals.bml'>Remove Verticals</a></p>"; + $ret .= "<p><a href='./upload_verticals.bml'>Upload Verticals</a></p>"; + $ret .= "<p><a href='./recent_posts.bml'>Manage Recent Posts</a></p>"; + $ret .= "</blockquote>"; + $ret .= "<h2>Manage Communities</h2><blockquote>"; $ret .= "<p><a href='./moderate_community.bml'>Moderate Community Submissions</a></p>"; @@ -26,6 +34,7 @@ $ret .= "<h2>Manage Categories</h2><blockquote>"; $ret .= "<p><a href='./add_category.bml'>Add Category</a></p>"; + $ret .= "<p><a href='./manage_category.bml'>Manage Categories</a></p>"; $ret .= "<p><a href='./remove_category.bml'>Remove Category</a></p>"; $ret .= "</blockquote>"; Modified: trunk/htdocs/browse/index.bml =================================================================== --- trunk/htdocs/browse/index.bml 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/htdocs/browse/index.bml 2010-10-26 05:23:19 UTC (rev 17601) @@ -19,7 +19,16 @@ $uri .= "?$args" if $args; my $page = defined $GET{page} ? $GET{page} : 1; + my $post_page = defined $GET{post_page} ? $GET{post_page} : 1; + my $vertical = LJ::Vertical->load_by_url($uri); + unless ($vertical) { + LJ::Request->pnotes ('error' => 'e404'); + LJ::Request->pnotes ('remote' => LJ::get_remote()); + BML::return_error_status(LJ::Request::NOT_FOUND()); + return; + } + return LJ::Widget::Browse->render( browse => 'new', title => \$title, @@ -27,6 +36,7 @@ remote => $remote, uri => $uri, page => $page, + post_page => $post_page, ); } _code?> Added: trunk/templates/Browse/browse.tmpl =================================================================== --- trunk/templates/Browse/browse.tmpl (rev 0) +++ trunk/templates/Browse/browse.tmpl 2010-10-26 05:23:19 UTC (rev 17601) @@ -0,0 +1,18 @@ +<div class="l-body"> + <div class="b-catalogue"> + <div class="l-aside"> + <TMPL_INCLUDE menu.tmpl> + </div> + <div class="l-content"> + <TMPL_INCLUDE communities.tmpl> + </div> + <div class="l-content"> + <TMPL_INCLUDE recent_posts.tmpl> + </div> + <div class="l-sidebar"> + <TMPL_INCLUDE sidebar.tmpl> + </div> + </div> +</div> + + Modified: trunk/templates/Browse/index.tmpl =================================================================== --- trunk/templates/Browse/index.tmpl 2010-10-26 04:40:30 UTC (rev 17600) +++ trunk/templates/Browse/index.tmpl 2010-10-26 05:23:19 UTC (rev 17601) @@ -1,15 +1,10 @@ <div class="l-body"> - <div id="ljbreadcrumbs"><TMPL_VAR nav_line></div> + <div>Vertical name</div> + <div>AD Block</div> <div class="b-catalogue"> <div class="l-aside"> - <TMPL_INCLUDE menu.tmpl> + <TMPL_INCLUDE browse.tmpl> </div> - <div class="l-content"> - <TMPL_INCLUDE communities.tmpl> - </div> - <div class="l-sidebar"> - <TMPL_INCLUDE sidebar.tmpl> - </div> </div> </div> Added: trunk/templates/Browse/recent_posts.tmpl =================================================================== --- trunk/templates/Browse/recent_posts.tmpl (rev 0) +++ trunk/templates/Browse/recent_posts.tmpl 2010-10-26 05:23:19 UTC (rev 17601) @@ -0,0 +1,23 @@ +<tmpl_loop posts> + <img src="<tmpl_var userpic>"><br/> + <a href="<tmpl_var url_to_post>"><tmpl_var subject></a><br/> + <tmpl_loop tags><tmpl_unless __first__>, </tmpl_unless><tmpl_var tag></tmpl_loop><br/> + <tmpl_var mood><br/> + <tmpl_var music><br/> + <tmpl_var location><br/> + <tmpl_var post_text><br/> + <tmpl_if is_need_more>(<a href="<tmpl_var url_to_post>">Read more in original post</a>)<br/></tmpl_if> + <a href="<tmpl_var url_to_post>#comments"><tmpl_var comments_count> comments</a> | <a href="<tmpl_var url_to_post>?mode=reply">Leave comment</a><br/> + <hr/> +</tmpl_loop> + + <TMPL_IF expr="post_pages gt 1"> + <ul> + <li><TMPL_IF post_page_first><a href="<TMPL_VAR post_page_first>" title="<TMPL_VAR expr="ml('widget.browse.page.first')">"><i><TMPL_VAR expr="ml('widget.browse.page.first')"></i></a><TMPL_ELSE><span><i><TMPL_VAR expr="ml('widget.browse.page.first')"></i></span></TMPL_IF></li> + <li><TMPL_IF post_page_prev><a href="<TMPL_VAR post_page_prev>" title="<TMPL_VAR expr="ml('widget.browse.page.previous')">"><i><TMPL_VAR expr="ml('widget.browse.page.previous')"></i></a><TMPL_ELSE><span><i><TMPL_VAR expr="ml('widget.browse.page.previous')"></i></span></TMPL_IF></li> + <li><TMPL_VAR post_page>/<TMPL_VAR post_pages></li> + <li><TMPL_IF post_page_next><a href="<TMPL_VAR post_page_next>" title="<TMPL_VAR expr="ml('widget.browse.page.next')">"><i><TMPL_VAR expr="ml('widget.browse.page.next')"></i></a><TMPL_ELSE><span><i><TMPL_VAR expr="ml('widget.browse.page.next')"></i></span></TMPL_IF></li> + <li><TMPL_IF post_page_last><a href="<TMPL_VAR post_page_last>" title="<TMPL_VAR expr="ml('widget.browse.page.last')">"><i><TMPL_VAR expr="ml('widget.browse.page.last')"></i></a><TMPL_ELSE><span><i><TMPL_VAR expr="ml('widget.browse.page.last')"></i></span></TMPL_IF></li> + </ul> + </TMPL_IF> +