moin-2.0 / contrib / ExamplePlugin / ExampleMoinPlugin /

Miks Kalniņš 4d5b078 

Miks Kalniņš 916df33 

Miks Kalniņš 4d5b078 

Miks Kalniņš e9f9137 

Miks Kalniņš 4d5b078 
Miks Kalniņš e9f9137 

Miks Kalniņš 4d5b078 
Miks Kalniņš 2c6223f 

Miks Kalniņš 4d5b078 
Miks Kalniņš 281c4b7 

Miks Kalniņš 2c6223f 
Miks Kalniņš e9f9137 

Miks Kalniņš 281c4b7 

Miks Kalniņš e9f9137 
Miks Kalniņš 281c4b7 

Miks Kalniņš e9f9137 

Miks Kalniņš 0616fb2 
# Copyright: 2012 MoinMoin:Miks Kalnins <>
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

    ExampleMoinPlugin - Example plugin for MoinMoin wiki engine.

    Example configuration:

    from wikiconfig import *

    class LocalConfig(Config):
        example_plugin_config = {
            "default_name": "Jack Sparrow",
        plugins_config = {
            "ExampleMoinPlugin": example_plugin_config,
        plugins_enabled = [
        theme_default = "Modernized"

    MOINCFG = LocalConfig
    DEBUG = True

from flask import Blueprint
from flask import Response

from MoinMoin.themes import render_template
from MoinMoin.plugin import BlueprintBase
from import before_wiki, teardown_wiki

class ExampleMoinPlugin(BlueprintBase):

    name = u"Example Plugin"
    author = u"Miks Kalnins"
    description = u"An example plugin for MoinMoin wiki engine to demonstrate some of the plugin systems features."

    blueprint = Blueprint('example', __name__, template_folder='templates')
    blueprint_options = dict(url_prefix="/+example")

    def __init__(self, cfg):
        self.default_name = cfg.get("default_name", "Anonymous")


        self.blueprint.add_url_rule("/", "index", self.index)
        self.blueprint.add_url_rule("/hello/", "hello", self.hello, defaults=dict(name=None))
        self.blueprint.add_url_rule("/hello/<name>", "hello", self.hello)

    def index(self):
        return render_template("example_index.html",
                               title="ExampleMoinPlugin - Index",
                               content="Hello from ExampleMoinPlugin!")

    def hello(self, name):
        if not name:
            name = self.default_name
        return u"Hello, {0}!".format(name)