[dokuwiki] Re: better way to show file version?

  • From: "Getz, Robin" <robin.getz@xxxxxxxxxx>
  • To: <dokuwiki@xxxxxxxxxxxxx>
  • Date: Wed, 28 Nov 2012 12:14:14 -0500

On Mon 26 Nov 2012 15:25, Andreas Gohr pondered:
> Hi,
>
> >> This could be added through a custom XHTML renderer.
> >
> > Is this the right way, or just a different way? :)
> >
> :-) Well, it would be a way that survives an upgrade. But on the other
> hand your upgrades are handled via git anyway...

Only if you don't commit it upstream. :)
(which is obviously my preference)

> > If you are OK with the size, I will send a different patch.
> >
> >> I like the idea, at least showing the file size in the tooltip makes
> >> sense to me.
> >
> > So, add it to the existing path, or replace the path all together (which
> > the current link['title']?
>
> I would add it to the title. The path shows where the link goes even
> if you use a different name in your link. It's the same for page links
> and I would keep it this way for consistency. Patch or pull request
> would be nice.

So, something like:

diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 01e9c46..c7d9c64 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -802,6 +802,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
             $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
             $link['class'] .= ' mediafile mf_'.$class;
             $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
+            $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))).')';
         }

         if($hash) $link['url'] .= '#'.$hash;

-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: