moin-2.0 / contrib / ExamplePlugin / ExampleMoinPlugin / __init__.py

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 <mikskalnins@maikumori.com>
# 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 = [
            "ExampleMoinPlugin",
            "MoinMoin.themes.foobar",
            "MoinMoin.themes.modernized",
            "MoinMoin.storage.stores.fs",
            "MoinMoin.auth",
        ]
        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 MoinMoin.app 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.before_request(before_wiki)
        self.blueprint.after_request(teardown_wiki)

        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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.