Class: WordPressImporter

Inherits:
Object
  • Object
show all
Includes:
IoTools::Helpers::MetaWeblog, IoTools::Importer
Defined in:
lib/server/importers/word_press_importer.rb

Constant Summary collapse

RSD_SELECTOR =
'link[rel=EditURI]'
METAWEB_SELECTOR =
'api[name=MetaWeblog]'
MAX_POSTS_TO_REQUEST =
20

Instance Method Summary collapse

Methods included from IoTools::Helpers::MetaWeblog

#recent_posts, #rpc, #server

Methods included from IoTools::Importer

included

Instance Method Details

#api_urlObject



61
62
63
# File 'lib/server/importers/word_press_importer.rb', line 61

def api_url
  @api_url ||= scan_for_url
end

#htmlObject



33
34
35
# File 'lib/server/importers/word_press_importer.rb', line 33

def html
  @html ||= open self.params['import_url']
end

#metaweblog_idObject



57
58
59
# File 'lib/server/importers/word_press_importer.rb', line 57

def metaweblog_id
  @metaweblog_id ||= scan_for_id
end

#rsd_docObject



49
50
51
# File 'lib/server/importers/word_press_importer.rb', line 49

def rsd_doc
  @rsd_doc ||= Nokogiri::HTML(rsd_html)
end

#rsd_htmlObject



53
54
55
# File 'lib/server/importers/word_press_importer.rb', line 53

def rsd_html
  @rsd_html ||= open(rsd_url)
end

#rsd_urlObject



37
38
39
# File 'lib/server/importers/word_press_importer.rb', line 37

def rsd_url
  @rsd_url ||= scan_for_rsd
end

#scan_for_idObject



45
46
47
# File 'lib/server/importers/word_press_importer.rb', line 45

def scan_for_id
  rsd_doc.css( METAWEB_SELECTOR ).first['blogid']
end

#scan_for_rsdObject



41
42
43
# File 'lib/server/importers/word_press_importer.rb', line 41

def scan_for_rsd
  site_doc.css( RSD_SELECTOR ).first['href']
end

#scan_for_urlObject

Methods below are helpers for detecting RSD for the XML-RPC protocol.



25
26
27
# File 'lib/server/importers/word_press_importer.rb', line 25

def scan_for_url
  rsd_doc.css( METAWEB_SELECTOR ).first['apilink']
end

#site_docObject



29
30
31
# File 'lib/server/importers/word_press_importer.rb', line 29

def site_doc
  @site_doc ||= Nokogiri::HTML(html)
end