Files
2012-02-21 01:15:00 -05:00

1 line
35 KiB
JSON

[{"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1300730208.873632, "message": "aposdpoajdpaod", "group_id": 7200, "id": 400670}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301575078.0250931, "message": "Messages\n++++++++\n\n :ConvoreCreateMessage <message> - Write a message to the current topic\n \n :ConvorePostCurrent - Posts the current buffer, preserving newlines, or\n visual selection - :`<,`>ConvorePostCurrent", "group_id": 7200, "id": 491184}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301574885.7142689, "message": "rng_start = int(vim.eval(`a:line1`)) - 1\nrng_end = int(vim.eval(`a:line2`))\nif int(vim.eval(`a:count`)):\n code = `\\n`.join(vim.current.buffer[rng_start:rng_end])\nelse:\n code = `\\n`.join(vim.current.buffer)", "group_id": 7200, "id": 491165}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301576356.4829459, "message": "\"=============================================================================\n\" File: convore.vim\n\" Author: Dejan Noveski <dr.mote@gmail.com>\n\" Last Change: 21-Mar-2011.\n\" Version: 0.4\n\" WebPage: http://github.com/dekomote/convore.vim\n\" Description: Reader plugin for https://convore.com\n\" Usage:\n\" Put the script in plugins dir, or :source it.\n\" :Convore - Opens your groups list\n\" Hit return on top of a group or topic to advance into it. Hit 'b' inside\n\" the buffer to go back from messages to topics and from topics to groups.\n\"\n\" Check README for detailed instructions\n\"\n\" Notes:\n\" Set g:convore_user and g:convore_password in the script or in .vimrc to\n\" your convore auth info.\n\" Requires vim compiled with +python.\n\"\n\"\n\n\" Check if vim is compiled with python support.\nif !has('python')\n echo \"Error: Required vim compiled with +python\"\n finish\nendif\n\n\" Set auth info here if you don't want to set it in .vimrc\n\" .vimrc overrides this.\nif !exists('g:convore_user')\n let g:convore_user = ''\n let g:convore_password = ''\nendif\n\n\" HTTP request timeout set to 20 seconds. If you have a very very slow\n\" connection and you have issues with the requests, try bump this number up.\nif !exists('g:convore_api_timeout')\n let g:convore_api_timeout = 20\nendif\n\n\" Everything is displayed in a scratch buffer named CONVORE.\nlet g:convore_scratch_buffer = 'CONVORE'\n\n\" Function that opens or navigates to the scratch buffer.\nfunction! s:ConvoreScratchBufferOpen(name)\n \n let scr_bufnum = bufnr(a:name)\n if scr_bufnum == -1\n exe \"new \" . a:name \n else\n let scr_winnum = bufwinnr(scr_bufnum)\n if scr_winnum != -1\n if winnr() != scr_winnum\n exe scr_winnum . \"wincmd w\"\n endif\n else\n exe \"split +buffer\" . scr_bufnum\n endif\n endif\n call ConvoreScratchBuffer()\nendfunction\n\n\" After opening the scratch buffer, this sets some properties for it.\nfunction! ConvoreScratchBuffer()\n setlocal buftype=nofile\n setlocal bufhidden=hide\n setlocal noswapfile\n setlocal buflisted\n setlocal cursorline\n setlocal filetype=rst\nendfunction\n\n\n\" Define some python functions here\npython << EOF\nimport urllib2, base64, exceptions, vim, urllib \ntry:\n import simplejson as json\nexcept ImportError:\n import json\n\nDEFAULT_SCRATCH_NAME = vim.eval('g:convore_scratch_buffer')\nUSERNAME = vim.eval('g:convore_user')\nPASSWORD = vim.eval('g:convore_password')\nCONVORE_URL = 'https://convore.com'\nGROUPS_LIST_URL = CONVORE_URL + '/api/groups.json'\n\ndef request(url, post_data = None):\n \"\"\" Simple function for http requests using urllib2 \"\"\"\n\n api_timeout = float(vim.eval('g:convore_api_timeout'))\n\n request = urllib2.Request(url)\n base64auth = base64.encodestring('%s:%s' % (USERNAME, PASSWORD)).replace(\n '\n', '')\n request.add_header(\"Authorization\", \"Basic %s\" % base64auth)\n try:\n if post_data:\n post_data = urllib.urlencode(post_data)\n response = urllib2.urlopen(request, post_data, api_timeout)\n return json.loads(response.read())\n except exceptions.Exception, e:\n print e\n return None\n\ndef scratch_buffer(sb_name = DEFAULT_SCRATCH_NAME):\n \"\"\" Opens a scratch buffer from python \"\"\"\n vim.command(\"call s:ConvoreScratchBufferOpen('%s')\" % sb_name)\n\ndef utf8_code(code):\n enc = vim.eval('&fenc') or vim.eval('&enc')\n return code.decode(enc, 'ignore').encode('utf-8')\nEOF\n\n\n\" Function that displays user's groups\n\" Locally maps <CR> to call ConvoreTopicsList\nfunction! ConvoreGroupsList()\npython << EOF\n\nimport vim\ngroups = request(GROUPS_LIST_URL).get(\"groups\")\n\n# Initialize the scratch buffer\nscratch_buffer()\ndel vim.current.buffer[:]\nvim.current.buffer[0] = \"%s's CONVORE GROUPS\" % USERNAME\nvim.current.buffer.append(79 * \"#\")\n\n# Write group info in the buffer\nfor group in groups:\n group_name = group.get(\"name\").encode('utf-8')\n group_url = CONVORE_URL + group.get(\"url\").encode('utf-8') \n topics_count = group.get(\"topics_count\")\n unread_count = group.get(\"unread\")\n group_id = group.get(\"id\").encode(\"utf-8\")\n vim.current.buffer.append(\"%s > Topics: %s | Unread: %s | [%s] (convore_gid:%s)\" % (\n group_name, topics_count, unread_count,\n group_url, group_id))\n vim.current.buffer.append(79 * \"-\")\nvim.command(\"map <buffer> <CR> <Esc>:call ConvoreTopicsList()<CR>\")\n\nEOF\nendfunction\n\n\" Function that displays \nfunction! ConvoreTopicsList(...)\npython << EOF\nimport vim\nimport re\n\nif int(vim.eval(\"a:0\")) > 1:\n group_id = vim.eval(\"a:1\")\n group_name = vim.eval(\"a:2\")\nelse:\n line = vim.current.line\n group_re = re.search(\"(convore_gid:([0-9]+))\", line)\n if group_re:\n gn_re = re.search(\"^(.*) > Topics: [0-9]+\", line)\n group_name = gn_re.group(1)\n group_id = group_re.group(1)\n\nif group_name and group_id:\n vim.command(\"let g:convore_current_group_id=%s\" % group_id)\n vim.command(\"let g:convore_current_group_name='%s'\" % group_name)\n topics = request(CONVORE_URL + \"/api/groups/%s/topics.json\" % group_id).get(\"topics\")\n scratch_buffer()\n del vim.current.buffer[:]\n vim.current.buffer[0] = 'TOPICS IN GROUP \"%s\"' % group_name \n vim.current.buffer.append(79 * \"#\")\n for topic in topics:\n topic_name = topic.get(\"name\").encode('utf-8')\n message_count = topic.get(\"message_count\")\n unread_count = topic.get(\"unread\")\n topic_id = topic.get(\"id\").encode(\"utf-8\")\n topic_url = CONVORE_URL + topic.get(\"url\").encode(\"utf-8\") \n vim.current.buffer.append(\"%s > Messages: %s | Unread: %s | [%s] (convore_tid:%s)\" % (\n topic_name, message_count, unread_count,\n topic_url, topic_id))\n vim.current.buffer.append(79 * \"-\")\n vim.command(\"map <buffer> <CR> <Esc>:call ConvoreMessagesList()<CR>\")\n vim.command(\"map <buffer> b <Esc>:call ConvoreGroupsList()<CR>\")\n vim.command(\"command! -nargs=1 ConvoreCreateTopic call ConvoreCreateTopic('%s', '<args>')\" % group_id)\nEOF\nendfunction\n\nfunction! ConvoreMessagesList(...)\npython << EOF\nimport vim\nimport re, datetime\n\nif int(vim.eval(\"a:0\")) > 1:\n topic_id = vim.eval(\"a:1\")\n topic_name = vim.eval(\"a:2\")\nelse:\n line = vim.current.line\n topic_re = re.search(\"(convore_tid:([0-9]+))\", line)\n if topic_re:\n tn_re = re.search(\"^(.*) > Messages: [0-9]+\", line)\n topic_name = tn_re.group(1)\n topic_id = topic_re.group(1)\n\nif topic_name and topic_id:\n vim.command(\"let g:convore_current_topic_id=%s\" % topic_id)\n vim.command(\"\"\"let g:convore_current_topic_name=\"%s\" \"\"\" % topic_name)\n messages = request(CONVORE_URL + \"/api/topics/%s/messages.json\" % topic_id).get(\"messages\")\n scratch_buffer()\n del vim.current.buffer[:]\n vim.current.buffer[0] = 'MESSAGES IN TOPIC ' + vim.eval(\"g:convore_current_group_name\") + \" > \" + topic_name\n vim.current.buffer.append(79 * \"#\")\n for message in messages:\n body = message.get(\"message\").encode('utf-8')\n user = message.get(\"user\").get(\"username\").encode(\"utf-8\") \n date_created = datetime.datetime.fromtimestamp(message.get(\"date_created\")).strftime(\"%a %b %d %H:%M:%S %Y\")\n stars = message.get(\"stars\")\n message_id = message.get(\"id\").encode(\"utf-8\")\n vim.current.buffer.append(body.split(\"\n\"))\n vim.current.buffer.append(\"%s | %s | %s\" % (user, date_created, \", \".join([\"\u2605\" + star.get(\"user\").get(\"username\").encode(\"utf-8\") for star in stars])))\n vim.current.buffer.append(79 * \"-\")\n vim.command(\"map <buffer> b <Esc>:call ConvoreTopicsList(g:convore_current_group_id, g:convore_current_group_name)<CR>\")\n vim.command(\"command! -nargs=1 ConvoreCreateMessage call ConvoreCreateMessage('%s', '<args>')\" % topic_id)\n vim.command(\"command! -nargs=* -range=0 ConvorePostCurrent call ConvorePostCurrent(<line1>, <line2>, <count>, '%s')\" % topic_id)\n vim.command(\"map <buffer> <CR> <Esc>ConvoreCreateMessage \")\nEOF\nendfunction\n\n\nfunction! ConvoreCreateGroup(name, kind)\npython << EOF\nimport vim\n\ngroup_name = vim.eval(\"a:name\")\ngroup_kind = vim.eval(\"a:kind\")\ncreate_url = CONVORE_URL + '/api/groups/create.json'\n\nresp = request(create_url, {\"name\": group_name, \"kind\": group_kind})\nif resp:\n try:\n group_id = resp.get(\"group\").get(\"id\").encode(\"utf-8\")\n vim.command(\"call ConvoreTopicsList('%s', '%s')\" % (str(group_id), str(group_name),))\n except Exception, e:\n print e\nEOF\nendfunction\n\n\nfunction! ConvoreCreateTopic(group_id, name)\npython << EOF\nimport vim\n\ngroup_id = vim.eval(\"a:group_id\")\ntopic_name = vim.eval(\"a:name\")\ncreate_url = CONVORE_URL + '/api/groups/%s/topics/create.json' % group_id\n\nresp = request(create_url, {\"name\": topic_name, \"group_id\": group_id})\nif resp:\n try:\n topic_id = resp.get(\"topic\").get(\"id\").encode(\"utf-8\")\n vim.command(\"call ConvoreMessagesList('%s', '%s')\" % (str(topic_id), str(topic_name),))\n except Exception, e:\n print e\nEOF\nendfunction\n\nfunction! ConvoreCreateMessage(topic_id, message)\npython << EOF\nimport vim\n\ntopic_id = vim.eval(\"a:topic_id\")\nmessage = vim.eval(\"a:message\")\ncreate_url = CONVORE_URL + '/api/topics/%s/messages/create.json' % topic_id\n\nresp = request(create_url, {\"message\": message, \"topic_id\": topic_id})\nif resp:\n try:\n vim.command(\"call ConvoreMessagesList('%s', '%s')\" % (str(topic_id), str(vim.eval(\"g:convore_current_topic_name\")),))\n except Exception, e:\n print e\nEOF\nendfunction\n\nfunction! ConvorePostCurrent(line1, line2, count, topic_id)\npython << EOF\nimport vim\nrng_start = int(vim.eval('a:line1')) - 1\nrng_end = int(vim.eval('a:line2'))\nif int(vim.eval('a:count')):\n code = '\n'.join(vim.current.buffer[rng_start:rng_end])\nelse:\n code = '\n'.join(vim.current.buffer)\n\nvim.command('call ConvoreCreateMessage(\"%s\", \"%s\")' % (topic_id, utf8_code(code).replace('\"','\\\"'),))\nEOF\nendfunction\n\ncommand! -nargs=0 Convore call ConvoreGroupsList()\ncommand! -nargs=1 ConvoreCreateGroup call ConvoreCreateGroup(\"<args>\", \"public\")\ncommand! -nargs=1 ConvoreCreatePrivateGroup call ConvoreCreateGroup(\"<args>\", \"private\")", "group_id": 7200, "id": 491385}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301576540.3063791, "message": "\"=============================================================================\n\" File: convore.vim\n\" Author: Dejan Noveski <dr.mote@gmail.com>\n\" Last Change: 21-Mar-2011.\n\" Version: 0.4\n\" WebPage: http://github.com/dekomote/convore.vim\n\" Description: Reader plugin for https://convore.com\n\" Usage:\n\" Put the script in plugins dir, or :source it.\n\" :Convore - Opens your groups list\n\" Hit return on top of a group or topic to advance into it. Hit 'b' inside\n\" the buffer to go back from messages to topics and from topics to groups.\n\"\n\" Check README for detailed instructions\n\"\n\" Notes:\n\" Set g:convore_user and g:convore_password in the script or in .vimrc to\n\" your convore auth info.\n\" Requires vim compiled with +python.\n\"\n\"\n\n\" Check if vim is compiled with python support.\nif !has('python')\n echo \"Error: Required vim compiled with +python\"\n finish\nendif\n\n\" Set auth info here if you don't want to set it in .vimrc\n\" .vimrc overrides this.\nif !exists('g:convore_user')\n let g:convore_user = ''\n let g:convore_password = ''\nendif\n\n\" HTTP request timeout set to 20 seconds. If you have a very very slow\n\" connection and you have issues with the requests, try bump this number up.\nif !exists('g:convore_api_timeout')\n let g:convore_api_timeout = 20\nendif\n\n\" Everything is displayed in a scratch buffer named CONVORE.\nlet g:convore_scratch_buffer = 'CONVORE'\n\n\" Function that opens or navigates to the scratch buffer.\nfunction! s:ConvoreScratchBufferOpen(name)\n \n let scr_bufnum = bufnr(a:name)\n if scr_bufnum == -1\n exe \"new \" . a:name \n else\n let scr_winnum = bufwinnr(scr_bufnum)\n if scr_winnum != -1\n if winnr() != scr_winnum\n exe scr_winnum . \"wincmd w\"\n endif\n else\n exe \"split +buffer\" . scr_bufnum\n endif\n endif\n call ConvoreScratchBuffer()\nendfunction\n\n\" After opening the scratch buffer, this sets some properties for it.\nfunction! ConvoreScratchBuffer()\n setlocal buftype=nofile\n setlocal bufhidden=hide\n setlocal noswapfile\n setlocal buflisted\n setlocal cursorline\n setlocal filetype=rst\nendfunction\n\n\n\" Define some python functions here\npython << EOF\nimport urllib2, base64, exceptions, vim, urllib \ntry:\n import simplejson as json\nexcept ImportError:\n import json\n\nDEFAULT_SCRATCH_NAME = vim.eval('g:convore_scratch_buffer')\nUSERNAME = vim.eval('g:convore_user')\nPASSWORD = vim.eval('g:convore_password')\nCONVORE_URL = 'https://convore.com'\nGROUPS_LIST_URL = CONVORE_URL + '/api/groups.json'\n\ndef request(url, post_data = None):\n \"\"\" Simple function for http requests using urllib2 \"\"\"\n\n api_timeout = float(vim.eval('g:convore_api_timeout'))\n\n request = urllib2.Request(url)\n base64auth = base64.encodestring('%s:%s' % (USERNAME, PASSWORD)).replace(\n '\n', '')\n request.add_header(\"Authorization\", \"Basic %s\" % base64auth)\n try:\n if post_data:\n post_data = urllib.urlencode(post_data)\n response = urllib2.urlopen(request, post_data, api_timeout)\n return json.loads(response.read())\n except exceptions.Exception, e:\n print e\n return None\n\ndef scratch_buffer(sb_name = DEFAULT_SCRATCH_NAME):\n \"\"\" Opens a scratch buffer from python \"\"\"\n vim.command(\"call s:ConvoreScratchBufferOpen('%s')\" % sb_name)\n\ndef utf8_code(code):\n enc = vim.eval('&fenc') or vim.eval('&enc')\n return code.decode(enc, 'ignore').encode('utf-8')\n\ndef escape_dbl_quotes(msg):\n return msg.replace('\"', '\\\"')\nEOF\n\n\n\" Function that displays user's groups\n\" Locally maps <CR> to call ConvoreTopicsList\nfunction! ConvoreGroupsList()\npython << EOF\n\nimport vim\ngroups = request(GROUPS_LIST_URL).get(\"groups\")\n\n# Initialize the scratch buffer\nscratch_buffer()\ndel vim.current.buffer[:]\nvim.current.buffer[0] = \"%s's CONVORE GROUPS\" % USERNAME\nvim.current.buffer.append(79 * \"#\")\n\n# Write group info in the buffer\nfor group in groups:\n group_name = group.get(\"name\").encode('utf-8')\n group_url = CONVORE_URL + group.get(\"url\").encode('utf-8') \n topics_count = group.get(\"topics_count\")\n unread_count = group.get(\"unread\")\n group_id = group.get(\"id\").encode(\"utf-8\")\n vim.current.buffer.append(\"%s > Topics: %s | Unread: %s | [%s] (convore_gid:%s)\" % (\n group_name, topics_count, unread_count,\n group_url, group_id))\n vim.current.buffer.append(79 * \"-\")\nvim.command(\"map <buffer> <CR> <Esc>:call ConvoreTopicsList()<CR>\")\n\nEOF\nendfunction\n\n\" Function that displays \nfunction! ConvoreTopicsList(...)\npython << EOF\nimport vim\nimport re\n\nif int(vim.eval(\"a:0\")) > 1:\n group_id = vim.eval(\"a:1\")\n group_name = vim.eval(\"a:2\")\nelse:\n line = vim.current.line\n group_re = re.search(\"(convore_gid:([0-9]+))\", line)\n if group_re:\n gn_re = re.search(\"^(.*) > Topics: [0-9]+\", line)\n group_name = gn_re.group(1)\n group_id = group_re.group(1)\n\nif group_name and group_id:\n vim.command(\"let g:convore_current_group_id=%s\" % group_id)\n vim.command(\"let g:convore_current_group_name='%s'\" % group_name)\n topics = request(CONVORE_URL + \"/api/groups/%s/topics.json\" % group_id).get(\"topics\")\n scratch_buffer()\n del vim.current.buffer[:]\n vim.current.buffer[0] = 'TOPICS IN GROUP \"%s\"' % group_name \n vim.current.buffer.append(79 * \"#\")\n for topic in topics:\n topic_name = topic.get(\"name\").encode('utf-8')\n message_count = topic.get(\"message_count\")\n unread_count = topic.get(\"unread\")\n topic_id = topic.get(\"id\").encode(\"utf-8\")\n topic_url = CONVORE_URL + topic.get(\"url\").encode(\"utf-8\") \n vim.current.buffer.append(\"%s > Messages: %s | Unread: %s | [%s] (convore_tid:%s)\" % (\n topic_name, message_count, unread_count,\n topic_url, topic_id))\n vim.current.buffer.append(79 * \"-\")\n vim.command(\"map <buffer> <CR> <Esc>:call ConvoreMessagesList()<CR>\")\n vim.command(\"map <buffer> b <Esc>:call ConvoreGroupsList()<CR>\")\n vim.command(\"command! -nargs=1 ConvoreCreateTopic call ConvoreCreateTopic('%s', '<args>')\" % group_id)\nEOF\nendfunction\n\nfunction! ConvoreMessagesList(...)\npython << EOF\nimport vim\nimport re, datetime\n\nif int(vim.eval(\"a:0\")) > 1:\n topic_id = vim.eval(\"a:1\")\n topic_name = vim.eval(\"a:2\")\nelse:\n line = vim.current.line\n topic_re = re.search(\"(convore_tid:([0-9]+))\", line)\n if topic_re:\n tn_re = re.search(\"^(.*) > Messages: [0-9]+\", line)\n topic_name = tn_re.group(1)\n topic_id = topic_re.group(1)\n\nif topic_name and topic_id:\n vim.command(\"let g:convore_current_topic_id=%s\" % topic_id)\n vim.command(\"\"\"let g:convore_current_topic_name=\"%s\" \"\"\" % topic_name)\n messages = request(CONVORE_URL + \"/api/topics/%s/messages.json\" % topic_id).get(\"messages\")\n scratch_buffer()\n del vim.current.buffer[:]\n vim.current.buffer[0] = 'MESSAGES IN TOPIC ' + vim.eval(\"g:convore_current_group_name\") + \" > \" + topic_name\n vim.current.buffer.append(79 * \"#\")\n for message in messages:\n body = message.get(\"message\").encode('utf-8')\n user = message.get(\"user\").get(\"username\").encode(\"utf-8\") \n date_created = datetime.datetime.fromtimestamp(message.get(\"date_created\")).strftime(\"%a %b %d %H:%M:%S %Y\")\n stars = message.get(\"stars\")\n message_id = message.get(\"id\").encode(\"utf-8\")\n vim.current.buffer.append(body.split(\"\n\"))\n vim.current.buffer.append(\"%s | %s | %s\" % (user, date_created, \", \".join([\"\u2605\" + star.get(\"user\").get(\"username\").encode(\"utf-8\") for star in stars])))\n vim.current.buffer.append(79 * \"-\")\n vim.command(\"map <buffer> b <Esc>:call ConvoreTopicsList(g:convore_current_group_id, g:convore_current_group_name)<CR>\")\n vim.command(\"command! -nargs=1 ConvoreCreateMessage call ConvoreCreateMessage('%s', '<args>')\" % topic_id)\n vim.command(\"command! -nargs=* -range=0 ConvorePostCurrent call ConvorePostCurrent(<line1>, <line2>, <count>, '%s')\" % topic_id)\n vim.command(\"map <buffer> <CR> <Esc>ConvoreCreateMessage \")\nEOF\nendfunction\n\n\nfunction! ConvoreCreateGroup(name, kind)\npython << EOF\nimport vim\n\ngroup_name = vim.eval(\"a:name\")\ngroup_kind = vim.eval(\"a:kind\")\ncreate_url = CONVORE_URL + '/api/groups/create.json'\n\nresp = request(create_url, {\"name\": group_name, \"kind\": group_kind})\nif resp:\n try:\n group_id = resp.get(\"group\").get(\"id\").encode(\"utf-8\")\n vim.command(\"call ConvoreTopicsList('%s', '%s')\" % (str(group_id), str(group_name),))\n except Exception, e:\n print e\nEOF\nendfunction\n\n\nfunction! ConvoreCreateTopic(group_id, name)\npython << EOF\nimport vim\n\ngroup_id = vim.eval(\"a:group_id\")\ntopic_name = vim.eval(\"a:name\")\ncreate_url = CONVORE_URL + '/api/groups/%s/topics/create.json' % group_id\n\nresp = request(create_url, {\"name\": topic_name, \"group_id\": group_id})\nif resp:\n try:\n topic_id = resp.get(\"topic\").get(\"id\").encode(\"utf-8\")\n vim.command(\"call ConvoreMessagesList('%s', '%s')\" % (str(topic_id), str(topic_name),))\n except Exception, e:\n print e\nEOF\nendfunction\n\nfunction! ConvoreCreateMessage(topic_id, message)\npython << EOF\nimport vim\n\ntopic_id = vim.eval(\"a:topic_id\")\nmessage = vim.eval(\"a:message\")\ncreate_url = CONVORE_URL + '/api/topics/%s/messages/create.json' % topic_id\n\nresp = request(create_url, {\"message\": message, \"topic_id\": topic_id})\nif resp:\n try:\n vim.command('call ConvoreMessagesList(\"%s\", \"%s\")' % (topic_id, vim.eval(\"g:convore_current_topic_name\"),))\n except Exception, e:\n print e\nEOF\nendfunction\n\nfunction! ConvorePostCurrent(line1, line2, count, topic_id)\npython << EOF\nimport vim\nrng_start = int(vim.eval('a:line1')) - 1\nrng_end = int(vim.eval('a:line2'))\nif int(vim.eval('a:count')):\n code = '\n'.join(vim.current.buffer[rng_start:rng_end])\nelse:\n code = '\n'.join(vim.current.buffer)\n\nvim.command('call ConvoreCreateMessage(\"%s\", \"%s\")' % (topic_id, utf8_code(code).replace('\"','\\\"'),))\nEOF\nendfunction\n\ncommand! -nargs=0 Convore call ConvoreGroupsList()\ncommand! -nargs=1 ConvoreCreateGroup call ConvoreCreateGroup(\"<args>\", \"public\")\ncommand! -nargs=1 ConvoreCreatePrivateGroup call ConvoreCreateGroup(\"<args>\", \"private\")", "group_id": 7200, "id": 491415}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301576367.2942779, "message": "\"=============================================================================\n\" File: convore.vim\n\" Author: Dejan Noveski <dr.mote@gmail.com>\n\" Last Change: 21-Mar-2011.\n\" Version: 0.4\n\" WebPage: http://github.com/dekomote/convore.vim\n\" Description: Reader plugin for https://convore.com\n\" Usage:\n\" Put the script in plugins dir, or :source it.\n\" :Convore - Opens your groups list\n\" Hit return on top of a group or topic to advance into it. Hit 'b' inside\n\" the buffer to go back from messages to topics and from topics to groups.\n\"\n\" Check README for detailed instructions\n\"\n\" Notes:\n\" Set g:convore_user and g:convore_password in the script or in .vimrc to\n\" your convore auth info.\n\" Requires vim compiled with +python.\n\"\n\"\n\n\" Check if vim is compiled with python support.\nif !has('python')\n echo \"Error: Required vim compiled with +python\"\n finish\nendif\n\n\" Set auth info here if you don't want to set it in .vimrc\n\" .vimrc overrides this.\nif !exists('g:convore_user')\n let g:convore_user = ''\n let g:convore_password = ''\nendif\n\n\" HTTP request timeout set to 20 seconds. If you have a very very slow\n\" connection and you have issues with the requests, try bump this number up.\nif !exists('g:convore_api_timeout')\n let g:convore_api_timeout = 20\nendif\n\n\" Everything is displayed in a scratch buffer named CONVORE.\nlet g:convore_scratch_buffer = 'CONVORE'\n\n\" Function that opens or navigates to the scratch buffer.\nfunction! s:ConvoreScratchBufferOpen(name)\n \n let scr_bufnum = bufnr(a:name)\n if scr_bufnum == -1\n exe \"new \" . a:name \n else\n let scr_winnum = bufwinnr(scr_bufnum)\n if scr_winnum != -1\n if winnr() != scr_winnum\n exe scr_winnum . \"wincmd w\"\n endif\n else\n exe \"split +buffer\" . scr_bufnum\n endif\n endif\n call ConvoreScratchBuffer()\nendfunction\n\n\" After opening the scratch buffer, this sets some properties for it.\nfunction! ConvoreScratchBuffer()\n setlocal buftype=nofile\n setlocal bufhidden=hide\n setlocal noswapfile\n setlocal buflisted\n setlocal cursorline\n setlocal filetype=rst\nendfunction\n\n\n\" Define some python functions here\npython << EOF\nimport urllib2, base64, exceptions, vim, urllib \ntry:\n import simplejson as json\nexcept ImportError:\n import json\n\nDEFAULT_SCRATCH_NAME = vim.eval('g:convore_scratch_buffer')\nUSERNAME = vim.eval('g:convore_user')\nPASSWORD = vim.eval('g:convore_password')\nCONVORE_URL = 'https://convore.com'\nGROUPS_LIST_URL = CONVORE_URL + '/api/groups.json'\n\ndef request(url, post_data = None):\n \"\"\" Simple function for http requests using urllib2 \"\"\"\n\n api_timeout = float(vim.eval('g:convore_api_timeout'))\n\n request = urllib2.Request(url)\n base64auth = base64.encodestring('%s:%s' % (USERNAME, PASSWORD)).replace(\n '\n', '')\n request.add_header(\"Authorization\", \"Basic %s\" % base64auth)\n try:\n if post_data:\n post_data = urllib.urlencode(post_data)\n response = urllib2.urlopen(request, post_data, api_timeout)\n return json.loads(response.read())\n except exceptions.Exception, e:\n print e\n return None\n\ndef scratch_buffer(sb_name = DEFAULT_SCRATCH_NAME):\n \"\"\" Opens a scratch buffer from python \"\"\"\n vim.command(\"call s:ConvoreScratchBufferOpen('%s')\" % sb_name)\n\ndef utf8_code(code):\n enc = vim.eval('&fenc') or vim.eval('&enc')\n return code.decode(enc, 'ignore').encode('utf-8')\nEOF\n\n\n\" Function that displays user's groups\n\" Locally maps <CR> to call ConvoreTopicsList\nfunction! ConvoreGroupsList()\npython << EOF\n\nimport vim\ngroups = request(GROUPS_LIST_URL).get(\"groups\")\n\n# Initialize the scratch buffer\nscratch_buffer()\ndel vim.current.buffer[:]\nvim.current.buffer[0] = \"%s's CONVORE GROUPS\" % USERNAME\nvim.current.buffer.append(79 * \"#\")\n\n# Write group info in the buffer\nfor group in groups:\n group_name = group.get(\"name\").encode('utf-8')\n group_url = CONVORE_URL + group.get(\"url\").encode('utf-8') \n topics_count = group.get(\"topics_count\")\n unread_count = group.get(\"unread\")\n group_id = group.get(\"id\").encode(\"utf-8\")\n vim.current.buffer.append(\"%s > Topics: %s | Unread: %s | [%s] (convore_gid:%s)\" % (\n group_name, topics_count, unread_count,\n group_url, group_id))\n vim.current.buffer.append(79 * \"-\")\nvim.command(\"map <buffer> <CR> <Esc>:call ConvoreTopicsList()<CR>\")\n\nEOF\nendfunction\n\n\" Function that displays \nfunction! ConvoreTopicsList(...)\npython << EOF\nimport vim\nimport re\n\nif int(vim.eval(\"a:0\")) > 1:\n group_id = vim.eval(\"a:1\")\n group_name = vim.eval(\"a:2\")\nelse:\n line = vim.current.line\n group_re = re.search(\"(convore_gid:([0-9]+))\", line)\n if group_re:\n gn_re = re.search(\"^(.*) > Topics: [0-9]+\", line)\n group_name = gn_re.group(1)\n group_id = group_re.group(1)\n\nif group_name and group_id:\n vim.command(\"let g:convore_current_group_id=%s\" % group_id)\n vim.command(\"let g:convore_current_group_name='%s'\" % group_name)\n topics = request(CONVORE_URL + \"/api/groups/%s/topics.json\" % group_id).get(\"topics\")\n scratch_buffer()\n del vim.current.buffer[:]\n vim.current.buffer[0] = 'TOPICS IN GROUP \"%s\"' % group_name \n vim.current.buffer.append(79 * \"#\")\n for topic in topics:\n topic_name = topic.get(\"name\").encode('utf-8')\n message_count = topic.get(\"message_count\")\n unread_count = topic.get(\"unread\")\n topic_id = topic.get(\"id\").encode(\"utf-8\")\n topic_url = CONVORE_URL + topic.get(\"url\").encode(\"utf-8\") \n vim.current.buffer.append(\"%s > Messages: %s | Unread: %s | [%s] (convore_tid:%s)\" % (\n topic_name, message_count, unread_count,\n topic_url, topic_id))\n vim.current.buffer.append(79 * \"-\")\n vim.command(\"map <buffer> <CR> <Esc>:call ConvoreMessagesList()<CR>\")\n vim.command(\"map <buffer> b <Esc>:call ConvoreGroupsList()<CR>\")\n vim.command(\"command! -nargs=1 ConvoreCreateTopic call ConvoreCreateTopic('%s', '<args>')\" % group_id)\nEOF\nendfunction\n\nfunction! ConvoreMessagesList(...)\npython << EOF\nimport vim\nimport re, datetime\n\nif int(vim.eval(\"a:0\")) > 1:\n topic_id = vim.eval(\"a:1\")\n topic_name = vim.eval(\"a:2\")\nelse:\n line = vim.current.line\n topic_re = re.search(\"(convore_tid:([0-9]+))\", line)\n if topic_re:\n tn_re = re.search(\"^(.*) > Messages: [0-9]+\", line)\n topic_name = tn_re.group(1)\n topic_id = topic_re.group(1)\n\nif topic_name and topic_id:\n vim.command(\"let g:convore_current_topic_id=%s\" % topic_id)\n vim.command(\"\"\"let g:convore_current_topic_name=\"%s\" \"\"\" % topic_name)\n messages = request(CONVORE_URL + \"/api/topics/%s/messages.json\" % topic_id).get(\"messages\")\n scratch_buffer()\n del vim.current.buffer[:]\n vim.current.buffer[0] = 'MESSAGES IN TOPIC ' + vim.eval(\"g:convore_current_group_name\") + \" > \" + topic_name\n vim.current.buffer.append(79 * \"#\")\n for message in messages:\n body = message.get(\"message\").encode('utf-8')\n user = message.get(\"user\").get(\"username\").encode(\"utf-8\") \n date_created = datetime.datetime.fromtimestamp(message.get(\"date_created\")).strftime(\"%a %b %d %H:%M:%S %Y\")\n stars = message.get(\"stars\")\n message_id = message.get(\"id\").encode(\"utf-8\")\n vim.current.buffer.append(body.split(\"\n\"))\n vim.current.buffer.append(\"%s | %s | %s\" % (user, date_created, \", \".join([\"\u2605\" + star.get(\"user\").get(\"username\").encode(\"utf-8\") for star in stars])))\n vim.current.buffer.append(79 * \"-\")\n vim.command(\"map <buffer> b <Esc>:call ConvoreTopicsList(g:convore_current_group_id, g:convore_current_group_name)<CR>\")\n vim.command(\"command! -nargs=1 ConvoreCreateMessage call ConvoreCreateMessage('%s', '<args>')\" % topic_id)\n vim.command(\"command! -nargs=* -range=0 ConvorePostCurrent call ConvorePostCurrent(<line1>, <line2>, <count>, '%s')\" % topic_id)\n vim.command(\"map <buffer> <CR> <Esc>ConvoreCreateMessage \")\nEOF\nendfunction\n\n\nfunction! ConvoreCreateGroup(name, kind)\npython << EOF\nimport vim\n\ngroup_name = vim.eval(\"a:name\")\ngroup_kind = vim.eval(\"a:kind\")\ncreate_url = CONVORE_URL + '/api/groups/create.json'\n\nresp = request(create_url, {\"name\": group_name, \"kind\": group_kind})\nif resp:\n try:\n group_id = resp.get(\"group\").get(\"id\").encode(\"utf-8\")\n vim.command(\"call ConvoreTopicsList('%s', '%s')\" % (str(group_id), str(group_name),))\n except Exception, e:\n print e\nEOF\nendfunction\n\n\nfunction! ConvoreCreateTopic(group_id, name)\npython << EOF\nimport vim\n\ngroup_id = vim.eval(\"a:group_id\")\ntopic_name = vim.eval(\"a:name\")\ncreate_url = CONVORE_URL + '/api/groups/%s/topics/create.json' % group_id\n\nresp = request(create_url, {\"name\": topic_name, \"group_id\": group_id})\nif resp:\n try:\n topic_id = resp.get(\"topic\").get(\"id\").encode(\"utf-8\")\n vim.command(\"call ConvoreMessagesList('%s', '%s')\" % (str(topic_id), str(topic_name),))\n except Exception, e:\n print e\nEOF\nendfunction\n\nfunction! ConvoreCreateMessage(topic_id, message)\npython << EOF\nimport vim\n\ntopic_id = vim.eval(\"a:topic_id\")\nmessage = vim.eval(\"a:message\")\ncreate_url = CONVORE_URL + '/api/topics/%s/messages/create.json' % topic_id\n\nresp = request(create_url, {\"message\": message, \"topic_id\": topic_id})\nif resp:\n try:\n vim.command(\"call ConvoreMessagesList('%s', '%s')\" % (str(topic_id), str(vim.eval(\"g:convore_current_topic_name\")),))\n except Exception, e:\n print e\nEOF\nendfunction\n\nfunction! ConvorePostCurrent(line1, line2, count, topic_id)\npython << EOF\nimport vim\nrng_start = int(vim.eval('a:line1')) - 1\nrng_end = int(vim.eval('a:line2'))\nif int(vim.eval('a:count')):\n code = '\n'.join(vim.current.buffer[rng_start:rng_end])\nelse:\n code = '\n'.join(vim.current.buffer)\n\nvim.command('call ConvoreCreateMessage(\"%s\", \"%s\")' % (topic_id, utf8_code(code).replace('\"','\\\"'),))\nEOF\nendfunction\n\ncommand! -nargs=0 Convore call ConvoreGroupsList()\ncommand! -nargs=1 ConvoreCreateGroup call ConvoreCreateGroup(\"<args>\", \"public\")\ncommand! -nargs=1 ConvoreCreatePrivateGroup call ConvoreCreateGroup(\"<args>\", \"private\")", "group_id": 7200, "id": 491386}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301576599.3864951, "message": "asdiaudiausd", "group_id": 7200, "id": 491423}, {"user_id": 13893, "stars": [], "topic_id": 14258, "date_created": 1301575203.822078, "message": "###########\nConvore.vim\n###########\n\nConvore.vim is a vim plugin- reader for convore, in early alpha at the moment.\nIf you want to try it, put it in your \"plugins\" folder or :source it.\n\n.. image:: http://i.imgur.com/bC0FZ.png\n\n.. image:: http://i.imgur.com/hAw2o.png\n\n.. image:: http://i.imgur.com/Lm3Bp.png\n\nUsage\n=====\n\nYou need to set g:convore_user and g:convore_password in your .vimrc\n\nAfter that, just do \":Convore\". That will show you a buffer with a list of your \ngroups. Go over a group and hit Return. That will show you a list of the topics\nin the group. If you hit Return while on top on a topic, it will list the\nmessages in that topic.\n\nTo get back from messages to topics or from topics to groups, press b when in \nCONVORE buffer.\n\nGroup Management\n++++++++++++++++\n\n :ConvoreCreateGroup <group_name> - Creates a public group\n\n :ConvoreCreatePrivateGroup <group_name> - Creates a private group\n\nafter the group is created, the user is directed to the group`s display\n\nTopic Management\n++++++++++++++++\n\n :ConvoreCreateTopic <topic_name> - Creates a topic\n\nNote: It`s best if you are in a group context while creating a topic. The last \ngroup listed will be used for the topic. That means, if you are on the display\nthat lists the messages from a topic, the new topic will be created in the listed\none`s parent group.\n\nDirects you to the messages listing of the new topic.\n\nMessages\n++++++++\n\n :ConvoreCreateMessage <message> - Write a message to the current topic\n \n :ConvorePostCurrent - Posts the current buffer, preserving newlines, or\n visual selection - :`<,`>ConvorePostCurrent\n\nSame goes here. The current or last listed topic will be used for the message.\n\n\nAditional Notes\n===============\n\nThe script is in a very early stage. Feel free to suggest stuff, comment\nand critique.\n\nI would really appreciate help with highlighting.\n\nYou need vim compiled with +python support.", "group_id": 7200, "id": 491200}]