| 75 | ---- |
| 76 | |
| 77 | == Site Navigation == |
| 78 | |
| 79 | === BackLinks === |
| 80 | First stab at a macro that displays all wiki pages linking to a specified page name. |
| 81 | |
| 82 | Usage: |
| 83 | |
| 84 | {{{ |
| 85 | [[BackLinks(pagename)]] |
| 86 | }}} |
| 87 | |
| 88 | I'd really like it to default to displaying backlinks to the current page when a page name isn't supplied, but, um, I have no idea how to do that. Suggestions greatly appreciated. |
| 89 | [[BR]] |
| 90 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks.py |
| 91 | [[BR]]''By:'' Dan Hon <danhon+trac@gmail.com> -- ''Ver.'' >= 0.7.1 |
| 92 | |
| 93 | Dan, here's an idea. |
| 94 | {{{ |
| 95 | thispage = hdf.getValue('wiki.page_name', '') |
| 96 | }}} |
| 97 | |
| 98 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks.2.py patches the wikimacro to default to display backlinks to the current page if a page name is not specified. |
| 99 | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> -- ''Ver.'' >= 0.8 |
| 100 | |
| 101 | Well, both those seem to have a bug: they will list pages for which at least one version linked to thispage, rather than just the latest version. So here's a fixed macro. |
| 102 | |
| 103 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks3.py patches the wikimacro to display only pages where the latest version links to the specified or current page. |
| 104 | [[BR]] |
| 105 | ''By:'' Andrew Durdin <adurdin at gmail.com> -- ''Ver.'' >= 0.8 |
| 106 | [[BR]] |
| 107 | ''Notes:'' An outstanding issue with these macros is that it incorrectly registers links from pages where their titles appear like !CamelCase (i.e. not a link) or where the name (not a TracLink-style name) is used legitimately in a different context (e.g. a page named 'History' would show backlinks to any other pages with the word 'History' in them). |
| 108 | |
| 109 | === SubWiki === |
| 110 | |
| 111 | Derived from TitleIndex. Returns a list of sub-wiki entries. A sub-wiki page is a page that is is deeper in the hierarchy than the current page. e.g. if the current page is People, this will return a list of all wiki entries that start with "People/" |
| 112 | |
| 113 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.py |
| 114 | [[BR]]''Version:'' >= 0.8 |
| 115 | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
| 116 | |
| 117 | A different version that lists the contents of the line specified in the second parameter next to the the link. |
| 118 | |
| 119 | [[BR]]''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.2.py |
| 120 | [[BR]]''By:'' csawyer@yumaed.org -- ''Ver:'' 0.8 |
| 121 | |
| 122 | A different version that lists the contents of the first heading element next to the link. The second parameter specifies the number of levels to display. Based on the version by csawyer@yumaed.org. |
| 123 | |
| 124 | [[BR]]''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.3.py |
| 125 | [[BR]]''By:'' muness@gmail.com -- ''Ver:'' 0.8 |
| 126 | |
| 127 | |
| 128 | === ParentWiki === |
| 129 | |
| 130 | Inserts a link to the "parent" wiki entry. This only applies to wikis that have a "/" in their name indicating hierarchy. e.g. an entry named Java/Introduction will have a parent of Java. All other wiki entries have a parent of WikiStart. |
| 131 | |
| 132 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ParentWiki.py |
| 133 | [[BR]]''Version:'' >= 0.8 |
| 134 | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
| 135 | |
| 136 | === ShowPath === |
| 137 | |
| 138 | Show the path to the specified wiki or the current wiki if none is specified. This is similar to the directory names at the top of the TracBrowser. This applies mainly to hierarchical wiki entries. e.g. the path to a {{{Book/Chapter/Section/Subsection}}} would be {{{WikiStart/Book/Chapter/Section/Subsection}}} (all but the current would be linked). |
| 139 | |
| 140 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ShowPath.py |
| 141 | [[BR]]''Version:'' >= 0.8 |
| 142 | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
| 143 | |
| 144 | ---- |
| 145 | |
| 146 | == Time & Date == |
| 147 | |
| 148 | === Timestamp === |
| 149 | Inserts current date and time. Distributed with Trac. |
| 150 | [[BR]]''Download:'' source:trunk/trac/wikimacros/Timestamp.py |
| 151 | [[BR]]''By:'' TracTeam -- ''Ver:'' >0.5.2 |
| 152 | |
| 153 | === DateOffset === |
| 154 | |
| 155 | Returns the date referred to as follows: |
| 156 | * First arg is the offset, i.e. the date to start from |
| 157 | * Second arg is the multiplier to multiply the count by (e.g. 7 for a week) |
| 158 | * Third arg is the count (i.e. the number of additions to make). |
| 159 | |
| 160 | So, for example: |
| 161 | * {{{ [[DateOffset(2005/01/05,7,0)]] }}} returns Wed Jan 05 |
| 162 | * {{{ [[DateOffset(2005/01/05,7,4)]] }}} returns Wed Feb 02 |
| 163 | |
| 164 | You can also configure the input and output date formats. (See http://python.org/doc/2.3.4/lib/module-time.html). e.g.: |
| 165 | * {{{ [[DateOffset(01/05/2005,7,0,%m/%d/%Y,%A %B %d)]] }}} returns Wednesday January 05 |
| 166 | |
| 167 | Please email me fixes and excuse any obvious errors: I've never written any python before this. |
| 168 | |
| 169 | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/DateOffset.py |
| 170 | [[BR]]''Version:'' >= 0.8 |
| 171 | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
| 172 | |
| 173 | ---- |
| 174 | |
| 175 | == Miscellaneous == |
93 | | === BackLinks === |
94 | | First stab at a macro that displays all wiki pages linking to a specified page name. |
95 | | |
96 | | Usage: |
97 | | |
98 | | {{{ |
99 | | [[BackLinks(pagename)]] |
100 | | }}} |
101 | | |
102 | | I'd really like it to default to displaying backlinks to the current page when a page name isn't supplied, but, um, I have no idea how to do that. Suggestions greatly appreciated. |
103 | | [[BR]] |
104 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks.py |
105 | | [[BR]]''By:'' Dan Hon <danhon+trac@gmail.com> -- ''Ver.'' >= 0.7.1 |
106 | | |
107 | | Dan, here's an idea. |
108 | | {{{ |
109 | | thispage = hdf.getValue('wiki.page_name', '') |
110 | | }}} |
111 | | |
112 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks.2.py patches the wikimacro to default to display backlinks to the current page if a page name is not specified. |
113 | | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> -- ''Ver.'' >= 0.8 |
114 | | |
115 | | Well, both those seem to have a bug: they will list pages for which at least one version linked to thispage, rather than just the latest version. So here's a fixed macro. |
116 | | |
117 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks3.py patches the wikimacro to display only pages where the latest version links to the specified or current page. |
118 | | [[BR]] |
119 | | ''By:'' Andrew Durdin <adurdin at gmail.com> -- ''Ver.'' >= 0.8 |
120 | | [[BR]] |
121 | | ''Notes:'' An outstanding issue with these macros is that it incorrectly registers links from pages where their titles appear like !CamelCase (i.e. not a link) or where the name (not a TracLink-style name) is used legitimately in a different context (e.g. a page named 'History' would show backlinks to any other pages with the word 'History' in them). |
122 | | |
123 | | |
233 | | === DateOffset === |
234 | | |
235 | | Returns the date referred to as follows: |
236 | | * First arg is the offset, i.e. the date to start from |
237 | | * Second arg is the multiplier to multiply the count by (e.g. 7 for a week) |
238 | | * Third arg is the count (i.e. the number of additions to make). |
239 | | |
240 | | So, for example: |
241 | | * {{{ [[DateOffset(2005/01/05,7,0)]] }}} returns Wed Jan 05 |
242 | | * {{{ [[DateOffset(2005/01/05,7,4)]] }}} returns Wed Feb 02 |
243 | | |
244 | | You can also configure the input and output date formats. (See http://python.org/doc/2.3.4/lib/module-time.html). e.g.: |
245 | | * {{{ [[DateOffset(01/05/2005,7,0,%m/%d/%Y,%A %B %d)]] }}} returns Wednesday January 05 |
246 | | |
247 | | Please email me fixes and excuse any obvious errors: I've never written any python before this. |
248 | | |
249 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/DateOffset.py |
250 | | [[BR]]''Version:'' >= 0.8 |
251 | | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
252 | | |
253 | | |
254 | | === SubWiki === |
255 | | |
256 | | Derived from TitleIndex. Returns a list of sub-wiki entries. A sub-wiki page is a page that is is deeper in the hierarchy than the current page. e.g. if the current page is People, this will return a list of all wiki entries that start with "People/" |
257 | | |
258 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.py |
259 | | [[BR]]''Version:'' >= 0.8 |
260 | | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
261 | | |
262 | | A different version that lists the contents of the line specified in the second parameter next to the the link. |
263 | | |
264 | | [[BR]]''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.2.py |
265 | | [[BR]]''By:'' csawyer@yumaed.org -- ''Ver:'' 0.8 |
266 | | |
267 | | A different version that lists the contents of the first heading element next to the link. The second parameter specifies the number of levels to display. Based on the version by csawyer@yumaed.org. |
268 | | |
269 | | [[BR]]''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.3.py |
270 | | [[BR]]''By:'' muness@gmail.com -- ''Ver:'' 0.8 |
271 | | |
272 | | |
273 | | === ParentWiki === |
274 | | |
275 | | Inserts a link to the "parent" wiki entry. This only applies to wikis that have a "/" in their name indicating hierarchy. e.g. an entry named Java/Introduction will have a parent of Java. All other wiki entries have a parent of WikiStart. |
276 | | |
277 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ParentWiki.py |
278 | | [[BR]]''Version:'' >= 0.8 |
279 | | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
280 | | |
281 | | === ShowPath === |
282 | | |
283 | | Show the path to the specified wiki or the current wiki if none is specified. This is similar to the directory names at the top of the TracBrowser. This applies mainly to hierarchical wiki entries. e.g. the path to a {{{Book/Chapter/Section/Subsection}}} would be {{{WikiStart/Book/Chapter/Section/Subsection}}} (all but the current would be linked). |
284 | | |
285 | | ''Download:'' http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ShowPath.py |
286 | | [[BR]]''Version:'' >= 0.8 |
287 | | [[BR]]''By:'' Muness Alrubaie <muness@gmail.com> |
288 | | |