Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 48 lines (41 sloc) 1.284 kB
#! /usr/bin/python
#
# wdput - Send one page to a Wikidot site
# Part of the ztools toolkit. Install into any directory on PATH.
#
# Author: Pieter Hintjens <ph@imatix.com>
# License: public domain
#
# syntax: wdput sitename category page title
#
# Wikidot text must be in page + '.wd'
#
# Supply your Wikidot user name as an environment variable APISITE_USER
# Supply your Wikidot API key as an environment variable APISITE_KEY
# Get script arguments
import sys
if len(sys.argv) != 5:
print "Usage: wdput sitename category name title"
sys.exit(1)
sitename = sys.argv [1]
category = sys.argv [2]
name = sys.argv [3]
title = sys.argv [4]
# Get authentication credentials
import os
user = os.environ ['APISITE_USER']
key = os.environ ['APISITE_KEY']
# Create XML/RPC connection to Wikidot
from xmlrpclib import ServerProxy
server = ServerProxy ('https://' + user + ':' + key + '@www.wikidot.com/xml-rpc-api.php')
# Send page content (create or update)
file = open (name + ".wd", "r")
content = ""
for line in file:
content = content + line
print " - " + sitename + ":" + category + ":" + name + " - " + title
server.pages.save_one ({
"site": sitename,
"page": category + ":" + name,
"title": title,
"content": content})
Jump to Line
Something went wrong with that request. Please try again.