Attachment 'HttpLink-1.0.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - HttpLink macro Version 1.0, 24.06.2014
4
5 Inserts a local wiki page link as an external link, for stituations where
6 it would be helpful to show the full URL, such as pages intended to be
7 printed or saved in PDF formated.
8
9 Syntax:
10 <<HttpLink>>; <<HttpLink()>>
11 <<HttpLink(page)>>
12
13 @copyright: 2014 Ian Riley <ian@riley.asia>
14 license: GNU GPL, see COPYING for details.
15
16 """
17
18 from MoinMoin import wikiutil
19 from MoinMoin.Page import Page
20 from werkzeug.utils import get_host
21
22 def execute(macro, args):
23 request = macro.request
24 page_name = macro.formatter.page.page_name
25 result = []
26
27 url_page = page_name
28 if args:
29 url_page = args
30
31 if Page(request, url_page).exists():
32 url_page = wikiutil.AbsPageName(page_name, url_page)
33 url_page = url_page.replace(' ','_')
34
35 url_base = get_host(request.environ) + '/'
36 if request.script_root:
37 url_base += request.script_root + '/'
38
39 target = 'http://' + (url_base + url_page).replace('//','/')
40
41 result.extend([
42 '\n',
43 macro.formatter.url(1, target, css='http') +
44 macro.formatter.text(target) +
45 macro.formatter.url(0)
46 ])
47
48 return ''.join(result)
You are not allowed to attach a file to this page.