opengraph_transporter 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9dfbf1c2f753ed6527becf7c583032a64c7edd1
|
4
|
+
data.tar.gz: 1d86006b6e2d7c0fc5759a1610b15256235b6fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f288df21619bd8146375bd324cd9b1271afb990213a1f3a2ea0c997bf2b760606013853886a2aa08e5de76d98f411d4b886866fc2854240ea9b908a109918e82
|
7
|
+
data.tar.gz: 3be213e978d3cf21ed462035a438df46ed70ccab6d5e278792624e77384881e6d047fc4bb128c3c1e2ec76ff1a75351c87261c91e585f1065922874f040cd68e
|
data/README.md
CHANGED
@@ -27,20 +27,34 @@ Or install it yourself as:
|
|
27
27
|
### Facebook
|
28
28
|
* Admin Role on Facebook Developer Applications used in translations export process.
|
29
29
|
* Translation process is dependent on English(US) primary language selection (this will be configurable in future releases).
|
30
|
+
* Consistent Destination App Open Graph story configuration.
|
30
31
|
|
31
32
|
## Usage
|
32
33
|
|
33
34
|
1. Run opengraph_transporter
|
34
35
|
2. Enter Source Facebook Developer App ID and App Secret
|
35
36
|
3. Enter Destination Facebook Developer App ID and App Secret
|
36
|
-
4. Enter
|
37
|
-
5.
|
37
|
+
4. Enter Facebook translations Primary Locale (primary language locale - generally defaults to en_US).
|
38
|
+
5. Enter Facebook translations App locale.
|
39
|
+
6. Follow the prompts.
|
38
40
|
|
39
41
|
|
40
42
|
```
|
43
|
+
$ Please Enter Source Application Id
|
44
|
+
619023458209241
|
45
|
+
|
46
|
+
$ Please Enter Source Application Secret
|
47
|
+
2a1c3c1a878e8f52a8b7788dfe89g15f
|
48
|
+
|
49
|
+
$ Please Enter Destination Application Id
|
50
|
+
639876543218648
|
51
|
+
|
41
52
|
$ Please Enter Destination Application Secret
|
42
|
-
|
43
|
-
|
53
|
+
29ae3c3bd62106eae636132be8676eb2
|
54
|
+
|
55
|
+
$ Please Enter Primary Locale
|
56
|
+
en_US
|
57
|
+
|
44
58
|
$ Please Enter App Locale
|
45
59
|
pt_BR
|
46
60
|
```
|
@@ -48,9 +48,9 @@ module OpengraphTransporter
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def run_export
|
51
|
-
translation[:dst_translation_arr] = Scraper.ingest_app_translations(translation[:destination_application_id], translation[:app_locale])
|
51
|
+
translation[:dst_translation_arr] = Scraper.ingest_app_translations(translation[:destination_application_id], translation[:app_locale], translation[:primary_locale])
|
52
52
|
if translation[:dst_translation_arr].length == 0
|
53
|
-
say("No destination app <%= color('(#{Base.translation[:dst_app_name]})', RED, BOLD) %> Open Graph Translations found, please check that Open Graph stories exist and
|
53
|
+
say("No destination app <%= color('(#{Base.translation[:dst_app_name]})', RED, BOLD) %> Open Graph Translations found, please check that Open Graph stories exist and locales are correct.")
|
54
54
|
else
|
55
55
|
translation[:src_translation_arr] = Scraper.update_display_names!(translation[:src_translation_arr], translation[:src_app_name].to_s, translation[:dst_app_name].to_s)
|
56
56
|
translations_cleanup
|
@@ -123,10 +123,15 @@ module OpengraphTransporter
|
|
123
123
|
end
|
124
124
|
if translation[:app_locale].empty?
|
125
125
|
error_keys << "app_locale"
|
126
|
+
elsif translation[:primary_locale].empty?
|
127
|
+
error_keys << "primary_locale"
|
126
128
|
else
|
127
129
|
if !locales.include?(translation[:app_locale])
|
128
130
|
error_keys << "app_locale"
|
129
131
|
end
|
132
|
+
if !locales.include?(translation[:primary_locale])
|
133
|
+
error_keys << "primary_locale"
|
134
|
+
end
|
130
135
|
end
|
131
136
|
|
132
137
|
if !error_keys.empty?
|
@@ -169,7 +174,7 @@ module OpengraphTransporter
|
|
169
174
|
end
|
170
175
|
|
171
176
|
def initialize_translation
|
172
|
-
@@translation ||= {:source_application_id => '', :source_application_secret => '', :destination_application_id => '', :destination_application_secret => '', :app_locale => '' }
|
177
|
+
@@translation ||= {:source_application_id => '', :source_application_secret => '', :destination_application_id => '', :destination_application_secret => '', :primary_locale => '', :app_locale => '' }
|
173
178
|
end
|
174
179
|
|
175
180
|
def translations_cleanup
|
@@ -2,6 +2,7 @@ module OpengraphTransporter
|
|
2
2
|
class Browser
|
3
3
|
|
4
4
|
MAX_TRANSLATION_PAGE_LIMIT = 30
|
5
|
+
DEFAULT_PRIMARY_LOCALE = "en_US"
|
5
6
|
|
6
7
|
class << self
|
7
8
|
|
@@ -15,7 +16,11 @@ module OpengraphTransporter
|
|
15
16
|
@translation_arr = @translation [:dst_translation_arr].clone
|
16
17
|
fb_login
|
17
18
|
|
18
|
-
|
19
|
+
if @translation[:primary_locale].nil?
|
20
|
+
primary_locale = DEFAULT_PRIMARY_LOCALE
|
21
|
+
end
|
22
|
+
|
23
|
+
developer_translations_home_uri = "https://www.facebook.com/translations/admin/browse.php?search=&sloc=#{primary_locale}&aloc=#{@translation[:app_locale]}&app=#{@translation[:destination_application_id]}"
|
19
24
|
@browser.goto developer_translations_home_uri
|
20
25
|
GracefulQuit.enable
|
21
26
|
parse_translation_rows
|
@@ -69,6 +69,7 @@ module OpengraphTransporter
|
|
69
69
|
say("<%= color('\n***********************************************************************************************************', YELLOW, BOLD) %>")
|
70
70
|
say("Source Application ID: <%= color('#{Base.translation[:source_application_id]}', YELLOW, BOLD) %> Application Name: <%= color('#{Base.translation[:src_app_name]}', YELLOW, BOLD) %>")
|
71
71
|
say("Destination Application ID: <%= color('#{Base.translation[:destination_application_id]}', YELLOW, BOLD) %> Application Name: <%= color('#{Base.translation[:dst_app_name]}', YELLOW, BOLD) %>")
|
72
|
+
say("Primary Locale: <%= color('#{Base.translation[:primary_locale]}', YELLOW, BOLD) %>")
|
72
73
|
say("Selected Locale: <%= color('#{Base.translation[:app_locale]}', YELLOW, BOLD) %>")
|
73
74
|
say("<%= color('***********************************************************************************************************\n', YELLOW, BOLD) %>")
|
74
75
|
end
|
@@ -3,13 +3,18 @@ module OpengraphTransporter
|
|
3
3
|
|
4
4
|
MAX_FB_LOGIN_ATTEMPTS = 3
|
5
5
|
MAX_TRANSLATION_PAGE_LIMIT = 30
|
6
|
+
DEFAULT_PRIMARY_LOCALE = "en_US"
|
6
7
|
|
7
8
|
class << self
|
8
9
|
|
9
|
-
def ingest_app_translations(app_id, locale)
|
10
|
+
def ingest_app_translations(app_id, locale, primary_locale)
|
11
|
+
if primary_locale.nil?
|
12
|
+
primary_locale = DEFAULT_PRIMARY_LOCALE
|
13
|
+
end
|
10
14
|
@agent = Mechanize.new
|
11
15
|
# Defaulting to en_US native locale
|
12
|
-
source_app_uri = "https://www.facebook.com/translations/admin/browse.php?search&sloc
|
16
|
+
source_app_uri = "https://www.facebook.com/translations/admin/browse.php?search&sloc=#{primary_locale}&aloc=#{locale}&app=#{app_id}"
|
17
|
+
|
13
18
|
@agent.get(source_app_uri)
|
14
19
|
login_attempt = 1
|
15
20
|
login(login_attempt) do |continue|
|
@@ -119,7 +124,7 @@ module OpengraphTransporter
|
|
119
124
|
end
|
120
125
|
|
121
126
|
def get_user_credentials
|
122
|
-
Base.user[:fb_username] = ask("Facebook
|
127
|
+
Base.user[:fb_username] = ask("Facebook Email: ", lambda { |u| u.to_s.strip } ) do |q|
|
123
128
|
q.validate = lambda { |p| (p =~ /^.+@.+$/) != nil }
|
124
129
|
q.responses[:not_valid] = "Please enter a valid email address."
|
125
130
|
end
|