xotcl.wu-wien.ac.at
Begin main content
Search · Index
No registered users in community s5-xowiki-tutorial
in last 10 minutes

Custom Link Definition

# define link class
Class create ::xowiki::Link::cite -superclass ::xowiki::Link

::xowiki::Link::cite instproc render_found {href label} {
  # resolve the referenced page
  set item_id [my resolve]
  set reference [::xo::db::CrClass get_instance_from_db -item_id $item_id]

  # generate citation information
  set creation_date [::xo::db::tcl_date [reference set creation_date]]
  set creation_stamp [clock scan $creation_date]
  set user_id [$reference set creation_user]

  set author(url) [export_vars -base /shared/community-member {user_id}]
  set author(pretty_name)    [::xo::get_user_name $user_id]
  set published(pretty_date) $creation_date
  set published(raw)         [::xo::ical clock_to_iso $creation_stamp]

  return [subst {
   <cite class="hcite">
     <a class="fn url" href="$href">$label</a>
     <span class="author vcard">
       <a href="$author(url)" class="url fn">$author(pretty_name)</a>
     </span>
     <abbr class="dtpublished" title="$published(raw)">
     $publihsed(pretty_date)
     </abbr>
   </cite>
  }]
}