Skip to content

Instantly share code, notes, and snippets.

@cdent
Created July 16, 2009 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdent/148326 to your computer and use it in GitHub Desktop.
Save cdent/148326 to your computer and use it in GitHub Desktop.
"""
Quick twanager hack to lowercase all tags in
a bag.
twanager_plugins: ['lowertags']
"""
from tiddlyweb.model.bag import Bag
from tiddlyweb.manage import make_command
from tiddlyweb.store import Store
def get_store(config):
"""
Given the config, return a reference to the store.
"""
return Store(config['server_store'][0], {'tiddlyweb.config': config})
@make_command()
def lowertags(args):
"""Lower case all the tags in all the tiddlers in the named bag: <bag>"""
bag_name = args[0]
store = get_store(config)
bag = store.get(Bag(bag_name))
for tiddler in bag.gen_tiddlers():
tiddler = store.get(tiddler)
print tiddler.tags
tiddler.tags = [tag.lower() for tag in tiddler.tags]
print tiddler.tags
store.put(tiddler)
def init(config_in):
global config
config = config_in
"""
Case insensitive text filtering.
Workaround for a bug in tiddlyweb < 0.9.54
system_plugins: ['ltext']
"""
import tiddlyweb.filters.select
def ltext_in_text(tiddler, attribute, value):
return value.lower() in tiddler.text.lower()
tiddlyweb.filters.select.ATTRIBUTE_SELECTOR['text'] = ltext_in_text
def init(config):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment