Changeset 3 in bookmarks for trunk


Ignore:
Timestamp:
03/02/12 20:51:06 (13 years ago)
Author:
peter
Message:
  • Added a base URL to the list, guarenteed to end in "bookmarks/"
  • Default the ?format parameer to the list to "html" to avoid the unitialized value warnings
  • Added more classes to the individual bookmark page elements
  • Added an onclick handler to the tag links in a bookmark edit form that will attempt to open the link in the opener window; failing that, they will use a new window
  • Check for an opener before attempting to reload it on page load
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bookmark.tt

    r2 r3  
    2222      <a href="[% uri %]" target="_blank">[% title or uri %]</a> 
    2323      [% IF exists %] 
    24         <p>[% created %]</p> 
     24        <p class="timestamps">[% created %]</p> 
    2525        [% IF tags.size %] 
    26           <p>Tagged as: 
     26          <p class="tags">Tagged as: 
    2727            [% FOREACH tag IN tags %] 
    28               <a href="?tag=[% tag %]">[% tag %]</a> 
     28              <a href=".?tag=[% tag %]" class="tag" target="_blank" onclick="if (opener && !opener.closed) { opener.location = this.href; return false; }">[% tag %]</a> 
    2929            [% END %] 
    3030          </p> 
     
    6464window.onload = function() { 
    6565    if (document.location.hash == '#updated') { 
    66         opener.location.reload(); 
     66        if (opener) { 
     67            opener.location.reload(); 
     68        } 
    6769    } 
    6870}; 
  • trunk/index.cgi

    r2 r3  
    9898            } 
    9999        } else { 
    100             #print $q->header('text/html'); 
    101             #print "TODO: list bookmarks"; 
    102             #return; 
    103             # list all the resources 
    104             my $format = $q->param('format'); 
     100            # list all the bookmarks  
     101            my $format = $q->param('format') || 'html'; 
    105102            my $tag = $q->param('tag'); 
    106103            my @resources = $bookmarks->get_resources({ tag => $tag }); 
     
    123120                    -charset => 'UTF-8', 
    124121                ); 
     122 
     123                # set the base URL, adding a trailing slash if needed 
     124                my $base_url = $q->url; 
     125                $base_url .= '/' if $base_url =~ m{/bookmarks$}; 
     126 
    125127                $template->process( 
    126128                    'list.tt', 
    127129                    { 
     130                        base_url     => $base_url, 
    128131                        selected_tag => $tag, 
    129132                        tags         => \@all_tags, 
  • trunk/list.tt

    r2 r3  
    22  <head> 
    33    <title>Bookmarks</title> 
     4    <base href="[% base_url %]"/> 
    45    <style type="text/css"> 
    56a:hover { 
     
    6465        <li> 
    6566          <span class="edit"> 
    66             (<a href="bookmarks/[% resource.id %]" onclick="window.open(this.href, 'edit_bookmark', 'width=800,height=250').focus(); return false;">Edit</a>) 
     67            (<a href="[% resource.id %]" onclick="window.open(this.href, 'edit_bookmark', 'width=800,height=250').focus(); return false;">Edit</a>) 
    6768          </span> 
    6869          <a href="[% resource.uri %]" title="[% resource.title | html %] ([% resource.tags.join(', ') %])">[% resource.title or resource.uri %]</a> 
Note: See TracChangeset for help on using the changeset viewer.