fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-08-23 09:33 am

[dw-free] create community landing page

[commit: http://hg.dwscoalition.org/dw-free/rev/9dc8b94f2d30]

http://bugs.dwscoalition.org/show_bug.cgi?id=1286

Updated landing page when going to http://www.dreamwidth.org/community:
added ten most recently active and recently created communities, help links,
links to managing your own communities. Much thanks to [personal profile] skud
who did initial work, and [personal profile] cesy who came up with the list of
items that should go on the page!

Patch by [staff profile] denise.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/DW/Widget/NewlyCreatedComms.pm
  • cgi-bin/DW/Widget/RecentlyActiveComms.pm
  • htdocs/community/index.bml
  • htdocs/community/index.bml.text
  • htdocs/stc/widgets/commlanding.css
--------------------------------------------------------------------------------
diff -r 2429856a65ef -r 9dc8b94f2d30 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Tue Aug 23 12:11:45 2011 +0800
+++ b/bin/upgrading/en.dat	Tue Aug 23 17:32:58 2011 +0800
@@ -4172,6 +4172,12 @@
 
 widget.betafeature.journaljquery.title=New JS on Journals
 
+widget.comms.notavailable=This list is currently unavailable.
+
+widget.comms.recentactive=Recently Active Communities
+
+widget.comms.recentcreate=Recently Created Communities
+
 widget.communitymanagement.nopending=No communities require action.
 
 widget.communitymanagement.pending=Pending:
diff -r 2429856a65ef -r 9dc8b94f2d30 cgi-bin/DW/Widget/NewlyCreatedComms.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Widget/NewlyCreatedComms.pm	Tue Aug 23 17:32:58 2011 +0800
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+#
+# DW::Widget::NewlyCreatedComms
+#
+# Returns the 10 most recently created communities
+#
+# Authors:
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# Copyright (c) 2011 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself.  For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::Widget::NewlyCreatedComms;
+
+use strict;
+use base qw/ LJ::Widget /;
+
+# hang this widget on the same hook as the (old) stats page uses for
+# determining whether or not to show the newly created journals
+# section, since the queries are mostly taken from those queries
+# anyway. disable this feature in config.pl if you start having
+# load issues, or if you just don't want this widget to render.
+sub should_render { LJ::is_enabled( 'stats-newjournals' ) }
+
+sub need_res { qw( stc/widgets/commlanding.css ) }
+
+sub render_body {
+    my ( $class, %opts ) = @_;
+
+    # prep the db reader
+
+    my $dbr = LJ::get_db_reader();
+    my $sth;
+    my $ret;
+
+    # prep the stats we're interested in using here
+
+    $sth = $dbr->prepare( "SELECT u.user, u.name, uu.timeupdate FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate IS NOT NULL AND u.journaltype = 'C' ORDER BY uu.timecreate DESC LIMIT 10" );
+    $sth->execute;
+
+    $ret .= "<h2>" . $class->ml( 'widget.comms.recentcreate' ) . "</h2>";
+    $ret .= "<ul>";
+
+    # build the list
+
+    my $ct;
+    my $targetu;
+
+    while ( my ( $iuser, $iname, $itime ) = $sth->fetchrow_array ) {
+        $targetu = LJ::load_user( $iuser );
+        $ret .= "<li>" . $targetu->ljuser_display . ": " . $iname . ", " . $itime . "</li>\n";
+        $ct++;
+    }
+
+    $ret .= "<li><em> " . BML::ml( 'widget.comms.notavailable' ) . "</em></li>" unless $ct;
+    $ret .= "</ul>\n";
+
+    return $ret;
+}
+
+1;
+
diff -r 2429856a65ef -r 9dc8b94f2d30 cgi-bin/DW/Widget/RecentlyActiveComms.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Widget/RecentlyActiveComms.pm	Tue Aug 23 17:32:58 2011 +0800
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+#
+# DW::Widget::RecentlyActiveComms
+#
+# Returns the 10 most recently updated communities
+#
+# Authors:
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# Copyright (c) 2011 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself.  For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::Widget::RecentlyActiveComms;
+
+use strict;
+use base qw/ LJ::Widget /;
+
+# hang this widget on the same hook as the (old) stats page uses for
+# determining whether or not to show the newly updated journals
+# section, since the queries are mostly taken from those queries
+# anyway. disable this feature in config.pl if you start having
+# load issues, or if you just don't want this widget to render.
+sub should_render { LJ::is_enabled( 'stats-recentupdates' ) }
+
+sub need_res { qw( stc/widgets/commlanding.css ) }
+
+sub render_body {
+    my ( $class, %opts ) = @_;
+
+    # prep the db reader
+
+    my $dbr = LJ::get_db_reader();
+    my $sth;
+    my $ret;
+
+    # prep the stats we're interested in using here
+
+    $sth = $dbr->prepare( "SELECT u.user, u.name, uu.timeupdate FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate > DATE_SUB(NOW(), INTERVAL 30 DAY) AND u.journaltype = 'C' ORDER BY uu.timeupdate DESC LIMIT 10" );
+    $sth->execute;
+
+    $ret .= "<h2>" . $class->ml( 'widget.comms.recentactive' ) . "</h2>";
+    $ret .= "<ul>";
+
+    # build the list
+
+    my $ct;
+    my $targetu;
+
+    while ( my ( $iuser, $iname, $itime ) = $sth->fetchrow_array ) {
+        $targetu = LJ::load_user( $iuser );
+        $ret .= "<li>" . $targetu->ljuser_display . ": " . $iname . ", " . $itime . "</li>\n";
+        $ct++;
+    }
+
+    $ret .= "<li><em> " . BML::ml( 'widget.comms.notavailable' ) . "</em></li>" unless $ct;
+    $ret .= "</ul>\n";
+
+    return $ret;
+}
+
+1;
+
diff -r 2429856a65ef -r 9dc8b94f2d30 htdocs/community/index.bml
--- a/htdocs/community/index.bml	Tue Aug 23 12:11:45 2011 +0800
+++ b/htdocs/community/index.bml	Tue Aug 23 17:32:58 2011 +0800
@@ -1,23 +1,92 @@
 <?_c
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
 #
-# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
+# community/index.bml
 #
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-_c?>
-<?page
-title=><?_ml .title _ml?>
+# Provides a "landing page" for communities and community-related 
+# stuff, including links for both comm members and admins.
+#
+# Authors:
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# Copyright (c) 2011 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+_c?><?page
 body<=
 <?_code
-    LJ::set_active_crumb('community');
-    return BML::ml('.main2', {'aopts' => "href='$LJ::SITEROOT/community/create'", 'sitename' => $LJ::SITENAMESHORT});
+{
+    use strict;
+    use vars qw/ $title $windowtitle $headextra /;
+
+    $title = $ML{'.title'};
+    $windowtitle = $ML{'.header'};
+
+    my $remote = LJ::get_remote();
+
+    my $ret;
+
+    $ret .= "<p>" . BML::ml( '.intro', { sitename => $LJ::SITENAMESHORT } ) . "</p>";
+
+    # 'learn more about comms' block -- implemented as a hook because
+    # most/all the links are to dreamwidth.org specific FAQs. see
+    # cgi-bin/DW/Hooks/Community.pm in dw-nonfree as an example to create
+    # your own.
+    my $learnmore = LJ::Hooks::run_hook( 'community_faqs' );
+    if ( $learnmore ) {
+        $ret .= "<h2>$ML{'.learnmore'}</h2><ul>";
+        $ret .= $learnmore;
+        $ret .= "</ul><br />";
+    }
+
+    # 'how to find communities' block. hook is to list dw-community-promo;
+    # define your own in a hook if you have a similar community or want to
+    # add other links to the list.
+
+    $ret .= "<h2>" . BML::ml( '.findcomms' ) . "</h2>";
+    $ret .= "<ul><li><a href='$LJ::SITEROOT/community/search'>" . BML::ml( '.findcomms.commsearch' ) . "</li>";
+    $ret .= "<li><a href='$LJ::SITEROOT/community/random'>" . BML::ml( '.findcomms.random' ) . "</li>";
+    $ret .= "<li><a href='LJ::SITEROOT/search'>" . BML::ml( '.findcomms.sitesearch' ) . "</a>: " . BML::ml( '.findcomms.sitesearch.detail' ) . "</li>";
+    $ret .= LJ::Hooks::run_hook( 'community_search_links' );
+
+    $ret .= "</ul><br /><hr width='50%' />";
+
+    # div box of recently-updated communities
+
+    $ret .= DW::Widget::RecentlyActiveComms->render;  
+
+    # div box of recently-created communities
+
+    $ret .= DW::Widget::NewlyCreatedComms->render;    
+
+    # hook to create the div box of official DW communities
+
+    $ret .= LJ::Hooks::run_hook( 'official_comms' );
+
+    # information on creating/managing a community. most of the FAQs
+    # linked here are going to be site-specific, so -- you guessed it,
+    # another hook. see the same package as earlier -- create and define
+    # your own if you want to link to your own site's community management
+    # FAQs. in an if block because none of this is applicable to 
+    # logged-out users. 
+
+    if ( $remote ) {
+        $ret .= "<br /><h2>" . BML::ml( '.manage' ) . "</h2><ul>";
+        $ret .= "<li><a href='$LJ::SITEROOT/community/create'>" . BML::ml( '.manage.create' ) . "</li>";
+        $ret .= "<li><a href='$LJ::SITEROOT/community/manage'>" . BML::ml( '.manage.yours' ) . "</li>" if LJ::load_rel_target( $remote, 'A' );
+        $ret .= LJ::Hooks::run_hook( 'community_manage_links' );
+    }
+
+    $ret .= "</ul><br />";
+    return $ret;
+}
 _code?>
 <=body
+title=><?_code return $title; _code?>
+windowtitle=><?_code return $windowtitle; _code?>
+head<=
+<?_code return $headextra; _code?>
+<=head
 page?>
diff -r 2429856a65ef -r 9dc8b94f2d30 htdocs/community/index.bml.text
--- a/htdocs/community/index.bml.text	Tue Aug 23 12:11:45 2011 +0800
+++ b/htdocs/community/index.bml.text	Tue Aug 23 17:32:58 2011 +0800
@@ -1,13 +1,24 @@
 ;; -*- coding: utf-8 -*-
-.main2<<
-<?h1 Welcome! h1?>
-<?p Welcome to the Community Center.  This is where you can find out where and how to interact with your fellow members of the [[sitename]] community!  [[sitename]] isn't only a great place for keeping a journal &mdash; it's a place where people meet, interact, share common interests, and have a good time. p?>
+.findcomms=Find Communities
 
-<?h1 What is a Community? h1?>
-<?p A community is a journal run by a member of the site where people share a common interest.  Communities are free to use and create. Anyone can have them and they're easy to set up. p?>
+.findcomms.commsearch=Community Search
 
-<p align='center' style='font-size: 1.7em'><a [[aopts]]>Create a Community Now!</a></p>
-.
+.findcomms.random=Random Active Community
+
+.findcomms.sitesearch=Site Search
+
+.findcomms.sitesearch.detail=Search for content on the site as a whole.
+
+.header=Communities & Community Features
+
+.intro=A community is a journal that many people, not just you, can post to. There are [[sitename]] communities for all sorts of topics, from hobbies to shared beliefs to discussion groups and more. Communities are easy to create and participate in, and anyone can set one up.
+
+.learnmore=Learn More About Communities
+
+.manage=Managing Communities
+
+.manage.create=Create a new community
+
+.manage.yours=Manage your existing communities
 
 .title=Community Center
-
diff -r 2429856a65ef -r 9dc8b94f2d30 htdocs/stc/widgets/commlanding.css
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/stc/widgets/commlanding.css	Tue Aug 23 17:32:58 2011 +0800
@@ -0,0 +1,17 @@
+.appwidget-recentlyactivecomms, .appwidget-newlycreatedcomms {
+    float: left;
+    width: auto;
+}
+
+.appwidget-recentlyactivecomms
+{
+    margin-right: 3em;
+}
+
+h2 {
+    clear: both;
+}
+
+#content ul li {
+    margin-left: 2em;
+}
--------------------------------------------------------------------------------