Skip to content

Commit f86659d

Browse files
committed
Merge pull request vim-scripts#1 from raghur/master
Sure, thanks for your contribution.
2 parents 4002b6d + 0f65c94 commit f86659d

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

plugin/vimrepress.vim

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ tag_re = re.compile(tag_string % dict(url = '(?P<mkd_url>\S+)', file = '(?P<mkd_
126126
default_meta = dict(strid = "", title = "", slug = "",
127127
cats = "", tags = "", editformat = "Markdown", edittype = "post", textattach = '')
128128

129+
class Urllib2Transport(xmlrpclib.Transport):
130+
def __init__(self, opener=None, https=False, use_datetime=0):
131+
xmlrpclib.Transport.__init__(self, use_datetime)
132+
self.opener = opener or urllib2.build_opener()
133+
self.https = https
134+
135+
def request(self, host, handler, request_body, verbose=0):
136+
proto = ('http', 'https')[bool(self.https)]
137+
req = urllib2.Request('%s://%s%s' % (proto, host, handler), request_body)
138+
req.add_header('User-agent', self.user_agent)
139+
self.verbose = verbose
140+
return self.parse_response(self.opener.open(req))
141+
142+
143+
class HTTPProxyTransport(Urllib2Transport):
144+
def __init__(self, proxies, use_datetime=0):
145+
opener = urllib2.build_opener(urllib2.ProxyHandler(proxies))
146+
Urllib2Transport.__init__(self, opener, use_datetime)
147+
148+
129149
class VimPressException(Exception):
130150
pass
131151

@@ -247,7 +267,7 @@ def blog_upload_markdown_attachment(post_id, attach_name, mkd_rawtext):
247267

248268
# New Post, new file
249269
if post_id == '' or attach_name == '':
250-
attach_name = "vimpress_%s_mkd.txt" % hex(int(time.time()))[2:]
270+
attach_name = "vimpress_%s_mkd.odt" % hex(int(time.time()))[2:]
251271
overwrite = False
252272
else:
253273
overwrite = True
@@ -736,8 +756,14 @@ def blog_update_config():
736756
blog_password = config.get('password', '')
737757
if blog_password == '':
738758
blog_password = vim_input("Enter password for %s" % blog_url, True)
739-
mw_api = xmlrpclib.ServerProxy("%s/xmlrpc.php" % blog_url).metaWeblog
740-
wp_api = xmlrpclib.ServerProxy("%s/xmlrpc.php" % blog_url).wp
759+
transport = None
760+
if (os.getenv("http_proxy")):
761+
transport = HTTPProxyTransport ( {
762+
'http': os.getenv("http_proxy"),
763+
'https': os.getenv("https_proxy")
764+
})
765+
mw_api = xmlrpclib.ServerProxy("%s/xmlrpc.php" % blog_url, transport).metaWeblog
766+
wp_api = xmlrpclib.ServerProxy("%s/xmlrpc.php" % blog_url, transport).wp
741767

742768
# Setting tags and categories for completefunc
743769
terms = []
@@ -828,3 +854,4 @@ def blog_wise_open_view():
828854
vim.command(":new")
829855
vim.command('setl syntax=blogsyntax')
830856
vim.command('setl completefunc=Completable')
857+
vim.command('setl ft=markdown')

0 commit comments

Comments
 (0)