向tiddlyweb添加post和二进制文件上载(通过html)支持
tiddlywebplugins.form的Python项目详细描述
tiddlywebplugins.form
提供序列化程序以将HTML表单数据转换为可放入存储区的对象。
还添加了对标准url集的post支持和对上载二进制文件的支持。
支持post的url是:
/bags/foo/tiddlers /recipes/foo/tiddlers
要使用,请将tiddlywebplugins.form添加到tiddlywebconfig.py中的系统插件中。
然后,您可以按如下方式将整理程序发送到服务器:
使用任何命名元素设置HTML表单。支持的名称包括:
title - tiddler.title (this is optional and, depends upon which URL you POST to. Additionally, if you POST to /bags/foo/tiddlers without a title, you will get a UUID title instead). text - tiddler.text tags - tiddler.tags (this can be a list (eg checkboxes), or a string formatted as per standard TiddlyWiki tags). created - tiddler.created modified - tiddler.modified file - this is a special case and represents a binary file so must take the form of an HTML <input type=”file” /> tag. If this is specified, you may include tags and a title, but anything else will be ignored.
表单的内容类型(HTML表单行话中的enctype属性)必须是appilation/x-www-form-urlencoded或multipart/form数据(如果上载二进制文件)
将表单(ie-set the method to post)发布到上述URL之一(ie-set the action attribute),根据需要替换foo。
(可选)指定重定向以重定向到其他页面。
示例用法:
如果您想将一个新的tiddler发布到包“common”,您可以包含以下html:
<;form action=“/bags/common/tiddler”method=“post”>; <;input type=“text”name=“title”value=“new tiddler”/>; <;textarea name=“text”rows=“5”cols=“40”>;<;/textarea>; <;input type=“text”name=“tags”/>; <;input type=“submit”value=“save”/>; <;/表单>;
或者,您可能希望将二进制文件上载到包“common”:
<;form action=“/bags/common/tiddler”method=“post”enctype=“multipart/form data”>; <;input type=“file”name=“file”/>; <;input type=“submit”value=“upload”/>; <;/表单>;
还有一个为tiddlywiki设计的二进制上传插件,专门用于tiddlyweplugins.form。你可以在https://raw.githubusercontent.com/TiddlySpace/tiddlyspace/master/src/plugins/BinaryUploadPlugin.js
您可以在https://github.com/tiddlyweb/tiddlywebplugins.form