Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

Improved admin_tools for Scoop

If you've ever built a site with Scoop, you know that all that messy hard-coded table-based HTML can be a pain. In the course of building several Scoop sites I've been reworking some of the common boxes to use cleaner, easily-styled, semantic markup, and this seems as good a place as any to post the code.

Here's a reworked admin_tools which outputs as an unordered list (and puts the "edit user" form in a definition list):

my $content;
my @tools = sort { $a->{pos} <=> $b->{pos} } values %{ $S->{ADMIN_TOOLS} };
foreach my $t (@tools) {
        if ( $S->have_perm($t->{perm}) ) {
                $content .= qq\|
        <LI><A href="|rootdir|/admin/$t->{tool}">$t->{menuname}A></LI>\|;
        }
}
if ($S->have_perm('edit_user')) {
 $content .= qq{<LI>
 <FORM NAME="uedit" METHOD="GET" ACTION="|rootdir|/">
 <DL>
 <DT>Edit User:DT>
 
</DD> DL> </FORM> LI>}; } return '' unless $content; return{content=>qq{
    $content</UL>}};

Improved user_box for Scoop

If you've ever built a site with Scoop, you know that all that messy hard-coded table-based HTML can be a pain. In the course of building several Scoop sites I've been reworking some of the common boxes to use cleaner, easily-styled, semantic markup, and this seems as good a place as any to post the code.

Here's a reworked user_box which outputs the tools menu as an unordered list:

my $content;
if ($S->{UID} > 0) {
  if ($S->have_perm('moderate')) {
    my ($nstories, $tstories) = $S->_count_new_sub();
    my $color = '';
    my $c_end = '';
    if ($nstories) {
       $color = '';
       $c_end = '';
    }
    $content = qq\|<ul>
    <li><a href="|rootdir|/modsub">Vote on Submissionsa> ($tstories/$color$nstories$c_end new)li>\|;
  }

  if ($S->{TRUSTLEV} == 2 \|\| $S->have_perm('super_mojo')) {
    $content .= qq{
  • /search?type=comment;hidden_comments=show">Review Hidden Comments
  • }; } my $urlnick = $S->urlify($S->{NICK}); my $diary_link = $S->{UI}->{VARS}->{use_diaries} ? qq{
  • "|rootdir|/user/$urlnick/diary">Your Diary
  • "|rootdir|/submitstory/Diary">New Diary Entry
  • } : ''; my $upload_link = ($S->{UI}->{VARS}->{allow_uploads} && ($S->have_perm('upload_user') \|\| $S->have_perm('upload_admin'))) ? qq{
  • "|rootdir|/user/$urlnick/files">Your Files
  • } : ''; my $ad_link = $S->{UI}->{VARS}->{use_ads} ? qq{
  • "light" href="|rootdir|/user/$urlnick/ads">Your Advertisements
  • "|rootdir|/submitad">Submit Ad</a>li> } : ''; $content .= qq\|
  • /user/$urlnick">User Info
  • "|rootdir|/user/$urlnick/comments">Your Comments
  • "|rootdir|/user/$urlnick/stories">Your Stories
  • $diary_link $ad_link $upload_link
  • "|rootdir|/user/$urlnick/prefs">User Preferences
  • "|rootdir|/my/prefs/Interface">Display Preferences
  • "|rootdir|/my/prefs/Comments">Comment Preferences
  • "|rootdir|/logout">Logout $S->{NICK}</a>li></ul>\|; $title = $S->{NICK}; } else { $content = $S->{UI}->{BLOCKS}->{login_box}; $content =~ s/|LOGIN_ERROR|/$S->{LOGIN_ERROR}/; } return {content => $content, title => $title };
  • « Newer Snippets
    Older Snippets »
    2 total  XML / RSS feed