Edgewall Software

Changes between Initial Version and Version 1 of TracDev/PluginDevelopment/ExtensionPoints/trac.wiki.api.IWikiChangeListener


Ignore:
Timestamp:
Jul 19, 2014, 4:05:39 PM (10 years ago)
Author:
Peter Suter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PluginDevelopment/ExtensionPoints/trac.wiki.api.IWikiChangeListener

    v1 v1  
     1== Extension Point : ''IWikiChangeListener'' ==
     2
     3||'''Interface'''||''IWikiChangeListener''||'''Since'''||0.10||
     4||'''Module'''||''trac.wiki.api''||'''Source'''||[source:trunk/trac/wiki/api.py#/IWikiChangeListener api.py]||
     5
     6The ''IWikiChangeListener'' allows components to listen for and to react to wiki page events.
     7
     8== Purpose ==
     9
     10The [TracWiki Trac wiki system] organizes knowledge and information in wiki pages. Plugins can hook into the wiki system to trigger their own actions when wiki pages are created, deleted, changed or renamed.
     11
     12The main purpose for this interface is to allow plugins to stay informed about the existing wiki pages and trigger appropriate actions elsewhere (e.g. sending notifications, starting indexing services, updating supplementary data structures etc.)
     13
     14(For ticket validation and manipulation use [../trac.wiki.api.IWikiPageManipulator IWikiPageManipulator] instead.)
     15
     16== Usage ==
     17
     18Implementing the interface follows the standard guidelines found in [wiki:TracDev/ComponentArchitecture] and of course [wiki:TracDev/PluginDevelopment].
     19
     20When a user creates a new milestone the `wiki_page_added` method is called. Similarly methods are called when a user deletes a wiki page (`wiki_page_deleted`) or a version of a wiki page (`wiki_page_version_deleted` ), edits the wiki page (`wiki_page_changed`) or renames a wiki page (`wiki_page_renamed`).
     21
     22The [TracDev/DataModels#WikiPage Wiki page data] can be accessed as usual (e.g. `page.text`).
     23
     24== Examples ==
     25
     26The CommitTicketUpdater can be enabled so referencing a ticket in a commit log message automatically updates that ticket.
     27Similarly [ticket:9216 sometimes] you might want to reference a ticket in a  wiki page change comment.
     28The following minimal example IWikiChangeListener implementation could implement such a feature:
     29{{{#!python
     30import re
     31from trac.core import Component, implements
     32from trac.wiki.api import IWikiChangeListener
     33from trac.ticket.model import Ticket
     34
     35class WikiTicketUpdater(Component):
     36    implements(IWikiChangeListener)
     37
     38    def wiki_page_added(self, page):
     39        pass
     40
     41    def wiki_page_changed(self, page, version, t, comment, author, ipnr):
     42        ref = re.search('see #(\d+)', comment)
     43        if ref:
     44            id = int(ref.group(1))
     45            ticket = Ticket(self.env, id)
     46            ticket_comment = "In [wiki:%s@%s]: %s" % (page.name, version, comment)
     47            ticket.save_changes(author, ticket_comment, t)
     48
     49    def wiki_page_deleted(self, page):
     50        pass
     51
     52    def wiki_page_version_deleted(self, page):
     53        pass
     54
     55    def wiki_page_renamed(self, page, old_name):
     56        pass
     57}}}
     58
     59== Available Implementations ==
     60
     61* [source:trunk/trac/wiki/interwiki.py#/InterWikiMap InterWikiMap component]: Invalidates the cached InterWiki data from InterMapTxt.
     62
     63* th:WikiCreateTicketPlugin: Creates new tickets.
     64* th:BoilerplatePlugin: Creates new wiki pages from boilerplate data.
     65* th:AcronymsPlugin: Updates the acronym cache.
     66* th:AutoWikifyPlugin: Updates the list of known pages.
     67* th:FieldTooltipPlugin: Invalidates field help pages cache.
     68* th:FullTextSearchPlugin: Updates search index.
     69* th:TracAdvancedSearchPlugin: Updates search index.
     70* th:GlossaryBuilderPlugin: Updates index of glossary pages.
     71* th:HierWikiPlugin: Updates the list of known pages.
     72* th:KeywordReplacePlugin: Updates the keyword replacement data.
     73* th:TagsPlugin: Updates the tags data.
     74* th:TracWikiNegotiatorPlugin: Invalidates language pages cache.
     75* th:VotePlugin: Delete or reassign votes.
     76* th:GoogleSitemapPlugin: Sends notification to request a sitemap update.
     77* th:AnnouncerPlugin: Sends notifications.
     78* th:GrowlPlugin: Sends notifications.
     79* th:IrcAnnouncerPlugin: Sends notifications.
     80* th:TracCiaPlugin: Sends notifications.
     81* th:WikiNotificationPlugin: Sends notifications.
     82
     83== Additional Information and References ==
     84
     85 * [apiref:trac.wiki.api.IWikiChangeListener-class epydoc]
     86 * [apidoc:api/trac_wiki_api#trac.wiki.api.IWikiChangeListener API Reference]
     87 * See [../trac.wiki.api.IWikiPageManipulator trac.ticket.api.IWikiPageManipulator]
     88 * See [../trac.ticket.api.IMilestoneChangeListener trac.ticket.api.IMilestoneChangeListener], [../trac.ticket.api.ITicketChangeListener trac.ticket.api.ITicketChangeListener], [../trac.versioncontrol.api.IRepositoryChangeListener trac.versioncontrol.api.IRepositoryChangeListener],  [../trac.attachment.IAttachmentChangeListener trac.attachment.IAttachmentChangeListener]
     89 * [TracDev/DatabaseSchema/WikiSystem Wiki database schema]
     90 * Related tickets:
     91   * Generic change listener replacement: #8834, #11148, #6543, Trac-dev:7737
     92
     93=== API History
     94 * 0.9 introduced the interface
     95 * 0.10 Added method `wiki_page_version_deleted` (changeset:3206, #2885)
     96 * 0.12 Added method `wiki_page_renamed` (changeset:9362, #1106)
     97 * (TODO) add method `wiki_page_comment_modified` (#6573)