Changeset 414


Ignore:
Timestamp:
Jun 17, 2004, 2:45:18 AM (18 years ago)
Author:
kake
Message:

Added preference for default edit type.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r413 r414  
    1717        Internal rejigging - extracted some methods from wiki.cgi to
    1818          OpenGuides.pm.
     19        Added new preference for default edit type.
    1920
    20210.32    7 June 2004
  • trunk/lib/OpenGuides/CGI.pm

    r413 r414  
    22use strict;
    33use vars qw( $VERSION );
    4 $VERSION = '0.04';
     4$VERSION = '0.05';
    55
    66use Carp qw( croak );
     
    3434      omit_help_links        => 1,
    3535      show_minor_edits_in_rc => 1,
     36      default_edit_type      => "tidying",
    3637  );
    3738
     
    6263      omit_help_links        => 1,
    6364      show_minor_edits_in_rc => 1,
     65      default_edit_type      => "tidying",
    6466  );
    6567
     
    8587                    omithlplks => $args{omit_help_links} || 0,
    8688                    rcmined    => $args{show_minor_edits_in_rc} || 0,
     89                    defedit    => $args{default_edit_type} || "normal",
    8790                  },
    8891        -expires => "+1M",
     
    119122             omit_help_links        => $data{omithlplks}|| 0,
    120123             show_minor_edits_in_rc => $data{rcmined}   || 0,
     124             default_edit_type      => $data{defedit}   || "normal",
    121125           );
    122126}
     
    137141=head1 COPYRIGHT
    138142
    139      Copyright (C) 2003 The OpenGuides Project.  All Rights Reserved.
     143     Copyright (C) 2003-4 The OpenGuides Project.  All Rights Reserved.
    140144
    141145This module is free software; you can redistribute it and/or modify it
  • trunk/preferences.cgi

    r413 r414  
    3030    my $omit_hlplnks = $cgi->param("omit_help_links")        || 0;
    3131    my $rc_minor_eds = $cgi->param("show_minor_edits_in_rc") || 0;
     32    my $edit_type    = $cgi->param("default_edit_type") || "normal";
    3233    my $cookie = OpenGuides::CGI->make_prefs_cookie(
    3334        config => $config,
     
    3839        omit_help_links        => $omit_hlplnks,
    3940        show_minor_edits_in_rc => $rc_minor_eds,
     41        default_edit_type      => $edit_type,
    4042    );
    4143    print OpenGuides::Template->output(
     
    5254                      omit_help_links        => $omit_hlplnks,
    5355                      show_minor_edits_in_rc => $rc_minor_eds,
     56                      default_edit_type      => $edit_type,
    5457                    }
    5558    );
  • trunk/t/13_cookies.t

    r413 r414  
    22use Config::Tiny;
    33use OpenGuides::CGI;
    4 use Test::More tests => 15;
     4use Test::More tests => 16;
    55
    66eval { OpenGuides::CGI->make_prefs_cookie; };
     
    2626    omit_help_links        => 1,
    2727    show_minor_edits_in_rc => 1,
     28    default_edit_type      => "tidying",
    2829);
    2930isa_ok( $cookie, "CGI::Cookie", "->make_prefs_cookie returns a cookie" );
     
    4849is( $prefs{omit_help_links}, 1, "...and help link prefs" );
    4950is( $prefs{show_minor_edits_in_rc}, 1, "...and minor edits prefs" );
     51is( $prefs{default_edit_type}, "tidying", "...and default edit prefs" );
    5052
    5153# Check that cookie parsing fails nicely if no cookie set.
     
    5355%prefs = eval { OpenGuides::CGI->get_prefs_from_cookie( config => $config ); };
    5456is( $@, "", "->get_prefs_from_cookie doesn't die if no cookie set" );
    55 is( keys %prefs, 6, "...and returns six default values" );
     57is( keys %prefs, 7, "...and returns seven default values" );
    5658
  • trunk/templates/preferences.tt

    r413 r414  
    6868    </p>
    6969
     70    <p>
     71      <label for="default_edit_type">Default edit type:</label>
     72      <select name="default_edit_type">
     73        [% IF default_edit_type == 'normal' %]
     74          <option value="normal" selected="1">Normal edit</option>
     75          <option value="tidying">Minor tidying</option>
     76        [% ELSE %]
     77          <option value="normal">Normal edit</option>
     78          <option value="tidying" selected="1">Minor tidying</option>
     79        [% END %]
     80      </select>
     81    </p>
     82
    7083    <input type="submit" value="Set it" class="form_button" />
    7184    <input type="hidden" name="action" value="set_preferences">
     
    107120  included in Recent Changes.</p>
    108121
     122  <p>Default edit type set to
     123    [% IF default_edit_type == 'normal' %]
     124      &#8220;Normal edit&#8221;.
     125    [% ELSE %]
     126      &#8220;Minor tidying&#8221;.
     127    [% END %]
     128  </p>
     129
    109130<ul>
    110131  <li><a href="[% full_cgi_url %]">Return to [% site_name %]</a></li>
  • trunk/wiki.cgi

    r413 r414  
    213213    my ($content, $checksum) = @node_data{ qw( content checksum ) };
    214214    my $username = get_cookie( "username" );
     215    my $edit_type = get_cookie( "default_edit_type" ) eq "normal" ?
     216                        "Normal edit" : "Minor tidying";
    215217
    216218    my %metadata_vars = OpenGuides::Template->extract_metadata_vars(
     
    222224                    checksum   => $q->escapeHTML($checksum),
    223225                    %metadata_vars,
    224                     username   => $username
     226                    username   => $username,
     227                    edit_type  => $edit_type,
    225228    );
    226229
Note: See TracChangeset for help on using the changeset viewer.