Giter VIP home page Giter VIP logo

tiddlywebplugins.urls's Introduction

tiddlywebplugins.urls
=====================

This plugin lets you:

* Map a custom URL to a default TiddlyWeb URL.
* Map a custom URL to any other URL, for use as a URL shortener

It uses selector syntax for the custom URL (http://lukearno.com/projects/selector/)

Configuration
-------------

This plugin is a "system" and a "twanager" plugin. Type ``twanager usage`` in the command line. Your ``tiddlywebconfig.py`` should look similar to this configuration::

    config = {
    'system_plugins': ['tiddlywebwiki', 'tiddlywebplugins.urls' ],
    'secret': 'XXXXXXXX',
    'twanager_plugins': ['tiddlywebwiki', 'tiddlywebplugins.urls'],

    # the tiddlywebwiki.friendlywiki function doesn't work with urls plugin, 

    # it needs to be disabled.
    'tiddlywebwiki.friendlywiki': False,

    #'url_bag':'__urls',
    }

Note: All urls are stored in a bag called "urls" by default. 

The name of this bag can be changed by adding "urls_bag" to tiddlywebconfig.py, but all tiddlers in the bag must be "url tiddlers" of the described format. If this bag doesn't exists already, it will be created automatically.

Rewrite URLs
============

To bring up a tiddlywiki at ``/default``, create a tiddler like::

    title:
    /default

    text:
    /recipes/default/tiddlers.wiki

This configuration creates a link eg: ``http://example.com/default`` that would otherwise be: ``http://example.com/recipes/default/tiddlers.wiki``, which is still valid. Be sure the recipe named "default" exists!

Flexible Version
----------------

Using the above format you'd need to create one tiddler per recipe. This isn't very "user friendly". So we need to be more flexibe, using "placeholders" to define the relation. Now we want to map every recipe_name, that the user may enter eg: ``/wiki/anyRecipeName``::

    title: 
    /wiki/{recipe_name:segment}

    text:
    /recipes/{{ recipe_name }}/tiddlers.wiki

A URL ``http://example.com/wiki/myWiki`` will load ``http://example.com/recipes/myWiki/tiddlers.wiki``

Link to a Single Page Application
---------------------------------

It is possible to directly link to a single tiddler within a recipe or bag::

    title: 
    /spa/{spa_name:segment}

    text:
    /recipes/my_recipe/tiddlers/{{ spa_name }}
    or
    /bags/my_bag/tiddlers/{{ spa_name }}

Be aware of the title ``/spa`` prefix. It is optional. Here it is used, to separate the function from the "Rewrite Recipe URL" configuration. 

Redirect URLs
=============

Redirect to internal URL
------------------------

If you want to redirect instead of rewrite to an internal URL, you can add the tag "redirect"::

    title:
    /wiki/{user:segment}
    
    tags:
    redirect
    
    text:
    /recipes/{{ user }}/tiddlers.wiki

Be aware, that adding a user will not automatically add a user recipe. So if you need one, you need to create it. 

Redirect to exernal URL
-----------------------

To create a short link to google.com, you might do the following. There is no need for the "redirect" tag::

    title:
    /google
    
    text:
    http://www.google.com


Experimental
============

If we create a tiddlywiki with a bag eg: ``/bags/{{ bag_name }}/tiddlers.wiki`` it will be loaded as a TiddlyWiki representation, but it is not saveable:: 

    title:
    /test/{bag_name:segment}

    text:
    /recipes/experiment/tiddlers.wiki

The ``experiment`` recipe needs to look similar to this one (in production you'll need access rights!)::

    desc: some description text ...
    policy: {"read": [], "create": [], "manage": [R:ADMIN], "write": [], "owner": null, "delete": []}

    /bags/system/tiddlers
    /bags/{{ bag_name }}/tiddlers

Where bag_name can be any variable name.

Note that this does not support PUTs, you are unable to PUT to the recipe (unless you provide a default for bag_name). This version needs a client side plugin to work with PUTs.


tiddlywebplugins.urls's People

Contributors

bengillies avatar pmario avatar

Stargazers

Andrew Back avatar  avatar

Watchers

 avatar  avatar James Cloos avatar

Forkers

pmario

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.