--- /usr/local/src/pyblosxom-contrib-1.2/xmlrpc_plugins/xmlrpc_blogger.py 2005-03-27 15:38:21.000000000 -0700 +++ ../plugins/xmlrpc_blogger.py 2005-04-08 23:27:07.000000000 -0600 @@ -38,6 +38,7 @@ """ import os, xmlrpclib, re +import time from Pyblosxom import tools, plugin_utils LINEFEED = os.linesep @@ -84,6 +85,53 @@ xmlrpc_plugin = plugin_utils.get_plugin_by_name("xmlrpc") xmlrpc_plugin.authenticate(request, username, password) +def blog_document_nameXXX(request, appkey, blogid, content, publish, config): + # This is the code that originally came in xmlrpc_blogger.py + # Disabled + # Look at content + blogTitle = content.split(LINEFEED)[0].strip() + + tempMarker = (not publish and '-' or '') + blogID = os.path.normpath( + os.path.join( + config['datadir'], blogid[1:] + + re.sub('[^A-Za-z0-9]','_',blogTitle) + '.txt' + + tempMarker + ) + ) + if os.path.isfile(blogID) or os.path.isfile(blogID + '-'): + # Generate a ficticious blog name + blogID = os.path.normpath( + os.path.join( + config['datadir'], blogid[1:] + + re.sub('[^A-Za-z0-9]','_',blogTitle) + + tools.generateRandStr() + '.txt' + tempMarker + ) + ) + return blogID + +def blog_document_name(request, appkey, blogid, content, publish, config): + # Look at content + blogTitle = content.split(LINEFEED)[0].strip() + + (year, month, day) = time.localtime()[:3] + (year, month, day) = ('%04i'%year, '%02i'%month, '%02i'%day) + + temp_marker = (not publish and '-' or '') + path = os.path.normpath( + os.path.join(config['datadir'], blogid[1:], year + '-' + month + '-' + day) + ) + if not os.path.isdir(path): + os.makedirs(path) + blog_file_stem = re.sub('[^A-Za-z0-9]', '_', blogTitle) + full_path = os.path.join(path, blog_file_stem + '.txt' + temp_marker) + suffix = 0 + while os.path.isfile(full_path): + suffix += 1 + full_path = os.path.join(path, blog_file_stem + str(suffix) + '.txt' + temp_marker) + return full_path + + def blogger_newPost(request, appkey, blogid, username, password, content, publish=1): """ @@ -94,26 +142,7 @@ config = request.getConfiguration() if os.path.isdir(os.path.normpath(os.path.join(config['datadir'], blogid[1:]))): - # Look at content - blogTitle = content.split(LINEFEED)[0].strip() - - tempMarker = (not publish and '-' or '') - blogID = os.path.normpath( - os.path.join( - config['datadir'], blogid[1:] + - re.sub('[^A-Za-z0-9]','_',blogTitle) + '.txt' + - tempMarker - ) - ) - if os.path.isfile(blogID) or os.path.isfile(blogID + '-'): - # Generate a ficticious blog name - blogID = os.path.normpath( - os.path.join( - config['datadir'], blogid[1:] + - re.sub('[^A-Za-z0-9]','_',blogTitle) + - tools.generateRandStr() + '.txt' + tempMarker - ) - ) + blogID = blog_document_name(request, appkey, blogid, content, publish, config) open(blogID, 'w').write(content.encode(config['blog_encoding'])) # Generate BlogID