Hi,
On 2023/01/16 22:24, 'Tony Brian Albers (XTOAL)' via Trac Users wrote:
> Hi guys,
>
> I finally managed to join this group(which is not so easy when you don't have a google account).
>
> So, I'm using the wikinfo plugin to have a small table at the bottom of specific pages so that when they're exported to i.e. pdf, you can see what version of the trac page the pdf was made from.
>
> The code looks like this:
> {{{
> ||= Page info =|| ||
> || Page URL: || !
https://tracker.jobjob.dk/si/wiki/BaseReplacement/svcs/sshd ||
> || Page version: || [[Wikinfo(version)]] ||
> || Page last changed by: || [[Wikinfo(changed_by)]] ||
> || Page last changed: || [[Wikinfo(changed_ts)]] ||
> }}}
>
> And that's all fine and dandy. However, I'd like to somehow auto-populate the URL row with the specific full URL of the page. Right now I have to do it manually, and that's quite annoying.
>
> Does anyone know of a way to do this? (apart from adding the functionality to the plugin)
One of solutions is to add the contents using /wiki_render by javascript on
loading wiki pages, and add the javascript to site_footer.html template.
Example: $ENV/templates/site_footer.html
==========
# if page and not action:
<script>
jQuery(function($) {
if ($('#wikipage').length == 0 || $('.trac-modifiedby').length == 0)
return;
var url = ${to_json(req.href('wiki_render'))|safe};
var text = [
'||= Page info =||= ||',
'|| Page URL: || ' + ${to_json(abs_url_of(page.resource))|safe} + ' ||',
'|| Page version: || [[Wikinfo(version)]] ||',
'|| Page last changed by: || [[Wikinfo(changed_by)]] ||',
'|| Page last changed: || [[Wikinfo(changed_ts)]] ||',
''];
var data = {realm: 'wiki', id: ${to_json(
page.name)|safe},
text: text.join('\n'),
__FORM_TOKEN: ${to_json(req.form_token)|safe}};
$.post(url, data, function(response) {
var element = $('<div>').html(response);
$('.trac-modifiedby').before(element);
});
});
</script>
# endif
==========
--
Jun Omae <
jun...@gmail.com> (大前 潤)