discourse_theme 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/discourse_theme/cli.rb +18 -1
- data/lib/discourse_theme/version.rb +1 -1
- 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: 5018db22dc1253f3812b0b9d1904c7d23f88ecc8
|
4
|
+
data.tar.gz: 11d66ad3bcf8b5d598d719d8ecaa62e773a112db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc69715ebf934735f5f78948ff3bacddc2af7326701f7494c69d786317cee651f0cd30c2a62eb7dc5ce0fb82bfa2387d22549bcd58c58456f1e92cdd7f3c989f
|
7
|
+
data.tar.gz: 1e2cdd532b2f17fcad4c71f8383a64b118b451905a8b0727394c5f3cec94041f8fb96593ccaf1d4e2570781764bf7ee36db5d150358b98e2b913ba9107a1e5e9
|
data/lib/discourse_theme/cli.rb
CHANGED
@@ -34,6 +34,15 @@ class DiscourseTheme::Cli
|
|
34
34
|
api_key
|
35
35
|
end
|
36
36
|
|
37
|
+
def is_https_redirect?(url)
|
38
|
+
url = URI.parse(url)
|
39
|
+
path = url.path
|
40
|
+
path = "/" if path.empty?
|
41
|
+
req = Net::HTTP::Get.new("/")
|
42
|
+
response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
|
43
|
+
Net::HTTPRedirection === response && response['location'] =~ /^https/i
|
44
|
+
end
|
45
|
+
|
37
46
|
def guess_url(settings)
|
38
47
|
url = ENV['DISCOURSE_URL']
|
39
48
|
if url
|
@@ -48,7 +57,15 @@ class DiscourseTheme::Cli
|
|
48
57
|
if !url
|
49
58
|
puts "No site found! Where would you like to synchronize the theme to: "
|
50
59
|
url = STDIN.gets.strip
|
51
|
-
url
|
60
|
+
url = "http://#{url}" unless url =~ /^https?:\/\//
|
61
|
+
|
62
|
+
# maybe this is an HTTPS redirect
|
63
|
+
uri = URI.parse(url)
|
64
|
+
if URI::HTTP === uri && uri.port == 80 && is_https_redirect?(url)
|
65
|
+
puts "Detected an #{url} is an HTTPS domain"
|
66
|
+
url = url.sub("http", "https")
|
67
|
+
end
|
68
|
+
|
52
69
|
puts "Would you like me to store this site name at: #{SETTINGS_FILE}? (Yes|No)"
|
53
70
|
answer = STDIN.gets.strip
|
54
71
|
if answer =~ /y(es)?/i
|