Permalink
Browse files

subiendo vimpress-elric

  • Loading branch information...
1 parent a01cc21 commit fbfa0ed3258fab2704d4555d20b2e2a33e155b8c @elric committed Oct 28, 2009
Showing with 290 additions and 0 deletions.
  1. +9 −0 README
  2. +37 −0 doc/vimpress.txt
  3. +10 −0 makepw.py
  4. +222 −0 plugin/blog.vim
  5. +12 −0 syntax/blogsyntax.vim
View
9 README
@@ -1,5 +1,14 @@
*vimpress-elric"
+===============
This is only the vimpress script I made from bits and pieces of the
already existing ones. So far, this one contains all features
available through the other.
+
+Install:
+========
+Copy the files to ~/.vim in each folder.
+Edit blog.vim with your username and password (see
+instructions).
+Run :helptags ~/.vim/doc.
+
View
@@ -0,0 +1,37 @@
+*vimpress.txt*
+
+* Commands :
+============
+ ":BlogList [count]"
+ Lists recent <count> articles in the blog, default is 10, use 0 for all
+ ":BlogNew"
+ Opens page to write new article
+ ":BlogOpen <id>"
+ Opens the article <id> for edition
+ ":BlogSend"
+ Saves the article to the blog
+ ":BlogSave"
+ Saves the article as a draft
+
+* Common HTML tags
+==================
+
+<strong>bold</strong>
+<em>italics</em>
+<span style="text-decoration: underline;">underlinedtext</span>
+<code>code</code>
+<a href="link.org">link</a>
+<span style="text-decoration: line-through;">strikeline</span>
+
+<p style="text-align: center;">centertext</p>
+<p style="padding-left: 30px;">indentation</p>
+
+<h2>header123</h2>
+
+Bullets
+<ul>
+ <li>sdfsdfsdf</li>
+ <li>sdfsdfsdf</li>
+ <li>sdfsdfsdfs</li>
+ <li>sdfsdf</li>
+</ul>
View
@@ -0,0 +1,10 @@
+import sys
+from itertools import izip, cycle
+def xor_crypt_string(data, key):
+ return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
+
+if len(sys.argv) < 2:
+ print "Supply a password."
+ exit(0)
+
+print "Your XORed Password: '"+xor_crypt_string(sys.argv[1], 'seed123').encode("string-escape")+"'"
View
@@ -0,0 +1,222 @@
+" Copyright (C) 2007 Adrien Friggeri.
+"
+" This program is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 2, or (at your option)
+" any later version.
+"
+" This program is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this program; if not, write to the Free Software Foundation,
+" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+"
+" Maintainer: Adrien Friggeri <adrien@friggeri.net>
+" URL: http://www.friggeri.net/projets/vimblog/
+" Version: 0.9
+" Last Change: 2007 July 13
+"
+" Commands :
+" ":BlogList [count]"
+" Lists recent <count> articles in the blog, default is 10, use 0 for all
+" ":BlogNew"
+" Opens page to write new article
+" ":BlogOpen <id>"
+" Opens the article <id> for edition
+" ":BlogSend"
+" Saves the article to the blog
+" ":BlogSave"
+" Saves the article as a draft
+" Configuration :
+" Edit the "Settings" section (starts at line 51).
+"
+" If you wish to use UTW tags, you should install the following plugin :
+" http://blog.circlesixdesign.com/download/utw-rpc-autotag/
+" and set "enable_tags" to 1 on line 50
+"
+" Usage :
+" Just fill in the blanks, do not modify the highlighted parts and everything
+" should be ok.
+
+if !has("python")
+ finish
+endif
+
+command! -nargs=* BlogList exec("py blog_list_posts(<args>)")
+command! -nargs=0 BlogNew exec("py blog_new_post()")
+command! -nargs=0 BlogSend exec("py blog_send_post(1)")
+command! -nargs=0 BlogSave exec("py blog_send_post(0)")
+command! -nargs=1 BlogOpen exec('py blog_open_post(<f-args>)')
+python <<EOF
+# -*- coding: utf-8 -*-
+import urllib , urllib2 , vim , xml.dom.minidom , xmlrpclib , sys , string , re
+from itertools import izip, cycle
+def xor_crypt_string(data, key):
+ return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
+#####################
+# Settings #
+#####################
+
+enable_tags = 1
+blog_username = 'name'
+# Make password on command line like so:
+# python makepw.py mypassword
+# Then, insert it, single quoted, below:
+blog_password = xor_crypt_string('generated_enc_password', 'seed123')
+blog_url = 'https://yourblog.wordpress.com/xmlrpc.php'
+
+#####################
+# Do not edit below #
+#####################
+
+handler = xmlrpclib.ServerProxy(blog_url).metaWeblog
+edit = 1
+
+def blog_edit_off():
+ global edit
+ if edit:
+ edit = 0
+ for i in ["i","a","s","o","I","A","S","O"]:
+ vim.command('map '+i+' <nop>')
+
+def blog_edit_on():
+ global edit
+ if not edit:
+ edit = 1
+ for i in ["i","a","s","o","I","A","S","O"]:
+ vim.command('unmap '+i)
+
+def blog_send_post(publish):
+ def get_line(what):
+ start = 0
+ while not vim.current.buffer[start].startswith('"'+what):
+ start +=1
+ return start
+ def get_meta(what):
+ start = get_line(what)
+ end = start + 1
+ while not vim.current.buffer[end][0] == '"':
+ end +=1
+ return " ".join(vim.current.buffer[start:end]).split(":")[1].strip()
+
+ strid = get_meta("StrID")
+ title = get_meta("Title")
+ slug = get_meta("Slug")
+ cats = [i.strip() for i in get_meta("Cats").split(",")]
+ if enable_tags:
+ tags = get_meta("Tags")
+
+ text_start = 0
+ while not vim.current.buffer[text_start] == "\"========== Content ==========":
+ text_start +=1
+ text_start +=1
+ text = '\n'.join(vim.current.buffer[text_start:])
+
+ content = text
+
+ if enable_tags:
+ post = {
+ 'title': title,
+ 'description': content,
+ 'wp_slug': slug,
+ 'categories': cats,
+ 'mt_keywords': tags
+ }
+ else:
+ post = {
+ 'title': title,
+ 'description': content,
+ 'wp_slug': slug,
+ 'categories': cats,
+ }
+
+ if strid == '':
+ strid = handler.newPost('', blog_username,
+ blog_password, post, 1)
+
+ vim.current.buffer[get_line("StrID")] = "\"StrID : "+strid
+ else:
+ handler.editPost(strid, blog_username,
+ blog_password, post, 1)
+
+ vim.command('set nomodified')
+
+
+def blog_new_post():
+ def blog_get_cats():
+ l = handler.getCategories('', blog_username, blog_password)
+ s = ""
+ for i in l:
+ s = s + (i["description"].encode("utf-8"))+", "
+ if s != "":
+ return s[:-2]
+ else:
+ return s
+ del vim.current.buffer[:]
+ blog_edit_on()
+ vim.command("set syntax=blogsyntax")
+ vim.current.buffer[0] = "\"=========== Meta ============\n"
+ vim.current.buffer.append("\"StrID : ")
+ vim.current.buffer.append("\"Title : ")
+ vim.current.buffer.append("\"Slug : ")
+ vim.current.buffer.append("\"Cats : "+blog_get_cats())
+ if enable_tags:
+ vim.current.buffer.append("\"Tags : ")
+ vim.current.buffer.append("\"========== Content ==========\n")
+ vim.current.buffer.append("\n")
+ vim.current.window.cursor = (len(vim.current.buffer), 0)
+ vim.command('set nomodified')
+ vim.command('set textwidth=0')
+
+def blog_open_post(id):
+ try:
+ post = handler.getPost(id, blog_username, blog_password)
+ blog_edit_on()
+ vim.command("set syntax=blogsyntax")
+ del vim.current.buffer[:]
+ vim.current.buffer[0] = "\"=========== Meta ============\n"
+ vim.current.buffer.append("\"StrID : "+str(id))
+ vim.current.buffer.append("\"Title : "+(post["title"]).encode("utf-8"))
+ vim.current.buffer.append("\"Slug : "+(post["wp_slug"]).encode("utf-8"))
+ vim.current.buffer.append("\"Cats : "+",".join(post["categories"]).encode("utf-8"))
+ if enable_tags:
+ vim.current.buffer.append("\"Tags : "+(post["mt_keywords"]).encode("utf-8"))
+ vim.current.buffer.append("\"========== Content ==========\n")
+ content = (post["description"]).encode("utf-8")
+ for line in content.split('\n'):
+ vim.current.buffer.append(line)
+ text_start = 0
+ while not vim.current.buffer[text_start] == "\"========== Content ==========":
+ text_start +=1
+ text_start +=1
+ vim.current.window.cursor = (text_start+1, 0)
+ vim.command('set nomodified')
+ vim.command('set textwidth=0')
+ except:
+ sys.stderr.write("An error has occured")
+
+def blog_list_edit():
+ try:
+ row,col = vim.current.window.cursor
+ id = vim.current.buffer[row-1].split()[0]
+ blog_open_post(int(id))
+ except:
+ pass
+
+def blog_list_posts(count=10):
+ try:
+ allposts = handler.getRecentPosts('',blog_username, blog_password, count)
+ del vim.current.buffer[:]
+ vim.command("set syntax=blogsyntax")
+ vim.current.buffer[0] = "\"====== List of Posts ========="
+ for p in allposts:
+ vim.current.buffer.append(("%-7s\t" % p["postid"]) + (p["title"]).encode("utf-8"))
+ vim.command('set nomodified')
+ blog_edit_off()
+ vim.current.window.cursor = (2, 0)
+ vim.command('map <enter> :py blog_list_edit()<cr>')
+ except:
+ sys.stderr.write("An error has occured")
View
@@ -0,0 +1,12 @@
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+sy match blogeditorEntry "^ *[0-9]*\t.*$"
+sy match blogeditorComment '^".*$'
+sy match blogeditorIdent '^".*:'
+hi link blogeditorComment Comment
+hi link blogeditorEntry Directory
+hi link blogeditorIdent Function
+let b:current_syntax = "blogsyntax"

0 comments on commit fbfa0ed

Please sign in to comment.