Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 271fb94823
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (66 sloc) 2.43 kB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundleUUID</key>
<string>79741B2E-271D-4CBC-A61A-380C83D36863</string>
<key>command</key>
<string>#!/usr/bin/env ruby -rjcode -Ku
require "#{ENV['TM_SUPPORT_PATH']}/lib/progress"
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui"
require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/blogging"
require 'xmlrpc/client'
# fetches available categories (only tested with Wordpress)
def select_from_cats(cats)
# the metaWeblog API says the result is a per-category struct containing a
# description, but nothing about a categoryName (which e.g. WP will *also*
# give us). So we prefer a categoryName, then falls back on description,
# though Typo just returns strings instead of structs, so we handle that as
# well
names = cats.map do |p|
if Hash === p &amp;&amp; p.has_key?('categoryName')
p['categoryName']
elsif Hash === p &amp;&amp; p.has_key?('description')
p['description']
else
p.to_s
end
end
names.sort! { |a, b| a &lt;=&gt; b }
res = TextMate::UI.request_item(
:title =&gt; "Categories",
:prompt =&gt; "Choose categories to insert:",
:items =&gt; names,
:button1 =&gt; 'Insert'
)
TextMate.exit_discard if res.nil?
puts res.gsub(/([^,]+),?\s*/, "Category: \\1\n")
end # select_cats
cred = Blogging.new
endpoint = cred.endpoint
username = cred.username
password = cred.password
res = TextMate.call_with_progress(:title =&gt; "Fetch Categories", :message =&gt; "Contacting Server “#{cred.host}”…") do
cred.client.call("metaWeblog.getCategories", endpoint, username, password)
end
TextMate.exit_show_tool_tip "No categories are available!" if res.nil? || res.empty?
select_from_cats(res)
</string>
<key>input</key>
<string>document</string>
<key>name</key>
<string>Category</string>
<key>output</key>
<string>afterSelectedText</string>
<key>scope</key>
<string>text.blog, text.blog text.html.markdown, text.blog text.plain, text.blog text.html.textile, text.blog text.html</string>
<key>tabTrigger</key>
<string>cat</string>
<key>uuid</key>
<string>40318F5D-111F-4451-BBB0-F282DEAC881F</string>
</dict>
</plist>
Jump to Line
Something went wrong with that request. Please try again.