Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6648394
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
= !TopMacro = | ||
|
||
TopMacro is exceedingly simple, like all good software ;-). In a nutshell, it | ||
does exactly what you think it would, inserts a "top of page" link in your Wiki | ||
page. The only option is a string that is inserted into the content of the markup. | ||
This defaults to a single circumflex "!^" character (more commonly known as a caret), | ||
surrounded by square brackets. The anchor element returned includes a "Top of Page" | ||
title attribute so the user knows its purpose, and a "topofpage" class so the Wiki | ||
author may style it in any way they please. | ||
|
||
{{{ | ||
[[Top]] becomes: | ||
|
||
[<a href="#" class="topofpage" title="Top of page">^</a>] | ||
}}} | ||
|
||
You could of course achieve the same effect by doing this: | ||
|
||
{{{ | ||
{{{ | ||
#!html | ||
[<a href="#" class="topofpage" title="Top of page">^</a>] | ||
}}} | ||
}}} | ||
|
||
Resulting in this: | ||
|
||
{{{ | ||
#!html | ||
[<a href="#" class="topofpage" title="Top of page">^</a>] | ||
}}} | ||
|
||
But who wants to do all that typing? That's what [http://en.wikipedia.org/wiki/Macro_(computer_science) macros] | ||
are for after all. Note that the brackets do not form part of the anchor itself. | ||
That is a personal preference. If you pass a string to the macro they are ommited. | ||
|
||
== Installation == | ||
|
||
{{{ | ||
python setup.py bdist_egg | ||
cp dist/*.egg /trac/env/Project/plugins | ||
}}} | ||
|
||
== Configuration == | ||
|
||
Enable the macro in: | ||
|
||
/trac/env/Project/conf/trac.ini: | ||
|
||
{{{ | ||
[components] | ||
top.* = enabled | ||
}}} | ||
|
||
Then restart you Web server. | ||
|
||
== Examples == | ||
|
||
{{{ | ||
[[Top]] | ||
[[Top(top)]] | ||
[[Top(Top of page)]] | ||
}}} | ||
|
||
== Source == | ||
|
||
Browse the source at: [http://github.com/dwclifton/tracinigetmacro/tree/master GitHub][[BR]] | ||
Public clone URL: | ||
{{{ | ||
git clone git://github.com/dwclifton/topmacro.git | ||
}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
|
||
import os.path | ||
from setuptools import setup | ||
|
||
setup( | ||
name = 'TracTopMacro', | ||
packages = ['top'], | ||
version = '0.11.0', | ||
|
||
author = 'Douglas Clifton', | ||
author_email = 'dwclifton@gmail.com', | ||
description = 'Top of page Macro', | ||
long_description = open(os.path.join(os.path.dirname(__file__), 'README')).read(), | ||
keywords = '0.11 dwclifton macro wiki', | ||
url = 'http://trac-hacks.org/wiki/TopMacro', | ||
license = 'BSD', | ||
|
||
entry_points = { 'trac.plugins': [ 'top.macro = top.macro' ], | ||
classifiers = ['Framework :: Trac'], | ||
install_requires = ['Trac'] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# __init__.py | ||
from top import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" @package TopMacro | ||
@file macro.py | ||
@brief The TopMacro class | ||
Return a top of page anchor element. | ||
@author Douglas Clifton <dwclifton@gmail.com> | ||
@date December, 2008 | ||
@version 0.11.0 | ||
""" | ||
|
||
from trac.core import * | ||
from trac.wiki.macros import WikiMacroBase | ||
from trac.wiki.api import parse_args | ||
from genshi.builder import tag | ||
|
||
__all__ = ['TopMacro'] | ||
|
||
class TopMacro(WikiMacroBase): | ||
|
||
def expand_macro(self, formatter, name, args): | ||
""" Return a top of page anchor element.""" | ||
|
||
prefix = '[' | ||
content = '^' | ||
suffix = ']' | ||
|
||
args, kw = parse_args(args) | ||
|
||
if args: | ||
content = args.pop(0).strip() | ||
prefix = suffix = '' | ||
|
||
# class is a python reserved identifier | ||
|
||
class_ = 'topofpage' | ||
title = 'Top of page' | ||
|
||
return tag.span(prefix, | ||
tag.a(content, href='#', title='%s' % title), | ||
suffix, | ||
class_='%s' % class_) |