Changeset 45 in bookmarks for trunk/BookmarkApp.pm
- Timestamp:
- 06/03/13 17:43:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BookmarkApp.pm
r43 r45 20 20 view 21 21 view_field 22 create 22 23 edit 23 24 }]); … … 361 362 } 362 363 363 #TODO: split this into edit and create methods 364 sub edit { 364 sub create { 365 365 my $self = shift; 366 366 my $q = $self->query; 367 #TODO: get the bookmark based on the id and edit it directly?368 #TODO: deal with changing URIs369 367 my $uri = $q->param('uri'); 370 368 my $title = $q->param('title'); … … 392 390 } 393 391 392 sub edit { 393 my $self = shift; 394 my $q = $self->query; 395 my $id = $self->param('id'); 396 397 my $bookmark = $self->_bookmarks->get_bookmark({ id => $id }); 398 if ($bookmark) { 399 # update the URI, title, and tags 400 $bookmark->uri($q->param('uri')); 401 $bookmark->title($q->param('title')); 402 $bookmark->tags([ split(' ', $q->param('tags')) ]); 403 $bookmark->update($self->_bookmarks->dbh); 404 405 # return to the form 406 $self->header_type('redirect'); 407 $self->header_props( 408 -uri => $bookmark->bookmark_uri->canonical, 409 -status => 303, 410 ); 411 } else { 412 $self->header_props( 413 -type => 'text/html', 414 -charset => 'UTF-8', 415 -status => 404, 416 ); 417 return "Bookmark $id Not Found"; 418 } 419 } 420 394 421 1;
Note: See TracChangeset
for help on using the changeset viewer.