Top Level Namespace

Defined Under Namespace

Modules: BluxIndexer Classes: BlogManager, BluxConfigurationReader, BluxOptionParser, DraftManager, WPOptionParser

Instance Method Summary collapse

Instance Method Details

#delete(options, base, username, password) ⇒ Object

a great thanks to the devs of all the libs used here some info about you and your blog



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/publishing/wp_publish.rb', line 24

def delete(options, base, username, password)
	entry = Atom::Entry.new
	entry.updated!
	entry.edit_url = options.entry_id

	h = Atom::HTTP.new
	h.user = username
	h.pass = password
	h.always_auth = :basic

	c = Atom::Collection.new(base + "/posts", h)
	res = c.delete! entry

	return entry, res
end

#get_contentObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/publishing/wp_publish.rb', line 40

def get_content
	content = ""
	loop do
		line = STDIN.gets
		break unless line
		content += line
	end

	content
end

#publish_or_update(command, options, username, password, base, bloguri, authorname) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/publishing/wp_publish.rb', line 51

def publish_or_update(command, options, username, password, base, bloguri, authorname)
	raise "please specify a title for the post with the -t option" unless options.title
	content = get_content

	entry = Atom::Entry.new
	entry.title = options.title
	entry.updated!

	author = Atom::Author.new
	author.name = authorname
	author.uri = bloguri
	entry.authors << author

	options.tags.each do |t|
		c = Atom::Category.new
		c["scheme"] = bloguri
		c["term"] = t.strip
		entry.categories << c
	end

	entry.content = content
	entry.content["type"] = options.type if options.type

	h = Atom::HTTP.new
	h.user = username
	h.pass = password
	h.always_auth = :basic

	c = Atom::Collection.new(base + "/posts", h)

	if command == :post
		res = c.post! entry
	elsif command == :put
		entry.edit_url = options.entry_id
		res = c.put! entry
	end

	return entry, res
end