Skip to content

Instantly share code, notes, and snippets.

@cdent
Created November 24, 2009 15:28
Show Gist options
  • Select an option

  • Save cdent/241940 to your computer and use it in GitHub Desktop.

Select an option

Save cdent/241940 to your computer and use it in GitHub Desktop.
__import__("pkg_resources").declare_namespace(__name__)
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.
{% if username != 'GUEST' %}
<h1>Hi {{ username }}</h1>
{% else %}
<h1>Hi Visitor</h1>
{% endif %}
Welcome to <a href="http://tiddlyweb.com/">TiddlyWeb</a>
# 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
"""
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)
recursive-include tiddlywebplugins/templates *
include README Makefile
# 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'],
)
tiddlywebplugins/templates
"""
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)
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