Created
November 24, 2009 15:28
-
-
Save cdent/241940 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| __import__("pkg_resources").declare_namespace(__name__) |
This file contains hidden or 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
| This is a stub README for a new TiddlyWeb plugin. | |
| The entire maker package provides a sort of fill in the blank | |
| opportunity for creating TiddlyWeb plugins in the tiddylwebplugins | |
| namespace. | |
| Rename tiddlywebplugins/example.py to the name you want to use for | |
| your plugin. Edit setup.py to set the variables at the top of the | |
| file. Edit your plugin file to add the necessary code. Edit this | |
| README so it provides a description of the plugin. | |
| See http://www.python.org/~jeremy/weblog/030924.html for some | |
| info on how to register for PyPI. | |
| If you have suggestions for things to add to maker post at the | |
| TiddlyWeb Google Group: http://groups.google.com/group/tiddlyweb | |
| To start with maker itself clone this repo, and then remove .git | |
| directory. |
This file contains hidden or 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
| {% if username != 'GUEST' %} | |
| <h1>Hi {{ username }}</h1> | |
| {% else %} | |
| <h1>Hi Visitor</h1> | |
| {% endif %} | |
| Welcome to <a href="http://tiddlyweb.com/">TiddlyWeb</a> |
This file contains hidden or 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
| # Simple Makefile for some common tasks. This will get | |
| # fleshed out with time to make things easier on developer | |
| # and tester types. | |
| .PHONY: test dist upload | |
| clean: | |
| find . -name "*.pyc" |xargs rm || true | |
| rm -r dist || true | |
| rm -r build || true | |
| rm -r *.egg-info || true | |
| test: | |
| py.test -x test | |
| dist: | |
| python setup.py sdist | |
| upload: clean pypi | |
| pypi: | |
| python setup.py sdist upload |
This file contains hidden or 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
| """ | |
| adjusts module path to account for virtual namespace | |
| This is required primarily for testing. | |
| """ | |
| import sys | |
| import os | |
| VIRTUAL_NAMESPACE = "tiddlywebplugins" | |
| local_package = os.path.abspath(VIRTUAL_NAMESPACE) | |
| sys.modules[VIRTUAL_NAMESPACE].__dict__["__path__"].insert(0, local_package) |
This file contains hidden or 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
| recursive-include tiddlywebplugins/templates * | |
| include README Makefile |
This file contains hidden or 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
| # YOU NEED TO EDIT THESE | |
| AUTHOR = 'Chris Dent' | |
| AUTHOR_EMAIL = '[email protected]' | |
| NAME = 'tiddlywebplugins.templatinghello' | |
| DESCRIPTION = 'An example of using templates with tiddlyweb' | |
| VERSION = '0.9' | |
| import os | |
| from setuptools import setup, find_packages | |
| # You should review the below so that it seems correct. install_requires | |
| # especially. | |
| setup( | |
| namespace_packages = ['tiddlywebplugins'], | |
| name = NAME, | |
| version = VERSION, | |
| description = DESCRIPTION, | |
| long_description=file(os.path.join(os.path.dirname(__file__), 'README')).read(), | |
| author = AUTHOR, | |
| url = 'http://pypi.python.org/pypi/%s' % NAME, | |
| packages = find_packages(exclude='test'), | |
| author_email = AUTHOR_EMAIL, | |
| platforms = 'Posix; MacOS X; Windows', | |
| install_requires = ['setuptools', 'tiddlyweb', 'tiddlywebplugins.templates'], | |
| ) |
This file contains hidden or 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
| tiddlywebplugins/templates |
This file contains hidden or 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
| """ | |
| Description of My Plugin. | |
| """ | |
| from tiddlywebplugins.templates import get_template | |
| def hello(environ, start_response): | |
| username = environ['tiddlyweb.usersign']['name'] | |
| template = get_template(environ, 'hello.html') | |
| start_response('200 OK', [('Content-Type', 'text/html; charset=UTF-8')]) | |
| return template.generate(username=username) | |
| def init(config): | |
| config['selector'].add('/hello', GET=hello) |
This file contains hidden or 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
| import mangler | |
| config = { | |
| 'system_plugins': ['tiddlywebplugins.templatinghello'], | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment