-
Notifications
You must be signed in to change notification settings - Fork 4
yeago/django-wiki-syntax
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Ever want to type [[username]] into your blog-entries and get a handy link? Ever want to allow users to link to [[things]]s in your database with the most minimal hassle possible? Love how Wikipedia lets you create [[links]], like, super easily? INSTALLATION: 1. Add 'wikify' to your INSTALLED_APPS 2. Create some wiki classes (example below) 3. Add a WIKISYNTAX list to your settings.py. Example: WIKISYNTAX = [ ('name': 'path.to.the.class'), ] 4. load the {% wiki_tags %} and pass strings through the {% wikify str %} template tag. EXAMPLES: """ First one commented up for your edification Keep in mind these need not be tied to a model at all. You can match and return anything you please. """ class WikiCard(object): name = "card" # This is if you want to allow people to specify, aka [[card:Jack of Hearts]] def attempt(self,token): # A token is passed and you do whatever checking to tell if this object should be used if Card.objects.filter(name=token).count() == 1: return True # Use it! We found a match! return False # Skip! Try another! def render(self,token,trail=None): # What should [[card:Jack of Hearts]] look like when rendered? obj = Card.objects.get(name=token) return "<a href='%s'>%s</a>" % (obj.get_absolute_url(),obj.name) class WikiCardImage(object): name = "image" def attempt(self,token): if Card.objects.filter(name=token).count(): return True return False def render(self,token,trail=None): obj = Card.objects.get(name=token) return obj.image_url class WikiDeck(object): name = "deck" def attempt(self,token): if Deck.objects.filter(Q(name=token)|Q(slug=token)).count(): return True return False def render(self,obj,trail=None): return "Whatever, you get it"
About
A helpful app for allowing wiki-syntax around your site (comments, articles, etc)
Resources
Stars
Watchers
Forks
Packages 0
No packages published