Rubric::WebApp::URI - URIs for Rubric web requests


Rubric documentation Contained in the Rubric distribution.

Index


Code Index:

NAME

Top

Rubric::WebApp::URI - URIs for Rubric web requests

VERSION

Top

version 0.147

DESCRIPTION

Top

This module provides methods for generating the URIs for Rubric requests.

METHODS

Top

root

the URI for the root of the Rubric; taken from uri_root in config

stylesheet

the URI for the stylesheet

logout

URI to log out

login

URI to form for log in

reset_password

URI to reset user password

newuser

URI to form for new user registration form; returns false if registration is closed.

entries(\%arg)

URI for entry listing; valid keys for %arg:

 user - entries for one user
 tags - arrayref of tag names

entry($entry)

URI to view entry

edit_entry($entry)

URI to edit entry

delete_entry($entry)

URI to delete entry

post_entry

URI for new entry form

by_date

URI for by_date

tag_cloud

URI for all tags / tag cloud

preferences

URI for preferences form

verify_user

URI for new entry form

doc($doc_page)

URI for documentation page.

TODO

Top

AUTHOR

Top

Ricardo SIGNES, <rjbs@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-rubric@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT

Top


Rubric documentation Contained in the Rubric distribution.
use strict;
use warnings;
package Rubric::WebApp::URI;
our $VERSION = '0.147';

use Rubric::Config;

sub root { Rubric::Config->uri_root }
	
sub stylesheet {
  my $href = Rubric::Config->css_href;
  return $href if $href;
  return Rubric::Config->uri_root . '/style/rubric.css';
}

sub logout { Rubric::Config->uri_root . '/logout' }

sub login { Rubric::Config->uri_root . '/login' }

sub reset_password {
	my ($class, $arg) = @_;
	my $uri = Rubric::Config->uri_root . '/reset_password';
	if ($arg->{user} and defined $arg->{reset_code}) {
		$uri .= "/$arg->{user}/$arg->{reset_code}";
	}
	return $uri;
}

sub newuser {
	return if Rubric::Config->registration_closed;
	return Rubric::Config->uri_root . '/newuser';
}

sub entries {
	my ($class, $arg) = @_;
	$arg->{tags} ||= {};
  $arg->{tags} = { map { $_ => undef } @{$arg->{tags}} }
    if ref $arg->{tags} eq 'ARRAY';

	my $format = delete $arg->{format};

	my $uri = $class->root . '/entries';
	$uri .= "/user/$arg->{user}" if $arg->{user};
	$uri .= '/tags/' . join('+', keys %{$arg->{tags}}) if %{$arg->{tags}};
	for (qw(has_body has_link)) {
		$uri .= "/$_/" . ($arg->{$_} ? 1 : 0)
			if (defined $arg->{$_} and $arg->{$_} ne '');
	}
	$uri .= "/urimd5/$arg->{urimd5}" if $arg->{urimd5};
	$uri .= "?format=$format" if $format;
	return $uri;
}

sub entry {
	my ($class, $entry) = @_;
	return unless UNIVERSAL::isa($entry,  'Rubric::Entry');

	return Rubric::Config->uri_root . "/entry/" . $entry->id;
}


sub edit_entry {
	my ($class, $entry) = @_;
	return unless UNIVERSAL::isa($entry,  'Rubric::Entry');

	return Rubric::Config->uri_root . "/edit/" . $entry->id;
}

sub delete_entry {
	my ($class, $entry) = @_;
	return unless UNIVERSAL::isa($entry,  'Rubric::Entry');

	return Rubric::Config->uri_root . "/delete/" . $entry->id;
}

sub post_entry { Rubric::Config->uri_root . "/post"; }

sub by_date {
	my ($class) = @_;
  shift;
  my $year = shift;
  my $month = shift;
  my $uri = '/calendar';
  $uri .= "/$year" if ($year);
  $uri .= "/$month" if ($month);

	Rubric::Config->uri_root . $uri;
}



sub tag_cloud { 
	my ($class) = @_;
	Rubric::Config->uri_root . "/tag_cloud";
}


sub preferences { Rubric::Config->uri_root . "/preferences"; }

sub verify_user {
	my ($class, $user) = @_;
	Rubric::Config->uri_root . "/verify/$user/" . $user->verification_code;
}

sub doc {
	my ($class, $doc_page) = @_;
	Rubric::Config->uri_root . "/doc/" . $doc_page;
}

1;