The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

E2::Writeup - A module for accessing, updating, and cooling writeups.

SYNOPSIS

        use E2::Writeup;
        use E2::E2Node;  # Used to load the writeup.

        my $e2node = new E2::E2node;

        $e2node->load( "test" ) or die "Unable to load test.";

        my $writeup = $e2node->get_writeup; # Returns an E2::Writeup
        
        # Print writeup info (See E2::Node for these)

        print "Title: . $writeup->title;
        print "\nAuthor: " . $writeup->author;
        print "\nDoctext: " . $writeup->text;

        # Cool the writeup

        $writeup->cool;

        # Update the writeup

        $writeup->update( $writeup->text . "THIS TEXT APPENDED TO WRITEUP" );

DESCRIPTION

This module is used to load, access, and manipulate writeups on E2. It is probably best used in conjunction with E2::E2Node. It inherits E2::Node.

The relationship between writeups and e2nodes is such that e2nodes contain writeups (0 or more writeups, specifically). E2::Writeup defines the operations that can be performed on writeups contained within e2nodes. Technically, we could load a writeup without loading its enclosing e2node (just pass load_by_id the id of a writeup), but doing so would discard much of the information passed to us (softlinks, firmlinks, etc.). If you want access to this sort of information, use E2::E2Node to load the node, then access the writeup using on of its get_writeup methods.

CONSTRUCTOR

new

new creates a new E2::E2Node object. Until that object is logged in in one way or another (see E2::Interface), it will use the "Guest User" account, and will be limited in which operations it can perform.

METHODS

$writeup->clear

clear clears all the information currently stored in $writeup. It returns true.

$writeup->wrtype;
$writeup->parent;
$writeup->parent_id;
$writeup->marked;
$writeup-><gt>cool_count;
$writeup->text;

These methods return, respectively, the writeup's type, its parent's title, its parent's node_id, its "marked for destruction" status (boolean: is it marked for destruction?), the number of C!s it has received, and the text of the writeup.

$writeup->cools;

This method returns a list of the users who've cooled this writeup. Each item in the list is a hashref with the following keys:

        name
        id
$writeup->rep;

This method returns a hashref concerning the reputation of this writeup with the following keys:

        up      # Upvotes
        down    # Downvotes
        total   # Total rep (should be == to upvotes - downvotes)
        cast    # Have you already cast your vote? (boolean)
$writeup->cool [ NODE_ID ]

This method attempts to cool (C!) a writeup. If NODE_ID is specified, it attempts to cool the writeup with that id, otherwise it attempts to cool the currently-loaded writeup.

Exceptions: 'Unable to process request'

$node->update TEXT [ , TYPE ]

update updates the currently-loaded writeup. TYPE, which defaults to the type the writeup was prior to the update, is the type of writeup this is (one of: "person", "place", "thing", or "idea"). During the update, the writeup is re-loaded, so any changes should be immediately visible in this object.

This method returns true on success and undef on failure.

Exceptions: 'Unable to process request', 'Invalid document', 'Parse error:'

SEE ALSO

E2::Interface, E2::Node, E2::E2Node, http://everything2.com, http://everything2.com/?node=clientdev

AUTHOR

Jose M. Weeks <jose@joseweeks.com> (Simpleton on E2)

COPYRIGHT

This software is public domain.