glossyapp 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/glossyapp/session/page_elements.rb +30 -2
- data/lib/glossyapp/session/pages.rb +14 -0
- data/lib/glossyapp/version.rb +1 -1
- data/old_vanga_main.rb +0 -44
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d1b292b327a89672de3093508d8814100c92ec
|
4
|
+
data.tar.gz: 8d0261d67fffc6bb1ae1a16a372401dedc7e2248
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28343382cf62028e639727a9344f37c3aff7e33e0090666c3b9c59d38b0d87913037fc58252f11b514c4103eb15fb9e788178398c71e82fd2db760c77d5de74a
|
7
|
+
data.tar.gz: 701046567fc15f49b82845d113665517d96263597219176372b091e30680e7ee8a2d926587d84b614472516d93dfd2bea37d323069a7d57281922442aed541f0
|
@@ -1,11 +1,39 @@
|
|
1
1
|
module GlossyApp
|
2
2
|
|
3
3
|
class Session
|
4
|
+
|
5
|
+
def create_page_element(document_id, page_id, x, y, width, height, type, data, title = nil)
|
6
|
+
data = {
|
7
|
+
'page_element' => {
|
8
|
+
'page_id' => page_id,
|
9
|
+
'type' => type,
|
10
|
+
'title' => title,
|
11
|
+
'x' => x,
|
12
|
+
'y' => y,
|
13
|
+
'width' => width,
|
14
|
+
'height' => height
|
15
|
+
}.merge(data)
|
16
|
+
}
|
17
|
+
|
18
|
+
response = @glossy_api.post("/documents/#{document_id}/pages/#{page_id}/page_elements", data.to_json, {"Content-Type" => "application/json"})
|
19
|
+
if [200, 201].include?(response.status)
|
20
|
+
json = JSON.parse(response.body)
|
21
|
+
return json['id']
|
22
|
+
else
|
23
|
+
raise "Invalid response: #{response.inspect}\n#{response.body}"
|
24
|
+
end
|
25
|
+
end
|
4
26
|
|
5
|
-
def
|
6
|
-
|
27
|
+
def delete_page_element(document_id, page_id, page_element_id)
|
28
|
+
response = @glossy_api.delete "/documents/#{document_id}/pages/#{page_id}/page_elements/#{page_element_id}"
|
29
|
+
if [200].include?(response.status)
|
30
|
+
return true
|
31
|
+
else
|
32
|
+
raise "Invalid response: #{response.inspect}\n#{response.body}"
|
33
|
+
end
|
7
34
|
end
|
8
35
|
|
36
|
+
|
9
37
|
end
|
10
38
|
|
11
39
|
end
|
@@ -11,6 +11,20 @@ module GlossyApp
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def page_id_for_page_position(document_id, position)
|
15
|
+
response = @glossy_api.get "/documents/#{document_id}/pages?positions=#{position}"
|
16
|
+
if [200].include?(response.status)
|
17
|
+
json = JSON.parse(response.body)
|
18
|
+
if json['pages'].is_a?(Array) and json['pages'].size > 0
|
19
|
+
return json['pages'].first['id']
|
20
|
+
else
|
21
|
+
return nil
|
22
|
+
end
|
23
|
+
else
|
24
|
+
return nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
14
28
|
end
|
15
29
|
|
16
30
|
end
|
data/lib/glossyapp/version.rb
CHANGED
data/old_vanga_main.rb
CHANGED
@@ -29,50 +29,6 @@ def create_article(article, gallery = nil, asset_file_id = nil)
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def delete_page_element(page_id, page_element_id)
|
33
|
-
response = @glossy_api.delete "/documents/#{@options[:document_id]}/pages/#{page_id}/page_elements/#{page_element_id}"
|
34
|
-
if [200].include?(response.status)
|
35
|
-
return true
|
36
|
-
else
|
37
|
-
raise "Couldn't get pages: #{response.inspect}\n#{response.body}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def create_page_element(page_id, x, y, width, height, type, data, title = nil)
|
42
|
-
data = {
|
43
|
-
'page_element' => {
|
44
|
-
'page_id' => page_id,
|
45
|
-
'type' => type,
|
46
|
-
'title' => title,
|
47
|
-
'x' => x,
|
48
|
-
'y' => y,
|
49
|
-
'width' => width,
|
50
|
-
'height' => height
|
51
|
-
}.merge(data)
|
52
|
-
}
|
53
|
-
|
54
|
-
response = @glossy_api.post("/documents/#{@options[:document_id]}/pages/#{page_id}/page_elements", data.to_json, {"Content-Type" => "application/json"})
|
55
|
-
if [200, 201].include?(response.status)
|
56
|
-
json = JSON.parse(response.body)
|
57
|
-
# TODO return id of page element
|
58
|
-
else
|
59
|
-
raise "Invalid response: #{response.inspect}\n#{response.body}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def page_id_for_page_position(position)
|
64
|
-
response = @glossy_api.get "/documents/#{@options[:document_id]}/pages?positions=#{position}"
|
65
|
-
if [200].include?(response.status)
|
66
|
-
json = JSON.parse(response.body)
|
67
|
-
if json['pages'].is_a?(Array) and json['pages'].size > 0
|
68
|
-
return json['pages'].first['id']
|
69
|
-
else
|
70
|
-
return nil
|
71
|
-
end
|
72
|
-
else
|
73
|
-
return nil
|
74
|
-
end
|
75
|
-
end
|
76
32
|
|
77
33
|
def toc_section_id_for_section_with_title(title)
|
78
34
|
response = @glossy_api.get "/documents/#{@options[:document_id]}/toc_sections?title=#{CGI.escape(title)}"
|