25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
90
91
92
93
94
|
# File 'lib/app/controllers/pagelime_receiver_controller.rb', line 25
def after_publish_callback_old
page_id = params[:page_id]
uri = URI.parse("http://qa.cms.pagelime.com/API/Account/SOAP/Page.asmx/Get")
http = Net::HTTP.new(uri.host, uri.port)
http.open_timeout = 2
http.read_timeout = 7
data = {:apiKey => "0fa155c4-9c42-4df6-856a-5cff6e2ff631", :pageId => page_id}.to_json
response = http.post(uri.path,data,{"content-type"=>"application/json; charset=utf-8","accept"=>"application/json, text/javascript, */*"})
page_json = JSON.parse(response.body)
page_json = page_json["d"]
page = PagelimePage.find_by_page_id(page_id)
if (page)
page.editable_areas.destroy
page.meta_data.destroy
else
page = PagelimePage.new
end
page.page_id = page_id
page.path = page_json[:Path]
page.title = page_json[:Title]
page.date_published = DateTime.now
page.save
for page_content_json in page_json["EditableRegions"]
page_content = PagelimeContent.new
page_content.client_id = page_content_json[:ClientID]
page_content.page = page
page_content.html = page_content_json[:Html]
page_content.save
end
for metadata_json in page_json["MetaDataJSON"]
page_metadata = PagelimeMetaData.new
page_metadata.name = metadata_json[0]
page_metadata.content = metadata_json[1]
page_metadata.page = page
page_metadata.save
end
render :status => 200
end
|